File indexing completed on 2025-01-19 04:46:49
0001 /* 0002 SPDX-FileCopyrightText: 2016 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <MimeTreeParser/BodyPart> 0010 #include <MimeTreeParser/Enums> 0011 #include <QObject> 0012 0013 #include <gpgme++/key.h> 0014 0015 namespace GpgME 0016 { 0017 class KeyListResult; 0018 } 0019 0020 class PgpKeyMemento : public QObject, public MimeTreeParser::Interface::BodyPartMemento 0021 { 0022 Q_OBJECT 0023 public: 0024 PgpKeyMemento(); 0025 ~PgpKeyMemento() override; 0026 0027 [[nodiscard]] bool isRunning() const; 0028 void setRunning(bool running); 0029 0030 [[nodiscard]] GpgME::Key key() const; 0031 [[nodiscard]] QString error() const; 0032 0033 [[nodiscard]] bool start(const QString &fingerprint); 0034 void exec(const QString &fingerprint); 0035 0036 void detach() override; 0037 0038 Q_SIGNALS: 0039 void update(MimeTreeParser::UpdateMode update); 0040 0041 private: 0042 void notify(); 0043 0044 private: 0045 void onKeyReceived(const GpgME::Key &key); 0046 void onListJobFinished(const GpgME::KeyListResult &result); 0047 0048 GpgME::Key mKey; 0049 QString mError; 0050 bool mIsRunning = false; 0051 };