Verified Commit 805f5cfa authored by Andre Heinecke's avatar Andre Heinecke
Browse files

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;
static QStringList s_lookedUpKeys;
CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
QWidget *parent,
KeyFilter *filter)
......@@ -91,7 +97,7 @@ CertificateLineEdit::CertificateLineEdit(AbstractKeyListModel *model,
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,
/* 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
// Only check once per mailbox
const auto mailText = text();
if (s_lookedUpKeys.contains(mailText)) {
s_lookedUpKeys << mailText;
qCDebug(KLEOPATRA_LOG) << "Lookup job for" << mailText;
QGpgME::KeyForMailboxJob *job = QGpgME::openpgp()->keyForMailboxJob();
void CertificateLineEdit::updateKey()
const auto mailText = text();
......@@ -99,6 +99,7 @@ private Q_SLOTS:
void updateKey();
void dialogRequested();
void editChanged();
void checkLocate();
KeyListSortFilterProxyModel *mFilterModel;
Supports Markdown
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