diff options
Diffstat (limited to 'dummyresource/domainadaptor.cpp')
-rw-r--r-- | dummyresource/domainadaptor.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/dummyresource/domainadaptor.cpp b/dummyresource/domainadaptor.cpp index 865a4c0..b133614 100644 --- a/dummyresource/domainadaptor.cpp +++ b/dummyresource/domainadaptor.cpp | |||
@@ -14,11 +14,8 @@ | |||
14 | using namespace DummyCalendar; | 14 | using namespace DummyCalendar; |
15 | using namespace flatbuffers; | 15 | using namespace flatbuffers; |
16 | 16 | ||
17 | using namespace DummyCalendar; | ||
18 | using namespace flatbuffers; | ||
19 | |||
20 | //This will become a generic implementation that simply takes the resource buffer and local buffer pointer | 17 | //This will become a generic implementation that simply takes the resource buffer and local buffer pointer |
21 | class DummyEventAdaptor : public Akonadi2::Domain::BufferAdaptor | 18 | class DummyEventAdaptor : public Akonadi2::ApplicationDomain::BufferAdaptor |
22 | { | 19 | { |
23 | public: | 20 | public: |
24 | DummyEventAdaptor() | 21 | DummyEventAdaptor() |
@@ -55,10 +52,10 @@ public: | |||
55 | return props; | 52 | return props; |
56 | } | 53 | } |
57 | 54 | ||
58 | Akonadi2::Domain::Buffer::Event const *mLocalBuffer; | 55 | Akonadi2::ApplicationDomain::Buffer::Event const *mLocalBuffer; |
59 | DummyEvent const *mResourceBuffer; | 56 | DummyEvent const *mResourceBuffer; |
60 | 57 | ||
61 | QSharedPointer<PropertyMapper<Akonadi2::Domain::Buffer::Event> > mLocalMapper; | 58 | QSharedPointer<PropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > mLocalMapper; |
62 | QSharedPointer<PropertyMapper<DummyEvent> > mResourceMapper; | 59 | QSharedPointer<PropertyMapper<DummyEvent> > mResourceMapper; |
63 | }; | 60 | }; |
64 | 61 | ||
@@ -73,14 +70,14 @@ DummyEventAdaptorFactory::DummyEventAdaptorFactory() | |||
73 | } | 70 | } |
74 | return QVariant(); | 71 | return QVariant(); |
75 | }); | 72 | }); |
76 | mLocalMapper = QSharedPointer<PropertyMapper<Akonadi2::Domain::Buffer::Event> >::create(); | 73 | mLocalMapper = QSharedPointer<PropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >::create(); |
77 | mLocalMapper->mReadAccessors.insert("summary", [](Akonadi2::Domain::Buffer::Event const *buffer) -> QVariant { | 74 | mLocalMapper->mReadAccessors.insert("summary", [](Akonadi2::ApplicationDomain::Buffer::Event const *buffer) -> QVariant { |
78 | if (buffer->summary()) { | 75 | if (buffer->summary()) { |
79 | return QString::fromStdString(buffer->summary()->c_str()); | 76 | return QString::fromStdString(buffer->summary()->c_str()); |
80 | } | 77 | } |
81 | return QVariant(); | 78 | return QVariant(); |
82 | }); | 79 | }); |
83 | mLocalMapper->mReadAccessors.insert("uid", [](Akonadi2::Domain::Buffer::Event const *buffer) -> QVariant { | 80 | mLocalMapper->mReadAccessors.insert("uid", [](Akonadi2::ApplicationDomain::Buffer::Event const *buffer) -> QVariant { |
84 | if (buffer->uid()) { | 81 | if (buffer->uid()) { |
85 | return QString::fromStdString(buffer->uid()->c_str()); | 82 | return QString::fromStdString(buffer->uid()->c_str()); |
86 | } | 83 | } |
@@ -90,10 +87,10 @@ DummyEventAdaptorFactory::DummyEventAdaptorFactory() | |||
90 | } | 87 | } |
91 | 88 | ||
92 | //TODO pass EntityBuffer instead? | 89 | //TODO pass EntityBuffer instead? |
93 | QSharedPointer<Akonadi2::Domain::BufferAdaptor> DummyEventAdaptorFactory::createAdaptor(const Akonadi2::Entity &entity) | 90 | QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> DummyEventAdaptorFactory::createAdaptor(const Akonadi2::Entity &entity) |
94 | { | 91 | { |
95 | const auto resourceBuffer = Akonadi2::EntityBuffer::readBuffer<DummyEvent>(entity.resource()); | 92 | const auto resourceBuffer = Akonadi2::EntityBuffer::readBuffer<DummyEvent>(entity.resource()); |
96 | const auto localBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Domain::Buffer::Event>(entity.local()); | 93 | const auto localBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::ApplicationDomain::Buffer::Event>(entity.local()); |
97 | // const auto metadataBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Metadata>(entity.metadata()); | 94 | // const auto metadataBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Metadata>(entity.metadata()); |
98 | 95 | ||
99 | auto adaptor = QSharedPointer<DummyEventAdaptor>::create(); | 96 | auto adaptor = QSharedPointer<DummyEventAdaptor>::create(); |
@@ -104,7 +101,7 @@ QSharedPointer<Akonadi2::Domain::BufferAdaptor> DummyEventAdaptorFactory::create | |||
104 | return adaptor; | 101 | return adaptor; |
105 | } | 102 | } |
106 | 103 | ||
107 | void DummyEventAdaptorFactory::createBuffer(const Akonadi2::Domain::Event &event, flatbuffers::FlatBufferBuilder &fbb) | 104 | void DummyEventAdaptorFactory::createBuffer(const Akonadi2::ApplicationDomain::Event &event, flatbuffers::FlatBufferBuilder &fbb) |
108 | { | 105 | { |
109 | flatbuffers::FlatBufferBuilder eventFbb; | 106 | flatbuffers::FlatBufferBuilder eventFbb; |
110 | eventFbb.Clear(); | 107 | eventFbb.Clear(); |
@@ -119,10 +116,10 @@ void DummyEventAdaptorFactory::createBuffer(const Akonadi2::Domain::Event &event | |||
119 | flatbuffers::FlatBufferBuilder localFbb; | 116 | flatbuffers::FlatBufferBuilder localFbb; |
120 | { | 117 | { |
121 | auto uid = localFbb.CreateString(event.getProperty("uid").toString().toStdString()); | 118 | auto uid = localFbb.CreateString(event.getProperty("uid").toString().toStdString()); |
122 | auto localBuilder = Akonadi2::Domain::Buffer::EventBuilder(localFbb); | 119 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); |
123 | localBuilder.add_uid(uid); | 120 | localBuilder.add_uid(uid); |
124 | auto location = localBuilder.Finish(); | 121 | auto location = localBuilder.Finish(); |
125 | Akonadi2::Domain::Buffer::FinishEventBuffer(localFbb, location); | 122 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
126 | } | 123 | } |
127 | 124 | ||
128 | Akonadi2::EntityBuffer::assembleEntityBuffer(fbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 125 | Akonadi2::EntityBuffer::assembleEntityBuffer(fbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |