summaryrefslogtreecommitdiffstats
path: root/dummyresource/facade.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dummyresource/facade.cpp')
-rw-r--r--dummyresource/facade.cpp34
1 files changed, 3 insertions, 31 deletions
diff --git a/dummyresource/facade.cpp b/dummyresource/facade.cpp
index 1af735e..209ad0d 100644
--- a/dummyresource/facade.cpp
+++ b/dummyresource/facade.cpp
@@ -28,7 +28,6 @@
28#include "event_generated.h" 28#include "event_generated.h"
29#include "entity_generated.h" 29#include "entity_generated.h"
30#include "metadata_generated.h" 30#include "metadata_generated.h"
31#include "createentity_generated.h"
32#include "domainadaptor.h" 31#include "domainadaptor.h"
33#include <common/entitybuffer.h> 32#include <common/entitybuffer.h>
34#include <common/index.h> 33#include <common/index.h>
@@ -37,9 +36,9 @@
37using namespace DummyCalendar; 36using namespace DummyCalendar;
38using namespace flatbuffers; 37using namespace flatbuffers;
39 38
39
40DummyResourceFacade::DummyResourceFacade() 40DummyResourceFacade::DummyResourceFacade()
41 : Akonadi2::StoreFacade<Akonadi2::Domain::Event>(), 41 : Akonadi2::GenericFacade<Akonadi2::Domain::Event>("org.kde.dummy"),
42 mResourceAccess(new Akonadi2::ResourceAccess("org.kde.dummy")),
43 mFactory(new DummyEventAdaptorFactory) 42 mFactory(new DummyEventAdaptorFactory)
44{ 43{
45} 44}
@@ -52,15 +51,7 @@ Async::Job<void> DummyResourceFacade::create(const Akonadi2::Domain::Event &doma
52{ 51{
53 flatbuffers::FlatBufferBuilder entityFbb; 52 flatbuffers::FlatBufferBuilder entityFbb;
54 mFactory->createBuffer(domainObject, entityFbb); 53 mFactory->createBuffer(domainObject, entityFbb);
55 54 return sendCreateCommand("event", QByteArray::fromRawData(reinterpret_cast<const char*>(entityFbb.GetBufferPointer()), entityFbb.GetSize()));
56 flatbuffers::FlatBufferBuilder fbb;
57 //This is the resource buffer type and not the domain type
58 auto type = fbb.CreateString("event");
59 auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize());
60 auto location = Akonadi2::Commands::CreateCreateEntity(fbb, type, delta);
61 Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location);
62 mResourceAccess->open();
63 return mResourceAccess->sendCommand(Akonadi2::Commands::CreateEntityCommand, fbb);
64} 55}
65 56
66Async::Job<void> DummyResourceFacade::modify(const Akonadi2::Domain::Event &domainObject) 57Async::Job<void> DummyResourceFacade::modify(const Akonadi2::Domain::Event &domainObject)
@@ -115,25 +106,6 @@ static std::function<bool(const std::string &key, DummyEvent const *buffer, Akon
115 return preparedQuery; 106 return preparedQuery;
116} 107}
117 108
118Async::Job<void> DummyResourceFacade::synchronizeResource(bool sync, bool processAll)
119{
120 //TODO check if a sync is necessary
121 //TODO Only sync what was requested
122 //TODO timeout
123 //TODO the synchronization should normally not be necessary: We just return what is already available.
124
125 if (sync || processAll) {
126 return Async::start<void>([=](Async::Future<void> &future) {
127 mResourceAccess->open();
128 mResourceAccess->synchronizeResource(sync, processAll).then<void>([&future](Async::Future<void> &f) {
129 future.setFinished();
130 f.setFinished();
131 }).exec();
132 });
133 }
134 return Async::null<void>();
135}
136
137void DummyResourceFacade::readValue(QSharedPointer<Akonadi2::Storage> storage, const QByteArray &key, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback, std::function<bool(const std::string &key, DummyEvent const *buffer, Akonadi2::Domain::Buffer::Event const *local)> preparedQuery) 109void DummyResourceFacade::readValue(QSharedPointer<Akonadi2::Storage> storage, const QByteArray &key, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback, std::function<bool(const std::string &key, DummyEvent const *buffer, Akonadi2::Domain::Buffer::Event const *local)> preparedQuery)
138{ 110{
139 storage->scan(key, [=](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool { 111 storage->scan(key, [=](void *keyValue, int keySize, void *dataValue, int dataSize) -> bool {