Changeset View
Changeset View
Standalone View
Standalone View
src/qgpgmeencryptjob.cpp
| Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | void QGpgMEEncryptJob::setOutputIsBase64Encoded(bool on) | ||||
| mOutputIsBase64Encoded = on; | mOutputIsBase64Encoded = on; | ||||
| } | } | ||||
| static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, | static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, | ||||
| const std::vector<Key> &recipients, | const std::vector<Key> &recipients, | ||||
| const std::weak_ptr<QIODevice> &plainText_, | const std::weak_ptr<QIODevice> &plainText_, | ||||
| const std::weak_ptr<QIODevice> &cipherText_, | const std::weak_ptr<QIODevice> &cipherText_, | ||||
| const Context::EncryptionFlags eflags, | const Context::EncryptionFlags eflags, | ||||
| bool outputIsBsse64Encoded, | bool outputIsBase64Encoded, | ||||
| Data::Encoding inputEncoding, | Data::Encoding inputEncoding, | ||||
| const QString &fileName) | 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); | ||||
| Show All 11 Lines | static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, | ||||
| if (!pureFileName.empty()) { | if (!pureFileName.empty()) { | ||||
| indata.setFileName(pureFileName.c_str()); | indata.setFileName(pureFileName.c_str()); | ||||
| } | } | ||||
| 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 EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags); | const EncryptionResult res = ctx->encrypt(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, out.data(), log, ae); | return std::make_tuple(res, 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 EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags); | const EncryptionResult res = ctx->encrypt(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, QByteArray(), log, ae); | return std::make_tuple(res, QByteArray(), log, ae); | ||||
| } | } | ||||
| } | } | ||||
| static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, Data::Encoding inputEncoding, const QString &fileName) | static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBase64Encoded, Data::Encoding inputEncoding, 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 encrypt(ctx, nullptr, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded, inputEncoding, fileName); | return encrypt(ctx, nullptr, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBase64Encoded, inputEncoding, fileName); | ||||
| } | } | ||||
| static QGpgMEEncryptJob::result_type encrypt_to_filename(Context *ctx, | static QGpgMEEncryptJob::result_type encrypt_to_filename(Context *ctx, | ||||
| 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 90 Lines • Show Last 20 Lines | |||||