summaryrefslogtreecommitdiffstats
path: root/examples/mailtransportresource/mailtransportresource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mailtransportresource/mailtransportresource.cpp')
-rw-r--r--examples/mailtransportresource/mailtransportresource.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp
index 1e93bdf..a729d4d 100644
--- a/examples/mailtransportresource/mailtransportresource.cpp
+++ b/examples/mailtransportresource/mailtransportresource.cpp
@@ -44,6 +44,8 @@
44 44
45#define ENTITY_TYPE_MAIL "mail" 45#define ENTITY_TYPE_MAIL "mail"
46 46
47SINK_DEBUG_AREA("mailtransportresource")
48
47using namespace Sink; 49using namespace Sink;
48 50
49//TODO fold into synchronizer 51//TODO fold into synchronizer
@@ -58,7 +60,7 @@ public:
58 KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE 60 KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) Q_DECL_OVERRIDE
59 { 61 {
60 if (operation == Sink::Operation_Creation) { 62 if (operation == Sink::Operation_Creation) {
61 Trace() << "Dispatching message."; 63 SinkTrace() << "Dispatching message.";
62 // return send(mail, mSettings); 64 // return send(mail, mSettings);
63 } else if (operation == Sink::Operation_Removal) { 65 } else if (operation == Sink::Operation_Removal) {
64 } else if (operation == Sink::Operation_Modification) { 66 } else if (operation == Sink::Operation_Modification) {
@@ -86,9 +88,9 @@ public:
86 msg->setHead(KMime::CRLFtoLF(data)); 88 msg->setHead(KMime::CRLFtoLF(data));
87 msg->parse(); 89 msg->parse();
88 if (settings.testMode) { 90 if (settings.testMode) {
89 Log() << "I would totally send that mail, but I'm in test mode." << mail.identifier(); 91 SinkLog() << "I would totally send that mail, but I'm in test mode." << mail.identifier();
90 auto path = resourceStorageLocation(mResourceInstanceIdentifier) + "/test/"; 92 auto path = resourceStorageLocation(mResourceInstanceIdentifier) + "/test/";
91 Trace() << path; 93 SinkTrace() << path;
92 QDir dir; 94 QDir dir;
93 dir.mkpath(path); 95 dir.mkpath(path);
94 QFile f(path+ mail.identifier()); 96 QFile f(path+ mail.identifier());
@@ -97,9 +99,9 @@ public:
97 f.close(); 99 f.close();
98 } else { 100 } else {
99 if (MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), settings.password.toUtf8(), settings.cacert.toUtf8())) { 101 if (MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), settings.password.toUtf8(), settings.cacert.toUtf8())) {
100 Log() << "Sent message successfully"; 102 SinkLog() << "Sent message successfully";
101 } else { 103 } else {
102 Log() << "Failed to send message"; 104 SinkLog() << "Failed to send message";
103 return KAsync::error<void>(1, "Failed to send the message."); 105 return KAsync::error<void>(1, "Failed to send the message.");
104 } 106 }
105 } 107 }
@@ -108,13 +110,13 @@ public:
108 110
109 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE 111 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE
110 { 112 {
111 Log() << " Synchronizing"; 113 SinkLog() << " Synchronizing";
112 return KAsync::start<void>([this](KAsync::Future<void> future) { 114 return KAsync::start<void>([this](KAsync::Future<void> future) {
113 Sink::Query query; 115 Sink::Query query;
114 QList<ApplicationDomain::Mail> toSend; 116 QList<ApplicationDomain::Mail> toSend;
115 Log() << " Looking for mail"; 117 SinkLog() << " Looking for mail";
116 store().reader<ApplicationDomain::Mail>().query(query, [&](const ApplicationDomain::Mail &mail) -> bool { 118 store().reader<ApplicationDomain::Mail>().query(query, [&](const ApplicationDomain::Mail &mail) -> bool {
117 Trace() << "Found mail: " << mail.identifier(); 119 SinkTrace() << "Found mail: " << mail.identifier();
118 if (!mail.getSent()) { 120 if (!mail.getSent()) {
119 toSend << mail; 121 toSend << mail;
120 } 122 }