aboutsummaryrefslogtreecommitdiffstats
path: root/lang
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2024-08-06 16:08:11 +0000
committerIngo Klöcker <[email protected]>2024-08-07 08:53:21 +0000
commita73eee3655e21c60cbc572216a8a90eff5ac6ea5 (patch)
treed2ea6393c454b3d7806d474e96e4123419ae4553 /lang
parenttests,json: Remove no longer needed code (diff)
downloadgpgme-a73eee3655e21c60cbc572216a8a90eff5ac6ea5.tar.gz
gpgme-a73eee3655e21c60cbc572216a8a90eff5ac6ea5.zip
qt: Use --quick-set-ownertrust if available
* lang/qt/src/qgpgmechangeownertrustjob.cpp (set_owner_trust): New. (QGpgMEChangeOwnerTrustJob::start): Use set_owner_trust if gpg is new enough. * lang/qt/tests/t-ownertrust.cpp (ChangeOwnerTrustTest::testChangeOwnerTrust): Log unexpected error. -- Using the --quick-set-ownertrust command to set the owner trust is much more robust than using the edit interface. Prefer the former if gpg supports it. GnuPG-bug-id: 7239
Diffstat (limited to 'lang')
-rw-r--r--lang/qt/src/qgpgmechangeownertrustjob.cpp17
-rw-r--r--lang/qt/tests/t-ownertrust.cpp3
2 files changed, 19 insertions, 1 deletions
diff --git a/lang/qt/src/qgpgmechangeownertrustjob.cpp b/lang/qt/src/qgpgmechangeownertrustjob.cpp
index 07febab6..2c8c4e53 100644
--- a/lang/qt/src/qgpgmechangeownertrustjob.cpp
+++ b/lang/qt/src/qgpgmechangeownertrustjob.cpp
@@ -5,6 +5,8 @@
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
+ Copyright (c) 2024 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
@@ -42,6 +44,7 @@
#include <gpgme++/context.h>
#include <gpgme++/data.h>
+#include <gpgme++/engineinfo.h>
#include <gpgme++/gpgsetownertrusteditinteractor.h>
#include <gpgme++/key.h>
@@ -59,6 +62,14 @@ QGpgMEChangeOwnerTrustJob::QGpgMEChangeOwnerTrustJob(Context *context)
QGpgMEChangeOwnerTrustJob::~QGpgMEChangeOwnerTrustJob() {}
+static QGpgMEChangeOwnerTrustJob::result_type set_owner_trust(Context *ctx, const Key &key, Key::OwnerTrust trust)
+{
+ const Error err = ctx->setOwnerTrust(key, trust);
+ Error ae;
+ const QString log = _detail::audit_log_as_html(ctx, ae);
+ return std::make_tuple(err, log, ae);
+}
+
static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, const Key &key, Key::OwnerTrust trust)
{
EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(trust);
@@ -75,7 +86,11 @@ static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, co
Error QGpgMEChangeOwnerTrustJob::start(const Key &key, Key::OwnerTrust trust)
{
- run(std::bind(&change_ownertrust, std::placeholders::_1, key, trust));
+ if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.4.6") {
+ run(std::bind(&change_ownertrust, std::placeholders::_1, key, trust));
+ } else {
+ run(std::bind(&set_owner_trust, std::placeholders::_1, key, trust));
+ }
return Error();
}
#include "qgpgmechangeownertrustjob.moc"
diff --git a/lang/qt/tests/t-ownertrust.cpp b/lang/qt/tests/t-ownertrust.cpp
index 653304e4..a032dfbd 100644
--- a/lang/qt/tests/t-ownertrust.cpp
+++ b/lang/qt/tests/t-ownertrust.cpp
@@ -89,6 +89,9 @@ private Q_SLOTS:
ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
{
+ if (e) {
+ qDebug() << "Error in result: " << e;
+ }
QVERIFY(!e);
Q_EMIT asyncDone();
});