diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-08-13 01:27:21 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-08-13 01:27:21 +0200 |
commit | b6d5d206de4d02149c6530236154283bf834087a (patch) | |
tree | 0d57764b674df3ffee1df3f3e9fb1690ae06bbdc | |
parent | 7c9ae062101b5dc8f963c70fb753f8346a9b5c48 (diff) | |
download | sink-b6d5d206de4d02149c6530236154283bf834087a.tar.gz sink-b6d5d206de4d02149c6530236154283bf834087a.zip |
Untangled the include dependencies a bit.
We no longer depend on clientapi.h from everywhere.
-rw-r--r-- | common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | common/clientapi.cpp | 1 | ||||
-rw-r--r-- | common/clientapi.h | 50 | ||||
-rw-r--r-- | common/definitions.cpp | 38 | ||||
-rw-r--r-- | common/definitions.h | 29 | ||||
-rw-r--r-- | common/domain/event.cpp | 6 | ||||
-rw-r--r-- | common/domain/event.h | 2 | ||||
-rw-r--r-- | common/domainadaptor.h | 5 | ||||
-rw-r--r-- | common/entitystorage.h | 7 | ||||
-rw-r--r-- | common/facade.h | 3 | ||||
-rw-r--r-- | common/facadeinterface.h | 2 | ||||
-rw-r--r-- | common/genericresource.cpp | 6 | ||||
-rw-r--r-- | common/listener.cpp | 5 | ||||
-rw-r--r-- | common/listener.h | 7 | ||||
-rw-r--r-- | common/pipeline.cpp | 4 | ||||
-rw-r--r-- | common/pipeline.h | 1 | ||||
-rw-r--r-- | common/query.h | 62 | ||||
-rw-r--r-- | common/resource.cpp | 2 | ||||
-rw-r--r-- | common/resource.h | 2 | ||||
-rw-r--r-- | common/resourcefacade.cpp | 1 | ||||
-rw-r--r-- | common/resourcefacade.h | 9 | ||||
-rw-r--r-- | common/resultprovider.h | 4 | ||||
-rw-r--r-- | common/synclistresult.h | 7 | ||||
-rw-r--r-- | examples/client/main.cpp | 4 | ||||
-rw-r--r-- | examples/dummyresource/resourcefacade.cpp | 3 | ||||
-rw-r--r-- | examples/dummyresource/resourcefacade.h | 11 | ||||
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 6 | ||||
-rw-r--r-- | tests/genericresourcetest.cpp | 3 |
28 files changed, 197 insertions, 84 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 7778955..2f779b5 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -11,6 +11,7 @@ else (STORAGE_unqlite) | |||
11 | endif (STORAGE_unqlite) | 11 | endif (STORAGE_unqlite) |
12 | 12 | ||
13 | set(command_SRCS | 13 | set(command_SRCS |
14 | definitions.cpp | ||
14 | log.cpp | 15 | log.cpp |
15 | entitybuffer.cpp | 16 | entitybuffer.cpp |
16 | entitystorage.cpp | 17 | entitystorage.cpp |
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 8bb244c..5edab97 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "commands.h" | 4 | #include "commands.h" |
5 | #include "resourcefacade.h" | 5 | #include "resourcefacade.h" |
6 | #include "log.h" | 6 | #include "log.h" |
7 | #include "definitions.h" | ||
7 | #include <QtConcurrent/QtConcurrentRun> | 8 | #include <QtConcurrent/QtConcurrentRun> |
8 | #include <QTimer> | 9 | #include <QTimer> |
9 | 10 | ||
diff --git a/common/clientapi.h b/common/clientapi.h index 6294863..04433f8 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -21,22 +21,21 @@ | |||
21 | #pragma once | 21 | #pragma once |
22 | 22 | ||
23 | #include <QString> | 23 | #include <QString> |
24 | #include <QSet> | ||
25 | #include <QSharedPointer> | 24 | #include <QSharedPointer> |
26 | #include <QStandardPaths> | ||
27 | #include <QDebug> | ||
28 | #include <QEventLoop> | 25 | #include <QEventLoop> |
29 | #include <functional> | 26 | #include <functional> |
30 | #include <memory> | 27 | #include <memory> |
31 | 28 | ||
32 | #include <Async/Async> | 29 | #include <Async/Async> |
33 | 30 | ||
31 | #include "query.h" | ||
34 | #include "threadboundary.h" | 32 | #include "threadboundary.h" |
35 | #include "resultprovider.h" | 33 | #include "resultprovider.h" |
36 | #include "domain/applicationdomaintype.h" | 34 | #include "domain/applicationdomaintype.h" |
37 | #include "resourceconfig.h" | 35 | #include "resourceconfig.h" |
38 | #include "facadefactory.h" | 36 | #include "facadefactory.h" |
39 | #include "log.h" | 37 | #include "log.h" |
38 | #include "definitions.h" | ||
40 | 39 | ||
41 | namespace async { | 40 | namespace async { |
42 | //This should abstract if we execute from eventloop or in thread. | 41 | //This should abstract if we execute from eventloop or in thread. |
@@ -49,59 +48,18 @@ namespace Akonadi2 { | |||
49 | using namespace async; | 48 | using namespace async; |
50 | 49 | ||
51 | /** | 50 | /** |
52 | * A query that matches a set of objects | ||
53 | * | ||
54 | * The query will have to be updated regularly similary to the domain objects. | ||
55 | * It probably also makes sense to have a domain specific part of the query, | ||
56 | * such as what properties we're interested in (necessary information for on-demand | ||
57 | * loading of data). | ||
58 | * | ||
59 | * The query defines: | ||
60 | * * what resources to search | ||
61 | * * filters on various properties (parent collection, startDate range, ....) | ||
62 | * * properties we need (for on-demand querying) | ||
63 | * | ||
64 | * syncOnDemand: Execute a source sync before executing the query | ||
65 | * processAll: Ensure all local messages are processed before querying to guarantee an up-to date dataset. | ||
66 | */ | ||
67 | class Query | ||
68 | { | ||
69 | public: | ||
70 | Query() : syncOnDemand(true), processAll(false), liveQuery(false) {} | ||
71 | //Could also be a propertyFilter | ||
72 | QByteArrayList resources; | ||
73 | //Could also be a propertyFilter | ||
74 | QByteArrayList ids; | ||
75 | //Filters to apply | ||
76 | QHash<QByteArray, QVariant> propertyFilter; | ||
77 | //Properties to retrieve | ||
78 | QSet<QByteArray> requestedProperties; | ||
79 | bool syncOnDemand; | ||
80 | bool processAll; | ||
81 | //If live query is false, this query will not continuously be updated | ||
82 | bool liveQuery; | ||
83 | }; | ||
84 | |||
85 | |||
86 | |||
87 | /** | ||
88 | * Store interface used in the client API. | 51 | * Store interface used in the client API. |
89 | */ | 52 | */ |
90 | class Store { | 53 | class Store { |
91 | public: | 54 | public: |
92 | static QString storageLocation() | 55 | static QString storageLocation() |
93 | { | 56 | { |
94 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; | 57 | return Akonadi2::storageLocation(); |
95 | } | 58 | } |
96 | 59 | ||
97 | static QByteArray resourceName(const QByteArray &instanceIdentifier) | 60 | static QByteArray resourceName(const QByteArray &instanceIdentifier) |
98 | { | 61 | { |
99 | auto split = instanceIdentifier.split('.'); | 62 | return Akonadi2::resourceName(instanceIdentifier); |
100 | if (split.size() <= 1) { | ||
101 | return instanceIdentifier; | ||
102 | } | ||
103 | split.removeLast(); | ||
104 | return split.join('.'); | ||
105 | } | 63 | } |
106 | 64 | ||
107 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter) | 65 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter) |
diff --git a/common/definitions.cpp b/common/definitions.cpp new file mode 100644 index 0000000..33512ad --- /dev/null +++ b/common/definitions.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #include "definitions.h" | ||
22 | |||
23 | #include <QStandardPaths> | ||
24 | |||
25 | QString Akonadi2::storageLocation() | ||
26 | { | ||
27 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; | ||
28 | } | ||
29 | |||
30 | QByteArray Akonadi2::resourceName(const QByteArray &instanceIdentifier) | ||
31 | { | ||
32 | auto split = instanceIdentifier.split('.'); | ||
33 | if (split.size() <= 1) { | ||
34 | return instanceIdentifier; | ||
35 | } | ||
36 | split.removeLast(); | ||
37 | return split.join('.'); | ||
38 | } | ||
diff --git a/common/definitions.h b/common/definitions.h new file mode 100644 index 0000000..333d106 --- /dev/null +++ b/common/definitions.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #pragma once | ||
22 | |||
23 | #include <QString> | ||
24 | #include <QByteArray> | ||
25 | |||
26 | namespace Akonadi2 { | ||
27 | QString storageLocation(); | ||
28 | QByteArray resourceName(const QByteArray &instanceIdentifier); | ||
29 | } | ||
diff --git a/common/domain/event.cpp b/common/domain/event.cpp index d86ac16..15f5d11 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp | |||
@@ -27,6 +27,8 @@ | |||
27 | #include "../storage.h" | 27 | #include "../storage.h" |
28 | #include "../log.h" | 28 | #include "../log.h" |
29 | #include "../propertymapper.h" | 29 | #include "../propertymapper.h" |
30 | #include "../query.h" | ||
31 | #include "../definitions.h" | ||
30 | 32 | ||
31 | #include "event_generated.h" | 33 | #include "event_generated.h" |
32 | 34 | ||
@@ -36,7 +38,7 @@ ResultSet TypeImplementation<Event>::queryIndexes(const Akonadi2::Query &query, | |||
36 | { | 38 | { |
37 | QVector<QByteArray> keys; | 39 | QVector<QByteArray> keys; |
38 | if (query.propertyFilter.contains("uid")) { | 40 | if (query.propertyFilter.contains("uid")) { |
39 | Index uidIndex(Akonadi2::Store::storageLocation(), resourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); | 41 | Index uidIndex(Akonadi2::storageLocation(), resourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); |
40 | uidIndex.lookup(query.propertyFilter.value("uid").toByteArray(), [&](const QByteArray &value) { | 42 | uidIndex.lookup(query.propertyFilter.value("uid").toByteArray(), [&](const QByteArray &value) { |
41 | keys << value; | 43 | keys << value; |
42 | }, | 44 | }, |
@@ -50,7 +52,7 @@ ResultSet TypeImplementation<Event>::queryIndexes(const Akonadi2::Query &query, | |||
50 | 52 | ||
51 | void TypeImplementation<Event>::index(const Event &type) | 53 | void TypeImplementation<Event>::index(const Event &type) |
52 | { | 54 | { |
53 | Index uidIndex(Akonadi2::Store::storageLocation(), type.resourceInstanceIdentifier() + ".index.uid", Akonadi2::Storage::ReadWrite); | 55 | Index uidIndex(Akonadi2::storageLocation(), type.resourceInstanceIdentifier() + ".index.uid", Akonadi2::Storage::ReadWrite); |
54 | const auto uid = type.getProperty("uid"); | 56 | const auto uid = type.getProperty("uid"); |
55 | if (uid.isValid()) { | 57 | if (uid.isValid()) { |
56 | uidIndex.add(uid.toByteArray(), type.identifier()); | 58 | uidIndex.add(uid.toByteArray(), type.identifier()); |
diff --git a/common/domain/event.h b/common/domain/event.h index 38020f8..13cfc6e 100644 --- a/common/domain/event.h +++ b/common/domain/event.h | |||
@@ -18,7 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | #pragma once | 19 | #pragma once |
20 | 20 | ||
21 | #include "../clientapi.h" | 21 | #include "applicationdomaintype.h" |
22 | 22 | ||
23 | class ResultSet; | 23 | class ResultSet; |
24 | class QByteArray; | 24 | class QByteArray; |
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 7e9b171..f9dcc79 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h | |||
@@ -19,17 +19,16 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include "entity_generated.h" | ||
23 | #include <QVariant> | 22 | #include <QVariant> |
24 | #include <QByteArray> | 23 | #include <QByteArray> |
25 | #include <functional> | 24 | #include <functional> |
26 | #include "clientapi.h" //for domain parts | ||
27 | 25 | ||
26 | #include "domain/applicationdomaintype.h" | ||
27 | #include "domain/event.h" | ||
28 | #include "entity_generated.h" | 28 | #include "entity_generated.h" |
29 | #include "metadata_generated.h" | 29 | #include "metadata_generated.h" |
30 | #include "entitybuffer.h" | 30 | #include "entitybuffer.h" |
31 | #include "propertymapper.h" | 31 | #include "propertymapper.h" |
32 | #include "domain/event.h" | ||
33 | #include "log.h" | 32 | #include "log.h" |
34 | 33 | ||
35 | /** | 34 | /** |
diff --git a/common/entitystorage.h b/common/entitystorage.h index 516a889..2fce880 100644 --- a/common/entitystorage.h +++ b/common/entitystorage.h | |||
@@ -18,15 +18,16 @@ | |||
18 | */ | 18 | */ |
19 | #pragma once | 19 | #pragma once |
20 | 20 | ||
21 | #include "clientapi.h" | ||
22 | |||
23 | #include <QByteArray> | 21 | #include <QByteArray> |
24 | 22 | ||
23 | #include "query.h" | ||
25 | #include "domainadaptor.h" | 24 | #include "domainadaptor.h" |
26 | #include "entitybuffer.h" | 25 | #include "entitybuffer.h" |
27 | #include "log.h" | 26 | #include "log.h" |
28 | #include "storage.h" | 27 | #include "storage.h" |
29 | #include "resultset.h" | 28 | #include "resultset.h" |
29 | #include "resultprovider.h" | ||
30 | #include "definitions.h" | ||
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Wraps storage, entity adaptor factory and indexes into one. | 33 | * Wraps storage, entity adaptor factory and indexes into one. |
@@ -85,7 +86,7 @@ public: | |||
85 | 86 | ||
86 | virtual void read(const Akonadi2::Query &query, const QPair<qint64, qint64> &revisionRange, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider) | 87 | virtual void read(const Akonadi2::Query &query, const QPair<qint64, qint64> &revisionRange, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider) |
87 | { | 88 | { |
88 | Akonadi2::Storage storage(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier); | 89 | Akonadi2::Storage storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier); |
89 | storage.setDefaultErrorHandler([](const Akonadi2::Storage::Error &error) { | 90 | storage.setDefaultErrorHandler([](const Akonadi2::Storage::Error &error) { |
90 | Warning() << "Error during query: " << error.store << error.message; | 91 | Warning() << "Error during query: " << error.store << error.message; |
91 | }); | 92 | }); |
diff --git a/common/facade.h b/common/facade.h index 1715a7f..be053f6 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -19,8 +19,9 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <QByteArray> | 22 | #include "facadeinterface.h" |
23 | 23 | ||
24 | #include <QByteArray> | ||
24 | #include <Async/Async> | 25 | #include <Async/Async> |
25 | 26 | ||
26 | #include "resourceaccess.h" | 27 | #include "resourceaccess.h" |
diff --git a/common/facadeinterface.h b/common/facadeinterface.h index a88c104..ac60ae4 100644 --- a/common/facadeinterface.h +++ b/common/facadeinterface.h | |||
@@ -45,7 +45,7 @@ public: | |||
45 | virtual KAsync::Job<void> create(const DomainType &domainObject) = 0; | 45 | virtual KAsync::Job<void> create(const DomainType &domainObject) = 0; |
46 | virtual KAsync::Job<void> modify(const DomainType &domainObject) = 0; | 46 | virtual KAsync::Job<void> modify(const DomainType &domainObject) = 0; |
47 | virtual KAsync::Job<void> remove(const DomainType &domainObject) = 0; | 47 | virtual KAsync::Job<void> remove(const DomainType &domainObject) = 0; |
48 | virtual KAsync::Job<void> load(const Query &query, const QSharedPointer<async::ResultProvider<typename DomainType::Ptr> > &resultProvider) = 0; | 48 | virtual KAsync::Job<void> load(const Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider) = 0; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | } | 51 | } |
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 734c1b5..a86b518 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -6,9 +6,9 @@ | |||
6 | #include "createentity_generated.h" | 6 | #include "createentity_generated.h" |
7 | #include "domainadaptor.h" | 7 | #include "domainadaptor.h" |
8 | #include "commands.h" | 8 | #include "commands.h" |
9 | #include "clientapi.h" | ||
10 | #include "index.h" | 9 | #include "index.h" |
11 | #include "log.h" | 10 | #include "log.h" |
11 | #include "definitions.h" | ||
12 | 12 | ||
13 | using namespace Akonadi2; | 13 | using namespace Akonadi2; |
14 | 14 | ||
@@ -154,8 +154,8 @@ private: | |||
154 | 154 | ||
155 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) | 155 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) |
156 | : Akonadi2::Resource(), | 156 | : Akonadi2::Resource(), |
157 | mUserQueue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceInstanceIdentifier + ".userqueue"), | 157 | mUserQueue(Akonadi2::storageLocation(), resourceInstanceIdentifier + ".userqueue"), |
158 | mSynchronizerQueue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceInstanceIdentifier + ".synchronizerqueue"), | 158 | mSynchronizerQueue(Akonadi2::storageLocation(), resourceInstanceIdentifier + ".synchronizerqueue"), |
159 | mResourceInstanceIdentifier(resourceInstanceIdentifier), | 159 | mResourceInstanceIdentifier(resourceInstanceIdentifier), |
160 | mPipeline(pipeline ? pipeline : QSharedPointer<Akonadi2::Pipeline>::create(resourceInstanceIdentifier)), | 160 | mPipeline(pipeline ? pipeline : QSharedPointer<Akonadi2::Pipeline>::create(resourceInstanceIdentifier)), |
161 | mError(0) | 161 | mError(0) |
diff --git a/common/listener.cpp b/common/listener.cpp index 1159252..9773835 100644 --- a/common/listener.cpp +++ b/common/listener.cpp | |||
@@ -19,10 +19,10 @@ | |||
19 | 19 | ||
20 | #include "listener.h" | 20 | #include "listener.h" |
21 | 21 | ||
22 | #include "common/clientapi.h" | ||
23 | #include "common/commands.h" | 22 | #include "common/commands.h" |
24 | #include "common/resource.h" | 23 | #include "common/resource.h" |
25 | #include "common/log.h" | 24 | #include "common/log.h" |
25 | #include "common/definitions.h" | ||
26 | 26 | ||
27 | // commands | 27 | // commands |
28 | #include "common/commandcompletion_generated.h" | 28 | #include "common/commandcompletion_generated.h" |
@@ -31,13 +31,14 @@ | |||
31 | #include "common/synchronize_generated.h" | 31 | #include "common/synchronize_generated.h" |
32 | #include "common/notification_generated.h" | 32 | #include "common/notification_generated.h" |
33 | 33 | ||
34 | #include <QLocalServer> | ||
34 | #include <QLocalSocket> | 35 | #include <QLocalSocket> |
35 | #include <QTimer> | 36 | #include <QTimer> |
36 | 37 | ||
37 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) | 38 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) |
38 | : QObject(parent), | 39 | : QObject(parent), |
39 | m_server(new QLocalServer(this)), | 40 | m_server(new QLocalServer(this)), |
40 | m_resourceName(Akonadi2::Store::resourceName(resourceInstanceIdentifier)), | 41 | m_resourceName(Akonadi2::resourceName(resourceInstanceIdentifier)), |
41 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), | 42 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), |
42 | m_resource(0), | 43 | m_resource(0), |
43 | m_clientBufferProcessesTimer(new QTimer(this)), | 44 | m_clientBufferProcessesTimer(new QTimer(this)), |
diff --git a/common/listener.h b/common/listener.h index 2d69c35..30807d7 100644 --- a/common/listener.h +++ b/common/listener.h | |||
@@ -19,20 +19,19 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <QLocalServer> | ||
23 | #include <QLocalSocket> | ||
24 | #include <QObject> | 22 | #include <QObject> |
25 | 23 | ||
24 | #include <QPointer> | ||
25 | #include <QLocalSocket> | ||
26 | #include <flatbuffers/flatbuffers.h> | 26 | #include <flatbuffers/flatbuffers.h> |
27 | 27 | ||
28 | #include "common/pipeline.h" | ||
29 | |||
30 | namespace Akonadi2 | 28 | namespace Akonadi2 |
31 | { | 29 | { |
32 | class Resource; | 30 | class Resource; |
33 | } | 31 | } |
34 | 32 | ||
35 | class QTimer; | 33 | class QTimer; |
34 | class QLocalServer; | ||
36 | 35 | ||
37 | class Client | 36 | class Client |
38 | { | 37 | { |
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 0231631..207cc5e 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -21,7 +21,6 @@ | |||
21 | #include "pipeline.h" | 21 | #include "pipeline.h" |
22 | 22 | ||
23 | #include <QByteArray> | 23 | #include <QByteArray> |
24 | #include <QStandardPaths> | ||
25 | #include <QVector> | 24 | #include <QVector> |
26 | #include <QUuid> | 25 | #include <QUuid> |
27 | #include <QDebug> | 26 | #include <QDebug> |
@@ -33,6 +32,7 @@ | |||
33 | #include "entitybuffer.h" | 32 | #include "entitybuffer.h" |
34 | #include "log.h" | 33 | #include "log.h" |
35 | #include "domain/applicationdomaintype.h" | 34 | #include "domain/applicationdomaintype.h" |
35 | #include "definitions.h" | ||
36 | 36 | ||
37 | namespace Akonadi2 | 37 | namespace Akonadi2 |
38 | { | 38 | { |
@@ -41,7 +41,7 @@ class Pipeline::Private | |||
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | Private(const QString &resourceName) | 43 | Private(const QString &resourceName) |
44 | : storage(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage", resourceName, Storage::ReadWrite), | 44 | : storage(Akonadi2::storageLocation(), resourceName, Storage::ReadWrite), |
45 | stepScheduled(false) | 45 | stepScheduled(false) |
46 | { | 46 | { |
47 | } | 47 | } |
diff --git a/common/pipeline.h b/common/pipeline.h index 9c3e7a1..1a33f9a 100644 --- a/common/pipeline.h +++ b/common/pipeline.h | |||
@@ -30,7 +30,6 @@ | |||
30 | 30 | ||
31 | #include <Async/Async> | 31 | #include <Async/Async> |
32 | 32 | ||
33 | #include "entity_generated.h" | ||
34 | #include "domainadaptor.h" | 33 | #include "domainadaptor.h" |
35 | 34 | ||
36 | namespace Akonadi2 | 35 | namespace Akonadi2 |
diff --git a/common/query.h b/common/query.h new file mode 100644 index 0000000..0cad9fb --- /dev/null +++ b/common/query.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | #pragma once | ||
21 | |||
22 | #include <QByteArrayList> | ||
23 | #include <QHash> | ||
24 | #include <QSet> | ||
25 | |||
26 | namespace Akonadi2 { | ||
27 | |||
28 | /** | ||
29 | * A query that matches a set of objects | ||
30 | * | ||
31 | * The query will have to be updated regularly similary to the domain objects. | ||
32 | * It probably also makes sense to have a domain specific part of the query, | ||
33 | * such as what properties we're interested in (necessary information for on-demand | ||
34 | * loading of data). | ||
35 | * | ||
36 | * The query defines: | ||
37 | * * what resources to search | ||
38 | * * filters on various properties (parent collection, startDate range, ....) | ||
39 | * * properties we need (for on-demand querying) | ||
40 | * | ||
41 | * syncOnDemand: Execute a source sync before executing the query | ||
42 | * processAll: Ensure all local messages are processed before querying to guarantee an up-to date dataset. | ||
43 | */ | ||
44 | class Query | ||
45 | { | ||
46 | public: | ||
47 | Query() : syncOnDemand(true), processAll(false), liveQuery(false) {} | ||
48 | //Could also be a propertyFilter | ||
49 | QByteArrayList resources; | ||
50 | //Could also be a propertyFilter | ||
51 | QByteArrayList ids; | ||
52 | //Filters to apply | ||
53 | QHash<QByteArray, QVariant> propertyFilter; | ||
54 | //Properties to retrieve | ||
55 | QSet<QByteArray> requestedProperties; | ||
56 | bool syncOnDemand; | ||
57 | bool processAll; | ||
58 | //If live query is false, this query will not continuously be updated | ||
59 | bool liveQuery; | ||
60 | }; | ||
61 | |||
62 | } | ||
diff --git a/common/resource.cpp b/common/resource.cpp index 2a86df5..58ba82f 100644 --- a/common/resource.cpp +++ b/common/resource.cpp | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <QPluginLoader> | 25 | #include <QPluginLoader> |
26 | #include <QPointer> | 26 | #include <QPointer> |
27 | 27 | ||
28 | #include "facadefactory.h" | ||
29 | |||
28 | namespace Akonadi2 | 30 | namespace Akonadi2 |
29 | { | 31 | { |
30 | 32 | ||
diff --git a/common/resource.h b/common/resource.h index a51e12d..6563c09 100644 --- a/common/resource.h +++ b/common/resource.h | |||
@@ -19,13 +19,13 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <akonadi2common_export.h> | 21 | #include <akonadi2common_export.h> |
22 | #include <clientapi.h> | ||
23 | 22 | ||
24 | #include <Async/Async> | 23 | #include <Async/Async> |
25 | 24 | ||
26 | namespace Akonadi2 | 25 | namespace Akonadi2 |
27 | { | 26 | { |
28 | class Pipeline; | 27 | class Pipeline; |
28 | class FacadeFactory; | ||
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Resource interface | 31 | * Resource interface |
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp index 9792934..54185f8 100644 --- a/common/resourcefacade.cpp +++ b/common/resourcefacade.cpp | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "resourcefacade.h" | 19 | #include "resourcefacade.h" |
20 | 20 | ||
21 | #include "resourceconfig.h" | 21 | #include "resourceconfig.h" |
22 | #include "query.h" | ||
22 | 23 | ||
23 | ResourceFacade::ResourceFacade(const QByteArray &) | 24 | ResourceFacade::ResourceFacade(const QByteArray &) |
24 | : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>() | 25 | : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>() |
diff --git a/common/resourcefacade.h b/common/resourcefacade.h index 2b36f21..437ff75 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h | |||
@@ -19,8 +19,15 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include "common/clientapi.h" | 22 | #include "common/facadeinterface.h" |
23 | |||
24 | #include <Async/Async> | ||
23 | #include "common/resultprovider.h" | 25 | #include "common/resultprovider.h" |
26 | #include "common/domain/applicationdomaintype.h" | ||
27 | |||
28 | namespace Akonadi2 { | ||
29 | class Query; | ||
30 | } | ||
24 | 31 | ||
25 | class ResourceFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource> | 32 | class ResourceFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource> |
26 | { | 33 | { |
diff --git a/common/resultprovider.h b/common/resultprovider.h index a375815..841fd01 100644 --- a/common/resultprovider.h +++ b/common/resultprovider.h | |||
@@ -24,7 +24,9 @@ | |||
24 | #include <memory> | 24 | #include <memory> |
25 | #include "threadboundary.h" | 25 | #include "threadboundary.h" |
26 | 26 | ||
27 | namespace async { | 27 | using namespace async; |
28 | |||
29 | namespace Akonadi2 { | ||
28 | 30 | ||
29 | /** | 31 | /** |
30 | * Query result set | 32 | * Query result set |
diff --git a/common/synclistresult.h b/common/synclistresult.h index 0a86f8c..865d3e0 100644 --- a/common/synclistresult.h +++ b/common/synclistresult.h | |||
@@ -3,7 +3,8 @@ | |||
3 | #include <QList> | 3 | #include <QList> |
4 | #include <functional> | 4 | #include <functional> |
5 | #include <QSharedPointer> | 5 | #include <QSharedPointer> |
6 | #include <clientapi.h> | 6 | #include <QEventLoop> |
7 | #include "resultprovider.h" | ||
7 | 8 | ||
8 | namespace async { | 9 | namespace async { |
9 | 10 | ||
@@ -17,7 +18,7 @@ namespace async { | |||
17 | template<class T> | 18 | template<class T> |
18 | class SyncListResult : public QList<T> { | 19 | class SyncListResult : public QList<T> { |
19 | public: | 20 | public: |
20 | SyncListResult(const QSharedPointer<ResultEmitter<T> > &emitter) | 21 | SyncListResult(const QSharedPointer<Akonadi2::ResultEmitter<T> > &emitter) |
21 | :QList<T>(), | 22 | :QList<T>(), |
22 | mEmitter(emitter) | 23 | mEmitter(emitter) |
23 | { | 24 | { |
@@ -47,7 +48,7 @@ public: | |||
47 | } | 48 | } |
48 | 49 | ||
49 | private: | 50 | private: |
50 | QSharedPointer<ResultEmitter<T> > mEmitter; | 51 | QSharedPointer<Akonadi2::ResultEmitter<T> > mEmitter; |
51 | std::function<void()> eventLoopAborter; | 52 | std::function<void()> eventLoopAborter; |
52 | }; | 53 | }; |
53 | 54 | ||
diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 9445599..a0ca51b 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp | |||
@@ -73,7 +73,7 @@ template<class T> | |||
73 | class AkonadiListModel : public QAbstractListModel | 73 | class AkonadiListModel : public QAbstractListModel |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | AkonadiListModel(const QSharedPointer<async::ResultEmitter<T> > &emitter, const QByteArray &property) | 76 | AkonadiListModel(const QSharedPointer<Akonadi2::ResultEmitter<T> > &emitter, const QByteArray &property) |
77 | :QAbstractListModel(), | 77 | :QAbstractListModel(), |
78 | mEmitter(emitter) | 78 | mEmitter(emitter) |
79 | { | 79 | { |
@@ -116,7 +116,7 @@ public: | |||
116 | } | 116 | } |
117 | 117 | ||
118 | private: | 118 | private: |
119 | QSharedPointer<async::ResultEmitter<T> > mEmitter; | 119 | QSharedPointer<Akonadi2::ResultEmitter<T> > mEmitter; |
120 | QStringList mStringList; | 120 | QStringList mStringList; |
121 | }; | 121 | }; |
122 | 122 | ||
diff --git a/examples/dummyresource/resourcefacade.cpp b/examples/dummyresource/resourcefacade.cpp index 31c0b21..df805e4 100644 --- a/examples/dummyresource/resourcefacade.cpp +++ b/examples/dummyresource/resourcefacade.cpp | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "resourcefacade.h" | 20 | #include "resourcefacade.h" |
21 | 21 | ||
22 | #include <QSettings> | 22 | #include <QSettings> |
23 | #include <QStandardPaths> | ||
23 | 24 | ||
24 | DummyResourceConfigFacade::DummyResourceConfigFacade() | 25 | DummyResourceConfigFacade::DummyResourceConfigFacade() |
25 | : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>() | 26 | : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>() |
@@ -64,7 +65,7 @@ KAsync::Job<void> DummyResourceConfigFacade::remove(const Akonadi2::ApplicationD | |||
64 | return KAsync::null<void>(); | 65 | return KAsync::null<void>(); |
65 | } | 66 | } |
66 | 67 | ||
67 | KAsync::Job<void> DummyResourceConfigFacade::load(const Akonadi2::Query &query, const QSharedPointer<async::ResultProvider<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr> > &resultProvider) | 68 | KAsync::Job<void> DummyResourceConfigFacade::load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr> > &resultProvider) |
68 | { | 69 | { |
69 | //Read configuration and list all available instances. | 70 | //Read configuration and list all available instances. |
70 | //This includes runtime information about runing instances etc. | 71 | //This includes runtime information about runing instances etc. |
diff --git a/examples/dummyresource/resourcefacade.h b/examples/dummyresource/resourcefacade.h index 5d0291c..5a5f46b 100644 --- a/examples/dummyresource/resourcefacade.h +++ b/examples/dummyresource/resourcefacade.h | |||
@@ -19,9 +19,14 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include "common/clientapi.h" | ||
23 | |||
24 | #include <Async/Async> | 22 | #include <Async/Async> |
23 | #include <common/domain/applicationdomaintype.h> | ||
24 | #include <common/resultprovider.h> | ||
25 | #include <common/facadeinterface.h> | ||
26 | |||
27 | namespace Akonadi2 { | ||
28 | class Query; | ||
29 | } | ||
25 | 30 | ||
26 | class QSettings; | 31 | class QSettings; |
27 | 32 | ||
@@ -37,7 +42,7 @@ public: | |||
37 | //Remove instance | 42 | //Remove instance |
38 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) Q_DECL_OVERRIDE; | 43 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) Q_DECL_OVERRIDE; |
39 | //Read configuration and available instances | 44 | //Read configuration and available instances |
40 | KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<async::ResultProvider<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr> > &resultProvider) Q_DECL_OVERRIDE; | 45 | KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr> > &resultProvider) Q_DECL_OVERRIDE; |
41 | 46 | ||
42 | private: | 47 | private: |
43 | QSharedPointer<QSettings> getSettings(); | 48 | QSharedPointer<QSettings> getSettings(); |
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index e9bf6cd..e029308 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -31,6 +31,8 @@ | |||
31 | #include "log.h" | 31 | #include "log.h" |
32 | #include "domain/event.h" | 32 | #include "domain/event.h" |
33 | #include "dummystore.h" | 33 | #include "dummystore.h" |
34 | #include "definitions.h" | ||
35 | #include "facadefactory.h" | ||
34 | 36 | ||
35 | //This is the resources entity type, and not the domain type | 37 | //This is the resources entity type, and not the domain type |
36 | #define ENTITY_TYPE_EVENT "event" | 38 | #define ENTITY_TYPE_EVENT "event" |
@@ -46,7 +48,7 @@ DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QShared | |||
46 | Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor); | 48 | Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor); |
47 | Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::index(event); | 49 | Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::index(event); |
48 | 50 | ||
49 | Index ridIndex(Akonadi2::Store::storageLocation(), resourceIdentifier + ".index.rid", Akonadi2::Storage::ReadWrite); | 51 | Index ridIndex(Akonadi2::storageLocation(), resourceIdentifier + ".index.rid", Akonadi2::Storage::ReadWrite); |
50 | const auto rid = event.getProperty("remoteId"); | 52 | const auto rid = event.getProperty("remoteId"); |
51 | if (rid.isValid()) { | 53 | if (rid.isValid()) { |
52 | ridIndex.add(rid.toByteArray(), event.identifier()); | 54 | ridIndex.add(rid.toByteArray(), event.identifier()); |
@@ -62,7 +64,7 @@ KAsync::Job<void> DummyResource::synchronizeWithSource() | |||
62 | { | 64 | { |
63 | return KAsync::start<void>([this](KAsync::Future<void> &f) { | 65 | return KAsync::start<void>([this](KAsync::Future<void> &f) { |
64 | //TODO start transaction on index | 66 | //TODO start transaction on index |
65 | Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); | 67 | Index uidIndex(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); |
66 | 68 | ||
67 | const auto data = DummyStore::instance().data(); | 69 | const auto data = DummyStore::instance().data(); |
68 | for (auto it = data.constBegin(); it != data.constEnd(); it++) { | 70 | for (auto it = data.constBegin(); it != data.constEnd(); it++) { |
diff --git a/tests/genericresourcetest.cpp b/tests/genericresourcetest.cpp index b6f629a..0faa484 100644 --- a/tests/genericresourcetest.cpp +++ b/tests/genericresourcetest.cpp | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "entitybuffer.h" | 10 | #include "entitybuffer.h" |
11 | #include "pipeline.h" | 11 | #include "pipeline.h" |
12 | #include "genericresource.h" | 12 | #include "genericresource.h" |
13 | #include "definitions.h" | ||
13 | 14 | ||
14 | class TestResource : public Akonadi2::GenericResource | 15 | class TestResource : public Akonadi2::GenericResource |
15 | { | 16 | { |
@@ -28,7 +29,7 @@ public: | |||
28 | 29 | ||
29 | static void removeFromDisk(const QString &name) | 30 | static void removeFromDisk(const QString &name) |
30 | { | 31 | { |
31 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); | 32 | Akonadi2::Storage store(Akonadi2::storageLocation(), name, Akonadi2::Storage::ReadWrite); |
32 | store.removeFromDisk(); | 33 | store.removeFromDisk(); |
33 | } | 34 | } |
34 | 35 | ||