summaryrefslogtreecommitdiffstats
path: root/examples/mailtransportresource
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-11 11:55:29 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-11 11:55:29 +0200
commit3a3118e768e1447dc7524328e84b8d7faef81fe1 (patch)
treeaf5582170ed6164fffc9365f34b17bf449c0db40 /examples/mailtransportresource
parentf9379318d801df204cc50385c5eca1f28e91755e (diff)
parentce2fd2666f084eebe443598f6f3740a02913091e (diff)
downloadsink-3a3118e768e1447dc7524328e84b8d7faef81fe1.tar.gz
sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.zip
Merge branch 'feature/notifications' into develop
Diffstat (limited to 'examples/mailtransportresource')
-rw-r--r--examples/mailtransportresource/mailtransportresource.cpp18
-rw-r--r--examples/mailtransportresource/mailtransportresource.h4
-rw-r--r--examples/mailtransportresource/tests/mailtransporttest.cpp1
3 files changed, 12 insertions, 11 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 }
diff --git a/examples/mailtransportresource/mailtransportresource.h b/examples/mailtransportresource/mailtransportresource.h
index 6622ea6..cf6abf2 100644
--- a/examples/mailtransportresource/mailtransportresource.h
+++ b/examples/mailtransportresource/mailtransportresource.h
@@ -23,7 +23,7 @@
23#include "common/genericresource.h" 23#include "common/genericresource.h"
24 24
25//TODO: a little ugly to have this in two places, once here and once in Q_PLUGIN_METADATA 25//TODO: a little ugly to have this in two places, once here and once in Q_PLUGIN_METADATA
26#define PLUGIN_NAME "org.kde.mailtransport" 26#define PLUGIN_NAME "sink.mailtransport"
27 27
28class MailtransportResource : public Sink::GenericResource 28class MailtransportResource : public Sink::GenericResource
29{ 29{
@@ -46,7 +46,7 @@ private:
46class MailtransportResourceFactory : public Sink::ResourceFactory 46class MailtransportResourceFactory : public Sink::ResourceFactory
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 Q_PLUGIN_METADATA(IID "org.kde.mailtransport") 49 Q_PLUGIN_METADATA(IID "sink.mailtransport")
50 Q_INTERFACES(Sink::ResourceFactory) 50 Q_INTERFACES(Sink::ResourceFactory)
51 51
52public: 52public:
diff --git a/examples/mailtransportresource/tests/mailtransporttest.cpp b/examples/mailtransportresource/tests/mailtransporttest.cpp
index 3ce5f82..fdd591b 100644
--- a/examples/mailtransportresource/tests/mailtransporttest.cpp
+++ b/examples/mailtransportresource/tests/mailtransporttest.cpp
@@ -33,7 +33,6 @@ private slots:
33 void initTestCase() 33 void initTestCase()
34 { 34 {
35 Test::initTest(); 35 Test::initTest();
36 Log::setDebugOutputLevel(Sink::Log::Trace);
37 auto resource = createResource(); 36 auto resource = createResource();
38 QVERIFY(!resource.identifier().isEmpty()); 37 QVERIFY(!resource.identifier().isEmpty());
39 VERIFYEXEC(Store::create(resource)); 38 VERIFYEXEC(Store::create(resource));