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

Remove special widget for OpenPGP keyserver entry

It is only used for the gpg/keyserver entry that is no longer made
available via gpgconf in GnuPG 2.3. Moreover, it tries to parse
the keyserver entry which fails for LDAP urls. And it silently keeps
the optional keyserver configuration options one can append to gpg's
(but not dirmngr's) keyserver option. But those option may no longer be
appropriate if the user changes the keyserver.

Instead of this special widget now a simple line edit is used which
isn't very user friendly, but, OTOH, it doesn't hide anything from the
user.

GnuPG-bug-id: 5404
parent 2e7c0cc0
......@@ -483,8 +483,7 @@ static const struct WidgetsByEntryName {
const char *entryGlob;
constructor create;
} widgetsByEntryName[] = {
{ "*/*/debug-level", &_create<CryptoConfigEntryDebugLevel> },
{ "gpg/*/keyserver", &_create<CryptoConfigEntryKeyserver> }
{ "*/*/debug-level", &_create<CryptoConfigEntryDebugLevel> }
};
static const unsigned int numWidgetsByEntryName = sizeof widgetsByEntryName / sizeof * widgetsByEntryName;
......@@ -930,33 +929,6 @@ void Kleo::CryptoConfigEntryLDAPURL::setURLList(const QList<QUrl> &urlList)
}
}
Kleo::CryptoConfigEntryKeyserver::CryptoConfigEntryKeyserver(
CryptoConfigModule *module,
QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName)
{
mLabel = new QLabel(widget);
mPushButton = new QPushButton(i18n("Edit..."), widget);
const int row = glay->rowCount();
QLabel *label = new QLabel(i18n("Use keyserver at"), widget);
label->setBuddy(mPushButton);
glay->addWidget(label, row, 1);
auto hlay = new QHBoxLayout;
glay->addLayout(hlay, row, 2);
hlay->addWidget(mLabel, 1);
hlay->addWidget(mPushButton);
if (entry->isReadOnly()) {
mLabel->setEnabled(false);
mPushButton->hide();
} else {
connect(mPushButton, &QPushButton::clicked, this, &CryptoConfigEntryKeyserver::slotOpenDialog);
}
}
Kleo::ParsedKeyserver Kleo::parseKeyserver(const QString &str)
{
const QStringList list = str.split(QRegExp(QLatin1String("[\\s,]")), Qt::SkipEmptyParts);
......@@ -999,53 +971,4 @@ QString Kleo::assembleKeyserver(const ParsedKeyserver &keyserver)
return result;
}
void Kleo::CryptoConfigEntryKeyserver::doLoad()
{
mParsedKeyserver = parseKeyserver(mEntry->stringValue());
mLabel->setText(mParsedKeyserver.url);
}
void Kleo::CryptoConfigEntryKeyserver::doSave()
{
mParsedKeyserver.url = mLabel->text();
mEntry->setStringValue(assembleKeyserver(mParsedKeyserver));
}
static QList<QUrl> string2urls(const QString &str)
{
QList<QUrl> ret;
if (str.isEmpty()) {
return ret;
}
ret << QUrl::fromUserInput(str);
return ret;
}
static QString urls2string(const QList<QUrl> &urls)
{
return urls.empty() ? QString() : urls.front().url();
}
void Kleo::CryptoConfigEntryKeyserver::slotOpenDialog()
{
// I'm a bad boy and I do it all on the stack. Enough classes already :)
// This is just a simple dialog around the directory-services-widget
QDialog dialog(mPushButton->parentWidget());
dialog.setWindowTitle(i18nc("@title:window", "Configure Keyservers"));
auto dirserv = new DirectoryServicesWidget(&dialog);
prepareURLCfgDialog(&dialog, dirserv, mEntry->isReadOnly());
dirserv->setOpenPGPReadOnly(mEntry->isReadOnly());
dirserv->setAllowedSchemes(DirectoryServicesWidget::AllSchemes);
dirserv->setAllowedProtocols(DirectoryServicesWidget::OpenPGPProtocol);
dirserv->addOpenPGPServices(string2urls(mLabel->text()));
if (dialog.exec()) {
mLabel->setText(urls2string(dirserv->openPGPServices()));
slotChanged();
}
}
#include "moc_cryptoconfigmodule_p.cpp"
......@@ -282,27 +282,5 @@ private:
QList<QUrl> mURLList;
};
/**
* A widget manager for a (OpenPGP) keyserver entry in the crypto config
*/
class CryptoConfigEntryKeyserver : public CryptoConfigEntryGUI
{
Q_OBJECT
public:
CryptoConfigEntryKeyserver(CryptoConfigModule *module,
QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = nullptr);
void doSave() override;
void doLoad() override;
private Q_SLOTS:
void slotOpenDialog();
private:
QLabel *mLabel = nullptr;
QPushButton *mPushButton = nullptr;
ParsedKeyserver mParsedKeyserver;
};
}
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