summaryrefslogtreecommitdiffstats
path: root/examples/mailtransportresource
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 22:23:49 +0200
commitda2b049e248c1ad7efeb53685158a205335e4e36 (patch)
tree1e7e5e940e9b760b2108081b1d2f3879cebdb0ff /examples/mailtransportresource
parent9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (diff)
downloadsink-da2b049e248c1ad7efeb53685158a205335e4e36.tar.gz
sink-da2b049e248c1ad7efeb53685158a205335e4e36.zip
A new debug system.
Instead of a single #define as debug area the new system allows for an identifier for each debug message with the structure component.area. The component is a dot separated identifier of the runtime component, such as the process or the plugin. The area is the code component, and can be as such defined at compiletime. The idea of this system is that it becomes possible to i.e. look at the output of all messages in the query subsystem of a specific resource (something that happens in the client process, but in the resource-specific subcomponent). The new macros are supposed to be less likely to clash with other names, hence the new names.
Diffstat (limited to 'examples/mailtransportresource')
-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 }