diff options
-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 | ||||
-rw-r--r-- | examples/dummyresource/domainadaptor.cpp | 6 | ||||
-rw-r--r-- | examples/dummyresource/domainadaptor.h | 12 | ||||
-rw-r--r-- | examples/dummyresource/facade.cpp | 22 | ||||
-rw-r--r-- | examples/dummyresource/facade.h | 6 | ||||
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 2 |
12 files changed, 173 insertions, 24 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" |
diff --git a/examples/dummyresource/domainadaptor.cpp b/examples/dummyresource/domainadaptor.cpp index d08a783..74b170d 100644 --- a/examples/dummyresource/domainadaptor.cpp +++ b/examples/dummyresource/domainadaptor.cpp | |||
@@ -51,3 +51,9 @@ DummyMailAdaptorFactory::DummyMailAdaptorFactory() | |||
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | DummyFolderAdaptorFactory::DummyFolderAdaptorFactory() | ||
55 | : DomainTypeAdaptorFactory() | ||
56 | { | ||
57 | |||
58 | } | ||
59 | |||
diff --git a/examples/dummyresource/domainadaptor.h b/examples/dummyresource/domainadaptor.h index add3e8e..e5856f8 100644 --- a/examples/dummyresource/domainadaptor.h +++ b/examples/dummyresource/domainadaptor.h | |||
@@ -21,6 +21,8 @@ | |||
21 | #include "common/domainadaptor.h" | 21 | #include "common/domainadaptor.h" |
22 | #include "event_generated.h" | 22 | #include "event_generated.h" |
23 | #include "mail_generated.h" | 23 | #include "mail_generated.h" |
24 | #include "folder_generated.h" | ||
25 | #include "dummy_generated.h" | ||
24 | #include "dummycalendar_generated.h" | 26 | #include "dummycalendar_generated.h" |
25 | #include "entity_generated.h" | 27 | #include "entity_generated.h" |
26 | 28 | ||
@@ -31,10 +33,16 @@ public: | |||
31 | virtual ~DummyEventAdaptorFactory() {}; | 33 | virtual ~DummyEventAdaptorFactory() {}; |
32 | }; | 34 | }; |
33 | 35 | ||
34 | //TODO replace the resource specific event class by a mail class or a dummy class if no resource type is required. | 36 | class DummyMailAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Mail, Akonadi2::ApplicationDomain::Buffer::Dummy, Akonadi2::ApplicationDomain::Buffer::DummyBuilder> |
35 | class DummyMailAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Mail, DummyCalendar::DummyEvent, DummyCalendar::DummyEventBuilder> | ||
36 | { | 37 | { |
37 | public: | 38 | public: |
38 | DummyMailAdaptorFactory(); | 39 | DummyMailAdaptorFactory(); |
39 | virtual ~DummyMailAdaptorFactory() {}; | 40 | virtual ~DummyMailAdaptorFactory() {}; |
40 | }; | 41 | }; |
42 | |||
43 | class DummyFolderAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Folder, Akonadi2::ApplicationDomain::Buffer::Dummy, Akonadi2::ApplicationDomain::Buffer::DummyBuilder> | ||
44 | { | ||
45 | public: | ||
46 | DummyFolderAdaptorFactory(); | ||
47 | virtual ~DummyFolderAdaptorFactory() {}; | ||
48 | }; | ||
diff --git a/examples/dummyresource/facade.cpp b/examples/dummyresource/facade.cpp index 5a9d722..f337bdc 100644 --- a/examples/dummyresource/facade.cpp +++ b/examples/dummyresource/facade.cpp | |||
@@ -30,6 +30,7 @@ DummyResourceFacade::~DummyResourceFacade() | |||
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | |||
33 | DummyResourceMailFacade::DummyResourceMailFacade(const QByteArray &instanceIdentifier) | 34 | DummyResourceMailFacade::DummyResourceMailFacade(const QByteArray &instanceIdentifier) |
34 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<DummyMailAdaptorFactory>::create()) | 35 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<DummyMailAdaptorFactory>::create()) |
35 | { | 36 | { |
@@ -39,25 +40,12 @@ DummyResourceMailFacade::~DummyResourceMailFacade() | |||
39 | { | 40 | { |
40 | } | 41 | } |
41 | 42 | ||
42 | static void addFolder(const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Folder::Ptr> > &resultProvider, QByteArray uid, QString name, QString icon) | 43 | |
44 | DummyResourceFolderFacade::DummyResourceFolderFacade(const QByteArray &instanceIdentifier) | ||
45 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder>(instanceIdentifier, QSharedPointer<DummyFolderAdaptorFactory>::create()) | ||
43 | { | 46 | { |
44 | auto folder = Akonadi2::ApplicationDomain::Folder::Ptr::create(); | ||
45 | folder->setProperty("name", name); | ||
46 | folder->setProperty("uid", uid); | ||
47 | resultProvider->add(folder); | ||
48 | } | 47 | } |
49 | 48 | ||
50 | KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Folder::Ptr> > &resultProvider) | 49 | DummyResourceFolderFacade::~DummyResourceFolderFacade() |
51 | { | 50 | { |
52 | //Dummy implementation for a fixed set of folders | ||
53 | addFolder(resultProvider, "inbox", "INBOX", "mail-folder-inbox"); | ||
54 | addFolder(resultProvider, "sent", "Sent", "mail-folder-sent"); | ||
55 | addFolder(resultProvider, "trash", "Trash", "user-trash"); | ||
56 | addFolder(resultProvider, "drafts", "Drafts", "document-edit"); | ||
57 | addFolder(resultProvider, "1", "dragons", "folder"); | ||
58 | addFolder(resultProvider, "1", "super mega long tailed dragons", "folder"); | ||
59 | resultProvider->initialResultSetComplete(); | ||
60 | resultProvider->complete(); | ||
61 | return KAsync::null<void>(); | ||
62 | } | 51 | } |
63 | |||
diff --git a/examples/dummyresource/facade.h b/examples/dummyresource/facade.h index 948116b..b00e1d7 100644 --- a/examples/dummyresource/facade.h +++ b/examples/dummyresource/facade.h | |||
@@ -36,13 +36,9 @@ public: | |||
36 | virtual ~DummyResourceMailFacade(); | 36 | virtual ~DummyResourceMailFacade(); |
37 | }; | 37 | }; |
38 | 38 | ||
39 | class DummyResourceFolderFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::Folder> | 39 | class DummyResourceFolderFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder> |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | DummyResourceFolderFacade(const QByteArray &instanceIdentifier); | 42 | DummyResourceFolderFacade(const QByteArray &instanceIdentifier); |
43 | virtual ~DummyResourceFolderFacade(); | 43 | virtual ~DummyResourceFolderFacade(); |
44 | virtual KAsync::Job<void> create(const Akonadi2::ApplicationDomain::Folder &domainObject) { return KAsync::null<void>(); }; | ||
45 | virtual KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::Folder &domainObject) { return KAsync::null<void>(); }; | ||
46 | virtual KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::Folder &domainObject) { return KAsync::null<void>(); }; | ||
47 | virtual KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Folder::Ptr> > &resultProvider); | ||
48 | }; | 44 | }; |
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 397ca5f..edb3b42 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -40,6 +40,7 @@ | |||
40 | //This is the resources entity type, and not the domain type | 40 | //This is the resources entity type, and not the domain type |
41 | #define ENTITY_TYPE_EVENT "event" | 41 | #define ENTITY_TYPE_EVENT "event" |
42 | #define ENTITY_TYPE_MAIL "mail" | 42 | #define ENTITY_TYPE_MAIL "mail" |
43 | #define ENTITY_TYPE_FOLDER "folder" | ||
43 | 44 | ||
44 | /** | 45 | /** |
45 | * Index types: | 46 | * Index types: |
@@ -228,5 +229,6 @@ void DummyResourceFactory::registerFacades(Akonadi2::FacadeFactory &factory) | |||
228 | { | 229 | { |
229 | factory.registerFacade<Akonadi2::ApplicationDomain::Event, DummyResourceFacade>(PLUGIN_NAME); | 230 | factory.registerFacade<Akonadi2::ApplicationDomain::Event, DummyResourceFacade>(PLUGIN_NAME); |
230 | factory.registerFacade<Akonadi2::ApplicationDomain::Mail, DummyResourceMailFacade>(PLUGIN_NAME); | 231 | factory.registerFacade<Akonadi2::ApplicationDomain::Mail, DummyResourceMailFacade>(PLUGIN_NAME); |
232 | factory.registerFacade<Akonadi2::ApplicationDomain::Folder, DummyResourceFolderFacade>(PLUGIN_NAME); | ||
231 | } | 233 | } |
232 | 234 | ||