summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dummyresource/resourcefactory.cpp')
-rw-r--r--examples/dummyresource/resourcefactory.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index 2bd52cc..0f7463f 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -23,6 +23,7 @@
23#include "entitybuffer.h" 23#include "entitybuffer.h"
24#include "pipeline.h" 24#include "pipeline.h"
25#include "dummycalendar_generated.h" 25#include "dummycalendar_generated.h"
26#include "notification_generated.h"
26#include "mail_generated.h" 27#include "mail_generated.h"
27#include "createentity_generated.h" 28#include "createentity_generated.h"
28#include "domainadaptor.h" 29#include "domainadaptor.h"
@@ -47,6 +48,8 @@
47#define ENTITY_TYPE_MAIL "mail" 48#define ENTITY_TYPE_MAIL "mail"
48#define ENTITY_TYPE_FOLDER "folder" 49#define ENTITY_TYPE_FOLDER "folder"
49 50
51SINK_DEBUG_AREA("dummyresource")
52
50class DummySynchronizer : public Sink::Synchronizer { 53class DummySynchronizer : public Sink::Synchronizer {
51 public: 54 public:
52 55
@@ -104,12 +107,12 @@ class DummySynchronizer : public Sink::Synchronizer {
104 auto entity = createEntity(remoteId, it.value()); 107 auto entity = createEntity(remoteId, it.value());
105 createOrModify(bufferType, remoteId, *entity); 108 createOrModify(bufferType, remoteId, *entity);
106 } 109 }
107 Trace() << "Sync of " << count << " entities of type " << bufferType << " done." << Sink::Log::TraceTime(time->elapsed()); 110 SinkTrace() << "Sync of " << count << " entities of type " << bufferType << " done." << Sink::Log::TraceTime(time->elapsed());
108 } 111 }
109 112
110 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE 113 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE
111 { 114 {
112 Log() << " Synchronizing with the source"; 115 SinkLog() << " Synchronizing with the source";
113 return KAsync::start<void>([this]() { 116 return KAsync::start<void>([this]() {
114 synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) { 117 synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) {
115 return createEvent(ridBuffer, data); 118 return createEvent(ridBuffer, data);
@@ -120,7 +123,7 @@ class DummySynchronizer : public Sink::Synchronizer {
120 synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) { 123 synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) {
121 return createFolder(ridBuffer, data); 124 return createFolder(ridBuffer, data);
122 }); 125 });
123 Log() << "Done Synchronizing"; 126 SinkLog() << "Done Synchronizing";
124 }); 127 });
125 } 128 }
126 129
@@ -144,10 +147,22 @@ DummyResource::~DummyResource()
144 147
145} 148}
146 149
150KAsync::Job<void> DummyResource::synchronizeWithSource()
151{
152 SinkTrace() << "Synchronize with source and sending a notification about it";
153 Sink::Notification n;
154 n.id = "connected";
155 n.type = Sink::Notification::Status;
156 n.message = "We're connected";
157 n.code = Sink::ApplicationDomain::ConnectedStatus;
158 emit notify(n);
159 return GenericResource::synchronizeWithSource();
160}
161
147KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) 162KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue)
148{ 163{
149 164
150 Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; 165 SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue;
151 if (property == "testInspection") { 166 if (property == "testInspection") {
152 if (expectedValue.toBool()) { 167 if (expectedValue.toBool()) {
153 //Success 168 //Success