diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | framework/src/domain/mime/CMakeLists.txt | 8 | ||||
-rw-r--r-- | framework/src/domain/mime/attachmentmodel.cpp | 18 | ||||
-rw-r--r-- | framework/src/domain/mime/mailcrypto.cpp | 9 | ||||
-rw-r--r-- | framework/src/domain/mime/mailcrypto.h | 8 | ||||
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/partmetadata.h | 1 |
6 files changed, 33 insertions, 14 deletions
diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index a3c489b4..067da571 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt | |||
@@ -37,7 +37,6 @@ add_library(kubeframework SHARED | |||
37 | domain/mime/attachmentmodel.cpp | 37 | domain/mime/attachmentmodel.cpp |
38 | domain/mime/partmodel.cpp | 38 | domain/mime/partmodel.cpp |
39 | domain/mime/mailtemplates.cpp | 39 | domain/mime/mailtemplates.cpp |
40 | domain/mime/mailcrypto.cpp | ||
41 | accounts/accountfactory.cpp | 40 | accounts/accountfactory.cpp |
42 | accounts/accountsmodel.cpp | 41 | accounts/accountsmodel.cpp |
43 | fabric.cpp | 42 | fabric.cpp |
@@ -55,6 +54,7 @@ add_library(kubeframework SHARED | |||
55 | target_link_libraries(kubeframework | 54 | target_link_libraries(kubeframework |
56 | sink | 55 | sink |
57 | kube_otp | 56 | kube_otp |
57 | mailcrypto | ||
58 | Qt5::Core | 58 | Qt5::Core |
59 | Qt5::Quick | 59 | Qt5::Quick |
60 | Qt5::Qml | 60 | Qt5::Qml |
@@ -78,6 +78,7 @@ install(TARGETS frameworkplugin DESTINATION ${FRAMEWORK_INSTALL_DIR}) | |||
78 | set(BUILD_TESTING ON) | 78 | set(BUILD_TESTING ON) |
79 | 79 | ||
80 | add_subdirectory(tests) | 80 | add_subdirectory(tests) |
81 | add_subdirectory(domain/mime) | ||
81 | add_subdirectory(domain/mime/tests) | 82 | add_subdirectory(domain/mime/tests) |
82 | add_subdirectory(domain/mime/mimetreeparser) | 83 | add_subdirectory(domain/mime/mimetreeparser) |
83 | add_subdirectory(domain/settings/tests) | 84 | add_subdirectory(domain/settings/tests) |
diff --git a/framework/src/domain/mime/CMakeLists.txt b/framework/src/domain/mime/CMakeLists.txt new file mode 100644 index 00000000..c1cf22c1 --- /dev/null +++ b/framework/src/domain/mime/CMakeLists.txt | |||
@@ -0,0 +1,8 @@ | |||
1 | add_library(mailcrypto STATIC | ||
2 | mailcrypto.cpp | ||
3 | ) | ||
4 | target_link_libraries(mailcrypto | ||
5 | Qt5::Core | ||
6 | KF5::Mime | ||
7 | QGpgme | ||
8 | ) | ||
diff --git a/framework/src/domain/mime/attachmentmodel.cpp b/framework/src/domain/mime/attachmentmodel.cpp index 8b12679b..45013f85 100644 --- a/framework/src/domain/mime/attachmentmodel.cpp +++ b/framework/src/domain/mime/attachmentmodel.cpp | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <mimetreeparser/objecttreeparser.h> | 23 | #include <mimetreeparser/objecttreeparser.h> |
24 | #include <fabric.h> | 24 | #include <fabric.h> |
25 | #include <mailcrypto.h> | ||
25 | 26 | ||
26 | #include <QDebug> | 27 | #include <QDebug> |
27 | #include <KMime/Content> | 28 | #include <KMime/Content> |
@@ -32,9 +33,6 @@ | |||
32 | #include <QUrl> | 33 | #include <QUrl> |
33 | #include <QMimeDatabase> | 34 | #include <QMimeDatabase> |
34 | 35 | ||
35 | #include <QGpgME/ImportJob> | ||
36 | #include <QGpgME/Protocol> | ||
37 | |||
38 | #include <memory> | 36 | #include <memory> |
39 | 37 | ||
40 | QString sizeHuman(float size) | 38 | QString sizeHuman(float size) |
@@ -221,21 +219,17 @@ bool AttachmentModel::importPublicKey(const QModelIndex &index) | |||
221 | const auto part = static_cast<MimeTreeParser::MessagePart *>(index.internalPointer()); | 219 | const auto part = static_cast<MimeTreeParser::MessagePart *>(index.internalPointer()); |
222 | Q_ASSERT(part); | 220 | Q_ASSERT(part); |
223 | auto pkey = part->node()->decodedContent(); | 221 | auto pkey = part->node()->decodedContent(); |
224 | 222 | auto result = MailCrypto::importKey(pkey); | |
225 | const auto *proto = QGpgME::openpgp(); | ||
226 | std::unique_ptr<QGpgME::ImportJob> job(proto->importJob()); | ||
227 | auto result = job->exec(pkey); | ||
228 | 223 | ||
229 | bool success = true; | 224 | bool success = true; |
230 | |||
231 | QString message; | 225 | QString message; |
232 | if(result.numConsidered() == 0) { | 226 | if(result.considered == 0) { |
233 | message = tr("No keys were found in this attachment"); | 227 | message = tr("No keys were found in this attachment"); |
234 | success = false; | 228 | success = false; |
235 | } else { | 229 | } else { |
236 | message = tr("%n Key(s) imported", "", result.numImported()); | 230 | message = tr("%n Key(s) imported", "", result.imported); |
237 | if(result.numUnchanged() != 0) { | 231 | if(result.unchanged != 0) { |
238 | message += "\n" + tr("%n Key(s) were already imported", "", result.numUnchanged()); | 232 | message += "\n" + tr("%n Key(s) were already imported", "", result.unchanged); |
239 | } | 233 | } |
240 | } | 234 | } |
241 | 235 | ||
diff --git a/framework/src/domain/mime/mailcrypto.cpp b/framework/src/domain/mime/mailcrypto.cpp index 4e20c84b..da1b82c7 100644 --- a/framework/src/domain/mime/mailcrypto.cpp +++ b/framework/src/domain/mime/mailcrypto.cpp | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <QGpgME/EncryptJob> | 27 | #include <QGpgME/EncryptJob> |
28 | #include <QGpgME/ExportJob> | 28 | #include <QGpgME/ExportJob> |
29 | #include <QGpgME/ImportFromKeyserverJob> | 29 | #include <QGpgME/ImportFromKeyserverJob> |
30 | #include <QGpgME/ImportJob> | ||
30 | #include <QGpgME/Protocol> | 31 | #include <QGpgME/Protocol> |
31 | #include <QGpgME/SignEncryptJob> | 32 | #include <QGpgME/SignEncryptJob> |
32 | #include <QGpgME/SignJob> | 33 | #include <QGpgME/SignJob> |
@@ -430,6 +431,14 @@ void MailCrypto::importKeys(const std::vector<GpgME::Key> &keys) | |||
430 | job->exec(keys); | 431 | job->exec(keys); |
431 | } | 432 | } |
432 | 433 | ||
434 | MailCrypto::ImportResult MailCrypto::importKey(const QByteArray &pkey) | ||
435 | { | ||
436 | const auto *proto = QGpgME::openpgp(); | ||
437 | std::unique_ptr<QGpgME::ImportJob> job(proto->importJob()); | ||
438 | auto result = job->exec(pkey); | ||
439 | return {result.numConsidered(), result.numImported(), result.numUnchanged()}; | ||
440 | } | ||
441 | |||
433 | static GpgME::KeyListResult listKeys(const QStringList &patterns, bool secretOnly, int keyListMode, std::vector<GpgME::Key> &keys) | 442 | static GpgME::KeyListResult listKeys(const QStringList &patterns, bool secretOnly, int keyListMode, std::vector<GpgME::Key> &keys) |
434 | { | 443 | { |
435 | QByteArrayList list; | 444 | QByteArrayList list; |
diff --git a/framework/src/domain/mime/mailcrypto.h b/framework/src/domain/mime/mailcrypto.h index 832f68ec..9e317b43 100644 --- a/framework/src/domain/mime/mailcrypto.h +++ b/framework/src/domain/mime/mailcrypto.h | |||
@@ -39,4 +39,12 @@ std::vector<GpgME::Key> findKeys(const QStringList &filter, bool findPrivate = f | |||
39 | 39 | ||
40 | void importKeys(const std::vector<GpgME::Key> &keys); | 40 | void importKeys(const std::vector<GpgME::Key> &keys); |
41 | 41 | ||
42 | struct ImportResult { | ||
43 | int considered; | ||
44 | int imported; | ||
45 | int unchanged; | ||
46 | }; | ||
47 | |||
48 | ImportResult importKey(const QByteArray &key); | ||
49 | |||
42 | }; // namespace MailCrypto | 50 | }; // namespace MailCrypto |
diff --git a/framework/src/domain/mime/mimetreeparser/partmetadata.h b/framework/src/domain/mime/mimetreeparser/partmetadata.h index b0f2674e..813ef4cb 100644 --- a/framework/src/domain/mime/mimetreeparser/partmetadata.h +++ b/framework/src/domain/mime/mimetreeparser/partmetadata.h | |||
@@ -17,7 +17,6 @@ | |||
17 | #define __MIMETREEPARSER_PARTMETADATA_H__ | 17 | #define __MIMETREEPARSER_PARTMETADATA_H__ |
18 | 18 | ||
19 | #include <gpgme++/verificationresult.h> | 19 | #include <gpgme++/verificationresult.h> |
20 | #include <gpgme++/context.h> | ||
21 | 20 | ||
22 | #include <QStringList> | 21 | #include <QStringList> |
23 | #include <QDateTime> | 22 | #include <QDateTime> |