aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src/qgpgmeencryptjob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lang/qt/src/qgpgmeencryptjob.cpp')
-rw-r--r--lang/qt/src/qgpgmeencryptjob.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/lang/qt/src/qgpgmeencryptjob.cpp b/lang/qt/src/qgpgmeencryptjob.cpp
index 8d0bfd43..82c8ed8a 100644
--- a/lang/qt/src/qgpgmeencryptjob.cpp
+++ b/lang/qt/src/qgpgmeencryptjob.cpp
@@ -65,7 +65,7 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread,
const std::vector<Key> &recipients,
const std::weak_ptr<QIODevice> &plainText_,
const std::weak_ptr<QIODevice> &cipherText_,
- bool alwaysTrust,
+ const Context::EncryptionFlags eflags,
bool outputIsBsse64Encoded)
{
@@ -78,9 +78,6 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread,
QGpgME::QIODeviceDataProvider in(plainText);
const Data indata(&in);
- const Context::EncryptionFlags eflags =
- alwaysTrust ? Context::AlwaysTrust : Context::None;
-
if (!cipherText) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
@@ -109,41 +106,54 @@ static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread,
}
-static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, bool outputIsBsse64Encoded)
+static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded)
{
const std::shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(plainText);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
- return encrypt(ctx, 0, recipients, buffer, std::shared_ptr<QIODevice>(), alwaysTrust, outputIsBsse64Encoded);
+ return encrypt(ctx, 0, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded);
}
Error QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust)
{
- run(std::bind(&encrypt_qba, std::placeholders::_1, recipients, plainText, alwaysTrust, mOutputIsBase64Encoded));
+ run(std::bind(&encrypt_qba, std::placeholders::_1, recipients, plainText,
+ alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded));
return Error();
}
-void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
+void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText,
+ const std::shared_ptr<QIODevice> &cipherText, const Context::EncryptionFlags eflags)
{
run(std::bind(&encrypt,
std::placeholders::_1, std::placeholders::_2,
recipients,
std::placeholders::_3, std::placeholders::_4,
- alwaysTrust,
+ eflags,
mOutputIsBase64Encoded),
plainText, cipherText);
}
-EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
+EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText,
+ const Context::EncryptionFlags eflags, QByteArray &cipherText)
{
- const result_type r = encrypt_qba(context(), recipients, plainText, alwaysTrust, mOutputIsBase64Encoded);
+ const result_type r = encrypt_qba(context(), recipients, plainText, eflags, mOutputIsBase64Encoded);
cipherText = std::get<1>(r);
resultHook(r);
return mResult;
}
+void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
+{
+ return start(recipients, plainText, cipherText, alwaysTrust ? Context::AlwaysTrust : Context::None);
+}
+
+EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
+{
+ return exec(recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText);
+}
+
void QGpgMEEncryptJob::resultHook(const result_type &tuple)
{
mResult = std::get<0>(tuple);