diff options
author | Minijackson <minijackson@riseup.net> | 2018-03-07 17:41:23 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-03-08 16:30:52 +0100 |
commit | 1112e1530587d71b1bc21f9e19b4ed95fbe30fa2 (patch) | |
tree | fbaa8735509fafff103bf73a5c73fe6b980e0c44 /framework/src | |
parent | 7ab399ce3b4b33439fe2607cf38e3f27a7d6008e (diff) | |
download | kube-1112e1530587d71b1bc21f9e19b4ed95fbe30fa2.tar.gz kube-1112e1530587d71b1bc21f9e19b4ed95fbe30fa2.zip |
Remove protocol differentiation since we only use OpenPGP
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/domain/composercontroller.cpp | 5 | ||||
-rw-r--r-- | framework/src/domain/mime/mailcrypto.cpp | 10 | ||||
-rw-r--r-- | framework/src/domain/mime/mailcrypto.h | 24 | ||||
-rw-r--r-- | framework/src/domain/mime/mailtemplates.cpp | 2 |
4 files changed, 20 insertions, 21 deletions
diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 37902164..d91d09be 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp | |||
@@ -133,9 +133,8 @@ public: | |||
133 | mb.fromUnicodeString(addressee); | 133 | mb.fromUnicodeString(addressee); |
134 | 134 | ||
135 | SinkLog() << "Searching key for: " << mb.address(); | 135 | SinkLog() << "Searching key for: " << mb.address(); |
136 | asyncRun<std::vector<GpgME::Key>>(this, | 136 | asyncRun<std::vector<GpgME::Key>>(this, [mb] { |
137 | [mb] { | 137 | return MailCrypto::findKeys(QStringList{} << mb.address(), false, false); |
138 | return MailCrypto::findKeys(QStringList{} << mb.address(), false, false, MailCrypto::OPENPGP); | ||
139 | }, | 138 | }, |
140 | [this, addressee, id](const std::vector<GpgME::Key> &keys) { | 139 | [this, addressee, id](const std::vector<GpgME::Key> &keys) { |
141 | if (!keys.empty()) { | 140 | if (!keys.empty()) { |
diff --git a/framework/src/domain/mime/mailcrypto.cpp b/framework/src/domain/mime/mailcrypto.cpp index f25c75fe..83ce293a 100644 --- a/framework/src/domain/mime/mailcrypto.cpp +++ b/framework/src/domain/mime/mailcrypto.cpp | |||
@@ -400,7 +400,7 @@ Expected<GpgME::Error, KMime::Content *> createSignedEmail(KMime::Content *conte | |||
400 | 400 | ||
401 | KMime::Content *MailCrypto::processCrypto(KMime::Content *content, | 401 | KMime::Content *MailCrypto::processCrypto(KMime::Content *content, |
402 | const std::vector<GpgME::Key> &signingKeys, const std::vector<GpgME::Key> &encryptionKeys, | 402 | const std::vector<GpgME::Key> &signingKeys, const std::vector<GpgME::Key> &encryptionKeys, |
403 | const GpgME::Key &attachedKey, MailCrypto::Protocol protocol) | 403 | const GpgME::Key &attachedKey) |
404 | { | 404 | { |
405 | 405 | ||
406 | qDebug() << "Attaching key:" << attachedKey.shortKeyID() << "from processCrypto"; | 406 | qDebug() << "Attaching key:" << attachedKey.shortKeyID() << "from processCrypto"; |
@@ -425,7 +425,7 @@ void MailCrypto::importKeys(const std::vector<GpgME::Key> &keys) | |||
425 | job->exec(keys); | 425 | job->exec(keys); |
426 | } | 426 | } |
427 | 427 | ||
428 | static GpgME::KeyListResult listKeys(GpgME::Protocol protocol, const QStringList &patterns, bool secretOnly, int keyListMode, std::vector<GpgME::Key> &keys) | 428 | static GpgME::KeyListResult listKeys(const QStringList &patterns, bool secretOnly, int keyListMode, std::vector<GpgME::Key> &keys) |
429 | { | 429 | { |
430 | QByteArrayList list; | 430 | QByteArrayList list; |
431 | std::transform(patterns.constBegin(), patterns.constEnd(), std::back_inserter(list), [] (const QString &s) { return s.toUtf8(); }); | 431 | std::transform(patterns.constBegin(), patterns.constEnd(), std::back_inserter(list), [] (const QString &s) { return s.toUtf8(); }); |
@@ -434,7 +434,7 @@ static GpgME::KeyListResult listKeys(GpgME::Protocol protocol, const QStringList | |||
434 | pattern.push_back(0); | 434 | pattern.push_back(0); |
435 | 435 | ||
436 | GpgME::initializeLibrary(); | 436 | GpgME::initializeLibrary(); |
437 | auto ctx = QSharedPointer<GpgME::Context>{GpgME::Context::createForProtocol(protocol)}; | 437 | auto ctx = QSharedPointer<GpgME::Context>{GpgME::Context::createForProtocol(GpgME::OpenPGP)}; |
438 | ctx->setKeyListMode(keyListMode); | 438 | ctx->setKeyListMode(keyListMode); |
439 | if (const GpgME::Error err = ctx->startKeyListing(pattern.data(), secretOnly)) { | 439 | if (const GpgME::Error err = ctx->startKeyListing(pattern.data(), secretOnly)) { |
440 | return GpgME::KeyListResult(0, err); | 440 | return GpgME::KeyListResult(0, err); |
@@ -452,10 +452,10 @@ static GpgME::KeyListResult listKeys(GpgME::Protocol protocol, const QStringList | |||
452 | return result; | 452 | return result; |
453 | } | 453 | } |
454 | 454 | ||
455 | std::vector<GpgME::Key> MailCrypto::findKeys(const QStringList &filter, bool findPrivate, bool remote, Protocol protocol) | 455 | std::vector<GpgME::Key> MailCrypto::findKeys(const QStringList &filter, bool findPrivate, bool remote) |
456 | { | 456 | { |
457 | std::vector<GpgME::Key> keys; | 457 | std::vector<GpgME::Key> keys; |
458 | GpgME::KeyListResult res = listKeys(protocol == SMIME ? GpgME::CMS : GpgME::OpenPGP, filter, findPrivate, remote ? GpgME::Extern : GpgME::Local, keys); | 458 | GpgME::KeyListResult res = listKeys(filter, findPrivate, remote ? GpgME::Extern : GpgME::Local, keys); |
459 | if (res.error()) { | 459 | if (res.error()) { |
460 | qWarning() << "Failed to lookup keys: " << res.error().asString(); | 460 | qWarning() << "Failed to lookup keys: " << res.error().asString(); |
461 | return keys; | 461 | return keys; |
diff --git a/framework/src/domain/mime/mailcrypto.h b/framework/src/domain/mime/mailcrypto.h index 724d6427..89343fc9 100644 --- a/framework/src/domain/mime/mailcrypto.h +++ b/framework/src/domain/mime/mailcrypto.h | |||
@@ -19,18 +19,18 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <QByteArray> | ||
23 | #include <KMime/Message> | 22 | #include <KMime/Message> |
24 | #include <gpgme++/key.h> | 23 | #include <QByteArray> |
25 | #include <functional> | 24 | #include <functional> |
25 | #include <gpgme++/key.h> | ||
26 | |||
27 | namespace MailCrypto { | ||
28 | |||
29 | KMime::Content *processCrypto(KMime::Content *content, const std::vector<GpgME::Key> &signingKeys, | ||
30 | const std::vector<GpgME::Key> &encryptionKeys, const GpgME::Key &attachedKey); | ||
31 | |||
32 | std::vector<GpgME::Key> findKeys(const QStringList &filter, bool findPrivate = false, bool remote = false); | ||
33 | |||
34 | void importKeys(const std::vector<GpgME::Key> &keys); | ||
26 | 35 | ||
27 | namespace MailCrypto | 36 | }; // namespace MailCrypto |
28 | { | ||
29 | enum Protocol { | ||
30 | OPENPGP, | ||
31 | SMIME | ||
32 | }; | ||
33 | KMime::Content *processCrypto(KMime::Content *content, const std::vector<GpgME::Key> &signingKeys, const std::vector<GpgME::Key> &encryptionKeys, const GpgME::Key &attachedKey, MailCrypto::Protocol protocol); | ||
34 | std::vector<GpgME::Key> findKeys(const QStringList &filter, bool findPrivate = false, bool remote = false, Protocol protocol = OPENPGP); | ||
35 | void importKeys(const std::vector<GpgME::Key> &keys); | ||
36 | }; | ||
diff --git a/framework/src/domain/mime/mailtemplates.cpp b/framework/src/domain/mime/mailtemplates.cpp index 399b6aa1..09932e86 100644 --- a/framework/src/domain/mime/mailtemplates.cpp +++ b/framework/src/domain/mime/mailtemplates.cpp | |||
@@ -1094,7 +1094,7 @@ KMime::Message::Ptr MailTemplates::createMessage(KMime::Message::Ptr existingMes | |||
1094 | QByteArray bodyData; | 1094 | QByteArray bodyData; |
1095 | if (!signingKeys.empty() || !encryptionKeys.empty()) { | 1095 | if (!signingKeys.empty() || !encryptionKeys.empty()) { |
1096 | auto result = MailCrypto::processCrypto( | 1096 | auto result = MailCrypto::processCrypto( |
1097 | bodyPart.get(), signingKeys, encryptionKeys, attachedKey, MailCrypto::OPENPGP); | 1097 | bodyPart.get(), signingKeys, encryptionKeys, attachedKey); |
1098 | if (!result) { | 1098 | if (!result) { |
1099 | qWarning() << "Signing failed"; | 1099 | qWarning() << "Signing failed"; |
1100 | return {}; | 1100 | return {}; |