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.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index f5ab2d9..8e81c79 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -37,6 +37,7 @@
37#include "facadefactory.h" 37#include "facadefactory.h"
38#include "adaptorfactoryregistry.h" 38#include "adaptorfactoryregistry.h"
39#include "synchronizer.h" 39#include "synchronizer.h"
40#include "inspector.h"
40#include "mailpreprocessor.h" 41#include "mailpreprocessor.h"
41#include "remoteidmap.h" 42#include "remoteidmap.h"
42#include <QDate> 43#include <QDate>
@@ -130,10 +131,36 @@ class DummySynchronizer : public Sink::Synchronizer {
130 131
131}; 132};
132 133
134class DummyInspector : public Sink::Inspector {
135public:
136 DummyInspector(const Sink::ResourceContext &resourceContext)
137 : Sink::Inspector(resourceContext)
138 {
139
140 }
141
142protected:
143 KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE
144 {
145 SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue;
146 if (property == "testInspection") {
147 if (expectedValue.toBool()) {
148 //Success
149 return KAsync::null<void>();
150 } else {
151 //Failure
152 return KAsync::error<void>(1, "Failed.");
153 }
154 }
155 return KAsync::null<void>();
156 }
157};
158
133DummyResource::DummyResource(const Sink::ResourceContext &resourceContext, const QSharedPointer<Sink::Pipeline> &pipeline) 159DummyResource::DummyResource(const Sink::ResourceContext &resourceContext, const QSharedPointer<Sink::Pipeline> &pipeline)
134 : Sink::GenericResource(resourceContext, pipeline) 160 : Sink::GenericResource(resourceContext, pipeline)
135{ 161{
136 setupSynchronizer(QSharedPointer<DummySynchronizer>::create(resourceContext)); 162 setupSynchronizer(QSharedPointer<DummySynchronizer>::create(resourceContext));
163 setupInspector(QSharedPointer<DummyInspector>::create(resourceContext));
137 setupPreprocessors(ENTITY_TYPE_MAIL, 164 setupPreprocessors(ENTITY_TYPE_MAIL,
138 QVector<Sink::Preprocessor*>() << new MailPropertyExtractor); 165 QVector<Sink::Preprocessor*>() << new MailPropertyExtractor);
139 setupPreprocessors(ENTITY_TYPE_FOLDER, 166 setupPreprocessors(ENTITY_TYPE_FOLDER,
@@ -159,23 +186,6 @@ KAsync::Job<void> DummyResource::synchronizeWithSource(const Sink::QueryBase &qu
159 return GenericResource::synchronizeWithSource(query); 186 return GenericResource::synchronizeWithSource(query);
160} 187}
161 188
162KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue)
163{
164
165 SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue;
166 if (property == "testInspection") {
167 if (expectedValue.toBool()) {
168 //Success
169 return KAsync::null<void>();
170 } else {
171 //Failure
172 return KAsync::error<void>(1, "Failed.");
173 }
174 }
175 return KAsync::null<void>();
176}
177
178
179DummyResourceFactory::DummyResourceFactory(QObject *parent) 189DummyResourceFactory::DummyResourceFactory(QObject *parent)
180 : Sink::ResourceFactory(parent) 190 : Sink::ResourceFactory(parent)
181{ 191{