From 01adeefb24bf72f1015e93aa5f075f93f56d94da Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 30 Jul 2015 13:43:31 +0200 Subject: Made the pipeline an implementation detail of the resource. This removes one dependency from the Listener and will allow us to test the Listener better. --- examples/dummyresource/resourcefactory.cpp | 17 ++++++----------- examples/dummyresource/resourcefactory.h | 5 ++--- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'examples/dummyresource') diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index c7a3eef..e9bf6cd 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp @@ -35,12 +35,8 @@ //This is the resources entity type, and not the domain type #define ENTITY_TYPE_EVENT "event" -DummyResource::DummyResource(const QByteArray &instanceIdentifier) - : Akonadi2::GenericResource(instanceIdentifier) -{ -} - -void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline) +DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer &pipeline) + : Akonadi2::GenericResource(instanceIdentifier, pipeline) { auto eventFactory = QSharedPointer::create(); const auto resourceIdentifier = mResourceInstanceIdentifier; @@ -57,15 +53,14 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline) } }); - pipeline->setPreprocessors(ENTITY_TYPE_EVENT, Akonadi2::Pipeline::NewPipeline, QVector() << eventIndexer); - pipeline->setAdaptorFactory(ENTITY_TYPE_EVENT, eventFactory); + mPipeline->setPreprocessors(ENTITY_TYPE_EVENT, Akonadi2::Pipeline::NewPipeline, QVector() << eventIndexer); + mPipeline->setAdaptorFactory(ENTITY_TYPE_EVENT, eventFactory); //TODO cleanup indexes during removal - GenericResource::configurePipeline(pipeline); } -KAsync::Job DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline) +KAsync::Job DummyResource::synchronizeWithSource() { - return KAsync::start([this, pipeline](KAsync::Future &f) { + return KAsync::start([this](KAsync::Future &f) { //TODO start transaction on index Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index f2362bc..4baafa7 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h @@ -32,9 +32,8 @@ class DummyResource : public Akonadi2::GenericResource { public: - DummyResource(const QByteArray &instanceIdentifier); - KAsync::Job synchronizeWithSource(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE; - void configurePipeline(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE; + DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer &pipeline = QSharedPointer()); + KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE; }; class DummyResourceFactory : public Akonadi2::ResourceFactory -- cgit v1.2.3