summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/domainadaptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dummyresource/domainadaptor.cpp')
-rw-r--r--examples/dummyresource/domainadaptor.cpp56
1 files changed, 18 insertions, 38 deletions
diff --git a/examples/dummyresource/domainadaptor.cpp b/examples/dummyresource/domainadaptor.cpp
index 8649bc3..67595af 100644
--- a/examples/dummyresource/domainadaptor.cpp
+++ b/examples/dummyresource/domainadaptor.cpp
@@ -1,23 +1,29 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
1 19
2#include "domainadaptor.h" 20#include "domainadaptor.h"
3 21
4#include <QDebug>
5#include <functional>
6
7#include "dummycalendar_generated.h" 22#include "dummycalendar_generated.h"
8#include "event_generated.h"
9#include "entity_generated.h"
10#include "metadata_generated.h"
11#include "domainadaptor.h"
12#include "log.h"
13#include <common/entitybuffer.h>
14 23
15using namespace DummyCalendar; 24using namespace DummyCalendar;
16using namespace flatbuffers; 25using namespace flatbuffers;
17 26
18
19
20
21DummyEventAdaptorFactory::DummyEventAdaptorFactory() 27DummyEventAdaptorFactory::DummyEventAdaptorFactory()
22 : DomainTypeAdaptorFactory() 28 : DomainTypeAdaptorFactory()
23{ 29{
@@ -32,29 +38,3 @@ DummyEventAdaptorFactory::DummyEventAdaptorFactory()
32 }); 38 });
33} 39}
34 40
35
36void DummyEventAdaptorFactory::createBuffer(const Akonadi2::ApplicationDomain::Event &event, flatbuffers::FlatBufferBuilder &fbb)
37{
38 flatbuffers::FlatBufferBuilder localFbb;
39 if (mLocalWriteMapper) {
40 auto pos = createBufferPart<Akonadi2::ApplicationDomain::Buffer::EventBuilder, Akonadi2::ApplicationDomain::Buffer::Event>(event, localFbb, *mLocalWriteMapper);
41 Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, pos);
42 flatbuffers::Verifier verifier(localFbb.GetBufferPointer(), localFbb.GetSize());
43 if (!verifier.VerifyBuffer<Akonadi2::ApplicationDomain::Buffer::Event>()) {
44 Warning() << "Created invalid local buffer";
45 }
46 }
47
48 flatbuffers::FlatBufferBuilder resFbb;
49 if (mResourceWriteMapper) {
50 auto pos = createBufferPart<DummyEventBuilder, DummyEvent>(event, resFbb, *mResourceWriteMapper);
51 DummyCalendar::FinishDummyEventBuffer(resFbb, pos);
52 flatbuffers::Verifier verifier(resFbb.GetBufferPointer(), resFbb.GetSize());
53 if (!verifier.VerifyBuffer<DummyEvent>()) {
54 Warning() << "Created invalid resource buffer";
55 }
56 }
57
58 Akonadi2::EntityBuffer::assembleEntityBuffer(fbb, 0, 0, resFbb.GetBufferPointer(), resFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize());
59}
60