7 #include "verifyopaquebodypartmemento.h"
9 #include <QGpgME/KeyListJob>
10 #include <QGpgME/VerifyOpaqueJob>
12 #include <gpgme++/keylistresult.h>
16 using namespace QGpgME;
17 using namespace GpgME;
18 using namespace MimeTreeParser;
20 VerifyOpaqueBodyPartMemento::VerifyOpaqueBodyPartMemento(VerifyOpaqueJob *job, KeyListJob *klj,
const QByteArray &signature)
21 : CryptoBodyPartMemento()
22 , m_signature(signature)
29 VerifyOpaqueBodyPartMemento::~VerifyOpaqueBodyPartMemento()
35 m_keylistjob->slotCancel();
42 #ifdef DEBUG_SIGNATURE
43 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento started";
45 if (
const Error err = m_job->start(m_signature)) {
46 m_vr = VerificationResult(err);
47 #ifdef DEBUG_SIGNATURE
48 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento stopped with error";
52 connect(m_job.data(), &VerifyOpaqueJob::result,
this, &VerifyOpaqueBodyPartMemento::slotResult);
57 void VerifyOpaqueBodyPartMemento::exec()
62 #ifdef DEBUG_SIGNATURE
63 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento execed";
65 saveResult(m_job->exec(m_signature, plainText), plainText);
66 #ifdef DEBUG_SIGNATURE
67 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento after execed";
71 if (canStartKeyListJob()) {
72 std::vector<GpgME::Key> keys;
73 m_keylistjob->exec(keyListPattern(),
false, keys);
79 m_keylistjob->deleteLater();
81 m_keylistjob =
nullptr;
85 bool VerifyOpaqueBodyPartMemento::canStartKeyListJob()
const
90 const char *
const fpr = m_vr.signature(0).fingerprint();
94 QStringList VerifyOpaqueBodyPartMemento::keyListPattern()
const
96 assert(canStartKeyListJob());
100 void VerifyOpaqueBodyPartMemento::saveResult(
const VerificationResult &vr,
const QByteArray &plainText)
103 #ifdef DEBUG_SIGNATURE
104 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento::saveResult called";
107 m_plainText = plainText;
108 setAuditLog(m_job->auditLogError(), m_job->auditLogAsHtml());
111 void VerifyOpaqueBodyPartMemento::slotResult(
const VerificationResult &vr,
const QByteArray &plainText)
113 #ifdef DEBUG_SIGNATURE
114 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento::slotResult called";
116 saveResult(vr, plainText);
118 if (canStartKeyListJob() && startKeyListJob()) {
119 #ifdef DEBUG_SIGNATURE
120 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento: canStartKeyListJob && startKeyListJob";
125 m_keylistjob->deleteLater();
127 m_keylistjob =
nullptr;
132 bool VerifyOpaqueBodyPartMemento::startKeyListJob()
134 assert(canStartKeyListJob());
135 if (
const GpgME::Error err = m_keylistjob->start(keyListPattern())) {
138 connect(m_keylistjob.data(), &Job::done,
this, &VerifyOpaqueBodyPartMemento::slotKeyListJobDone);
139 connect(m_keylistjob.data(), &KeyListJob::nextKey,
this, &VerifyOpaqueBodyPartMemento::slotNextKey);
143 void VerifyOpaqueBodyPartMemento::slotNextKey(
const GpgME::Key &key)
145 #ifdef DEBUG_SIGNATURE
146 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento::slotNextKey called";
151 void VerifyOpaqueBodyPartMemento::slotKeyListJobDone()
153 #ifdef DEBUG_SIGNATURE
154 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento::slotKeyListJobDone called";
156 m_keylistjob =
nullptr;