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

Explicitly ignore keys without user IDs and notify the user

Keys without user IDs are anyway ignored by the key model, so that it
makes little sense not to ignore them directly on retrieval. Inform the
user about ignored keys, so that they know that there may be more
results.

GnuPG-bug-id: 5725
parent ce5936a0
Pipeline #113497 passed with stage
in 1 minute and 57 seconds
......@@ -146,6 +146,7 @@ private:
QString pattern;
KeyListResult result;
std::vector<Key> keys;
int numKeysWithoutUserId = 0;
std::set<std::string> wkdKeyFingerprints;
QByteArray wkdKeyData;
QString wkdSource;
......@@ -289,6 +290,7 @@ void LookupCertificatesCommand::Private::slotSearchTextChanged(const QString &st
if (dialog) { //thus test
dialog->setPassive(true);
dialog->setCertificates(std::vector<Key>());
dialog->showInformation({});
}
query = str;
......@@ -355,16 +357,19 @@ void LookupCertificatesCommand::Private::startWKDLookupJob(const QString &str)
void LookupCertificatesCommand::Private::slotNextKey(const Key &key)
{
if (key.primaryFingerprint()) {
qCDebug(KLEOPATRA_LOG) << __func__ << "got key" << key;
keyListing.keys.push_back(key);
} else {
if (!key.primaryFingerprint()) {
qCDebug(KLEOPATRA_LOG) << __func__ << "ignoring key without fingerprint" << key;
if (q->sender() == keyListing.cms) {
keyListing.cmsKeysHaveNoFingerprints = true;
} else if (q->sender() == keyListing.openpgp) {
keyListing.openPgpKeysHaveNoFingerprints = true;
}
} else if (key.numUserIDs() == 0) {
qCDebug(KLEOPATRA_LOG) << __func__ << "ignoring key without user IDs" << key;
keyListing.numKeysWithoutUserId++;
} else {
qCDebug(KLEOPATRA_LOG) << __func__ << "got key" << key;
keyListing.keys.push_back(key);
}
}
......@@ -486,6 +491,12 @@ void LookupCertificatesCommand::Private::tryToFinishKeyLookup()
if (dialog) {
dialog->setPassive(false);
dialog->setCertificates(keyListing.keys);
if (keyListing.numKeysWithoutUserId > 0) {
dialog->showInformation(i18ncp("@info",
"One certificate without name and email address was ignored.",
"%1 certificates without name and email address were ignored.",
keyListing.numKeysWithoutUserId));
}
} else {
finished();
}
......
......@@ -17,6 +17,7 @@
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageWidget>
#include <KSeparator>
#include <KSharedConfig>
......@@ -108,6 +109,7 @@ private:
QPushButton *deselectAllPB;
QPushButton *detailsPB;
QPushButton *saveAsPB;
KMessageWidget *messageWidget;
QDialogButtonBox *buttonBox;
void setupUi(QDialog *dialog)
......@@ -162,6 +164,12 @@ private:
gridLayout->addLayout(buttonLayout, row, 2, 1, 1);
row++;
messageWidget = new KMessageWidget{dialog};
messageWidget->setMessageType(KMessageWidget::Information);
messageWidget->setVisible(false);
gridLayout->addWidget(messageWidget, row, 0, 1, 3);
verticalLayout->addLayout(gridLayout);
buttonBox = new QDialogButtonBox{dialog};
......@@ -298,6 +306,16 @@ QString LookupCertificatesDialog::searchText() const
return d->ui.findED->text();
}
void LookupCertificatesDialog::showInformation(const QString &message)
{
d->ui.messageWidget->setText(message);
if (message.isEmpty()) {
d->ui.messageWidget->animatedHide();
} else {
d->ui.messageWidget->animatedShow();
}
}
void LookupCertificatesDialog::accept()
{
Q_ASSERT(!selectedCertificates().empty());
......
......@@ -39,6 +39,7 @@ public:
bool isPassive() const;
void setSearchText(const QString &text);
QString searchText() const;
void showInformation(const QString &message);
Q_SIGNALS:
void searchTextChanged(const QString &text);
......
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