diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | common/CMakeLists.txt | 15 | ||||
-rw-r--r-- | common/clientapi.cpp | 39 | ||||
-rw-r--r-- | common/clientapi.h | 86 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 46 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 58 | ||||
-rw-r--r-- | common/domain/event.h | 3 | ||||
-rw-r--r-- | common/domainadaptor.h | 1 | ||||
-rw-r--r-- | common/facadefactory.h | 2 | ||||
-rw-r--r-- | common/facadeinterface.h | 2 |
10 files changed, 125 insertions, 129 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0be5d90..0ae6bcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -35,7 +35,7 @@ endfunction(generate_flatbuffers) | |||
35 | set(CMAKE_AUTOMOC ON) | 35 | set(CMAKE_AUTOMOC ON) |
36 | add_definitions("-Wall -std=c++0x -g") | 36 | add_definitions("-Wall -std=c++0x -g") |
37 | include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${FLATBUFFERS_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/common) | 37 | include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${FLATBUFFERS_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/common) |
38 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/common) | 38 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/common/domain) |
39 | 39 | ||
40 | configure_file(hawd.conf hawd.conf) | 40 | configure_file(hawd.conf hawd.conf) |
41 | 41 | ||
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 61019b3..b4a4703 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -1,4 +1,5 @@ | |||
1 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) | 1 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
2 | include_directories(domain) | ||
2 | 3 | ||
3 | project(akonadi2common) | 4 | project(akonadi2common) |
4 | 5 | ||
@@ -64,3 +65,17 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) | |||
64 | qt5_use_modules(${PROJECT_NAME} Network) | 65 | qt5_use_modules(${PROJECT_NAME} Network) |
65 | target_link_libraries(${PROJECT_NAME} ${storage_LIBS} KF5::Async) | 66 | target_link_libraries(${PROJECT_NAME} ${storage_LIBS} KF5::Async) |
66 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | 67 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) |
68 | |||
69 | install(FILES | ||
70 | clientapi.h | ||
71 | domain/applicationdomaintype.h | ||
72 | query.h | ||
73 | threadboundary.h | ||
74 | resultprovider.h | ||
75 | facadefactory.h | ||
76 | log.h | ||
77 | listmodelresult.h | ||
78 | bufferadaptor.h | ||
79 | facadeinterface.h | ||
80 | DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} COMPONENT Devel | ||
81 | ) | ||
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 5edab97..df48c3f 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "resourcefacade.h" | 5 | #include "resourcefacade.h" |
6 | #include "log.h" | 6 | #include "log.h" |
7 | #include "definitions.h" | 7 | #include "definitions.h" |
8 | #include "resourceconfig.h" | ||
8 | #include <QtConcurrent/QtConcurrentRun> | 9 | #include <QtConcurrent/QtConcurrentRun> |
9 | #include <QTimer> | 10 | #include <QTimer> |
10 | 11 | ||
@@ -31,6 +32,44 @@ namespace async | |||
31 | namespace Akonadi2 | 32 | namespace Akonadi2 |
32 | { | 33 | { |
33 | 34 | ||
35 | QString Store::storageLocation() | ||
36 | { | ||
37 | return Akonadi2::storageLocation(); | ||
38 | } | ||
39 | |||
40 | QByteArray Store::resourceName(const QByteArray &instanceIdentifier) | ||
41 | { | ||
42 | return Akonadi2::resourceName(instanceIdentifier); | ||
43 | } | ||
44 | |||
45 | QList<QByteArray> Store::getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type) | ||
46 | { | ||
47 | //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource | ||
48 | if (type == "akonadiresource") { | ||
49 | qWarning() << "Global resource"; | ||
50 | return QList<QByteArray>() << ""; | ||
51 | } | ||
52 | QList<QByteArray> resources; | ||
53 | const auto configuredResources = ResourceConfig::getResources(); | ||
54 | if (resourceFilter.isEmpty()) { | ||
55 | for (const auto &res : configuredResources) { | ||
56 | if (configuredResources.value(res) == type) { | ||
57 | resources << res; | ||
58 | } | ||
59 | } | ||
60 | } else { | ||
61 | for (const auto &res : resourceFilter) { | ||
62 | if (configuredResources.contains(res)) { | ||
63 | resources << res; | ||
64 | } else { | ||
65 | qWarning() << "Resource is not existing: " << res; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | qWarning() << "Found resources: " << resources; | ||
70 | return resources; | ||
71 | } | ||
72 | |||
34 | void Store::shutdown(const QByteArray &identifier) | 73 | void Store::shutdown(const QByteArray &identifier) |
35 | { | 74 | { |
36 | Trace() << "shutdown"; | 75 | Trace() << "shutdown"; |
diff --git a/common/clientapi.h b/common/clientapi.h index c4125bd..4e6db09 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -29,13 +29,10 @@ | |||
29 | #include <Async/Async> | 29 | #include <Async/Async> |
30 | 30 | ||
31 | #include "query.h" | 31 | #include "query.h" |
32 | #include "threadboundary.h" | ||
33 | #include "resultprovider.h" | 32 | #include "resultprovider.h" |
34 | #include "domain/applicationdomaintype.h" | 33 | #include "applicationdomaintype.h" |
35 | #include "resourceconfig.h" | ||
36 | #include "facadefactory.h" | 34 | #include "facadefactory.h" |
37 | #include "log.h" | 35 | #include "log.h" |
38 | #include "definitions.h" | ||
39 | 36 | ||
40 | namespace async { | 37 | namespace async { |
41 | //This should abstract if we execute from eventloop or in thread. | 38 | //This should abstract if we execute from eventloop or in thread. |
@@ -51,42 +48,12 @@ using namespace async; | |||
51 | * Store interface used in the client API. | 48 | * Store interface used in the client API. |
52 | */ | 49 | */ |
53 | class Store { | 50 | class Store { |
54 | public: | 51 | private: |
55 | static QString storageLocation() | 52 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type); |
56 | { | ||
57 | return Akonadi2::storageLocation(); | ||
58 | } | ||
59 | 53 | ||
60 | static QByteArray resourceName(const QByteArray &instanceIdentifier) | 54 | public: |
61 | { | 55 | static QString storageLocation(); |
62 | return Akonadi2::resourceName(instanceIdentifier); | 56 | static QByteArray resourceName(const QByteArray &instanceIdentifier); |
63 | } | ||
64 | |||
65 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type) | ||
66 | { | ||
67 | //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource | ||
68 | if (type == "akonadiresource") { | ||
69 | return QList<QByteArray>() << ""; | ||
70 | } | ||
71 | QList<QByteArray> resources; | ||
72 | const auto configuredResources = ResourceConfig::getResources(); | ||
73 | if (resourceFilter.isEmpty()) { | ||
74 | for (const auto &res : configuredResources) { | ||
75 | if (configuredResources.value(res) == type) { | ||
76 | resources << res; | ||
77 | } | ||
78 | } | ||
79 | } else { | ||
80 | for (const auto &res : resourceFilter) { | ||
81 | if (configuredResources.contains(res)) { | ||
82 | resources << res; | ||
83 | } else { | ||
84 | qWarning() << "Resource is not existing: " << res; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | return resources; | ||
89 | } | ||
90 | 57 | ||
91 | /** | 58 | /** |
92 | * Asynchronusly load a dataset | 59 | * Asynchronusly load a dataset |
@@ -192,47 +159,6 @@ public: | |||
192 | static void synchronize(const QByteArray &resourceIdentifier); | 159 | static void synchronize(const QByteArray &resourceIdentifier); |
193 | }; | 160 | }; |
194 | 161 | ||
195 | /** | ||
196 | * Configuration interface used in the client API. | ||
197 | * | ||
198 | * This interface provides convenience API for manipulating resources. | ||
199 | * This interface uses internally the same interface that is part of the regular Store API. | ||
200 | * | ||
201 | * Resources provide their configuration implementation by implementing a StoreFacade for the AkonadiResource type. | ||
202 | */ | ||
203 | class Configuration { | ||
204 | public: | ||
205 | static QWidget *getConfigurationWidget(const QByteArray &resourceIdentifier) | ||
206 | { | ||
207 | //TODO here we want to implement the code to create a configuration widget from the QML config interface provided by the resource | ||
208 | return nullptr; | ||
209 | } | ||
210 | |||
211 | static ApplicationDomain::AkonadiResource::Ptr getConfiguration(const QByteArray &resource) | ||
212 | { | ||
213 | Query query; | ||
214 | query.resources << resource; | ||
215 | // auto result = Store::load<ApplicationDomain::AkonadiResource>(query); | ||
216 | //FIXME retrieve result and return it | ||
217 | return ApplicationDomain::AkonadiResource::Ptr::create(); | ||
218 | } | ||
219 | |||
220 | static void setConfiguration(const ApplicationDomain::AkonadiResource &resource) | ||
221 | { | ||
222 | Store::modify<ApplicationDomain::AkonadiResource>(resource); | ||
223 | } | ||
224 | |||
225 | static void createResource(const ApplicationDomain::AkonadiResource &resource) | ||
226 | { | ||
227 | Store::create<ApplicationDomain::AkonadiResource>(resource); | ||
228 | } | ||
229 | |||
230 | static void removeResource(const QByteArray &resourceIdentifier) | ||
231 | { | ||
232 | ApplicationDomain::AkonadiResource resource(resourceIdentifier); | ||
233 | Store::remove<ApplicationDomain::AkonadiResource>(resource); | ||
234 | } | ||
235 | }; | ||
236 | 162 | ||
237 | } | 163 | } |
238 | 164 | ||
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 3cc075b..78a667e 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -18,10 +18,56 @@ | |||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
19 | */ | 19 | */ |
20 | #include "applicationdomaintype.h" | 20 | #include "applicationdomaintype.h" |
21 | #include "../bufferadaptor.h" | ||
21 | 22 | ||
22 | namespace Akonadi2 { | 23 | namespace Akonadi2 { |
23 | namespace ApplicationDomain { | 24 | namespace ApplicationDomain { |
24 | 25 | ||
26 | ApplicationDomainType::ApplicationDomainType() | ||
27 | :mAdaptor(new MemoryBufferAdaptor()) | ||
28 | { | ||
29 | |||
30 | } | ||
31 | |||
32 | ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceIdentifier) | ||
33 | :mAdaptor(new MemoryBufferAdaptor()), | ||
34 | mResourceInstanceIdentifier(resourceInstanceIdentifier) | ||
35 | { | ||
36 | |||
37 | } | ||
38 | |||
39 | ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor) | ||
40 | : mAdaptor(adaptor), | ||
41 | mResourceInstanceIdentifier(resourceInstanceIdentifier), | ||
42 | mIdentifier(identifier), | ||
43 | mRevision(revision) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | ApplicationDomainType::ApplicationDomainType(const ApplicationDomainType &other) | ||
48 | { | ||
49 | *this = other; | ||
50 | } | ||
51 | |||
52 | ApplicationDomainType& ApplicationDomainType::operator=(const ApplicationDomainType &other) | ||
53 | { | ||
54 | mAdaptor = other.mAdaptor; | ||
55 | mChangeSet = other.mChangeSet; | ||
56 | mResourceInstanceIdentifier = other.mResourceInstanceIdentifier; | ||
57 | mIdentifier = other.mIdentifier; | ||
58 | mRevision = other.mRevision; | ||
59 | return *this; | ||
60 | } | ||
61 | |||
62 | ApplicationDomainType::~ApplicationDomainType() {} | ||
63 | |||
64 | QVariant ApplicationDomainType::getProperty(const QByteArray &key) const { return mAdaptor->getProperty(key); } | ||
65 | void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value){ mChangeSet.insert(key, value); mAdaptor->setProperty(key, value); } | ||
66 | QByteArrayList ApplicationDomainType::changedProperties() const { return mChangeSet.keys(); } | ||
67 | qint64 ApplicationDomainType::revision() const { return mRevision; } | ||
68 | QByteArray ApplicationDomainType::resourceInstanceIdentifier() const { return mResourceInstanceIdentifier; } | ||
69 | QByteArray ApplicationDomainType::identifier() const { return mIdentifier; } | ||
70 | |||
25 | template<> | 71 | template<> |
26 | QByteArray getTypeName<Event>() | 72 | QByteArray getTypeName<Event>() |
27 | { | 73 | { |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index bd7ff65..137eb65 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <QSharedPointer> | 22 | #include <QSharedPointer> |
23 | #include <QVariant> | 23 | #include <QVariant> |
24 | #include <QByteArray> | 24 | #include <QByteArray> |
25 | #include "../bufferadaptor.h" | 25 | #include "bufferadaptor.h" |
26 | 26 | ||
27 | namespace Akonadi2 { | 27 | namespace Akonadi2 { |
28 | 28 | ||
@@ -39,41 +39,11 @@ class ApplicationDomainType { | |||
39 | public: | 39 | public: |
40 | typedef QSharedPointer<ApplicationDomainType> Ptr; | 40 | typedef QSharedPointer<ApplicationDomainType> Ptr; |
41 | 41 | ||
42 | ApplicationDomainType() | 42 | ApplicationDomainType(); |
43 | :mAdaptor(new MemoryBufferAdaptor()) | 43 | ApplicationDomainType(const QByteArray &resourceInstanceIdentifier); |
44 | { | 44 | ApplicationDomainType(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); |
45 | 45 | ApplicationDomainType(const ApplicationDomainType &other); | |
46 | } | 46 | ApplicationDomainType& operator=(const ApplicationDomainType &other); |
47 | |||
48 | ApplicationDomainType(const QByteArray &resourceInstanceIdentifier) | ||
49 | :mAdaptor(new MemoryBufferAdaptor()), | ||
50 | mResourceInstanceIdentifier(resourceInstanceIdentifier) | ||
51 | { | ||
52 | |||
53 | } | ||
54 | |||
55 | ApplicationDomainType(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor) | ||
56 | : mAdaptor(adaptor), | ||
57 | mResourceInstanceIdentifier(resourceInstanceIdentifier), | ||
58 | mIdentifier(identifier), | ||
59 | mRevision(revision) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | ApplicationDomainType(const ApplicationDomainType &other) | ||
64 | { | ||
65 | *this = other; | ||
66 | } | ||
67 | |||
68 | ApplicationDomainType& operator=(const ApplicationDomainType &other) | ||
69 | { | ||
70 | mAdaptor = other.mAdaptor; | ||
71 | mChangeSet = other.mChangeSet; | ||
72 | mResourceInstanceIdentifier = other.mResourceInstanceIdentifier; | ||
73 | mIdentifier = other.mIdentifier; | ||
74 | mRevision = other.mRevision; | ||
75 | return *this; | ||
76 | } | ||
77 | 47 | ||
78 | template <typename DomainType> | 48 | template <typename DomainType> |
79 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType) | 49 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType) |
@@ -84,14 +54,14 @@ public: | |||
84 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); | 54 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); |
85 | } | 55 | } |
86 | 56 | ||
87 | virtual ~ApplicationDomainType() {} | 57 | virtual ~ApplicationDomainType(); |
88 | 58 | ||
89 | virtual QVariant getProperty(const QByteArray &key) const { return mAdaptor->getProperty(key); } | 59 | virtual QVariant getProperty(const QByteArray &key) const; |
90 | virtual void setProperty(const QByteArray &key, const QVariant &value){ mChangeSet.insert(key, value); mAdaptor->setProperty(key, value); } | 60 | virtual void setProperty(const QByteArray &key, const QVariant &value); |
91 | virtual QByteArrayList changedProperties() const { return mChangeSet.keys(); } | 61 | virtual QByteArrayList changedProperties() const; |
92 | qint64 revision() const { return mRevision; } | 62 | qint64 revision() const; |
93 | QByteArray resourceInstanceIdentifier() const { return mResourceInstanceIdentifier; } | 63 | QByteArray resourceInstanceIdentifier() const; |
94 | QByteArray identifier() const { return mIdentifier; } | 64 | QByteArray identifier() const; |
95 | 65 | ||
96 | private: | 66 | private: |
97 | QSharedPointer<BufferAdaptor> mAdaptor; | 67 | QSharedPointer<BufferAdaptor> mAdaptor; |
@@ -186,3 +156,5 @@ class TypeImplementation; | |||
186 | 156 | ||
187 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType) | 157 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType) |
188 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr) | 158 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr) |
159 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event) | ||
160 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) | ||
diff --git a/common/domain/event.h b/common/domain/event.h index 17a0ad4..f21cd34 100644 --- a/common/domain/event.h +++ b/common/domain/event.h | |||
@@ -63,6 +63,3 @@ public: | |||
63 | 63 | ||
64 | } | 64 | } |
65 | } | 65 | } |
66 | |||
67 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event) | ||
68 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) | ||
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index e881b9a..b14fbcd 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 "bufferadaptor.h" | ||
29 | #include "entity_generated.h" | 30 | #include "entity_generated.h" |
30 | #include "metadata_generated.h" | 31 | #include "metadata_generated.h" |
31 | #include "entitybuffer.h" | 32 | #include "entitybuffer.h" |
diff --git a/common/facadefactory.h b/common/facadefactory.h index 4a6a698..19d1f40 100644 --- a/common/facadefactory.h +++ b/common/facadefactory.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <memory> | 27 | #include <memory> |
28 | 28 | ||
29 | #include "facadeinterface.h" | 29 | #include "facadeinterface.h" |
30 | #include "domain/applicationdomaintype.h" | 30 | #include "applicationdomaintype.h" |
31 | #include "log.h" | 31 | #include "log.h" |
32 | 32 | ||
33 | namespace Akonadi2 { | 33 | namespace Akonadi2 { |
diff --git a/common/facadeinterface.h b/common/facadeinterface.h index cd43fa1..3a38db8 100644 --- a/common/facadeinterface.h +++ b/common/facadeinterface.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <Async/Async> | 23 | #include <Async/Async> |
24 | #include <QByteArray> | 24 | #include <QByteArray> |
25 | #include <QSharedPointer> | 25 | #include <QSharedPointer> |
26 | #include "domain/applicationdomaintype.h" | 26 | #include "applicationdomaintype.h" |
27 | #include "resultprovider.h" | 27 | #include "resultprovider.h" |
28 | 28 | ||
29 | namespace Akonadi2 { | 29 | namespace Akonadi2 { |