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.cpp41
1 files changed, 1 insertions, 40 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index 3596a82..c746130 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -33,42 +33,6 @@
33#include "domain/event.h" 33#include "domain/event.h"
34#include "dummystore.h" 34#include "dummystore.h"
35#include <QUuid> 35#include <QUuid>
36#include <assert.h>
37
38
39/*
40 * Figure out how to implement various classes of processors:
41 * * read-only (index and such) => extractor function, probably using domain adaptor
42 * * filter => provide means to move entity elsewhere, and also reflect change in source (I guess?)
43 * * flag extractors? => like read-only? Or write to local portion of buffer?
44 * ** $ISSPAM should become part of domain object and is written to the local part of the mail.
45 * ** => value could be calculated by the server directly
46 */
47class SimpleProcessor : public Akonadi2::Preprocessor
48{
49public:
50 SimpleProcessor(const QString &id, const std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> &f)
51 : Akonadi2::Preprocessor(),
52 mFunction(f),
53 mId(id)
54 {
55 }
56
57 void process(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e) Q_DECL_OVERRIDE
58 {
59 mFunction(state, e);
60 processingCompleted(state);
61 }
62
63 QString id() const
64 {
65 return mId;
66 }
67
68protected:
69 std::function<void(const Akonadi2::PipelineState &state, const Akonadi2::Entity &e)> mFunction;
70 QString mId;
71};
72 36
73 37
74DummyResource::DummyResource(const QByteArray &instanceIdentifier) 38DummyResource::DummyResource(const QByteArray &instanceIdentifier)
@@ -78,12 +42,9 @@ DummyResource::DummyResource(const QByteArray &instanceIdentifier)
78 42
79void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline) 43void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline)
80{ 44{
81 //TODO In case of a non 1:1 mapping between resource and domain types special handling is required.
82 //i.e. If a resource stores tags as part of each message it needs to update the tag index
83
84 auto eventFactory = QSharedPointer<DummyEventAdaptorFactory>::create(); 45 auto eventFactory = QSharedPointer<DummyEventAdaptorFactory>::create();
85 const auto resourceIdentifier = mResourceInstanceIdentifier; 46 const auto resourceIdentifier = mResourceInstanceIdentifier;
86 auto eventIndexer = new SimpleProcessor("eventIndexer", [eventFactory, resourceIdentifier](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) { 47 auto eventIndexer = new Akonadi2::SimpleProcessor("eventIndexer", [eventFactory, resourceIdentifier](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) {
87 auto adaptor = eventFactory->createAdaptor(entity); 48 auto adaptor = eventFactory->createAdaptor(entity);
88 //FIXME set revision? 49 //FIXME set revision?
89 Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor); 50 Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor);