aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lang/qt/src/Makefile.am6
-rw-r--r--lang/qt/src/job.cpp3
-rw-r--r--lang/qt/src/protocol.h3
-rw-r--r--lang/qt/src/protocol_p.h13
-rw-r--r--lang/qt/src/qgpgmerevokekeyjob.cpp96
-rw-r--r--lang/qt/src/qgpgmerevokekeyjob.h70
-rw-r--r--lang/qt/src/revokekeyjob.h86
7 files changed, 277 insertions, 0 deletions
diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index d47da895..3b0b9c3c 100644
--- a/lang/qt/src/Makefile.am
+++ b/lang/qt/src/Makefile.am
@@ -36,6 +36,7 @@ qgpgme_sources = \
qgpgmelistallkeysjob.cpp qgpgmenewcryptoconfig.cpp \
qgpgmereceivekeysjob.cpp \
qgpgmerefreshkeysjob.cpp \
+ qgpgmerevokekeyjob.cpp \
qgpgmesignencryptjob.cpp \
qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \
qgpgmeverifyopaquejob.cpp qgpgmewkdlookupjob.cpp threadedjobmixin.cpp \
@@ -70,6 +71,7 @@ qgpgme_headers= \
qgpgmenewcryptoconfig.h \
quickjob.h \
receivekeysjob.h \
+ revokekeyjob.h \
specialjob.h \
signjob.h \
signkeyjob.h \
@@ -114,6 +116,7 @@ camelcase_headers= \
QGpgMENewCryptoConfig \
QuickJob \
ReceiveKeysJob \
+ RevokeKeyJob \
SpecialJob \
SignJob \
SignKeyJob \
@@ -159,6 +162,7 @@ private_qgpgme_headers = \
qgpgmelistallkeysjob.h \
qgpgmereceivekeysjob.h \
qgpgmerefreshkeysjob.h \
+ qgpgmerevokekeyjob.h \
qgpgmesignencryptjob.h \
qgpgmesignjob.h \
qgpgmesignkeyjob.h \
@@ -212,6 +216,7 @@ qgpgme_moc_sources = \
qgpgmelistallkeysjob.moc \
qgpgmereceivekeysjob.moc \
qgpgmerefreshkeysjob.moc \
+ qgpgmerevokekeyjob.moc \
qgpgmesignencryptjob.moc \
qgpgmesignjob.moc \
qgpgmesignkeyjob.moc \
@@ -223,6 +228,7 @@ qgpgme_moc_sources = \
qgpgmetofupolicyjob.moc \
receivekeysjob.moc \
refreshkeysjob.moc \
+ revokekeyjob.moc \
signencryptjob.moc \
signjob.moc \
signkeyjob.moc \
diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp
index a9edc8ea..dba7556b 100644
--- a/lang/qt/src/job.cpp
+++ b/lang/qt/src/job.cpp
@@ -72,6 +72,7 @@
#include "quickjob.h"
#include "gpgcardjob.h"
#include "receivekeysjob.h"
+#include "revokekeyjob.h"
#include <QCoreApplication>
#include <QDebug>
@@ -172,6 +173,7 @@ make_job_subclass(WKSPublishJob)
make_job_subclass(TofuPolicyJob)
make_job_subclass(QuickJob)
make_job_subclass(GpgCardJob)
+make_job_subclass(RevokeKeyJob)
#undef make_job_subclass
@@ -208,3 +210,4 @@ make_job_subclass(GpgCardJob)
#include "quickjob.moc"
#include "gpgcardjob.moc"
#include "receivekeysjob.moc"
+#include "revokekeyjob.moc"
diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h
index 62b2cb2f..8538bd8d 100644
--- a/lang/qt/src/protocol.h
+++ b/lang/qt/src/protocol.h
@@ -71,6 +71,7 @@ class TofuPolicyJob;
class QuickJob;
class GpgCardJob;
class ReceiveKeysJob;
+class RevokeKeyJob;
/** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
*
@@ -173,6 +174,8 @@ public:
virtual ExportJob *secretSubkeyExportJob(bool armor = false) const = 0;
virtual AddExistingSubkeyJob *addExistingSubkeyJob() const = 0;
virtual ReceiveKeysJob *receiveKeysJob() const = 0;
+
+ virtual RevokeKeyJob *revokeKeyJob() const = 0;
};
/** Obtain a reference to the OpenPGP Protocol.
diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h
index 4211e001..2ca1cf18 100644
--- a/lang/qt/src/protocol_p.h
+++ b/lang/qt/src/protocol_p.h
@@ -65,6 +65,7 @@
#include "qgpgmetofupolicyjob.h"
#include "qgpgmequickjob.h"
#include "qgpgmereceivekeysjob.h"
+#include "qgpgmerevokekeyjob.h"
namespace
{
@@ -481,6 +482,18 @@ public:
}
return new QGpgME::QGpgMEQuickJob(context);
}
+
+ QGpgME::RevokeKeyJob *revokeKeyJob() const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::OpenPGP) {
+ return nullptr;
+ }
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return nullptr;
+ }
+ return new QGpgME::QGpgMERevokeKeyJob(context);
+ }
};
}
diff --git a/lang/qt/src/qgpgmerevokekeyjob.cpp b/lang/qt/src/qgpgmerevokekeyjob.cpp
new file mode 100644
index 00000000..08585414
--- /dev/null
+++ b/lang/qt/src/qgpgmerevokekeyjob.cpp
@@ -0,0 +1,96 @@
+/*
+ qgpgmerevokekeyjob.cpp
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2022 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ QGpgME is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ QGpgME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "qgpgmerevokekeyjob.h"
+
+#include "dataprovider.h"
+
+#include <context.h>
+#include <data.h>
+#include <gpgrevokekeyeditinteractor.h>
+#include <key.h>
+
+#include <gpg-error.h>
+
+using namespace QGpgME;
+using namespace GpgME;
+
+QGpgMERevokeKeyJob::QGpgMERevokeKeyJob(Context *context)
+ : mixin_type{context}
+{
+ lateInitialization();
+}
+
+QGpgMERevokeKeyJob::~QGpgMERevokeKeyJob() = default;
+
+static QGpgMERevokeKeyJob::result_type revoke_key(Context *ctx, const Key &key,
+ RevocationReason reason,
+ const std::vector<std::string> &description)
+{
+ std::unique_ptr<GpgRevokeKeyEditInteractor> interactor{new GpgRevokeKeyEditInteractor};
+ interactor->setReason(reason, description);
+
+ QGpgME::QByteArrayDataProvider dp;
+ Data outData(&dp);
+ assert(!outData.isNull());
+
+ ctx->setFlag("extended-edit", "1");
+
+ const Error err = ctx->edit(key, std::unique_ptr<EditInteractor>(interactor.release()), outData);
+ Error ae;
+ const QString log = _detail::audit_log_as_html(ctx, ae);
+ return std::make_tuple(err, log, ae);
+}
+
+Error QGpgMERevokeKeyJob::start(const GpgME::Key &key,
+ GpgME::RevocationReason reason,
+ const std::vector<std::string> &description)
+{
+ run(std::bind(&revoke_key, std::placeholders::_1, key, reason, description));
+ return {};
+}
+
+Error QGpgMERevokeKeyJob::exec(const GpgME::Key &key,
+ GpgME::RevocationReason reason,
+ const std::vector<std::string> &description)
+{
+ const result_type r = revoke_key(context(), key, reason, description);
+ resultHook(r);
+ return std::get<0>(r);
+}
+
+#include "qgpgmerevokekeyjob.moc"
diff --git a/lang/qt/src/qgpgmerevokekeyjob.h b/lang/qt/src/qgpgmerevokekeyjob.h
new file mode 100644
index 00000000..0eba5cb7
--- /dev/null
+++ b/lang/qt/src/qgpgmerevokekeyjob.h
@@ -0,0 +1,70 @@
+/*
+ qgpgmerevokekeyjob.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2022 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ QGpgME is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ QGpgME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef __QGPGME_QGPGMEREVOKEKEYJOB_H__
+#define __QGPGME_QGPGMEREVOKEKEYJOB_H__
+
+#include "threadedjobmixin.h"
+#include "revokekeyjob.h"
+
+namespace QGpgME
+{
+
+class QGpgMERevokeKeyJob
+#ifdef Q_MOC_RUN
+ : public RevokeKeyJob
+#else
+ : public _detail::ThreadedJobMixin<RevokeKeyJob>
+#endif
+{
+ Q_OBJECT
+#ifdef Q_MOC_RUN
+public Q_SLOTS:
+ void slotFinished();
+#endif
+public:
+ explicit QGpgMERevokeKeyJob(GpgME::Context *context);
+ ~QGpgMERevokeKeyJob() override;
+
+ GpgME::Error start(const GpgME::Key &key,
+ GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified,
+ const std::vector<std::string> &description = {}) override;
+
+ GpgME::Error exec(const GpgME::Key &key,
+ GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified,
+ const std::vector<std::string> &description = {}) override;
+};
+
+}
+
+#endif // __QGPGME_QGPGMEREVOKEKEYJOB_H__
diff --git a/lang/qt/src/revokekeyjob.h b/lang/qt/src/revokekeyjob.h
new file mode 100644
index 00000000..69aef062
--- /dev/null
+++ b/lang/qt/src/revokekeyjob.h
@@ -0,0 +1,86 @@
+/*
+ revokekeyjob.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2022 g10 Code GmbH
+ Software engineering by Ingo Klöcker <[email protected]>
+
+ QGpgME is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ QGpgME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef __QGPGME_REVOKEKEYJOB_H__
+#define __QGPGME_REVOKEKEYJOB_H__
+
+#include "job.h"
+#include "qgpgme_export.h"
+
+class QString;
+
+namespace GpgME
+{
+class Error;
+class Key;
+}
+
+namespace QGpgME
+{
+
+class QGPGME_EXPORT RevokeKeyJob : public Job
+{
+ Q_OBJECT
+protected:
+ explicit RevokeKeyJob(QObject *parent);
+
+public:
+ ~RevokeKeyJob();
+
+ /**
+ Starts the operation. \a key is the key to revoke with reason \a reason and
+ optional description \a description. The individual elements of \a description
+ must be non-empty strings and they must not contain any endline characters.
+
+ The job deletes itself after it has completed the operation.
+ */
+ virtual GpgME::Error start(const GpgME::Key &key,
+ GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified,
+ const std::vector<std::string> &description = {}) = 0;
+
+ /**
+ Runs the operation. \a key is the key to revoke with reason \a reason and
+ optional description \a description. The individual elements of \a description
+ must be non-empty strings and they must not contain any endline characters.
+ */
+ virtual GpgME::Error exec(const GpgME::Key &key,
+ GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified,
+ const std::vector<std::string> &description = {}) = 0;
+
+Q_SIGNALS:
+ void result(const GpgME::Error &result, const QString &auditLogAsHtml = {}, const GpgME::Error &auditLogError = {});
+};
+
+}
+
+#endif // __QGPGME_REVOKEKEYJOB_H__