summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@gnupg.org>2019-10-29 16:33:58 +0100
committerAndre Heinecke <aheinecke@gnupg.org>2019-10-29 16:33:58 +0100
commit373acd6923f2fc968fb870d2a8a9b49398cb652f (patch)
tree3f0750f9fde0f8f5b915a624bb092ff69a9c1354
parent36f7f7a478228a64d3d51a4901a264c8f55f90bb (diff)
downloadgpgme-373acd6923f2fc968fb870d2a8a9b49398cb652f.tar.gz
qt: Extend signkeyjob to handle remarks and dups
* lang/qt/src/qgpgmesignkeyjob.cpp: Handle remarks and dupeOK. * lang/qt/src/signkeyjob.h (SignKeyJob::setDupeOk), (SignKeyJob::setRemark): New. -- This API makes it easy for Kleopatra to add remarks for: GnuPG-Bug-Id: T4734
-rw-r--r--NEWS5
-rw-r--r--lang/qt/src/qgpgmesignkeyjob.cpp31
-rw-r--r--lang/qt/src/qgpgmesignkeyjob.h10
-rw-r--r--lang/qt/src/signkeyjob.h18
4 files changed, 61 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 5a95184a..a986f937 100644
--- a/NEWS
+++ b/NEWS
@@ -8,10 +8,15 @@ Noteworthy changes in version 1.14.0 (unreleased)
* cpp: The sign key edit-interactor now supports multiple signatures
from the same key. [#4734]
+ * qt: Extended signkeyjob to handle remarks and multiple signatures.
+ [#4734]
+
* Interface changes relative to the 1.13.1 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpp: UserID::remark NEW.
cpp: GpgSignKeyEditInteractor::setDupeOk NEW.
+ qt: SignKeyJob::setDupeOk NEW.
+ qt: SignKeyJob::setRemark NEW.
Noteworthy changes in version 1.13.1 (2019-06-13)
diff --git a/lang/qt/src/qgpgmesignkeyjob.cpp b/lang/qt/src/qgpgmesignkeyjob.cpp
index 2befe539..7f79cb56 100644
--- a/lang/qt/src/qgpgmesignkeyjob.cpp
+++ b/lang/qt/src/qgpgmesignkeyjob.cpp
@@ -57,14 +57,17 @@ QGpgMESignKeyJob::QGpgMESignKeyJob(Context *context)
m_checkLevel(0),
m_exportable(false),
m_nonRevocable(false),
- m_started(false)
+ m_started(false),
+ m_dupeOk(false)
{
lateInitialization();
}
QGpgMESignKeyJob::~QGpgMESignKeyJob() {}
-static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, const std::vector<unsigned int> &uids, unsigned int checkLevel, const Key &signer, unsigned int opts)
+static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, const std::vector<unsigned int> &uids,
+ unsigned int checkLevel, const Key &signer, unsigned int opts,
+ bool dupeOk, const QString &remark)
{
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
@@ -74,6 +77,15 @@ static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, cons
skei->setCheckLevel(checkLevel);
skei->setSigningOptions(opts);
+ if (dupeOk) {
+ ctx->setFlag("extended-edit", "1");
+ skei->setDupeOk(true);
+ }
+
+ if (!remark.isEmpty()) {
+ ctx->addSignatureNotation("rem@gnupg.org", remark.toUtf8().constData());
+ }
+
if (!signer.isNull())
if (const Error err = ctx->addSigningKey(signer)) {
return std::make_tuple(err, QString(), Error());
@@ -93,7 +105,8 @@ Error QGpgMESignKeyJob::start(const Key &key)
if (m_exportable) {
opts |= GpgSignKeyEditInteractor::Exportable;
}
- run(std::bind(&sign_key, std::placeholders::_1, key, m_userIDsToSign, m_checkLevel, m_signingKey, opts));
+ run(std::bind(&sign_key, std::placeholders::_1, key, m_userIDsToSign, m_checkLevel, m_signingKey, opts,
+ m_dupeOk, m_remark));
m_started = true;
return Error();
}
@@ -127,4 +140,16 @@ void QGpgMESignKeyJob::setNonRevocable(bool nonRevocable)
assert(!m_started);
m_nonRevocable = nonRevocable;
}
+
+void QGpgMESignKeyJob::setRemark(const QString &remark)
+{
+ assert(!m_started);
+ m_remark = remark;
+}
+
+void QGpgMESignKeyJob::setDupeOk(bool value)
+{
+ assert(!m_started);
+ m_dupeOk = value;
+}
#include "qgpgmesignkeyjob.moc"
diff --git a/lang/qt/src/qgpgmesignkeyjob.h b/lang/qt/src/qgpgmesignkeyjob.h
index 3b311913..9c19c02b 100644
--- a/lang/qt/src/qgpgmesignkeyjob.h
+++ b/lang/qt/src/qgpgmesignkeyjob.h
@@ -39,6 +39,8 @@
#include "threadedjobmixin.h"
+#include <QString>
+
#ifdef BUILDING_QGPGME
# include "key.h"
#else
@@ -82,6 +84,12 @@ public:
/* from SignKeyJob */
void setNonRevocable(bool nonRevocable) Q_DECL_OVERRIDE;
+ /* from SignKeyJob */
+ void setRemark(const QString &remark) Q_DECL_OVERRIDE;
+
+ /* from SignKeyJob */
+ void setDupeOk(bool value) Q_DECL_OVERRIDE;
+
private:
std::vector<unsigned int> m_userIDsToSign;
GpgME::Key m_signingKey;
@@ -89,6 +97,8 @@ private:
bool m_exportable;
bool m_nonRevocable;
bool m_started;
+ bool m_dupeOk;
+ QString m_remark;
};
}
diff --git a/lang/qt/src/signkeyjob.h b/lang/qt/src/signkeyjob.h
index 7a7800dd..e3ae75f7 100644
--- a/lang/qt/src/signkeyjob.h
+++ b/lang/qt/src/signkeyjob.h
@@ -45,6 +45,8 @@ class Error;
class Key;
}
+class QString;
+
namespace QGpgME
{
@@ -109,6 +111,22 @@ public:
*/
virtual void setNonRevocable(bool nonRevocable) = 0;
+ /**
+ * Set this if it is ok to overwrite an existing signature. In that
+ * case the context has to have the flag "extended-edit" set to 1 through
+ * Context::setFlag before calling edit.
+ *
+ * Not pure virtual for ABI compatibility.
+ **/
+ virtual void setDupeOk(bool) {};
+
+ /**
+ * Add a remark to the signature. This uses rem@gnupg.org as a notation.
+ *
+ * Not pure virtual for ABI compatibility.
+ **/
+ virtual void setRemark(const QString &) {};
+
Q_SIGNALS:
void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
};