diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-24 13:18:57 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-24 13:18:57 +0100 |
commit | 24eec910e0098151f5c36f88c4337b4ebbca2c0b (patch) | |
tree | bcd3a8891a90420019eb2d6e651830396a75a832 | |
parent | e569a96e2c68954e9eacbe84ecc7963e462d1f0f (diff) | |
download | kube-24eec910e0098151f5c36f88c4337b4ebbca2c0b.tar.gz kube-24eec910e0098151f5c36f88c4337b4ebbca2c0b.zip |
Send mail from the composer
-rw-r--r-- | docs/requirements.md | 12 | ||||
-rw-r--r-- | framework/CMakeLists.txt | 1 | ||||
-rw-r--r-- | framework/actions/action.cpp | 8 | ||||
-rw-r--r-- | framework/actions/action.h | 1 | ||||
-rw-r--r-- | framework/mail/CMakeLists.txt | 2 | ||||
-rw-r--r-- | framework/mail/composer.cpp | 26 |
6 files changed, 48 insertions, 2 deletions
diff --git a/docs/requirements.md b/docs/requirements.md index 22de0cb5..a70965a7 100644 --- a/docs/requirements.md +++ b/docs/requirements.md | |||
@@ -57,6 +57,18 @@ Currently available dependencies: | |||
57 | 57 | ||
58 | * GCC 4.6.3 / MSVC 2013 | 58 | * GCC 4.6.3 / MSVC 2013 |
59 | * Qt 5.2 | 59 | * Qt 5.2 |
60 | * kf5-kpackage | ||
61 | ** Used as installation format for all qml parts. Intended to serve as abstraction layer to allow replacing certain modules on differnet platforms/formfactors. | ||
62 | * kf5-kcodecs | ||
63 | ** dependency of kmime, email address handling (KEmailAddress) | ||
64 | * kf5-kmime | ||
65 | ** Parsing and assembling of mails | ||
66 | * libcurl 7.20 | ||
67 | ** mailtransport | ||
68 | * libkleo | ||
69 | ** crypto-stack, currently only gpg | ||
70 | * libotp | ||
71 | ** parsing and html rendering of emails | ||
60 | 72 | ||
61 | # Codebase | 73 | # Codebase |
62 | 74 | ||
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index ff5fb746..d8d45af9 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt | |||
@@ -22,6 +22,7 @@ find_package(Sink CONFIG REQUIRED) | |||
22 | find_package(KF5Async CONFIG REQUIRED) | 22 | find_package(KF5Async CONFIG REQUIRED) |
23 | find_package(KF5Libkleo CONFIG REQUIRED) | 23 | find_package(KF5Libkleo CONFIG REQUIRED) |
24 | find_package(KF5IconThemes CONFIG REQUIRED) | 24 | find_package(KF5IconThemes CONFIG REQUIRED) |
25 | find_package(KF5Codecs CONFIG REQUIRED) | ||
25 | 26 | ||
26 | set(CMAKE_AUTOMOC ON) | 27 | set(CMAKE_AUTOMOC ON) |
27 | add_definitions("-Wall -std=c++0x -g") | 28 | add_definitions("-Wall -std=c++0x -g") |
diff --git a/framework/actions/action.cpp b/framework/actions/action.cpp index 1f94ae81..905f6f57 100644 --- a/framework/actions/action.cpp +++ b/framework/actions/action.cpp | |||
@@ -35,6 +35,14 @@ Action::Action(QObject *parent) | |||
35 | { | 35 | { |
36 | } | 36 | } |
37 | 37 | ||
38 | Action::Action(const QByteArray &actionId, Context &context, QObject *parent) | ||
39 | : QObject(parent), | ||
40 | mContext(&context), | ||
41 | mActionId(actionId) | ||
42 | { | ||
43 | |||
44 | } | ||
45 | |||
38 | void Action::setContext(Context *context) | 46 | void Action::setContext(Context *context) |
39 | { | 47 | { |
40 | //Get notified when any property changes | 48 | //Get notified when any property changes |
diff --git a/framework/actions/action.h b/framework/actions/action.h index 067c3c37..b820955e 100644 --- a/framework/actions/action.h +++ b/framework/actions/action.h | |||
@@ -33,6 +33,7 @@ class Action : public QObject | |||
33 | 33 | ||
34 | public: | 34 | public: |
35 | Action(QObject *parent = 0); | 35 | Action(QObject *parent = 0); |
36 | Action(const QByteArray &actionId, Context &context, QObject *parent = 0); | ||
36 | 37 | ||
37 | void setContext(Context *); | 38 | void setContext(Context *); |
38 | Context *context() const; | 39 | Context *context() const; |
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 94d15f4c..7215427b 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt | |||
@@ -24,7 +24,7 @@ add_library(mailplugin SHARED ${mailplugin_SRCS}) | |||
24 | 24 | ||
25 | qt5_use_modules(mailplugin Core Quick Qml) | 25 | qt5_use_modules(mailplugin Core Quick Qml) |
26 | 26 | ||
27 | target_link_libraries(mailplugin actionplugin sink KF5::Otp ${CURL_LIBRARIES}) | 27 | target_link_libraries(mailplugin actionplugin sink KF5::Otp KF5::Codecs ${CURL_LIBRARIES}) |
28 | 28 | ||
29 | install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) | 29 | install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) |
30 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) | 30 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) |
diff --git a/framework/mail/composer.cpp b/framework/mail/composer.cpp index 6f603979..1ec56347 100644 --- a/framework/mail/composer.cpp +++ b/framework/mail/composer.cpp | |||
@@ -19,6 +19,12 @@ | |||
19 | 19 | ||
20 | 20 | ||
21 | #include "composer.h" | 21 | #include "composer.h" |
22 | #include <actions/context.h> | ||
23 | #include <actions/action.h> | ||
24 | #include <KMime/Message> | ||
25 | #include <KCodecs/KEmailAddress> | ||
26 | #include <QVariant> | ||
27 | #include <QDebug> | ||
22 | 28 | ||
23 | Composer::Composer(QObject *parent) : QObject(parent) | 29 | Composer::Composer(QObject *parent) : QObject(parent) |
24 | { | 30 | { |
@@ -110,7 +116,25 @@ void Composer::setFromIndex(int fromIndex) | |||
110 | 116 | ||
111 | void Composer::send() | 117 | void Composer::send() |
112 | { | 118 | { |
113 | //TODO | 119 | auto mail = KMime::Message::Ptr::create(); |
120 | for (const auto &to : KEmailAddress::splitAddressList(m_to)) { | ||
121 | QByteArray displayName; | ||
122 | QByteArray addrSpec; | ||
123 | QByteArray comment; | ||
124 | KEmailAddress::splitAddress(to.toUtf8(), displayName, addrSpec, comment); | ||
125 | mail->to(true)->addAddress(addrSpec, displayName); | ||
126 | } | ||
127 | mail->subject(true)->fromUnicodeString(m_subject, "utf-8"); | ||
128 | mail->setBody(m_body.toUtf8()); | ||
129 | mail->assemble(); | ||
130 | Kube::Context context; | ||
131 | context.setProperty("message", QVariant::fromValue(mail)); | ||
132 | //TODO get from somewhere | ||
133 | context.setProperty("username", QVariant::fromValue(QByteArray("test@test.com"))); | ||
134 | context.setProperty("password", QVariant::fromValue(QByteArray("pass"))); | ||
135 | context.setProperty("server", QVariant::fromValue(QByteArray("smtp://smtp.gmail.com:587"))); | ||
136 | |||
137 | Kube::Action("org.kde.kube.actions.sendmail", context).execute(); | ||
114 | clear(); | 138 | clear(); |
115 | } | 139 | } |
116 | 140 | ||