summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dummyresource')
-rw-r--r--examples/dummyresource/resourcefactory.cpp23
-rw-r--r--examples/dummyresource/resourcefactory.h5
2 files changed, 22 insertions, 6 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
diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h
index 1c51b00..9192c68 100644
--- a/examples/dummyresource/resourcefactory.h
+++ b/examples/dummyresource/resourcefactory.h
@@ -27,7 +27,7 @@
27#include <flatbuffers/flatbuffers.h> 27#include <flatbuffers/flatbuffers.h>
28 28
29//TODO: a little ugly to have this in two places, once here and once in Q_PLUGIN_METADATA 29//TODO: a little ugly to have this in two places, once here and once in Q_PLUGIN_METADATA
30#define PLUGIN_NAME "org.kde.dummy" 30#define PLUGIN_NAME "sink.dummy"
31 31
32class DummyResource : public Sink::GenericResource 32class DummyResource : public Sink::GenericResource
33{ 33{
@@ -35,13 +35,14 @@ public:
35 DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline = QSharedPointer<Sink::Pipeline>()); 35 DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline = QSharedPointer<Sink::Pipeline>());
36 virtual ~DummyResource(); 36 virtual ~DummyResource();
37 37
38 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE;
38 KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; 39 KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE;
39}; 40};
40 41
41class DummyResourceFactory : public Sink::ResourceFactory 42class DummyResourceFactory : public Sink::ResourceFactory
42{ 43{
43 Q_OBJECT 44 Q_OBJECT
44 Q_PLUGIN_METADATA(IID "org.kde.dummy") 45 Q_PLUGIN_METADATA(IID "sink.dummy")
45 Q_INTERFACES(Sink::ResourceFactory) 46 Q_INTERFACES(Sink::ResourceFactory)
46 47
47public: 48public: