7#include "qgpgmejobexecutor.h"
8#include "mimetreeparser_debug.h"
10#include <QGpgME/DecryptVerifyJob>
11#include <QGpgME/ImportJob>
12#include <QGpgME/VerifyDetachedJob>
13#include <QGpgME/VerifyOpaqueJob>
20using namespace MimeTreeParser;
22QGpgMEJobExecutor::QGpgMEJobExecutor(
QObject *parent)
29GpgME::VerificationResult QGpgMEJobExecutor::exec(QGpgME::VerifyDetachedJob *job,
const QByteArray &signature,
const QByteArray &signedData)
31 qCDebug(MIMETREEPARSER_LOG) <<
"Starting detached verification job";
32 connect(job, &QGpgME::VerifyDetachedJob::result,
this, qOverload<const GpgME::VerificationResult &>(&QGpgMEJobExecutor::verificationResult));
33 GpgME::Error err = job->start(signature, signedData);
35 return VerificationResult(err);
38 return mVerificationResult;
41GpgME::VerificationResult QGpgMEJobExecutor::exec(QGpgME::VerifyOpaqueJob *job,
const QByteArray &signedData,
QByteArray &plainText)
43 qCDebug(MIMETREEPARSER_LOG) <<
"Starting opaque verification job";
45 &QGpgME::VerifyOpaqueJob::result,
47 qOverload<const GpgME::VerificationResult &, const QByteArray &>(&QGpgMEJobExecutor::verificationResult));
48 GpgME::Error err = job->start(signedData);
51 return VerificationResult(err);
55 return mVerificationResult;
58std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
59QGpgMEJobExecutor::exec(QGpgME::DecryptVerifyJob *job,
const QByteArray &cipherText,
QByteArray &plainText)
61 qCDebug(MIMETREEPARSER_LOG) <<
"Starting decryption job";
62 connect(job, &QGpgME::DecryptVerifyJob::result,
this, &QGpgMEJobExecutor::decryptResult);
63 GpgME::Error err = job->start(cipherText);
66 return std::make_pair(DecryptionResult(err), VerificationResult(err));
70 return std::make_pair(mDecryptResult, mVerificationResult);
73GpgME::ImportResult QGpgMEJobExecutor::exec(QGpgME::ImportJob *job,
const QByteArray &certData)
75 connect(job, &QGpgME::AbstractImportJob::result,
this, &QGpgMEJobExecutor::importResult);
76 GpgME::Error err = job->start(certData);
78 return ImportResult(err);
84Error QGpgMEJobExecutor::auditLogError()
const
86 return mAuditLogError;
89void QGpgMEJobExecutor::verificationResult(
const GpgME::VerificationResult &result)
91 qCDebug(MIMETREEPARSER_LOG) <<
"Detached verification job finished";
94 mVerificationResult = result;
95 mAuditLogError = job->auditLogError();
96 mAuditLog = job->auditLogAsHtml();
100void QGpgMEJobExecutor::verificationResult(
const GpgME::VerificationResult &result,
const QByteArray &plainText)
102 qCDebug(MIMETREEPARSER_LOG) <<
"Opaque verification job finished";
105 mVerificationResult = result;
107 mAuditLogError = job->auditLogError();
108 mAuditLog = job->auditLogAsHtml();
112void QGpgMEJobExecutor::decryptResult(
const GpgME::DecryptionResult &decryptionresult,
113 const GpgME::VerificationResult &verificationresult,
116 qCDebug(MIMETREEPARSER_LOG) <<
"Decryption job finished";
119 mVerificationResult = verificationresult;
120 mDecryptResult = decryptionresult;
122 mAuditLogError = job->auditLogError();
123 mAuditLog = job->auditLogAsHtml();
127void QGpgMEJobExecutor::importResult(
const GpgME::ImportResult &result)
131 mImportResult = result;
132 mAuditLogError = job->auditLogError();
133 mAuditLog = job->auditLogAsHtml();
137QString QGpgMEJobExecutor::auditLogAsHtml()
const
142#include "moc_qgpgmejobexecutor.cpp"
int exec(ProcessEventsFlags flags)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
T qobject_cast(QObject *object)
QObject * sender() const const