7#include "verifydetachedbodypartmemento.h"
9#include <QGpgME/KeyListJob>
10#include <QGpgME/VerifyDetachedJob>
12#include <gpgme++/keylistresult.h>
16using namespace QGpgME;
18using namespace MimeTreeParser;
20VerifyDetachedBodyPartMemento::VerifyDetachedBodyPartMemento(VerifyDetachedJob *job, KeyListJob *klj,
const QByteArray &signature,
const QByteArray &plainText)
21 : CryptoBodyPartMemento()
22 , m_signature(signature)
23 , m_plainText(plainText)
30VerifyDetachedBodyPartMemento::~VerifyDetachedBodyPartMemento()
36 m_keylistjob->slotCancel();
40bool VerifyDetachedBodyPartMemento::start()
44 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento started";
46 connect(m_job.
data(), &VerifyDetachedJob::result,
this, &VerifyDetachedBodyPartMemento::slotResult);
47 if (
const Error err = m_job->start(m_signature, m_plainText)) {
48 m_vr = VerificationResult(err);
50 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento stopped with error";
58void VerifyDetachedBodyPartMemento::exec()
63 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento execed";
65 saveResult(m_job->exec(m_signature, m_plainText));
69 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento 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;
85bool VerifyDetachedBodyPartMemento::canStartKeyListJob()
const
90 const char *
const fpr = m_vr.signature(0).fingerprint();
94QStringList VerifyDetachedBodyPartMemento::keyListPattern()
const
96 assert(canStartKeyListJob());
100void VerifyDetachedBodyPartMemento::saveResult(
const VerificationResult &vr)
103#ifdef DEBUG_SIGNATURE
104 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::saveResult called";
107 setAuditLog(m_job->auditLogError(), m_job->auditLogAsHtml());
110void VerifyDetachedBodyPartMemento::slotResult(
const VerificationResult &vr)
112#ifdef DEBUG_SIGNATURE
113 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotResult called";
117 if (canStartKeyListJob() && startKeyListJob()) {
118#ifdef DEBUG_SIGNATURE
119 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento: canStartKeyListJob && startKeyListJob";
124 m_keylistjob->deleteLater();
126 m_keylistjob =
nullptr;
131bool VerifyDetachedBodyPartMemento::startKeyListJob()
133 assert(canStartKeyListJob());
134 if (
const GpgME::Error err = m_keylistjob->start(keyListPattern())) {
137 connect(m_keylistjob.
data(), &Job::done,
this, &VerifyDetachedBodyPartMemento::slotKeyListJobDone);
138 connect(m_keylistjob.
data(), &KeyListJob::nextKey,
this, &VerifyDetachedBodyPartMemento::slotNextKey);
142void VerifyDetachedBodyPartMemento::slotNextKey(
const GpgME::Key &key)
144#ifdef DEBUG_SIGNATURE
145 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotNextKey called";
150void VerifyDetachedBodyPartMemento::slotKeyListJobDone()
152#ifdef DEBUG_SIGNATURE
153 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotKeyListJobDone called";
155 m_keylistjob =
nullptr;
160#include "moc_verifydetachedbodypartmemento.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString fromLatin1(QByteArrayView str)