summaryrefslogtreecommitdiffstats
path: root/framework/mail/composer.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-01 00:08:45 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-01 00:08:45 +0100
commit235b8cb38214fe1ec919fce8701737d7b944c6de (patch)
tree92468fe9c9f939086d8dac6f01d36f4f71a40c95 /framework/mail/composer.cpp
parent0467b39e1ca034ec7298017e3055e352c755a386 (diff)
downloadkube-235b8cb38214fe1ec919fce8701737d7b944c6de.tar.gz
kube-235b8cb38214fe1ec919fce8701737d7b944c6de.zip
Support for mail replies
A template message is generated based on the input message, including appropriate recepients and quoted text. Encoding and and options are mostly hardcoded still, and there might be one or the other crash with HTML mails. Also image/attachment support is incomplete.
Diffstat (limited to 'framework/mail/composer.cpp')
-rw-r--r--framework/mail/composer.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/framework/mail/composer.cpp b/framework/mail/composer.cpp
index 4ef112fa..9edc8345 100644
--- a/framework/mail/composer.cpp
+++ b/framework/mail/composer.cpp
@@ -27,6 +27,8 @@
27#include <QVariant> 27#include <QVariant>
28#include <QDebug> 28#include <QDebug>
29 29
30#include "mailtemplates.h"
31
30Composer::Composer(QObject *parent) : QObject(parent) 32Composer::Composer(QObject *parent) : QObject(parent)
31{ 33{
32 m_identityModel << "Kuberich <kuberich@kolabnow.com>" << "Uni <kuberich@university.edu>" << "Spam <hello.spam@spam.to>"; 34 m_identityModel << "Kuberich <kuberich@kolabnow.com>" << "Uni <kuberich@university.edu>" << "Spam <hello.spam@spam.to>";
@@ -115,9 +117,36 @@ void Composer::setFromIndex(int fromIndex)
115 } 117 }
116} 118}
117 119
120QVariant Composer::originalMessage() const
121{
122 return m_originalMessage;
123}
124
125void Composer::setOriginalMessage(const QVariant &originalMessage)
126{
127 const auto mailData = KMime::CRLFtoLF(originalMessage.toByteArray());
128 if (!mailData.isEmpty()) {
129 KMime::Message::Ptr mail(new KMime::Message);
130 mail->setContent(mailData);
131 mail->parse();
132 auto reply = MailTemplates::reply(mail);
133 //We assume reply
134 setTo(reply->to(true)->asUnicodeString());
135 setCc(reply->cc(true)->asUnicodeString());
136 setSubject(reply->subject(true)->asUnicodeString());
137 setBody(reply->body());
138 m_msg = QVariant::fromValue(reply);
139 } else {
140 m_msg = QVariant();
141 }
142}
143
118void Composer::send() 144void Composer::send()
119{ 145{
120 auto mail = KMime::Message::Ptr::create(); 146 auto mail = m_msg.value<KMime::Message::Ptr>();
147 if (!mail) {
148 mail = KMime::Message::Ptr::create();
149 }
121 for (const auto &to : KEmailAddress::splitAddressList(m_to)) { 150 for (const auto &to : KEmailAddress::splitAddressList(m_to)) {
122 QByteArray displayName; 151 QByteArray displayName;
123 QByteArray addrSpec; 152 QByteArray addrSpec;
@@ -159,4 +188,4 @@ void Composer::clear()
159 setCc(""); 188 setCc("");
160 setBcc(""); 189 setBcc("");
161 setFromIndex(-1); 190 setFromIndex(-1);
162} \ No newline at end of file 191}