summaryrefslogtreecommitdiffstats
path: root/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dummyresource/resourcefactory.cpp')
-rw-r--r--dummyresource/resourcefactory.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp
index dc716ef..6fe10ec 100644
--- a/dummyresource/resourcefactory.cpp
+++ b/dummyresource/resourcefactory.cpp
@@ -43,19 +43,27 @@
43class SimpleProcessor : public Akonadi2::Preprocessor 43class SimpleProcessor : public Akonadi2::Preprocessor
44{ 44{
45public: 45public:
46 SimpleProcessor(const std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> &f) 46 SimpleProcessor(const QString &id, const std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> &f)
47 : Akonadi2::Preprocessor(), 47 : Akonadi2::Preprocessor(),
48 mFunction(f) 48 mFunction(f),
49 mId(id)
49 { 50 {
50 } 51 }
51 52
52 void process(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e) { 53 void process(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e) Q_DECL_OVERRIDE
54 {
53 mFunction(state, e); 55 mFunction(state, e);
54 processingCompleted(state); 56 processingCompleted(state);
55 } 57 }
56 58
59 QString id() const
60 {
61 return mId;
62 }
63
57protected: 64protected:
58 std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> mFunction; 65 std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> mFunction;
66 QString mId;
59}; 67};
60 68
61// template <typename DomainType> 69// template <typename DomainType>
@@ -166,7 +174,7 @@ private slots:
166 break; 174 break;
167 case Akonadi2::Commands::CreateEntityCommand: { 175 case Akonadi2::Commands::CreateEntityCommand: {
168 //TODO job lifetime management 176 //TODO job lifetime management
169 mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()).then<void>([&messageQueueCallback, whileCallback](Async::Future<void> &future) { 177 mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()).then<void>([messageQueueCallback, whileCallback](Async::Future<void> &future) {
170 messageQueueCallback(true); 178 messageQueueCallback(true);
171 whileCallback(false); 179 whileCallback(false);
172 future.setFinished(); 180 future.setFinished();
@@ -239,7 +247,7 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline)
239 //i.e. If a resource stores tags as part of each message it needs to update the tag index 247 //i.e. If a resource stores tags as part of each message it needs to update the tag index
240 //TODO setup preprocessors for each domain type and pipeline type allowing full customization 248 //TODO setup preprocessors for each domain type and pipeline type allowing full customization
241 //Eventually the order should be self configuring, for now it's hardcoded. 249 //Eventually the order should be self configuring, for now it's hardcoded.
242 auto eventIndexer = new SimpleProcessor([eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) { 250 auto eventIndexer = new SimpleProcessor("summaryprocessor", [eventFactory](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) {
243 auto adaptor = eventFactory->createAdaptor(entity); 251 auto adaptor = eventFactory->createAdaptor(entity);
244 qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString(); 252 qDebug() << "Summary preprocessor: " << adaptor->getProperty("summary").toString();
245 }); 253 });