diff --git a/lang/qt/src/encryptjob.cpp b/lang/qt/src/encryptjob.cpp index 7b9f0f2b..48a0e24e 100644 --- a/lang/qt/src/encryptjob.cpp +++ b/lang/qt/src/encryptjob.cpp @@ -51,3 +51,15 @@ QString EncryptJob::fileName() const auto d = jobPrivate(this); return d->m_fileName; } + +void EncryptJob::setInputEncoding(GpgME::Data::Encoding inputEncoding) +{ + auto d = jobPrivate(this); + d->m_inputEncoding = inputEncoding; +} + +GpgME::Data::Encoding EncryptJob::inputEncoding() const +{ + auto d = jobPrivate(this); + return d->m_inputEncoding; +} diff --git a/lang/qt/src/encryptjob.h b/lang/qt/src/encryptjob.h index 8135053e..ac3664fa 100644 --- a/lang/qt/src/encryptjob.h +++ b/lang/qt/src/encryptjob.h @@ -38,6 +38,7 @@ #define __KLEO_ENCRYPTJOB_H__ #include "job.h" +#include "data.h" #include #include @@ -85,6 +86,9 @@ public: void setFileName(const QString &fileName); QString fileName() const; + void setInputEncoding(GpgME::Data::Encoding); + GpgME::Data::Encoding inputEncoding() const; + /** Starts the encryption operation. \a recipients is the a list of keys to encrypt \a plainText to. Empty (null) keys are diff --git a/lang/qt/src/encryptjob_p.h b/lang/qt/src/encryptjob_p.h index 4a93f5b3..9bb9e952 100644 --- a/lang/qt/src/encryptjob_p.h +++ b/lang/qt/src/encryptjob_p.h @@ -35,6 +35,7 @@ #define __QGPGME_ENCRYPTJOB_P_H__ #include "job_p.h" +#include "data.h" namespace QGpgME { @@ -42,6 +43,7 @@ namespace QGpgME struct EncryptJobPrivate : public JobPrivate { QString m_fileName; + GpgME::Data::Encoding m_inputEncoding; }; } diff --git a/lang/qt/src/qgpgmeencryptjob.cpp b/lang/qt/src/qgpgmeencryptjob.cpp index 5ea6162c..cfb8d4ac 100644 --- a/lang/qt/src/qgpgmeencryptjob.cpp +++ b/lang/qt/src/qgpgmeencryptjob.cpp @@ -107,6 +107,7 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, const std::weak_ptr &cipherText_, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, + Data::Encoding inputEncoding, const QString &fileName) { @@ -118,6 +119,8 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, QGpgME::QIODeviceDataProvider in(plainText); Data indata(&in); + indata.setEncoding(inputEncoding); + if (!plainText->isSequential()) { indata.setSizeHint(plainText->size()); } @@ -155,20 +158,20 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, } -static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, const QString &fileName) +static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, Data::Encoding inputEncoding, const QString &fileName) { const std::shared_ptr buffer(new QBuffer); buffer->setData(plainText); if (!buffer->open(QIODevice::ReadOnly)) { assert(!"This should never happen: QBuffer::open() failed"); } - return encrypt(ctx, nullptr, recipients, buffer, std::shared_ptr(), eflags, outputIsBsse64Encoded, fileName); + return encrypt(ctx, nullptr, recipients, buffer, std::shared_ptr(), eflags, outputIsBsse64Encoded, inputEncoding, fileName); } Error QGpgMEEncryptJob::start(const std::vector &recipients, const QByteArray &plainText, bool alwaysTrust) { run(std::bind(&encrypt_qba, std::placeholders::_1, recipients, plainText, - alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded, fileName())); + alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded, inputEncoding(), fileName())); return Error(); } @@ -181,6 +184,7 @@ void QGpgMEEncryptJob::start(const std::vector &recipients, const std::shar std::placeholders::_3, std::placeholders::_4, eflags, mOutputIsBase64Encoded, + inputEncoding(), fileName()), plainText, cipherText); } @@ -188,7 +192,7 @@ void QGpgMEEncryptJob::start(const std::vector &recipients, const std::shar EncryptionResult QGpgMEEncryptJob::exec(const std::vector &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, QByteArray &cipherText) { - const result_type r = encrypt_qba(context(), recipients, plainText, eflags, mOutputIsBase64Encoded, fileName()); + const result_type r = encrypt_qba(context(), recipients, plainText, eflags, mOutputIsBase64Encoded, inputEncoding(), fileName()); cipherText = std::get<1>(r); resultHook(r); return mResult;