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

Add config module for smart card related settings

For now this module only offers the configuration of the reader port.

GnuPG-bug-id: 5857
parent 91db9838
Pipeline #141751 passed with stage
in 1 minute and 59 seconds
......@@ -32,7 +32,7 @@ option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
set(KF5_MIN_VERSION "5.91.0")
set(KMIME_VERSION "5.19.40")
set(LIBKLEO_VERSION "5.19.52")
set(LIBKLEO_VERSION "5.19.53")
set(QT_REQUIRED_VERSION "5.15.2")
set(GPGME_REQUIRED_VERSION "1.15.0")
set(BOOST_REQUIRED_VERSION "1.58")
......
......@@ -11,6 +11,8 @@ if(BUILD_libkleopatraclient)
smimevalidationconfigurationpage.h
cryptooperationsconfigwidget.h
cryptooperationsconfigpage.h
smartcardconfigpage.cpp
smartcardconfigpage.h
)
ki18n_wrap_ui(_kcm_kleopatra_libkleopatraclient_extra_SRCS
......
......@@ -25,6 +25,7 @@
#include "conf/cryptooperationsconfigpage.h"
#include "conf/dirservconfigpage.h"
#include "conf/gnupgsystemconfigurationpage.h"
#include "conf/smartcardconfigpage.h"
#include "conf/smimevalidationconfigurationpage.h"
ConfigureDialog::ConfigureDialog(QWidget *parent)
......@@ -58,6 +59,12 @@ ConfigureDialog::ConfigureDialog(QWidget *parent)
QStringLiteral("preferences-system-network"),
new Kleo::Config::SMimeValidationConfigurationPage(this));
}
if (settings.showSmartCardsConfiguration()) {
addModule(i18n("Smart Cards"),
QStringLiteral("kleopatra/configuration.html"),
QStringLiteral("auth-sim-locked"),
new Kleo::Config::SmartCardConfigurationPage{this});
}
if (settings.showGnuPGSystemConfiguration()) {
addModule(i18n("GnuPG System"),
QStringLiteral("kleopatra/configuration.html#configuration-gnupgsystem"),
......
/* -*- mode: c++; c-basic-offset:4 -*-
conf/smartcardconfigpage.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "smartcardconfigpage.h"
#include <Libkleo/Compat>
#include <Libkleo/ReaderPortSelection>
#include <KLocalizedString>
#include <QGpgME/CryptoConfig>
#include <QGpgME/Protocol>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
using namespace Kleo;
using namespace Kleo::Config;
using namespace QGpgME;
class SmartCardConfigurationPage::Private
{
public:
Private(SmartCardConfigurationPage *q);
static CryptoConfigEntry *readerPortConfigEntry(const CryptoConfig *config = nullptr);
public:
ReaderPortSelection *const mReaderPort;
};
SmartCardConfigurationPage::Private::Private(SmartCardConfigurationPage *qq)
: mReaderPort{new ReaderPortSelection{qq}}
{
}
// static
CryptoConfigEntry *SmartCardConfigurationPage::Private::readerPortConfigEntry(const CryptoConfig *config)
{
if (!config) {
config = QGpgME::cryptoConfig();
}
return Kleo::getCryptoConfigEntry(config, "scdaemon", "reader-port");
}
SmartCardConfigurationPage::SmartCardConfigurationPage(QWidget *parent, const QVariantList &args)
: KCModule{parent, args}
, d{std::make_unique<Private>(this)}
{
auto mainLayout = new QVBoxLayout{this};
mainLayout->setContentsMargins(0, 0, 0, 0);
{
auto l = new QHBoxLayout{};
l->setContentsMargins(0, 0, 0, 0);
auto label = new QLabel{i18n("Smart card reader to use:"), this};
label->setBuddy(d->mReaderPort);
l->addWidget(label);
l->addWidget(d->mReaderPort, 1);
mainLayout->addLayout(l);
connect(d->mReaderPort, &ReaderPortSelection::valueChanged,
this, &SmartCardConfigurationPage::markAsChanged);
}
mainLayout->addStretch();
load();
}
SmartCardConfigurationPage::~SmartCardConfigurationPage() = default;
void SmartCardConfigurationPage::load()
{
const auto *const entry = d->readerPortConfigEntry();
if (entry) {
d->mReaderPort->setEnabled(!entry->isReadOnly());
d->mReaderPort->setValue(entry->stringValue());
} else {
d->mReaderPort->setEnabled(false);
d->mReaderPort->setValue(i18n("Cannot be configured with Kleopatra"));
}
}
void SmartCardConfigurationPage::save()
{
auto config = QGpgME::cryptoConfig();
auto const entry = d->readerPortConfigEntry(config);
if (entry && !entry->isReadOnly()) {
entry->setStringValue(d->mReaderPort->value());
}
config->sync(true);
}
void SmartCardConfigurationPage::defaults()
{
const auto *const entry = d->readerPortConfigEntry();
if (entry && !entry->isReadOnly()) {
d->mReaderPort->setValue({});
}
}
/* -*- mode: c++; c-basic-offset:4 -*-
conf/smartcardconfigpage.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <KCModule>
#include <memory>
namespace Kleo
{
namespace Config
{
class SmartCardConfigurationPage : public KCModule
{
Q_OBJECT
public:
explicit SmartCardConfigurationPage(QWidget *parent = nullptr, const QVariantList &args = {});
~SmartCardConfigurationPage() override;
void load() override;
void save() override;
void defaults() override;
private:
class Private;
std::unique_ptr<Private> d;
};
}
}
......@@ -93,6 +93,10 @@
<label>Show GnuPG system configuration</label>
<default>true</default>
</entry>
<entry name="ShowSmartCardsConfiguration" type="Bool">
<label>Show smart cards configuration</label>
<default>true</default>
</entry>
<entry name="ShowSMimeValidationConfiguration" type="Bool">
<label>Show S/MIME validation configuration</label>
<default>true</default>
......
Markdown is supported
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