Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Start KeyForMailboxJob in cert line edit

The KeyForMailboxJob triggers locate-keys in GnuPG,
which then might result in a Web Key Directory lookup.
This behaviro might then result in the import of the
according certificate which will be available afterwards.

GnuPG-Bug-Id: 3548
parent 005a2814
......@@ -44,6 +44,7 @@
#include "dialogs/certificateselectiondialog.h"
#include "commands/detailscommand.h"
#include <Libkleo/KeyCache>
#include <Libkleo/KeyFilter>
#include <Libkleo/KeyListModel>
#include <Libkleo/KeyListSortFilterProxyModel>
......@@ -54,12 +55,17 @@
#include <gpgme++/key.h>
#include <QGpgME/KeyForMailboxJob>
#include <QGpgME/Protocol>
using namespace Kleo;
using namespace Kleo::Dialogs;
using namespace GpgME;
Q_DECLARE_METATYPE(GpgME::Key)
static QStringList s_lookedUpKeys;
CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
QWidget *parent,
KeyFilter *filter)
......@@ -91,7 +97,7 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
mFilterModel->setKeyFilter(mFilter);
}
connect(model, &QAbstractItemModel::dataChanged,
connect(KeyCache::instance().get(), &Kleo::KeyCache::keyListingDone,
this, &CertificateLineEdit::updateKey);
connect(this, &QLineEdit::editingFinished,
this, &CertificateLineEdit::updateKey);
......@@ -99,7 +105,8 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
this, &CertificateLineEdit::editChanged);
connect(mLineAction, &QAction::triggered,
this, &CertificateLineEdit::dialogRequested);
connect(this, &QLineEdit::editingFinished, this,
&CertificateLineEdit::checkLocate);
updateKey();
/* Take ownership of the model to prevent double deletion when the
......@@ -117,6 +124,24 @@ void CertificateLineEdit::editChanged()
mEditFinished = false;
}
void CertificateLineEdit::checkLocate()
{
if (!key().isNull()) {
// Already have a key
return;
}
// Only check once per mailbox
const auto mailText = text();
if (s_lookedUpKeys.contains(mailText)) {
return;
}
s_lookedUpKeys << mailText;
qCDebug(KLEOPATRA_LOG) << "Lookup job for" << mailText;
QGpgME::KeyForMailboxJob *job = QGpgME::openpgp()->keyForMailboxJob();
job->start(mailText);
}
void CertificateLineEdit::updateKey()
{
const auto mailText = text();
......
......@@ -99,6 +99,7 @@ private Q_SLOTS:
void updateKey();
void dialogRequested();
void editChanged();
void checkLocate();
private:
KeyListSortFilterProxyModel *mFilterModel;
......
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