Page MenuHome GnuPG

No OneTemporary

diff --git a/src/commands/addadskcommand.cpp b/src/commands/addadskcommand.cpp
index 8e824e310..a793c433c 100644
--- a/src/commands/addadskcommand.cpp
+++ b/src/commands/addadskcommand.cpp
@@ -1,152 +1,152 @@
/*
SPDX-FileCopyrightText: 2024 g10 Code GmbH
SPDX-FileContributor: Tobias Fella <tobias.fella@gnupg.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "addadskcommand.h"
#include "command_p.h"
#include <Libkleo/Formatting>
#include <KLocalizedString>
#include <QGpgME/Protocol>
#include <QGpgME/QuickJob>
#include <gpgme++/key.h>
#include <gpgme.h>
using namespace Kleo::Commands;
using namespace GpgME;
using namespace QGpgME;
class AddADSKCommand::Private : public Command::Private
{
AddADSKCommand *q_func() const
{
return static_cast<AddADSKCommand *>(q);
}
public:
explicit Private(AddADSKCommand *qq);
~Private() override;
void slotResult(const Error &err);
void createJob();
void showErrorDialog(const Error &error);
void showSuccessDialog();
QPointer<QuickJob> job;
};
AddADSKCommand::Private *AddADSKCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const AddADSKCommand::Private *AddADSKCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
#define d d_func()
#define q q_func()
AddADSKCommand::Private::Private(AddADSKCommand *qq)
: Command::Private{qq}
{
}
AddADSKCommand::Private::~Private() = default;
void AddADSKCommand::Private::slotResult(const Error &err)
{
if (err.isCanceled()) {
canceled();
return;
}
if (err) {
showErrorDialog(err);
} else {
showSuccessDialog();
}
finished();
}
void AddADSKCommand::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;
}
void AddADSKCommand::Private::showErrorDialog(const Error &err)
{
error(i18nc("@info",
"<p>An error occurred while trying to add "
"an ADSK to <b>%1</b>:</p><p>%2</p>",
Formatting::formatForComboBox(key()),
Formatting::errorAsString(err)));
}
void AddADSKCommand::Private::showSuccessDialog()
{
success(i18nc("@info", "ADSK added successfully."));
}
AddADSKCommand::AddADSKCommand(const GpgME::Key &key)
: Command{key, new Private{this}}
{
}
AddADSKCommand::~AddADSKCommand() = default;
void AddADSKCommand::doStart()
{
auto code = KMessageBox::warningContinueCancel(d->parentWidgetOrView(),
i18nc("@info",
"By adding an ADSK to your certificate, you allow the owner of the ADSK to decrypt all new messages that "
"are encrypted for your certificate. Do you want to add the ADSK specified in the GnuPG configuration to your certificate?"),
i18nc("@title:dialog", "Add ADSK"),
KGuiItem(i18n("Add ADSK"), QStringLiteral("dialog-ok")));
if (code == KMessageBox::Cancel) {
- canceled();
+ d->canceled();
return;
}
d->createJob();
#if GPGME_VERSION_NUMBER >= 0x011800 // 1.24.0
d->job->startAddAdsk(d->key(), "default");
#endif
}
void AddADSKCommand::doCancel()
{
if (d->job) {
d->job->slotCancel();
}
}
#undef d
#undef q
#include "moc_addadskcommand.cpp"
diff --git a/src/commands/setinitialpincommand.cpp b/src/commands/setinitialpincommand.cpp
index 52a008e56..3b56f2a5d 100644
--- a/src/commands/setinitialpincommand.cpp
+++ b/src/commands/setinitialpincommand.cpp
@@ -1,193 +1,193 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/setinitialpincommand.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "cardcommand_p.h"
#include "setinitialpincommand.h"
#include "dialogs/setinitialpindialog.h"
#include "smartcard/netkeycard.h"
#include "smartcard/readerstatus.h"
#include <KLocalizedString>
using namespace Kleo;
using namespace Kleo::Commands;
using namespace Kleo::Dialogs;
using namespace Kleo::SmartCard;
using namespace GpgME;
class SetInitialPinCommand::Private : public CardCommand::Private
{
friend class ::Kleo::Commands::SetInitialPinCommand;
SetInitialPinCommand *q_func() const
{
return static_cast<SetInitialPinCommand *>(q);
}
public:
explicit Private(SetInitialPinCommand *qq, const std::string &serialNumber);
~Private() override;
private:
void init()
{
}
void ensureDialogCreated()
{
if (dialog) {
return;
}
auto dlg = new SetInitialPinDialog;
applyWindowID(dlg);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setWindowTitle(i18nc("@title:window", "Set Initial Pin"));
connect(dlg, &SetInitialPinDialog::nksPinRequested, q_func(), [this]() {
slotNksPinRequested();
});
connect(dlg, &SetInitialPinDialog::sigGPinRequested, q_func(), [this]() {
slotSigGPinRequested();
});
connect(dlg, &QDialog::rejected, q_func(), [this]() {
slotDialogRejected();
});
connect(dlg, &QDialog::accepted, q_func(), [this]() {
slotDialogAccepted();
});
dialog = dlg;
}
void ensureDialogVisible()
{
ensureDialogCreated();
if (dialog->isVisible()) {
dialog->raise();
} else {
dialog->show();
}
}
private:
void setInitialPin(const char *pinRef, const ReaderStatus::TransactionFunc &resultSlot)
{
const auto nksCard = ReaderStatus::instance()->getCard<NetKeyCard>(serialNumber());
if (!nksCard) {
error(i18n("Failed to find the NetKey card with the serial number: %1", QString::fromStdString(serialNumber())));
return;
}
const QByteArray command = QByteArray("SCD PASSWD --nullpin ") + pinRef;
ReaderStatus::mutableInstance()->startSimpleTransaction(nksCard, command, dialog, resultSlot);
}
void slotNksPinRequested()
{
setInitialPin("PW1.CH", [this](const GpgME::Error &error) {
dialog->setNksPinSettingResult(error);
});
}
void slotSigGPinRequested()
{
setInitialPin("PW1.CH.SIG", [this](const GpgME::Error &error) {
dialog->setSigGPinSettingResult(error);
});
}
void slotDialogRejected()
{
if (dialog->isComplete()) {
slotDialogAccepted();
} else {
canceled();
}
}
void slotDialogAccepted()
{
ReaderStatus::mutableInstance()->updateStatus();
finished();
}
private:
mutable QPointer<SetInitialPinDialog> dialog;
};
SetInitialPinCommand::Private *SetInitialPinCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const SetInitialPinCommand::Private *SetInitialPinCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
#define q q_func()
#define d d_func()
SetInitialPinCommand::Private::Private(SetInitialPinCommand *qq, const std::string &serialNumber)
: CardCommand::Private(qq, serialNumber, nullptr)
, dialog()
{
}
SetInitialPinCommand::Private::~Private()
{
}
SetInitialPinCommand::SetInitialPinCommand(const std::string &serialNumber)
: CardCommand(new Private(this, serialNumber))
{
d->init();
}
SetInitialPinCommand::~SetInitialPinCommand()
{
}
QDialog *SetInitialPinCommand::dialog()
{
d->ensureDialogCreated();
return d->dialog;
}
void SetInitialPinCommand::doStart()
{
d->ensureDialogCreated();
const auto nksCard = ReaderStatus::instance()->getCard<NetKeyCard>(d->serialNumber());
if (!nksCard) {
d->error(i18n("Failed to find the NetKey card with the serial number: %1", QString::fromStdString(d->serialNumber())));
d->dialog->close();
- finished();
+ d->finished();
return;
}
d->dialog->setNksPinPresent(!nksCard->hasNKSNullPin());
d->dialog->setSigGPinPresent(!nksCard->hasSigGNullPin());
d->ensureDialogVisible();
}
void SetInitialPinCommand::doCancel()
{
if (d->dialog) {
d->dialog->close();
}
}
#undef q_func
#undef d_func
#include "moc_setinitialpincommand.cpp"

File Metadata

Mime Type
text/x-diff
Expires
Sat, Feb 1, 9:13 AM (1 d, 7 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
80/b7/3ac96e87b579d2f13f9e7786a778

Event Timeline