summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/dummyresource/facade.cpp24
-rw-r--r--examples/dummyresource/facade.h4
2 files changed, 2 insertions, 26 deletions
diff --git a/examples/dummyresource/facade.cpp b/examples/dummyresource/facade.cpp
index e50e4f3..37f75ae 100644
--- a/examples/dummyresource/facade.cpp
+++ b/examples/dummyresource/facade.cpp
@@ -38,8 +38,7 @@ using namespace flatbuffers;
38 38
39 39
40DummyResourceFacade::DummyResourceFacade() 40DummyResourceFacade::DummyResourceFacade()
41 : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>("org.kde.dummy"), 41 : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>("org.kde.dummy", QSharedPointer<DummyEventAdaptorFactory>::create())
42 mFactory(new DummyEventAdaptorFactory)
43{ 42{
44} 43}
45 44
@@ -47,25 +46,6 @@ DummyResourceFacade::~DummyResourceFacade()
47{ 46{
48} 47}
49 48
50Async::Job<void> DummyResourceFacade::create(const Akonadi2::ApplicationDomain::Event &domainObject)
51{
52 flatbuffers::FlatBufferBuilder entityFbb;
53 mFactory->createBuffer(domainObject, entityFbb);
54 return sendCreateCommand("event", QByteArray::fromRawData(reinterpret_cast<const char*>(entityFbb.GetBufferPointer()), entityFbb.GetSize()));
55}
56
57Async::Job<void> DummyResourceFacade::modify(const Akonadi2::ApplicationDomain::Event &domainObject)
58{
59 //Create message buffer and send to resource
60 return Async::null<void>();
61}
62
63Async::Job<void> DummyResourceFacade::remove(const Akonadi2::ApplicationDomain::Event &domainObject)
64{
65 //Create message buffer and send to resource
66 return Async::null<void>();
67}
68
69static std::function<bool(const std::string &key, DummyEvent const *buffer, Akonadi2::ApplicationDomain::Buffer::Event const *local)> prepareQuery(const Akonadi2::Query &query) 49static std::function<bool(const std::string &key, DummyEvent const *buffer, Akonadi2::ApplicationDomain::Buffer::Event const *local)> prepareQuery(const Akonadi2::Query &query)
70{ 50{
71 //Compose some functions to make query matching fast. 51 //Compose some functions to make query matching fast.
@@ -133,7 +113,7 @@ void DummyResourceFacade::readValue(QSharedPointer<Akonadi2::Storage> storage, c
133 qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; 113 qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1;
134 //This only works for a 1:1 mapping of resource to domain types. 114 //This only works for a 1:1 mapping of resource to domain types.
135 //Not i.e. for tags that are stored as flags in each entity of an imap store. 115 //Not i.e. for tags that are stored as flags in each entity of an imap store.
136 auto adaptor = mFactory->createAdaptor(buffer.entity()); 116 auto adaptor = mDomainTypeAdaptorFactory->createAdaptor(buffer.entity());
137 //TODO only copy requested properties 117 //TODO only copy requested properties
138 auto memoryAdaptor = QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create(*adaptor); 118 auto memoryAdaptor = QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create(*adaptor);
139 // here we could copy additional properties that don't have a 1:1 mapping, such as separately stored tags. 119 // here we could copy additional properties that don't have a 1:1 mapping, such as separately stored tags.
diff --git a/examples/dummyresource/facade.h b/examples/dummyresource/facade.h
index 91ae351..2fd2fa9 100644
--- a/examples/dummyresource/facade.h
+++ b/examples/dummyresource/facade.h
@@ -34,12 +34,8 @@ class DummyResourceFacade : public Akonadi2::GenericFacade<Akonadi2::Application
34public: 34public:
35 DummyResourceFacade(); 35 DummyResourceFacade();
36 virtual ~DummyResourceFacade(); 36 virtual ~DummyResourceFacade();
37 Async::Job<void> create(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE;
38 Async::Job<void> modify(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE;
39 Async::Job<void> remove(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE;
40 Async::Job<qint64> load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::ApplicationDomain::Event::Ptr &)> &resultCallback) Q_DECL_OVERRIDE; 37 Async::Job<qint64> load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::ApplicationDomain::Event::Ptr &)> &resultCallback) Q_DECL_OVERRIDE;
41 38
42private: 39private:
43 void readValue(QSharedPointer<Akonadi2::Storage> storage, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::Event::Ptr &)> &resultCallback, std::function<bool(const std::string &key, DummyCalendar::DummyEvent const *buffer, Akonadi2::ApplicationDomain::Buffer::Event const *local)>); 40 void readValue(QSharedPointer<Akonadi2::Storage> storage, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::Event::Ptr &)> &resultCallback, std::function<bool(const std::string &key, DummyCalendar::DummyEvent const *buffer, Akonadi2::ApplicationDomain::Buffer::Event const *local)>);
44 QSharedPointer<DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, DummyCalendar::DummyEvent, Akonadi2::ApplicationDomain::Buffer::EventBuilder, DummyCalendar::DummyEventBuilder> > mFactory;
45}; 41};