diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-24 18:30:51 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-24 18:30:51 +0100 |
commit | 86927d185fec4d4621aa6d7744a88285fcf233b7 (patch) | |
tree | ccfa7cc768589ed7c5a6454f570759351d2fb8ea /framework | |
parent | 9f362f60e8ec15dccddfd80462f471c25f84dd52 (diff) | |
download | kube-86927d185fec4d4621aa6d7744a88285fcf233b7.tar.gz kube-86927d185fec4d4621aa6d7744a88285fcf233b7.zip |
Import missing keys
Diffstat (limited to 'framework')
-rw-r--r-- | framework/src/domain/composercontroller.cpp | 8 | ||||
-rw-r--r-- | framework/src/domain/mime/mailcrypto.cpp | 15 | ||||
-rw-r--r-- | framework/src/domain/mime/mailcrypto.h | 3 |
3 files changed, 22 insertions, 4 deletions
diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 5ac8adf1..c20c2b0f 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp | |||
@@ -113,7 +113,13 @@ public: | |||
113 | void findKey(const QString &addressee, QStandardItem *item) | 113 | void findKey(const QString &addressee, QStandardItem *item) |
114 | { | 114 | { |
115 | SinkLog() << "Searching key for: " << addressee; | 115 | SinkLog() << "Searching key for: " << addressee; |
116 | auto keys = MailCrypto::findKeys(QStringList{} << addressee, false, MailCrypto::OPENPGP); | 116 | auto keys = MailCrypto::findKeys(QStringList{} << addressee, false, false, MailCrypto::OPENPGP); |
117 | if (keys.empty()) { | ||
118 | //Search for key on remote server if it's missing and import | ||
119 | //TODO: this is blocking and thus blocks the UI | ||
120 | keys = MailCrypto::findKeys(QStringList{} << addressee, false, true, MailCrypto::OPENPGP); | ||
121 | MailCrypto::importKeys(keys); | ||
122 | } | ||
117 | if (item) { | 123 | if (item) { |
118 | if (!keys.empty()) { | 124 | if (!keys.empty()) { |
119 | if (keys.size() > 1 ) { | 125 | if (keys.size() > 1 ) { |
diff --git a/framework/src/domain/mime/mailcrypto.cpp b/framework/src/domain/mime/mailcrypto.cpp index 6c5d1b4f..8cf55089 100644 --- a/framework/src/domain/mime/mailcrypto.cpp +++ b/framework/src/domain/mime/mailcrypto.cpp | |||
@@ -25,10 +25,12 @@ | |||
25 | #include <QGpgME/EncryptJob> | 25 | #include <QGpgME/EncryptJob> |
26 | #include <QGpgME/SignEncryptJob> | 26 | #include <QGpgME/SignEncryptJob> |
27 | #include <QGpgME/KeyListJob> | 27 | #include <QGpgME/KeyListJob> |
28 | #include <QGpgME/ImportFromKeyserverJob> | ||
28 | #include <gpgme++/global.h> | 29 | #include <gpgme++/global.h> |
29 | #include <gpgme++/signingresult.h> | 30 | #include <gpgme++/signingresult.h> |
30 | #include <gpgme++/encryptionresult.h> | 31 | #include <gpgme++/encryptionresult.h> |
31 | #include <gpgme++/keylistresult.h> | 32 | #include <gpgme++/keylistresult.h> |
33 | #include <gpgme++/importresult.h> | ||
32 | #include <QDebug> | 34 | #include <QDebug> |
33 | 35 | ||
34 | /* | 36 | /* |
@@ -460,11 +462,20 @@ KMime::Content *MailCrypto::sign(KMime::Content *content, const std::vector<GpgM | |||
460 | return processCrypto(content, signers, {}, OPENPGP); | 462 | return processCrypto(content, signers, {}, OPENPGP); |
461 | } | 463 | } |
462 | 464 | ||
463 | std::vector<GpgME::Key> MailCrypto::findKeys(const QStringList &filter, bool findPrivate, Protocol protocol) | 465 | |
466 | void MailCrypto::importKeys(const std::vector<GpgME::Key> &keys) | ||
467 | { | ||
468 | const QGpgME::Protocol *const backend = QGpgME::openpgp(); | ||
469 | Q_ASSERT(backend); | ||
470 | auto *job = backend->importFromKeyserverJob(); | ||
471 | job->exec(keys); | ||
472 | } | ||
473 | |||
474 | std::vector<GpgME::Key> MailCrypto::findKeys(const QStringList &filter, bool findPrivate, bool remote, Protocol protocol) | ||
464 | { | 475 | { |
465 | const QGpgME::Protocol *const backend = protocol == SMIME ? QGpgME::smime() : QGpgME::openpgp(); | 476 | const QGpgME::Protocol *const backend = protocol == SMIME ? QGpgME::smime() : QGpgME::openpgp(); |
466 | Q_ASSERT(backend); | 477 | Q_ASSERT(backend); |
467 | QGpgME::KeyListJob *job = backend->keyListJob(false); | 478 | QGpgME::KeyListJob *job = backend->keyListJob(remote); |
468 | Q_ASSERT(job); | 479 | Q_ASSERT(job); |
469 | 480 | ||
470 | std::vector<GpgME::Key> keys; | 481 | std::vector<GpgME::Key> keys; |
diff --git a/framework/src/domain/mime/mailcrypto.h b/framework/src/domain/mime/mailcrypto.h index ed362ddc..0a6c2f4c 100644 --- a/framework/src/domain/mime/mailcrypto.h +++ b/framework/src/domain/mime/mailcrypto.h | |||
@@ -32,5 +32,6 @@ namespace MailCrypto | |||
32 | }; | 32 | }; |
33 | KMime::Content *processCrypto(KMime::Content *content, const std::vector<GpgME::Key> &signingKeys, const std::vector<GpgME::Key> &encryptionKeys, MailCrypto::Protocol protocol); | 33 | KMime::Content *processCrypto(KMime::Content *content, const std::vector<GpgME::Key> &signingKeys, const std::vector<GpgME::Key> &encryptionKeys, MailCrypto::Protocol protocol); |
34 | KMime::Content *sign(KMime::Content *content, const std::vector<GpgME::Key> &signers); | 34 | KMime::Content *sign(KMime::Content *content, const std::vector<GpgME::Key> &signers); |
35 | std::vector<GpgME::Key> findKeys(const QStringList &filter, bool findPrivate = false, Protocol protocol = OPENPGP); | 35 | std::vector<GpgME::Key> findKeys(const QStringList &filter, bool findPrivate = false, bool remote = false, Protocol protocol = OPENPGP); |
36 | void importKeys(const std::vector<GpgME::Key> &keys); | ||
36 | }; | 37 | }; |