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

Remove command to list the available smart card readers

Listing the available readers, so that they can be copied to a GnuPG
configuration file, isn't needed anymore, because the reader can now
be selected via the Smart Cards configuration.

GnuPG-bug-id: 5857
parent 9cd07dc4
Pipeline #141827 passed with stage
in 3 minutes and 29 seconds
......@@ -259,7 +259,6 @@ set(_kleopatra_SRCS
commands/importcertificatefrompivcardcommand.cpp
commands/createopenpgpkeyfromcardkeyscommand.cpp
commands/createcsrforcardkeycommand.cpp
commands/listreaderscommand.cpp
${_kleopatra_uiserver_files}
......
/* commands/listreaderscommand.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "listreaderscommand.h"
#include "command_p.h"
#include <Libkleo/SCDaemon>
#include <KLocalizedString>
#include <KMessageBox>
using namespace Kleo;
using namespace Kleo::Commands;
class ListReadersCommand::Private : public Command::Private
{
friend class ::Kleo::Commands::ListReadersCommand;
ListReadersCommand *q_func() const
{
return static_cast<ListReadersCommand *>(q);
}
public:
explicit Private(ListReadersCommand *qq, QWidget *parent);
~Private() override;
private:
void start();
};
ListReadersCommand::Private *ListReadersCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const ListReadersCommand::Private *ListReadersCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
#define d d_func()
#define q q_func()
ListReadersCommand::Private::Private(ListReadersCommand *qq, QWidget *parent)
: Command::Private(qq, parent)
{
}
ListReadersCommand::Private::~Private() = default;
void ListReadersCommand::Private::start()
{
GpgME::Error err;
const auto readers = SCDaemon::getReaders(err);
QString message;
if (err) {
message = i18nc("@info", "Reading the list of readers failed:") + QLatin1Char{'\n'} +
QString::fromUtf8(err.asString()).toHtmlEscaped();
} else if (readers.empty()) {
message = i18nc("@info", "Available smartcard readers:") + QLatin1String{"<p>"} +
i18nc("@info No smartcard readers have been found", "<em>None</em>") + QLatin1String{"</p>"};
} else {
QStringList l;
std::transform(std::cbegin(readers), std::cend(readers),
std::back_inserter(l),
[](const auto &s) { return QString::fromStdString(s).toHtmlEscaped(); });
message = i18nc("@info", "Available smartcard readers:") +
QLatin1String{"<ul><li>"} +
l.join(QLatin1String{"</li><li>"}) +
QLatin1String{"</li></ul>"};
}
KMessageBox::information(parentWidgetOrView(),
QLatin1String{"<html>"} + message + QLatin1String{"</html>"},
i18nc("@title", "Smartcard Readers"));
finished();
}
ListReadersCommand::ListReadersCommand(QWidget *parent)
: Command(new Private(this, parent))
{
}
ListReadersCommand::~ListReadersCommand() = default;
void ListReadersCommand::doStart()
{
d->start();
}
void ListReadersCommand::doCancel()
{
}
#undef d
#undef q
/* commands/listreaderscommand.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "command.h"
namespace Kleo
{
namespace Commands
{
class ListReadersCommand : public Command
{
Q_OBJECT
public:
explicit ListReadersCommand(QWidget *parent = nullptr);
~ListReadersCommand() override;
private:
void doStart() override;
void doCancel() override;
private:
class Private;
inline Private *d_func();
inline const Private *d_func() const;
};
} // namespace Commands
} // namespace Kleo
......@@ -72,7 +72,6 @@
<Menu name="settings">
<text>&amp;Settings</text>
<Action name="settings_self_test"/>
<Action name="settings_list_readers"/>
<Action name="configure_groups" append="configure_merge"/>
</Menu>
<Menu name="window" append="settings_merge">
......
......@@ -25,7 +25,6 @@
#include "commands/importcertificatefromfilecommand.h"
#include "commands/decryptverifyfilescommand.h"
#include "commands/signencryptfilescommand.h"
#include "commands/listreaderscommand.h"
#include "conf/groupsconfigdialog.h"
......@@ -288,12 +287,6 @@ public:
ui.stackWidget->resize(ui.padWidget->sizeHint());
}
void listSmartcardReaders()
{
auto command = new ListReadersCommand(q);
command->start();
}
void restartDaemons()
{
Kleo::killDaemons();
......@@ -464,10 +457,6 @@ void MainWindow::Private::setupActions()
"settings_self_test", i18n("Perform Self-Test"), QString(),
nullptr, q, SLOT(selfTest()), QString(), false, true
},
{
"settings_list_readers", i18n("List Smartcard Readers"), QString(),
nullptr, q, SLOT(listSmartcardReaders()), QString(), false, true
},
{
"configure_groups", i18n("Configure Groups..."), QString(),
"group", q, SLOT(configureGroups()), QString(), false, true
......
......@@ -53,6 +53,5 @@ private:
Q_PRIVATE_SLOT(d, void showPadView())
Q_PRIVATE_SLOT(d, void showSmartcardView())
Q_PRIVATE_SLOT(d, void forceUpdateCheck())
Q_PRIVATE_SLOT(d, void listSmartcardReaders())
Q_PRIVATE_SLOT(d, void restartDaemons())
};
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