7#include "verifyopaquebodypartmemento.h"
9#include <QGpgME/KeyListJob>
10#include <QGpgME/VerifyOpaqueJob>
12#include <gpgme++/keylistresult.h>
16using namespace QGpgME;
18using namespace MimeTreeParser;
20VerifyOpaqueBodyPartMemento::VerifyOpaqueBodyPartMemento(VerifyOpaqueJob *job, KeyListJob *klj,
const QByteArray &signature)
21 : CryptoBodyPartMemento()
22 , m_signature(signature)
29VerifyOpaqueBodyPartMemento::~VerifyOpaqueBodyPartMemento()
35 m_keylistjob->slotCancel();
39bool VerifyOpaqueBodyPartMemento::start()
43 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento started";
45 if (
const Error err = m_job->start(m_signature)) {
46 m_vr = VerificationResult(err);
48 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento stopped with error";
52 connect(m_job.
data(), &VerifyOpaqueJob::result,
this, &VerifyOpaqueBodyPartMemento::slotResult);
57void VerifyOpaqueBodyPartMemento::exec()
63 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento execed";
65 saveResult(m_job->exec(m_signature, plainText), plainText);
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;
85bool VerifyOpaqueBodyPartMemento::canStartKeyListJob()
const
90 const char *
const fpr = m_vr.signature(0).fingerprint();
94QStringList VerifyOpaqueBodyPartMemento::keyListPattern()
const
96 assert(canStartKeyListJob());
100void 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());
111void 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;
132bool 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);
143void VerifyOpaqueBodyPartMemento::slotNextKey(
const GpgME::Key &key)
145#ifdef DEBUG_SIGNATURE
146 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento::slotNextKey called";
151void VerifyOpaqueBodyPartMemento::slotKeyListJobDone()
153#ifdef DEBUG_SIGNATURE
154 qCDebug(MIMETREEPARSER_LOG) <<
"tokoe: VerifyOpaqueBodyPartMemento::slotKeyListJobDone called";
156 m_keylistjob =
nullptr;
161#include "moc_verifyopaquebodypartmemento.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString fromLatin1(QByteArrayView str)