File indexing completed on 2024-06-23 05:19:21

0001 /*
0002   SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "cryptobodypartmemento.h"
0010 #include <gpgme++/decryptionresult.h>
0011 #include <gpgme++/key.h>
0012 #include <gpgme++/verificationresult.h>
0013 
0014 #include <QPointer>
0015 #include <QString>
0016 
0017 #include "interfaces/bodypart.h"
0018 
0019 namespace QGpgME
0020 {
0021 class VerifyOpaqueJob;
0022 class KeyListJob;
0023 }
0024 
0025 #include <QStringList>
0026 
0027 namespace MimeTreeParser
0028 {
0029 class VerifyOpaqueBodyPartMemento : public CryptoBodyPartMemento
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit VerifyOpaqueBodyPartMemento(QGpgME::VerifyOpaqueJob *job, QGpgME::KeyListJob *klj, const QByteArray &signature);
0034     ~VerifyOpaqueBodyPartMemento() override;
0035 
0036     bool start() override;
0037     void exec() override;
0038 
0039     const QByteArray &plainText() const
0040     {
0041         return m_plainText;
0042     }
0043 
0044     const GpgME::VerificationResult &verifyResult() const
0045     {
0046         return m_vr;
0047     }
0048 
0049     const GpgME::Key &signingKey() const
0050     {
0051         return m_key;
0052     }
0053 
0054 private Q_SLOTS:
0055     void slotResult(const GpgME::VerificationResult &vr, const QByteArray &plainText);
0056     void slotKeyListJobDone();
0057     void slotNextKey(const GpgME::Key &);
0058 
0059 private:
0060     void saveResult(const GpgME::VerificationResult &, const QByteArray &);
0061     [[nodiscard]] bool canStartKeyListJob() const;
0062     [[nodiscard]] QStringList keyListPattern() const;
0063     [[nodiscard]] bool startKeyListJob();
0064 
0065 private:
0066     // input:
0067     const QByteArray m_signature;
0068     QPointer<QGpgME::VerifyOpaqueJob> m_job;
0069     QPointer<QGpgME::KeyListJob> m_keylistjob;
0070     // output:
0071     GpgME::VerificationResult m_vr;
0072     QByteArray m_plainText;
0073     GpgME::Key m_key;
0074 };
0075 }