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
This commit is contained in:
parent
668a1344c6
commit
a73eee3655
@ -5,6 +5,8 @@
|
|||||||
Copyright (c) 2008 Klarälvdalens Datakonsult AB
|
Copyright (c) 2008 Klarälvdalens Datakonsult AB
|
||||||
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
|
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
|
||||||
Software engineering by Intevation GmbH
|
Software engineering by Intevation GmbH
|
||||||
|
Copyright (c) 2024 g10 Code GmbH
|
||||||
|
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
|
||||||
|
|
||||||
QGpgME is free software; you can redistribute it and/or
|
QGpgME is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
@ -42,6 +44,7 @@
|
|||||||
|
|
||||||
#include <gpgme++/context.h>
|
#include <gpgme++/context.h>
|
||||||
#include <gpgme++/data.h>
|
#include <gpgme++/data.h>
|
||||||
|
#include <gpgme++/engineinfo.h>
|
||||||
#include <gpgme++/gpgsetownertrusteditinteractor.h>
|
#include <gpgme++/gpgsetownertrusteditinteractor.h>
|
||||||
#include <gpgme++/key.h>
|
#include <gpgme++/key.h>
|
||||||
|
|
||||||
@ -59,6 +62,14 @@ QGpgMEChangeOwnerTrustJob::QGpgMEChangeOwnerTrustJob(Context *context)
|
|||||||
|
|
||||||
QGpgMEChangeOwnerTrustJob::~QGpgMEChangeOwnerTrustJob() {}
|
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)
|
static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, const Key &key, Key::OwnerTrust trust)
|
||||||
{
|
{
|
||||||
EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(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)
|
Error QGpgMEChangeOwnerTrustJob::start(const Key &key, Key::OwnerTrust trust)
|
||||||
{
|
{
|
||||||
|
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.4.6") {
|
||||||
run(std::bind(&change_ownertrust, std::placeholders::_1, key, trust));
|
run(std::bind(&change_ownertrust, std::placeholders::_1, key, trust));
|
||||||
|
} else {
|
||||||
|
run(std::bind(&set_owner_trust, std::placeholders::_1, key, trust));
|
||||||
|
}
|
||||||
return Error();
|
return Error();
|
||||||
}
|
}
|
||||||
#include "qgpgmechangeownertrustjob.moc"
|
#include "qgpgmechangeownertrustjob.moc"
|
||||||
|
@ -89,6 +89,9 @@ private Q_SLOTS:
|
|||||||
ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
|
ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
|
||||||
connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
|
connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
|
||||||
{
|
{
|
||||||
|
if (e) {
|
||||||
|
qDebug() << "Error in result: " << e;
|
||||||
|
}
|
||||||
QVERIFY(!e);
|
QVERIFY(!e);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user