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 : m_signature(signature)
22 , m_plainText(plainText)
29VerifyDetachedBodyPartMemento::~VerifyDetachedBodyPartMemento()
35 m_keylistjob->slotCancel();
39bool VerifyDetachedBodyPartMemento::start()
43 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento started";
45 connect(m_job.data(), &VerifyDetachedJob::result,
this, &VerifyDetachedBodyPartMemento::slotResult);
46 if (
const Error err = m_job->start(m_signature, m_plainText)) {
47 m_vr = VerificationResult(err);
49 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento stopped with error";
57void VerifyDetachedBodyPartMemento::exec()
62 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento execed";
64 saveResult(m_job->exec(m_signature, m_plainText));
68 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento after execed";
70 if (canStartKeyListJob()) {
71 std::vector<GpgME::Key> keys;
72 m_keylistjob->exec(keyListPattern(),
false, keys);
78 m_keylistjob->deleteLater();
80 m_keylistjob =
nullptr;
84bool VerifyDetachedBodyPartMemento::canStartKeyListJob()
const
89 const char *
const fpr = m_vr.signature(0).fingerprint();
93QStringList VerifyDetachedBodyPartMemento::keyListPattern()
const
95 assert(canStartKeyListJob());
99void VerifyDetachedBodyPartMemento::saveResult(
const VerificationResult &vr)
102#ifdef DEBUG_SIGNATURE
103 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::saveResult called";
106 setAuditLog(m_job->auditLogError(), m_job->auditLogAsHtml());
109void VerifyDetachedBodyPartMemento::slotResult(
const VerificationResult &vr)
111#ifdef DEBUG_SIGNATURE
112 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotResult called";
116 if (canStartKeyListJob() && startKeyListJob()) {
117#ifdef DEBUG_SIGNATURE
118 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento: canStartKeyListJob && startKeyListJob";
123 m_keylistjob->deleteLater();
125 m_keylistjob =
nullptr;
130bool VerifyDetachedBodyPartMemento::startKeyListJob()
132 assert(canStartKeyListJob());
133 if (
const GpgME::Error err = m_keylistjob->start(keyListPattern())) {
136 connect(m_keylistjob.data(), &Job::done,
this, &VerifyDetachedBodyPartMemento::slotKeyListJobDone);
137 connect(m_keylistjob.data(), &KeyListJob::nextKey,
this, &VerifyDetachedBodyPartMemento::slotNextKey);
141void VerifyDetachedBodyPartMemento::slotNextKey(
const GpgME::Key &key)
143#ifdef DEBUG_SIGNATURE
144 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotNextKey called";
149void VerifyDetachedBodyPartMemento::slotKeyListJobDone()
151#ifdef DEBUG_SIGNATURE
152 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyDetachedBodyPartMemento::slotKeyListJobDone called";
154 m_keylistjob =
nullptr;
159#include "moc_verifydetachedbodypartmemento.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString fromLatin1(QByteArrayView str)