diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/CMakeLists.txt | 3 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 2 | ||||
-rw-r--r-- | common/domain/dummy.fbs | 7 | ||||
-rw-r--r-- | common/domain/folder.cpp | 71 | ||||
-rw-r--r-- | common/domain/folder.fbs | 9 | ||||
-rw-r--r-- | common/domain/folder.h | 56 | ||||
-rw-r--r-- | common/domainadaptor.h | 1 |
7 files changed, 149 insertions, 0 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b4a4703..f24ec46 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -36,6 +36,7 @@ set(command_SRCS | |||
36 | domain/applicationdomaintype.cpp | 36 | domain/applicationdomaintype.cpp |
37 | domain/event.cpp | 37 | domain/event.cpp |
38 | domain/mail.cpp | 38 | domain/mail.cpp |
39 | domain/folder.cpp | ||
39 | ${storage_SRCS}) | 40 | ${storage_SRCS}) |
40 | 41 | ||
41 | add_library(${PROJECT_NAME} SHARED ${command_SRCS}) | 42 | add_library(${PROJECT_NAME} SHARED ${command_SRCS}) |
@@ -55,6 +56,8 @@ generate_flatbuffers( | |||
55 | commands/revisionreplayed | 56 | commands/revisionreplayed |
56 | domain/event | 57 | domain/event |
57 | domain/mail | 58 | domain/mail |
59 | domain/folder | ||
60 | domain/dummy | ||
58 | entity | 61 | entity |
59 | metadata | 62 | metadata |
60 | queuedcommand | 63 | queuedcommand |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 5514d26..b4cf8c4 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -160,3 +160,5 @@ Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event) | |||
160 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) | 160 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) |
161 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Mail) | 161 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Mail) |
162 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Mail::Ptr) | 162 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Mail::Ptr) |
163 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Folder) | ||
164 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Folder::Ptr) | ||
diff --git a/common/domain/dummy.fbs b/common/domain/dummy.fbs new file mode 100644 index 0000000..8816b09 --- /dev/null +++ b/common/domain/dummy.fbs | |||
@@ -0,0 +1,7 @@ | |||
1 | namespace Akonadi2.ApplicationDomain.Buffer; | ||
2 | |||
3 | table Dummy { | ||
4 | } | ||
5 | |||
6 | root_type Dummy; | ||
7 | file_identifier "AKFB"; | ||
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp new file mode 100644 index 0000000..50f73c2 --- /dev/null +++ b/common/domain/folder.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastfolder.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 | */ | ||
19 | #include "folder.h" | ||
20 | |||
21 | #include <QVector> | ||
22 | #include <QByteArray> | ||
23 | #include <QString> | ||
24 | |||
25 | #include "../resultset.h" | ||
26 | #include "../index.h" | ||
27 | #include "../storage.h" | ||
28 | #include "../log.h" | ||
29 | #include "../propertymapper.h" | ||
30 | #include "../query.h" | ||
31 | #include "../definitions.h" | ||
32 | |||
33 | #include "folder_generated.h" | ||
34 | |||
35 | using namespace Akonadi2::ApplicationDomain; | ||
36 | |||
37 | ResultSet TypeImplementation<Folder>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) | ||
38 | { | ||
39 | QVector<QByteArray> keys; | ||
40 | return ResultSet(keys); | ||
41 | } | ||
42 | |||
43 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Folder>::Buffer> > TypeImplementation<Folder>::initializeReadPropertyMapper() | ||
52 | { | ||
53 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); | ||
54 | propertyMapper->addMapping<QString, Buffer>("parent", &Buffer::parent); | ||
55 | propertyMapper->addMapping<QString, Buffer>("name", &Buffer::name); | ||
56 | return propertyMapper; | ||
57 | } | ||
58 | |||
59 | QSharedPointer<WritePropertyMapper<TypeImplementation<Folder>::BufferBuilder> > TypeImplementation<Folder>::initializeWritePropertyMapper() | ||
60 | { | ||
61 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); | ||
62 | propertyMapper->addMapping("parent", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | ||
63 | auto offset = variantToProperty<QString>(value, fbb); | ||
64 | return [offset](BufferBuilder &builder) { builder.add_parent(offset); }; | ||
65 | }); | ||
66 | propertyMapper->addMapping("name", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | ||
67 | auto offset = variantToProperty<QString>(value, fbb); | ||
68 | return [offset](BufferBuilder &builder) { builder.add_name(offset); }; | ||
69 | }); | ||
70 | return propertyMapper; | ||
71 | } | ||
diff --git a/common/domain/folder.fbs b/common/domain/folder.fbs new file mode 100644 index 0000000..3476d58 --- /dev/null +++ b/common/domain/folder.fbs | |||
@@ -0,0 +1,9 @@ | |||
1 | namespace Akonadi2.ApplicationDomain.Buffer; | ||
2 | |||
3 | table Folder { | ||
4 | name:string; | ||
5 | parent:string; | ||
6 | } | ||
7 | |||
8 | root_type Folder; | ||
9 | file_identifier "AKFB"; | ||
diff --git a/common/domain/folder.h b/common/domain/folder.h new file mode 100644 index 0000000..545836f --- /dev/null +++ b/common/domain/folder.h | |||
@@ -0,0 +1,56 @@ | |||
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 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | #include "storage.h" | ||
24 | |||
25 | class ResultSet; | ||
26 | class QByteArray; | ||
27 | |||
28 | template<typename T> | ||
29 | class ReadPropertyMapper; | ||
30 | template<typename T> | ||
31 | class WritePropertyMapper; | ||
32 | |||
33 | namespace Akonadi2 { | ||
34 | class Query; | ||
35 | |||
36 | namespace ApplicationDomain { | ||
37 | namespace Buffer { | ||
38 | struct Folder; | ||
39 | struct FolderBuilder; | ||
40 | } | ||
41 | |||
42 | template<> | ||
43 | class TypeImplementation<Akonadi2::ApplicationDomain::Folder> { | ||
44 | public: | ||
45 | typedef Akonadi2::ApplicationDomain::Buffer::Folder Buffer; | ||
46 | typedef Akonadi2::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; | ||
47 | static QSet<QByteArray> indexedProperties(); | ||
48 | static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction); | ||
49 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | ||
50 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | ||
51 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); | ||
52 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); | ||
53 | }; | ||
54 | |||
55 | } | ||
56 | } | ||
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index b14fbcd..620a658 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "domain/applicationdomaintype.h" | 26 | #include "domain/applicationdomaintype.h" |
27 | #include "domain/event.h" | 27 | #include "domain/event.h" |
28 | #include "domain/mail.h" | 28 | #include "domain/mail.h" |
29 | #include "domain/folder.h" | ||
29 | #include "bufferadaptor.h" | 30 | #include "bufferadaptor.h" |
30 | #include "entity_generated.h" | 31 | #include "entity_generated.h" |
31 | #include "metadata_generated.h" | 32 | #include "metadata_generated.h" |