Commit d672b49d authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Make name of class reflect what it does

Rename NewCertificateCommand to NewCertificateSigningRequestCommand
and remove an unused c'tor.

GnuPG-bug-id: 5832
parent 83732575
Pipeline #211427 passed with stage
in 3 minutes and 8 seconds
......@@ -175,8 +175,8 @@ set(_kleopatra_SRCS
commands/learncardkeyscommand.h
commands/lookupcertificatescommand.cpp
commands/lookupcertificatescommand.h
commands/newcertificatecommand.cpp
commands/newcertificatecommand.h
commands/newcertificatesigningrequestcommand.cpp
commands/newcertificatesigningrequestcommand.h
commands/newopenpgpcertificatecommand.cpp
commands/newopenpgpcertificatecommand.h
commands/pivgeneratecardkeycommand.cpp
......
/* -*- mode: c++; c-basic-offset:4 -*-
commands/newcertificatecommand.cpp
commands/newcertificatesigningrequestcommand.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
......@@ -11,10 +11,9 @@
#include <config-kleopatra.h>
#include "newcertificatecommand.h"
#include "newcertificatesigningrequestcommand.h"
#include "command_p.h"
#include "newopenpgpcertificatecommand.h"
#include "newcertificatewizard/newcertificatewizard.h"
......@@ -26,20 +25,20 @@ using namespace Kleo;
using namespace Kleo::Commands;
using namespace GpgME;
class NewCertificateCommand::Private : public Command::Private
class NewCertificateSigningRequestCommand::Private : public Command::Private
{
friend class ::Kleo::Commands::NewCertificateCommand;
NewCertificateCommand *q_func() const
friend class ::Kleo::Commands::NewCertificateSigningRequestCommand;
NewCertificateSigningRequestCommand *q_func() const
{
return static_cast<NewCertificateCommand *>(q);
return static_cast<NewCertificateSigningRequestCommand *>(q);
}
public:
explicit Private(NewCertificateCommand *qq, KeyListController *c)
explicit Private(NewCertificateSigningRequestCommand *qq, KeyListController *c)
: Command::Private{qq, c}
{
}
void createCertificate();
void createCSR();
private:
void slotDialogAccepted();
......@@ -51,11 +50,11 @@ private:
QPointer<NewCertificateWizard> dialog;
};
NewCertificateCommand::Private *NewCertificateCommand::d_func()
NewCertificateSigningRequestCommand::Private *NewCertificateSigningRequestCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const NewCertificateCommand::Private *NewCertificateCommand::d_func() const
const NewCertificateSigningRequestCommand::Private *NewCertificateSigningRequestCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
......@@ -63,7 +62,7 @@ const NewCertificateCommand::Private *NewCertificateCommand::d_func() const
#define d d_func()
#define q q_func()
void NewCertificateCommand::Private::createCertificate()
void NewCertificateSigningRequestCommand::Private::createCSR()
{
Q_ASSERT(!dialog);
......@@ -82,40 +81,35 @@ void NewCertificateCommand::Private::createCertificate()
dialog->show();
}
void NewCertificateCommand::Private::slotDialogAccepted()
void NewCertificateSigningRequestCommand::Private::slotDialogAccepted()
{
finished();
}
NewCertificateCommand::NewCertificateCommand()
: Command(new Private(this, nullptr))
NewCertificateSigningRequestCommand::NewCertificateSigningRequestCommand()
: NewCertificateSigningRequestCommand(nullptr, nullptr)
{
}
NewCertificateCommand::NewCertificateCommand(KeyListController *c)
: Command(new Private(this, c))
{
}
NewCertificateCommand::NewCertificateCommand(QAbstractItemView *v, KeyListController *c)
NewCertificateSigningRequestCommand::NewCertificateSigningRequestCommand(QAbstractItemView *v, KeyListController *c)
: Command(v, new Private(this, c))
{
}
NewCertificateCommand::~NewCertificateCommand() = default;
NewCertificateSigningRequestCommand::~NewCertificateSigningRequestCommand() = default;
void NewCertificateCommand::doStart()
void NewCertificateSigningRequestCommand::doStart()
{
const Kleo::Settings settings{};
if (settings.cmsEnabled() && settings.cmsCertificateCreationAllowed()) {
d->createCertificate();
d->createCSR();
} else {
d->error(i18n("You are not allowed to create S/MIME certificate signing requests."));
d->finished();
}
}
void NewCertificateCommand::doCancel()
void NewCertificateSigningRequestCommand::doCancel()
{
if (d->dialog) {
d->dialog->close();
......@@ -124,5 +118,3 @@ void NewCertificateCommand::doCancel()
#undef d
#undef q
#include "moc_newcertificatecommand.cpp"
/* -*- mode: c++; c-basic-offset:4 -*-
commands/newcertificatecommand.h
commands/newcertificatesigningrequestcommand.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
......@@ -18,14 +18,13 @@ namespace Kleo
namespace Commands
{
class NewCertificateCommand : public Command
class NewCertificateSigningRequestCommand : public Command
{
Q_OBJECT
public:
explicit NewCertificateCommand(QAbstractItemView *view, KeyListController *parent);
explicit NewCertificateCommand(KeyListController *parent);
explicit NewCertificateCommand();
~NewCertificateCommand() override;
NewCertificateSigningRequestCommand();
NewCertificateSigningRequestCommand(QAbstractItemView *view, KeyListController *parent);
~NewCertificateSigningRequestCommand() override;
private:
void doStart() override;
......
......@@ -46,7 +46,7 @@
#include "commands/checksumcreatefilescommand.h"
#include "commands/checksumverifyfilescommand.h"
#include "commands/detailscommand.h"
#include "commands/newcertificatecommand.h"
#include "commands/newcertificatesigningrequestcommand.h"
#include "commands/newopenpgpcertificatecommand.h"
#include "dialogs/updatenotification.h"
......@@ -472,7 +472,7 @@ QString KleopatraApplication::newInstance(const QCommandLineParser &parser,
if (protocol == GpgME::CMS) {
const Kleo::Settings settings{};
if (settings.cmsEnabled() && settings.cmsCertificateCreationAllowed()) {
auto cmd = new NewCertificateCommand(nullptr);
auto cmd = new NewCertificateSigningRequestCommand;
cmd->setParentWId(parentId);
cmd->start();
} else {
......
......@@ -51,7 +51,7 @@
#include "commands/certifycertificatecommand.h"
#include "commands/revokecertificationcommand.h"
#include "commands/adduseridcommand.h"
#include "commands/newcertificatecommand.h"
#include "commands/newcertificatesigningrequestcommand.h"
#include "commands/newopenpgpcertificatecommand.h"
#include "commands/checksumverifyfilescommand.h"
#include "commands/checksumcreatefilescommand.h"
......@@ -526,7 +526,7 @@ void KeyListController::createActions(KActionCollection *coll)
// ### somehow make this better...
registerActionForCommand<NewOpenPGPCertificateCommand>(coll->action(QStringLiteral("file_new_certificate")));
registerActionForCommand<NewCertificateCommand>(coll->action(QStringLiteral("file_new_certificate_signing_request")));
registerActionForCommand<NewCertificateSigningRequestCommand>(coll->action(QStringLiteral("file_new_certificate_signing_request")));
//---
registerActionForCommand<LookupCertificatesCommand>(coll->action(QStringLiteral("file_lookup_certificates")));
registerActionForCommand<ImportCertificateFromFileCommand>(coll->action(QStringLiteral("file_import_certificates")));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment