summaryrefslogtreecommitdiffstats
path: root/framework/domain/actions/sinkactions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/actions/sinkactions.cpp')
-rw-r--r--framework/domain/actions/sinkactions.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp
index 6a0028e9..6b59829c 100644
--- a/framework/domain/actions/sinkactions.cpp
+++ b/framework/domain/actions/sinkactions.cpp
@@ -23,6 +23,9 @@
23#include <QFile> 23#include <QFile>
24 24
25#include <sink/store.h> 25#include <sink/store.h>
26#include <sink/log.h>
27
28SINK_DEBUG_AREA("sinkactions")
26 29
27using namespace Kube; 30using namespace Kube;
28 31
@@ -33,11 +36,11 @@ static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read"
33 [](Context *context) { 36 [](Context *context) {
34 auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); 37 auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>();
35 if (!mail) { 38 if (!mail) {
36 qWarning() << "Failed to get the mail mail: " << context->property("mail"); 39 SinkWarning() << "Failed to get the mail mail: " << context->property("mail");
37 return; 40 return;
38 } 41 }
39 mail->setProperty("unread", false); 42 mail->setProperty("unread", false);
40 qDebug() << "Mark as read " << mail->identifier(); 43 SinkLog() << "Mark as read " << mail->identifier();
41 Sink::Store::modify(*mail).exec(); 44 Sink::Store::modify(*mail).exec();
42 } 45 }
43); 46);
@@ -49,11 +52,11 @@ static ActionHandlerHelper moveToTrashHandler("org.kde.kube.actions.move-to-tras
49 [](Context *context) { 52 [](Context *context) {
50 auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); 53 auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>();
51 if (!mail) { 54 if (!mail) {
52 qWarning() << "Failed to get the mail mail: " << context->property("mail"); 55 SinkWarning() << "Failed to get the mail mail: " << context->property("mail");
53 return; 56 return;
54 } 57 }
55 mail->setTrash(true); 58 mail->setTrash(true);
56 qDebug() << "Move to trash " << mail->identifier(); 59 SinkLog() << "Move to trash " << mail->identifier();
57 Sink::Store::modify(*mail).exec(); 60 Sink::Store::modify(*mail).exec();
58 } 61 }
59); 62);
@@ -65,10 +68,10 @@ static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete",
65 [](Context *context) { 68 [](Context *context) {
66 auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); 69 auto mail = context->property("mail").value<Sink::ApplicationDomain::Mail::Ptr>();
67 if (!mail) { 70 if (!mail) {
68 qWarning() << "Failed to get the mail mail: " << context->property("mail"); 71 SinkWarning() << "Failed to get the mail mail: " << context->property("mail");
69 return; 72 return;
70 } 73 }
71 qDebug() << "Remove " << mail->identifier(); 74 SinkLog() << "Remove " << mail->identifier();
72 Sink::Store::remove(*mail).exec(); 75 Sink::Store::remove(*mail).exec();
73 } 76 }
74); 77);
@@ -79,10 +82,10 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize"
79 }, 82 },
80 [](Context *context) { 83 [](Context *context) {
81 if (auto folder = context->property("folder").value<Sink::ApplicationDomain::Folder::Ptr>()) { 84 if (auto folder = context->property("folder").value<Sink::ApplicationDomain::Folder::Ptr>()) {
82 qDebug() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); 85 SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier();
83 Sink::Store::synchronize(Sink::Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); 86 Sink::Store::synchronize(Sink::Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec();
84 } else { 87 } else {
85 qDebug() << "Synchronizing all"; 88 SinkLog() << "Synchronizing all";
86 Sink::Store::synchronize(Sink::Query()).exec(); 89 Sink::Store::synchronize(Sink::Query()).exec();
87 } 90 }
88 } 91 }
@@ -97,7 +100,7 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail",
97 [](Context *context) { 100 [](Context *context) {
98 auto accountId = context->property("accountId").value<QByteArray>(); 101 auto accountId = context->property("accountId").value<QByteArray>();
99 auto message = context->property("message").value<KMime::Message::Ptr>(); 102 auto message = context->property("message").value<KMime::Message::Ptr>();
100 qWarning() << "Sending a mail: "; 103 SinkLog() << "Sending a mail: ";
101 104
102 Sink::Query query; 105 Sink::Query query;
103 query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport); 106 query += Sink::Query::CapabilityFilter(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport);
@@ -106,12 +109,12 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail",
106 .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { 109 .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([=](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) {
107 if (!resources.isEmpty()) { 110 if (!resources.isEmpty()) {
108 auto resourceId = resources[0]->identifier(); 111 auto resourceId = resources[0]->identifier();
109 qDebug() << "Sending message via resource: " << resourceId; 112 SinkTrace() << "Sending message via resource: " << resourceId;
110 Sink::ApplicationDomain::Mail mail(resourceId); 113 Sink::ApplicationDomain::Mail mail(resourceId);
111 mail.setBlobProperty("mimeMessage", message->encodedContent()); 114 mail.setBlobProperty("mimeMessage", message->encodedContent());
112 return Sink::Store::create(mail); 115 return Sink::Store::create(mail);
113 } 116 }
114 qWarning() << "Failed to find a mailtransport resource"; 117 SinkWarning() << "Failed to find a mailtransport resource";
115 return KAsync::error<void>(0, "Failed to find a MailTransport resource."); 118 return KAsync::error<void>(0, "Failed to find a MailTransport resource.");
116 }).exec(); 119 }).exec();
117 } 120 }
@@ -124,12 +127,12 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft",
124 return !accountId.isEmpty() && message; 127 return !accountId.isEmpty() && message;
125 }, 128 },
126 ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { 129 ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> {
127 qWarning() << "executing save as draft"; 130 SinkWarning() << "executing save as draft";
128 const auto accountId = context->property("accountId").value<QByteArray>(); 131 const auto accountId = context->property("accountId").value<QByteArray>();
129 const auto message = context->property("message").value<KMime::Message::Ptr>(); 132 const auto message = context->property("message").value<KMime::Message::Ptr>();
130 auto existingMail = context->property("existingMail").value<Sink::ApplicationDomain::Mail>(); 133 auto existingMail = context->property("existingMail").value<Sink::ApplicationDomain::Mail>();
131 if (!message) { 134 if (!message) {
132 qWarning() << "Failed to get the mail: " << context->property("mail"); 135 SinkWarning() << "Failed to get the mail: " << context->property("mail");
133 return KAsync::error<void>(1, "Failed to get the mail: " + context->property("mail").toString()); 136 return KAsync::error<void>(1, "Failed to get the mail: " + context->property("mail").toString());
134 } 137 }
135 138
@@ -145,7 +148,7 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft",
145 return Sink::Store::create(mail); 148 return Sink::Store::create(mail);
146 }); 149 });
147 } else { 150 } else {
148 qWarning() << "Modifying an existing mail" << existingMail.identifier(); 151 SinkWarning() << "Modifying an existing mail" << existingMail.identifier();
149 existingMail.setBlobProperty("mimeMessage", message->encodedContent()); 152 existingMail.setBlobProperty("mimeMessage", message->encodedContent());
150 return Sink::Store::modify(existingMail); 153 return Sink::Store::modify(existingMail);
151 } 154 }