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

Add input field for OpenPGP keyserver

This adds the input field that was removed from
Kleo::DirectoryServicesWidget.

GnuPG-bug-id: 5465
parent 956ad28b
......@@ -14,7 +14,7 @@ option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
set(KF5_MIN_VERSION "5.83.0")
set(KMIME_VERSION "5.17.40")
set(LIBKLEO_VERSION "5.17.46")
set(LIBKLEO_VERSION "5.17.47")
set(QT_REQUIRED_VERSION "5.15.0")
set(GPGME_REQUIRED_VERSION "1.13.1")
set(BOOST_REQUIRED_VERSION "1.58")
......
......@@ -25,8 +25,11 @@
#include <QLabel>
#include <QCheckBox>
#include <QLayout>
#include <QLineEdit>
#include <QTimeEdit>
#include <gpgme++/engineinfo.h>
using namespace Kleo;
using namespace QGpgME;
......@@ -137,7 +140,28 @@ DirectoryServicesConfigurationPage::DirectoryServicesConfigurationPage(QWidget *
auto glay = new QGridLayout(this);
glay->setContentsMargins(0, 0, 0, 0);
// OpenPGP keyserver
int row = 0;
{
auto l = new QHBoxLayout{};
l->setContentsMargins(0, 0, 0, 0);
l->addWidget(new QLabel{i18n("OpenPGP keyserver:"), this});
mOpenPGPKeyserverEdit = new QLineEdit{this};
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16") {
mOpenPGPKeyserverEdit->setPlaceholderText(QStringLiteral("hkp://keys.gnupg.net"));
} else {
mOpenPGPKeyserverEdit->setPlaceholderText(QStringLiteral("hkps://hkps.pool.sks-keyservers.net"));
}
l->addWidget(mOpenPGPKeyserverEdit);
glay->addLayout(l, row, 0, 1, 3);
connect(mOpenPGPKeyserverEdit, &QLineEdit::textEdited, this, [this]() { Q_EMIT changed(true); });
}
// X.509 servers
++row;
mWidget = new Kleo::DirectoryServicesWidget(this);
if (QLayout *l = mWidget->layout()) {
l->setContentsMargins(0, 0, 0, 0);
......@@ -183,15 +207,23 @@ void DirectoryServicesConfigurationPage::load()
mWidget->clear();
// gpgsm's keyserver option is not provided by very old gpgconf versions
if ((mX509ServicesEntry = configEntry(s_x509services_componentName, s_x509services_entryName,
CryptoConfigEntry::ArgType_LDAPURL, ListValue, DoNotShowError))) {
mWidget->addX509Services(mX509ServicesEntry->urlValueList());
} else if ((mX509ServicesEntry = configEntry(s_x509services_legacy_componentName, s_x509services_legacy_entryName,
CryptoConfigEntry::ArgType_LDAPURL, ListValue, DoShowError))) {
mX509ServicesEntry = configEntry(s_x509services_componentName, s_x509services_entryName,
CryptoConfigEntry::ArgType_LDAPURL, ListValue, DoNotShowError);
if (!mX509ServicesEntry) {
mX509ServicesEntry = configEntry(s_x509services_legacy_componentName, s_x509services_legacy_entryName,
CryptoConfigEntry::ArgType_LDAPURL, ListValue, DoShowError);
}
if (mX509ServicesEntry) {
mWidget->addX509Services(mX509ServicesEntry->urlValueList());
}
mWidget->setX509ReadOnly(mX509ServicesEntry && mX509ServicesEntry->isReadOnly());
if (mX509ServicesEntry) {
mWidget->setAllowedProtocols(DirectoryServicesWidget::X509Protocol);
} else {
mWidget->setDisabled(true);
}
{
// gpg prefers the deprecated keyserver option in gpg.conf over the keyserver option in dirmngr.conf;
// therefore, we use the deprecated keyserver option if it is set or if the new option doesn't exist (gpg < 2.1.9)
......@@ -214,25 +246,8 @@ void DirectoryServicesConfigurationPage::load()
<< s_pgpservice_componentName << "/" << s_pgpservice_entryName;
}
mWidget->setOpenPGPService(mOpenPGPServiceEntry ? mOpenPGPServiceEntry->stringValue() : QString());
mWidget->setOpenPGPReadOnly(!mOpenPGPServiceEntry || mOpenPGPServiceEntry->isReadOnly());
}
if (mX509ServicesEntry)
if (mOpenPGPServiceEntry) {
mWidget->setAllowedProtocols(DirectoryServicesWidget::AllProtocols);
} else {
mWidget->setAllowedProtocols(DirectoryServicesWidget::X509Protocol);
}
else if (mOpenPGPServiceEntry) {
mWidget->setAllowedProtocols(DirectoryServicesWidget::OpenPGPProtocol);
} else {
mWidget->setDisabled(true);
}
DirectoryServicesWidget::Protocols readOnlyProtocols;
if (mX509ServicesEntry && mX509ServicesEntry->isReadOnly()) {
readOnlyProtocols = DirectoryServicesWidget::X509Protocol;
mOpenPGPKeyserverEdit->setText(mOpenPGPServiceEntry ? mOpenPGPServiceEntry->stringValue() : QString());
mOpenPGPKeyserverEdit->setEnabled(mOpenPGPServiceEntry && !mOpenPGPServiceEntry->isReadOnly());
}
// read LDAP timeout
......@@ -304,7 +319,9 @@ void DirectoryServicesConfigurationPage::save()
}
if (mOpenPGPServiceEntry) {
mOpenPGPServiceEntry->setStringValue(mWidget->openPGPService());
const auto keyserver = mOpenPGPKeyserverEdit->text();
const auto keyserverUrl = keyserver.contains(QLatin1String{"://"}) ? keyserver : (QLatin1String{"hkps://"} + keyserver);
mOpenPGPServiceEntry->setStringValue(keyserverUrl);
}
const QTime time{mTimeout->time()};
......
......@@ -15,6 +15,7 @@
class QCheckBox;
class QLabel;
class QLineEdit;
class QTimeEdit;
class QSpinBox;
namespace Kleo
......@@ -53,6 +54,7 @@ private:
EntryMultiplicity multiplicity,
ShowError showError);
QLineEdit *mOpenPGPKeyserverEdit = nullptr;
Kleo::DirectoryServicesWidget *mWidget = nullptr;
QTimeEdit *mTimeout = nullptr;
QSpinBox *mMaxItems = nullptr;
......
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