Changeset View
Changeset View
Standalone View
Standalone View
src/qgpgmesignencryptjob.cpp
| Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
| void QGpgMESignEncryptJob::setOutputIsBase64Encoded(bool on) | void QGpgMESignEncryptJob::setOutputIsBase64Encoded(bool on) | ||||
| { | { | ||||
| mOutputIsBase64Encoded = on; | mOutputIsBase64Encoded = on; | ||||
| } | } | ||||
| static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thread, const std::vector<Key> &signers, | static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thread, const std::vector<Key> &signers, | ||||
| const std::vector<Key> &recipients, const std::weak_ptr<QIODevice> &plainText_, | const std::vector<Key> &recipients, const std::weak_ptr<QIODevice> &plainText_, | ||||
| const std::weak_ptr<QIODevice> &cipherText_, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, const QString &fileName) | const std::weak_ptr<QIODevice> &cipherText_, const Context::EncryptionFlags eflags, bool outputIsBase64Encoded, const QString &fileName) | ||||
| { | { | ||||
| const std::shared_ptr<QIODevice> &plainText = plainText_.lock(); | const std::shared_ptr<QIODevice> &plainText = plainText_.lock(); | ||||
| const std::shared_ptr<QIODevice> &cipherText = cipherText_.lock(); | const std::shared_ptr<QIODevice> &cipherText = cipherText_.lock(); | ||||
| const _detail::ToThreadMover ctMover(cipherText, thread); | const _detail::ToThreadMover ctMover(cipherText, thread); | ||||
| const _detail::ToThreadMover ptMover(plainText, thread); | const _detail::ToThreadMover ptMover(plainText, thread); | ||||
| QGpgME::QIODeviceDataProvider in(plainText); | QGpgME::QIODeviceDataProvider in(plainText); | ||||
| Show All 15 Lines | for (const Key &signer : signers) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!cipherText) { | if (!cipherText) { | ||||
| QGpgME::QByteArrayDataProvider out; | QGpgME::QByteArrayDataProvider out; | ||||
| Data outdata(&out); | Data outdata(&out); | ||||
| if (outputIsBsse64Encoded) { | if (outputIsBase64Encoded) { | ||||
| outdata.setEncoding(Data::Base64Encoding); | outdata.setEncoding(Data::Base64Encoding); | ||||
| } | } | ||||
| const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags); | const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags); | ||||
| Error ae; | Error ae; | ||||
| const QString log = _detail::audit_log_as_html(ctx, ae); | const QString log = _detail::audit_log_as_html(ctx, ae); | ||||
| return std::make_tuple(res.first, res.second, out.data(), log, ae); | return std::make_tuple(res.first, res.second, out.data(), log, ae); | ||||
| } else { | } else { | ||||
| QGpgME::QIODeviceDataProvider out(cipherText); | QGpgME::QIODeviceDataProvider out(cipherText); | ||||
| Data outdata(&out); | Data outdata(&out); | ||||
| if (outputIsBsse64Encoded) { | if (outputIsBase64Encoded) { | ||||
| outdata.setEncoding(Data::Base64Encoding); | outdata.setEncoding(Data::Base64Encoding); | ||||
| } | } | ||||
| const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags); | const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags); | ||||
| Error ae; | Error ae; | ||||
| const QString log = _detail::audit_log_as_html(ctx, ae); | const QString log = _detail::audit_log_as_html(ctx, ae); | ||||
| return std::make_tuple(res.first, res.second, QByteArray(), log, ae); | return std::make_tuple(res.first, res.second, QByteArray(), log, ae); | ||||
| } | } | ||||
| } | } | ||||
| static QGpgMESignEncryptJob::result_type sign_encrypt_qba(Context *ctx, const std::vector<Key> &signers, | static QGpgMESignEncryptJob::result_type sign_encrypt_qba(Context *ctx, const std::vector<Key> &signers, | ||||
| const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, const QString &fileName) | const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBase64Encoded, const QString &fileName) | ||||
| { | { | ||||
| const std::shared_ptr<QBuffer> buffer(new QBuffer); | const std::shared_ptr<QBuffer> buffer(new QBuffer); | ||||
| buffer->setData(plainText); | buffer->setData(plainText); | ||||
| if (!buffer->open(QIODevice::ReadOnly)) { | if (!buffer->open(QIODevice::ReadOnly)) { | ||||
| assert(!"This should never happen: QBuffer::open() failed"); | assert(!"This should never happen: QBuffer::open() failed"); | ||||
| } | } | ||||
| return sign_encrypt(ctx, nullptr, signers, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded, fileName); | return sign_encrypt(ctx, nullptr, signers, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBase64Encoded, fileName); | ||||
| } | } | ||||
| static QGpgMESignEncryptJob::result_type sign_encrypt_to_filename(Context *ctx, | static QGpgMESignEncryptJob::result_type sign_encrypt_to_filename(Context *ctx, | ||||
| const std::vector<Key> &signers, | const std::vector<Key> &signers, | ||||
| const std::vector<Key> &recipients, | const std::vector<Key> &recipients, | ||||
| const QString &inputFilePath, | const QString &inputFilePath, | ||||
| const QString &outputFilePath, | const QString &outputFilePath, | ||||
| Context::EncryptionFlags flags) | Context::EncryptionFlags flags) | ||||
| ▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines | |||||