diff options
Diffstat (limited to 'framework/domain')
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 2 | ||||
-rw-r--r-- | framework/domain/composercontroller.cpp | 50 | ||||
-rw-r--r-- | framework/domain/composercontroller.h | 8 |
3 files changed, 28 insertions, 32 deletions
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index 354a5aca..129b538a 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -130,7 +130,7 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
130 | return Sink::Store::create(mail); | 130 | return Sink::Store::create(mail); |
131 | }); | 131 | }); |
132 | } else { | 132 | } else { |
133 | qWarning() << "Modifying an existing mail"; | 133 | qWarning() << "Modifying an existing mail" << existingMail.identifier(); |
134 | existingMail.setBlobProperty("mimeMessage", message->encodedContent()); | 134 | existingMail.setBlobProperty("mimeMessage", message->encodedContent()); |
135 | return Sink::Store::modify(existingMail); | 135 | return Sink::Store::modify(existingMail); |
136 | } | 136 | } |
diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index 94914f17..2dcf1bb1 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <QVariant> | 27 | #include <QVariant> |
28 | #include <QDebug> | 28 | #include <QDebug> |
29 | #include <QQmlEngine> | 29 | #include <QQmlEngine> |
30 | #include <sink/store.h> | ||
30 | 31 | ||
31 | #include "accountsmodel.h" | 32 | #include "accountsmodel.h" |
32 | #include "identitiesmodel.h" | 33 | #include "identitiesmodel.h" |
@@ -128,32 +129,28 @@ void ComposerController::setMessage(const KMime::Message::Ptr &msg) | |||
128 | m_msg = QVariant::fromValue(msg); | 129 | m_msg = QVariant::fromValue(msg); |
129 | } | 130 | } |
130 | 131 | ||
131 | void ComposerController::setOriginalMessage(const QVariant &originalMessage) | 132 | void ComposerController::loadMessage(const QVariant &message, bool loadAsDraft) |
132 | { | 133 | { |
133 | const auto mailData = KMime::CRLFtoLF(originalMessage.toByteArray()); | 134 | Sink::Query query(*message.value<Sink::ApplicationDomain::Mail::Ptr>()); |
134 | if (!mailData.isEmpty()) { | 135 | query.request<Sink::ApplicationDomain::Mail::MimeMessage>(); |
135 | KMime::Message::Ptr mail(new KMime::Message); | 136 | Sink::Store::fetchOne<Sink::ApplicationDomain::Mail>(query).then<void, Sink::ApplicationDomain::Mail>([this, loadAsDraft](const Sink::ApplicationDomain::Mail &mail) { |
136 | mail->setContent(mailData); | 137 | m_existingMail = mail; |
137 | mail->parse(); | 138 | const auto mailData = KMime::CRLFtoLF(mail.getMimeMessage()); |
138 | auto reply = MailTemplates::reply(mail); | 139 | if (!mailData.isEmpty()) { |
139 | //We assume reply | 140 | KMime::Message::Ptr mail(new KMime::Message); |
140 | setMessage(reply); | 141 | mail->setContent(mailData); |
141 | } else { | 142 | mail->parse(); |
142 | m_msg = QVariant(); | 143 | if (loadAsDraft) { |
143 | } | 144 | auto reply = MailTemplates::reply(mail); |
144 | } | 145 | //We assume reply |
145 | 146 | setMessage(reply); | |
146 | void ComposerController::setDraftMessage(const QVariant &originalMessage) | 147 | } else { |
147 | { | 148 | setMessage(mail); |
148 | const auto mailData = KMime::CRLFtoLF(originalMessage.toByteArray()); | 149 | } |
149 | if (!mailData.isEmpty()) { | 150 | } else { |
150 | KMime::Message::Ptr mail(new KMime::Message); | 151 | qWarning() << "Retrieved empty message"; |
151 | mail->setContent(mailData); | 152 | } |
152 | mail->parse(); | 153 | }).exec(); |
153 | setMessage(mail); | ||
154 | } else { | ||
155 | m_msg = QVariant(); | ||
156 | } | ||
157 | } | 154 | } |
158 | 155 | ||
159 | KMime::Message::Ptr ComposerController::assembleMessage() | 156 | KMime::Message::Ptr ComposerController::assembleMessage() |
@@ -203,6 +200,7 @@ void ComposerController::saveAsDraft() | |||
203 | Kube::Context context; | 200 | Kube::Context context; |
204 | context.setProperty("message", QVariant::fromValue(mail)); | 201 | context.setProperty("message", QVariant::fromValue(mail)); |
205 | context.setProperty("accountId", QVariant::fromValue(currentAccountId)); | 202 | context.setProperty("accountId", QVariant::fromValue(currentAccountId)); |
203 | context.setProperty("existingMail", QVariant::fromValue(m_existingMail)); | ||
206 | Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); | 204 | Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); |
207 | clear(); | 205 | clear(); |
208 | } | 206 | } |
diff --git a/framework/domain/composercontroller.h b/framework/domain/composercontroller.h index b24c16a9..8390c639 100644 --- a/framework/domain/composercontroller.h +++ b/framework/domain/composercontroller.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <QStringList> | 24 | #include <QStringList> |
25 | #include <QVariant> | 25 | #include <QVariant> |
26 | #include <QAbstractItemModel> | 26 | #include <QAbstractItemModel> |
27 | #include <sink/applicationdomaintype.h> | ||
27 | 28 | ||
28 | namespace KMime { | 29 | namespace KMime { |
29 | class Message; | 30 | class Message; |
@@ -32,8 +33,6 @@ class Message; | |||
32 | class ComposerController : public QObject | 33 | class ComposerController : public QObject |
33 | { | 34 | { |
34 | Q_OBJECT | 35 | Q_OBJECT |
35 | Q_PROPERTY (QVariant originalMessage WRITE setOriginalMessage) | ||
36 | Q_PROPERTY (QVariant draftMessage WRITE setDraftMessage) | ||
37 | Q_PROPERTY (QString to READ to WRITE setTo NOTIFY toChanged) | 36 | Q_PROPERTY (QString to READ to WRITE setTo NOTIFY toChanged) |
38 | Q_PROPERTY (QString cc READ cc WRITE setCc NOTIFY ccChanged) | 37 | Q_PROPERTY (QString cc READ cc WRITE setCc NOTIFY ccChanged) |
39 | Q_PROPERTY (QString bcc READ bcc WRITE setBcc NOTIFY bccChanged) | 38 | Q_PROPERTY (QString bcc READ bcc WRITE setBcc NOTIFY bccChanged) |
@@ -64,9 +63,7 @@ public: | |||
64 | QAbstractItemModel *identityModel() const; | 63 | QAbstractItemModel *identityModel() const; |
65 | 64 | ||
66 | QStringList attachemts() const; | 65 | QStringList attachemts() const; |
67 | 66 | Q_INVOKABLE void loadMessage(const QVariant &draft, bool loadAsDraft); | |
68 | void setOriginalMessage(const QVariant &originalMessage); | ||
69 | void setDraftMessage(const QVariant &draft); | ||
70 | 67 | ||
71 | signals: | 68 | signals: |
72 | void subjectChanged(); | 69 | void subjectChanged(); |
@@ -92,6 +89,7 @@ private: | |||
92 | QString m_subject; | 89 | QString m_subject; |
93 | QString m_body; | 90 | QString m_body; |
94 | QStringList m_attachments; | 91 | QStringList m_attachments; |
92 | Sink::ApplicationDomain::Mail m_existingMail; | ||
95 | QVariant m_msg; | 93 | QVariant m_msg; |
96 | int m_currentAccountIndex; | 94 | int m_currentAccountIndex; |
97 | }; | 95 | }; |