7 #include "verifydetachedbodypartmemento.h"
8 #include "mimetreeparser_debug.h"
10 #include <QGpgME/KeyListJob>
11 #include <QGpgME/VerifyDetachedJob>
13 #include <gpgme++/keylistresult.h>
17 using namespace QGpgME;
18 using namespace GpgME;
19 using namespace MimeTreeParser;
21 VerifyDetachedBodyPartMemento::VerifyDetachedBodyPartMemento(VerifyDetachedJob *job, KeyListJob *klj,
const QByteArray &signature,
const QByteArray &plainText)
22 : CryptoBodyPartMemento()
23 , m_signature(signature)
24 , m_plainText(plainText)
31 VerifyDetachedBodyPartMemento::~VerifyDetachedBodyPartMemento()
37 m_keylistjob->slotCancel();
44 #ifdef DEBUG_SIGNATURE
45 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento started";
47 connect(m_job.data(), &VerifyDetachedJob::result,
this, &VerifyDetachedBodyPartMemento::slotResult);
48 if (
const Error err = m_job->start(m_signature, m_plainText)) {
49 m_vr = VerificationResult(err);
50 #ifdef DEBUG_SIGNATURE
51 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento stopped with error";
59 void VerifyDetachedBodyPartMemento::exec()
63 #ifdef DEBUG_SIGNATURE
64 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento execed";
66 saveResult(m_job->exec(m_signature, m_plainText));
69 #ifdef DEBUG_SIGNATURE
70 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento after execed";
72 if (canStartKeyListJob()) {
73 std::vector<GpgME::Key> keys;
74 m_keylistjob->exec(keyListPattern(),
false, keys);
80 m_keylistjob->deleteLater();
82 m_keylistjob =
nullptr;
86 bool VerifyDetachedBodyPartMemento::canStartKeyListJob()
const
91 const char *
const fpr = m_vr.signature(0).fingerprint();
95 QStringList VerifyDetachedBodyPartMemento::keyListPattern()
const
97 assert(canStartKeyListJob());
101 void VerifyDetachedBodyPartMemento::saveResult(
const VerificationResult &vr)
104 #ifdef DEBUG_SIGNATURE
105 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::saveResult called";
108 setAuditLog(m_job->auditLogError(), m_job->auditLogAsHtml());
111 void VerifyDetachedBodyPartMemento::slotResult(
const VerificationResult &vr)
113 #ifdef DEBUG_SIGNATURE
114 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotResult called";
118 if (canStartKeyListJob() && startKeyListJob()) {
119 #ifdef DEBUG_SIGNATURE
120 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento: canStartKeyListJob && startKeyListJob";
125 m_keylistjob->deleteLater();
127 m_keylistjob =
nullptr;
132 bool VerifyDetachedBodyPartMemento::startKeyListJob()
134 assert(canStartKeyListJob());
135 if (
const GpgME::Error err = m_keylistjob->start(keyListPattern())) {
138 connect(m_keylistjob.data(), &Job::done,
this, &VerifyDetachedBodyPartMemento::slotKeyListJobDone);
139 connect(m_keylistjob.data(), &KeyListJob::nextKey,
this, &VerifyDetachedBodyPartMemento::slotNextKey);
143 void VerifyDetachedBodyPartMemento::slotNextKey(
const GpgME::Key &key)
145 #ifdef DEBUG_SIGNATURE
146 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotNextKey called";
151 void VerifyDetachedBodyPartMemento::slotKeyListJobDone()
153 #ifdef DEBUG_SIGNATURE
154 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotKeyListJobDone called";
156 m_keylistjob =
nullptr;