From f28ec43dca5b2915deb69d54fb942ddf1303f48c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 2 Mar 2018 12:07:18 +0100 Subject: Support encrypted mails forwarding Summary: Some notes: - What we do is: if the mail is encrypted, decrypt it and copy its content into a new message (with plaintext, html and attachments, if any), and use this message as attachment for forwarding - The `isEncrypted` function from KMime doesn't seem to detect every kind of encrypted mails. AFAIK this structure is not detected: - `multipart/mixed` - `text/plain` - `application/pgp-encrypted` (attachement, named "ATT00001") - `application/octet-stream` (attachment named "encrypted.asc") Reviewers: cmollekopf Tags: PHID-PROJ-6npnfcmppynqynn7slmv Maniphest Tasks: T8112, T7024 Differential Revision: https://phabricator.kde.org/D10966 --- framework/src/domain/composercontroller.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'framework/src/domain/composercontroller.cpp') diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 09d4c154..2286a71b 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp @@ -99,19 +99,19 @@ class AddresseeController : public Kube::ListPropertyController public: bool mFoundAllKeys = true; + QSet mMissingKeys; - AddresseeController() - : Kube::ListPropertyController{{"name", "keyFound", "key"}} + AddresseeController() : Kube::ListPropertyController{{"name", "keyFound", "key"}} { - QObject::connect(this, &Kube::ListPropertyController::added, this, [this] (const QByteArray &id, const QVariantMap &map) { - findKey(id, map.value("name").toString()); - }); + QObject::connect( + this, &Kube::ListPropertyController::added, this, [this](const QByteArray &id, const QVariantMap &map) { + findKey(id, map.value("name").toString()); + }); + QObject::connect(this, &Kube::ListPropertyController::removed, this, [this] (const QByteArray &id) { mMissingKeys.remove(id); setFoundAllKeys(mMissingKeys.isEmpty()); }); - - } bool foundAllKeys() @@ -133,12 +133,13 @@ public: mb.fromUnicodeString(addressee); SinkLog() << "Searching key for: " << mb.address(); - asyncRun>(this, [mb] { + asyncRun>(this, + [mb] { return MailCrypto::findKeys(QStringList{} << mb.address(), false, false, MailCrypto::OPENPGP); }, [this, addressee, id](const std::vector &keys) { if (!keys.empty()) { - if (keys.size() > 1 ) { + if (keys.size() > 1) { SinkWarning() << "Found more than one key, encrypting to all of them."; } SinkLog() << "Found key: " << keys.front().primaryFingerprint(); @@ -154,7 +155,7 @@ public: void set(const QStringList &list) { - for (const auto &email: list) { + for (const auto &email : list) { add({{"name", email}}); } } -- cgit v1.2.3