From 938554f267193b652478fc12343819fa45d76034 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 28 Nov 2016 19:33:01 +0100 Subject: Moved inspection commands to a separate inspector. --- examples/dummyresource/resourcefactory.cpp | 44 ++++++++++++++++++------------ examples/dummyresource/resourcefactory.h | 1 - 2 files changed, 27 insertions(+), 18 deletions(-) (limited to 'examples/dummyresource') 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 @@ #include "facadefactory.h" #include "adaptorfactoryregistry.h" #include "synchronizer.h" +#include "inspector.h" #include "mailpreprocessor.h" #include "remoteidmap.h" #include @@ -130,10 +131,36 @@ class DummySynchronizer : public Sink::Synchronizer { }; +class DummyInspector : public Sink::Inspector { +public: + DummyInspector(const Sink::ResourceContext &resourceContext) + : Sink::Inspector(resourceContext) + { + + } + +protected: + KAsync::Job inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE + { + SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; + if (property == "testInspection") { + if (expectedValue.toBool()) { + //Success + return KAsync::null(); + } else { + //Failure + return KAsync::error(1, "Failed."); + } + } + return KAsync::null(); + } +}; + DummyResource::DummyResource(const Sink::ResourceContext &resourceContext, const QSharedPointer &pipeline) : Sink::GenericResource(resourceContext, pipeline) { setupSynchronizer(QSharedPointer::create(resourceContext)); + setupInspector(QSharedPointer::create(resourceContext)); setupPreprocessors(ENTITY_TYPE_MAIL, QVector() << new MailPropertyExtractor); setupPreprocessors(ENTITY_TYPE_FOLDER, @@ -159,23 +186,6 @@ KAsync::Job DummyResource::synchronizeWithSource(const Sink::QueryBase &qu return GenericResource::synchronizeWithSource(query); } -KAsync::Job DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) -{ - - SinkTrace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; - if (property == "testInspection") { - if (expectedValue.toBool()) { - //Success - return KAsync::null(); - } else { - //Failure - return KAsync::error(1, "Failed."); - } - } - return KAsync::null(); -} - - DummyResourceFactory::DummyResourceFactory(QObject *parent) : Sink::ResourceFactory(parent) { diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index 8ef27a6..2eb7558 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h @@ -33,7 +33,6 @@ public: virtual ~DummyResource(); KAsync::Job synchronizeWithSource(const Sink::QueryBase &) Q_DECL_OVERRIDE; - KAsync::Job inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; }; class DummyResourceFactory : public Sink::ResourceFactory -- cgit v1.2.3