Changeset View
Changeset View
Standalone View
Standalone View
src/qgpgmesignjob.cpp
| Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | void QGpgMESignJob::setOutputIsBase64Encoded(bool on) | ||||
| mOutputIsBase64Encoded = on; | mOutputIsBase64Encoded = on; | ||||
| } | } | ||||
| static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread, | static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread, | ||||
| const std::vector<Key> &signers, | const std::vector<Key> &signers, | ||||
| const std::weak_ptr<QIODevice> &plainText_, | const std::weak_ptr<QIODevice> &plainText_, | ||||
| const std::weak_ptr<QIODevice> &signature_, | const std::weak_ptr<QIODevice> &signature_, | ||||
| SignatureMode mode, | SignatureMode mode, | ||||
| bool outputIsBsse64Encoded) | bool outputIsBase64Encoded) | ||||
| { | { | ||||
| const std::shared_ptr<QIODevice> plainText = plainText_.lock(); | const std::shared_ptr<QIODevice> plainText = plainText_.lock(); | ||||
| const std::shared_ptr<QIODevice> signature = signature_.lock(); | const std::shared_ptr<QIODevice> signature = signature_.lock(); | ||||
| const _detail::ToThreadMover ptMover(plainText, thread); | const _detail::ToThreadMover ptMover(plainText, thread); | ||||
| const _detail::ToThreadMover sgMover(signature, thread); | const _detail::ToThreadMover sgMover(signature, thread); | ||||
| Show All 11 Lines | for (const Key &signer : signers) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!signature) { | if (!signature) { | ||||
| 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 SigningResult res = ctx->sign(indata, outdata, mode); | const SigningResult res = ctx->sign(indata, outdata, mode); | ||||
| 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(signature); | QGpgME::QIODeviceDataProvider out(signature); | ||||
| Data outdata(&out); | Data outdata(&out); | ||||
| if (outputIsBsse64Encoded) { | if (outputIsBase64Encoded) { | ||||
| outdata.setEncoding(Data::Base64Encoding); | outdata.setEncoding(Data::Base64Encoding); | ||||
| } | } | ||||
| const SigningResult res = ctx->sign(indata, outdata, mode); | const SigningResult res = ctx->sign(indata, outdata, mode); | ||||
| 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 QGpgMESignJob::result_type sign_qba(Context *ctx, | static QGpgMESignJob::result_type sign_qba(Context *ctx, | ||||
| const std::vector<Key> &signers, | const std::vector<Key> &signers, | ||||
| const QByteArray &plainText, | const QByteArray &plainText, | ||||
| SignatureMode mode, | SignatureMode mode, | ||||
| bool outputIsBsse64Encoded) | bool outputIsBase64Encoded) | ||||
| { | { | ||||
| 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(ctx, nullptr, signers, buffer, std::shared_ptr<QIODevice>(), mode, outputIsBsse64Encoded); | return sign(ctx, nullptr, signers, buffer, std::shared_ptr<QIODevice>(), mode, outputIsBase64Encoded); | ||||
| } | } | ||||
| static QGpgMESignJob::result_type sign_to_filename(Context *ctx, | static QGpgMESignJob::result_type sign_to_filename(Context *ctx, | ||||
| const std::vector<Key> &signers, | const std::vector<Key> &signers, | ||||
| const QString &inputFilePath, | const QString &inputFilePath, | ||||
| const QString &outputFilePath, | const QString &outputFilePath, | ||||
| SignatureMode flags, | SignatureMode flags, | ||||
| bool appendSignature) | bool appendSignature) | ||||
| ▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines | |||||