summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-24 13:18:57 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-24 13:18:57 +0100
commit24eec910e0098151f5c36f88c4337b4ebbca2c0b (patch)
treebcd3a8891a90420019eb2d6e651830396a75a832
parente569a96e2c68954e9eacbe84ecc7963e462d1f0f (diff)
downloadkube-24eec910e0098151f5c36f88c4337b4ebbca2c0b.tar.gz
kube-24eec910e0098151f5c36f88c4337b4ebbca2c0b.zip
Send mail from the composer
-rw-r--r--docs/requirements.md12
-rw-r--r--framework/CMakeLists.txt1
-rw-r--r--framework/actions/action.cpp8
-rw-r--r--framework/actions/action.h1
-rw-r--r--framework/mail/CMakeLists.txt2
-rw-r--r--framework/mail/composer.cpp26
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)
22find_package(KF5Async CONFIG REQUIRED) 22find_package(KF5Async CONFIG REQUIRED)
23find_package(KF5Libkleo CONFIG REQUIRED) 23find_package(KF5Libkleo CONFIG REQUIRED)
24find_package(KF5IconThemes CONFIG REQUIRED) 24find_package(KF5IconThemes CONFIG REQUIRED)
25find_package(KF5Codecs CONFIG REQUIRED)
25 26
26set(CMAKE_AUTOMOC ON) 27set(CMAKE_AUTOMOC ON)
27add_definitions("-Wall -std=c++0x -g") 28add_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
38Action::Action(const QByteArray &actionId, Context &context, QObject *parent)
39 : QObject(parent),
40 mContext(&context),
41 mActionId(actionId)
42{
43
44}
45
38void Action::setContext(Context *context) 46void 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
34public: 34public:
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
25qt5_use_modules(mailplugin Core Quick Qml) 25qt5_use_modules(mailplugin Core Quick Qml)
26 26
27target_link_libraries(mailplugin actionplugin sink KF5::Otp ${CURL_LIBRARIES}) 27target_link_libraries(mailplugin actionplugin sink KF5::Otp KF5::Codecs ${CURL_LIBRARIES})
28 28
29install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) 29install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail)
30install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) 30install(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
23Composer::Composer(QObject *parent) : QObject(parent) 29Composer::Composer(QObject *parent) : QObject(parent)
24{ 30{
@@ -110,7 +116,25 @@ void Composer::setFromIndex(int fromIndex)
110 116
111void Composer::send() 117void 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