Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F36623973
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
4 KB
Subscribers
None
View Options
diff --git a/src/commands/togglecertificateenabledcommand.cpp b/src/commands/togglecertificateenabledcommand.cpp
index 412efe51f..858d88a98 100644
--- a/src/commands/togglecertificateenabledcommand.cpp
+++ b/src/commands/togglecertificateenabledcommand.cpp
@@ -1,139 +1,156 @@
/*
SPDX-FileCopyrightText: 2024 g10 Code GmbH
SPDX-FileContributor: Tobias Fella <tobias.fella@gnupg.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "togglecertificateenabledcommand.h"
#include "command_p.h"
#include <Libkleo/Formatting>
#include <QGpgME/Protocol>
#include <QGpgME/QuickJob>
#include <gpgme++/engineinfo.h>
#include <gpgme++/key.h>
#include <gpgme.h>
#include <KLocalizedString>
using namespace Kleo::Commands;
using namespace GpgME;
using namespace QGpgME;
class ToggleCertificateEnabledCommand::Private : public Command::Private
{
ToggleCertificateEnabledCommand *q_func() const
{
return static_cast<ToggleCertificateEnabledCommand *>(q);
}
public:
explicit Private(ToggleCertificateEnabledCommand *qq, KeyListController *c = nullptr);
~Private() override;
void slotResult(const Error &err);
void createJob();
QPointer<QuickJob> job;
};
ToggleCertificateEnabledCommand::Private *ToggleCertificateEnabledCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const ToggleCertificateEnabledCommand::Private *ToggleCertificateEnabledCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
#define d d_func()
#define q q_func()
ToggleCertificateEnabledCommand::Private::Private(ToggleCertificateEnabledCommand *qq, KeyListController *c)
: Command::Private{qq, c}
{
}
ToggleCertificateEnabledCommand::ToggleCertificateEnabledCommand(QAbstractItemView *v, KeyListController *c)
: Command{v, new Private{this, c}}
{
}
ToggleCertificateEnabledCommand::Private::~Private() = default;
void ToggleCertificateEnabledCommand::Private::slotResult(const Error &err)
{
if (err.isCanceled()) {
canceled();
return;
}
if (err) {
if (key().isDisabled()) {
error(xi18nc("@info", "<para>Failed to enable certificate:</para><para><message>%1</message></para>", Formatting::errorAsString(err)));
} else {
error(xi18nc("@info", "<para>Failed to disable certificate:</para><para><message>%1</message></para>", Formatting::errorAsString(err)));
}
}
finished();
}
void ToggleCertificateEnabledCommand::Private::createJob()
{
Q_ASSERT(!job);
const auto backend = QGpgME::openpgp();
if (!backend) {
return;
}
const auto j = backend->quickJob();
if (!j) {
return;
}
connect(j, &QGpgME::Job::jobProgress, q, &Command::progress);
connect(j, &QuickJob::result, q, [this](const auto &err) {
slotResult(err);
});
job = j;
}
ToggleCertificateEnabledCommand::~ToggleCertificateEnabledCommand() = default;
void ToggleCertificateEnabledCommand::doStart()
{
+ if (!d->key().isDisabled()) {
+ auto result = KMessageBox::warningContinueCancel(d->parentWidgetOrView(),
+ xi18nc("@info",
+ "<para>Disabled certificates cannot be selected for signing or encryption."
+ " They are only visible when the <interface>Disabled</interface> filter is active.</para>"
+ "<para>You can undo this action at any time by switching to the "
+ "<interface>Disabled</interface> filter and enabling the certificate again.</para>"
+ "<para>Are you sure you want to disable and hide the certificate %1?</para>",
+ Formatting::summaryLine(d->key())),
+ i18nc("@title:dialog", "Disable Certificate"),
+ KGuiItem(i18nc("@action:button", "Disable Certificate")));
+ if (result == KMessageBox::Cancel) {
+ d->canceled();
+ return;
+ }
+ }
+
d->createJob();
#if GPGME_VERSION_NUMBER >= 0x011800 // 1.24.0
d->job->startSetKeyEnabled(d->key(), d->key().isDisabled());
#endif
}
void ToggleCertificateEnabledCommand::doCancel()
{
if (d->job) {
d->job->slotCancel();
}
}
// static
bool ToggleCertificateEnabledCommand::isSupported()
{
#if GPGME_VERSION_NUMBER >= 0x011800 // 1.24.0
return engineInfo(GpgEngine).engineVersion() >= "2.4.6";
#else
return false;
#endif
}
#undef d
#undef q
#include "moc_togglecertificateenabledcommand.cpp"
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Feb 26, 7:04 PM (19 h, 8 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
01/de/1982479a77900ede625aa5245fff
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment