From e1c6979863b4994eabeb7ae35208472c234b24f6 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 3 Jan 2015 12:42:42 +0100 Subject: Pass entity to preprocessor. --- dummyresource/resourcefactory.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'dummyresource/resourcefactory.cpp') diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp index da6969a..87a6048 100644 --- a/dummyresource/resourcefactory.cpp +++ b/dummyresource/resourcefactory.cpp @@ -38,18 +38,19 @@ class SimpleProcessor : public Akonadi2::Preprocessor { public: - SimpleProcessor(const std::function &f) + SimpleProcessor(const std::function &f) : Akonadi2::Preprocessor(), mFunction(f) { } - void process(const Akonadi2::PipelineState &state) { - mFunction(state); + void process(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e) { + mFunction(state, e); + processingCompleted(state); } protected: - std::function mFunction; + std::function mFunction; }; // template @@ -102,13 +103,12 @@ DummyResource::DummyResource() void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline) { - auto factory = QSharedPointer::create(); + auto eventFactory = QSharedPointer::create(); //TODO setup preprocessors for each domain type and pipeline type allowing full customization //Eventually the order should be self configuring, for now it's hardcoded. - auto eventIndexer = new SimpleProcessor([factory](const Akonadi2::PipelineState &state) { - auto adaptor = factory->createAdaptor(state.entity()); - //Here we can plug in generic preprocessors - qDebug() << adaptor->getProperty("summary").toString(); + auto eventIndexer = new SimpleProcessor([eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) { + auto adaptor = eventFactory->createAdaptor(entity); + qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString(); }); pipeline->setPreprocessors(Akonadi2::Pipeline::NewPipeline, QVector() << eventIndexer); } -- cgit v1.2.3