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 
0011 #include <gpgme++/decryptionresult.h>
0012 #include <gpgme++/verificationresult.h>
0013 
0014 #include <QPointer>
0015 
0016 #include "interfaces/bodypart.h"
0017 
0018 namespace QGpgME
0019 {
0020 class DecryptVerifyJob;
0021 }
0022 
0023 namespace MimeTreeParser
0024 {
0025 class DecryptVerifyBodyPartMemento : public CryptoBodyPartMemento
0026 {
0027     Q_OBJECT
0028 public:
0029     explicit DecryptVerifyBodyPartMemento(QGpgME::DecryptVerifyJob *job, const QByteArray &cipherText);
0030     ~DecryptVerifyBodyPartMemento() override;
0031 
0032     [[nodiscard]] bool start() override;
0033     void exec() override;
0034 
0035     const QByteArray &plainText() const
0036     {
0037         return m_plainText;
0038     }
0039 
0040     const GpgME::DecryptionResult &decryptResult() const
0041     {
0042         return m_dr;
0043     }
0044 
0045     const GpgME::VerificationResult &verifyResult() const
0046     {
0047         return m_vr;
0048     }
0049 
0050 private Q_SLOTS:
0051     void slotResult(const GpgME::DecryptionResult &dr, const GpgME::VerificationResult &vr, const QByteArray &plainText);
0052 
0053 private:
0054     void saveResult(const GpgME::DecryptionResult &, const GpgME::VerificationResult &, const QByteArray &);
0055 
0056 private:
0057     // input:
0058     const QByteArray m_cipherText;
0059     QPointer<QGpgME::DecryptVerifyJob> m_job;
0060     // output:
0061     GpgME::DecryptionResult m_dr;
0062     GpgME::VerificationResult m_vr;
0063     QByteArray m_plainText;
0064 };
0065 }