diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-14 18:49:57 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-14 18:49:57 +0100 |
commit | 7de95983b30ca414c04bb3f877b67c1b7e9d6fa0 (patch) | |
tree | 19fec64f4d99b22b7611aedf62de4f1dec246c8b | |
parent | c631c520e260a8455dcdc501a19f4513bada13cb (diff) | |
download | sink-7de95983b30ca414c04bb3f877b67c1b7e9d6fa0.tar.gz sink-7de95983b30ca414c04bb3f877b67c1b7e9d6fa0.zip |
Introduced flushMessageQueue
to get rid of the processAll/sync flags in the query object
-rw-r--r-- | common/clientapi.cpp | 16 | ||||
-rw-r--r-- | common/clientapi.h | 9 |
2 files changed, 23 insertions, 2 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 2c25220..ffaa57b 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -212,6 +212,22 @@ KAsync::Job<void> Store::synchronize(const Akonadi2::Query &query) | |||
212 | .template then<void>([](){}); | 212 | .template then<void>([](){}); |
213 | } | 213 | } |
214 | 214 | ||
215 | KAsync::Job<void> Store::flushMessageQueue(const QByteArrayList &resourceIdentifier) | ||
216 | { | ||
217 | Trace() << "flushMessageQueue" << resourceIdentifier; | ||
218 | return KAsync::iterate(resourceIdentifier) | ||
219 | .template each<void, QByteArray>([](const QByteArray &resource, KAsync::Future<void> &future) { | ||
220 | Trace() << "Flushing message queue " << resource; | ||
221 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(resource); | ||
222 | resourceAccess->open(); | ||
223 | resourceAccess->synchronizeResource(false, true).then<void>([&future, resourceAccess]() { | ||
224 | future.setFinished(); | ||
225 | }).exec(); | ||
226 | }) | ||
227 | //FIXME JOBAPI this is only required because we don't care about the return value of each (and each shouldn't even have a return value) | ||
228 | .template then<void>([](){}); | ||
229 | } | ||
230 | |||
215 | template <class DomainType> | 231 | template <class DomainType> |
216 | KAsync::Job<DomainType> Store::fetchOne(const Akonadi2::Query &query) | 232 | KAsync::Job<DomainType> Store::fetchOne(const Akonadi2::Query &query) |
217 | { | 233 | { |
diff --git a/common/clientapi.h b/common/clientapi.h index f1c3bc6..eff8e8d 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -73,6 +73,11 @@ public: | |||
73 | static KAsync::Job<void> remove(const DomainType &domainObject); | 73 | static KAsync::Job<void> remove(const DomainType &domainObject); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Synchronize data to local cache. | ||
77 | */ | ||
78 | static KAsync::Job<void> synchronize(const Akonadi2::Query &query); | ||
79 | |||
80 | /** | ||
76 | * Shutdown resource. | 81 | * Shutdown resource. |
77 | */ | 82 | */ |
78 | static KAsync::Job<void> shutdown(const QByteArray &resourceIdentifier); | 83 | static KAsync::Job<void> shutdown(const QByteArray &resourceIdentifier); |
@@ -87,9 +92,9 @@ public: | |||
87 | static KAsync::Job<void> start(const QByteArray &resourceIdentifier); | 92 | static KAsync::Job<void> start(const QByteArray &resourceIdentifier); |
88 | 93 | ||
89 | /** | 94 | /** |
90 | * Synchronize data to local cache. | 95 | * Flushes any pending messages to disk |
91 | */ | 96 | */ |
92 | static KAsync::Job<void> synchronize(const Akonadi2::Query &query); | 97 | static KAsync::Job<void> flushMessageQueue(const QByteArrayList &resourceIdentifier); |
93 | 98 | ||
94 | /** | 99 | /** |
95 | * Removes a resource from disk. | 100 | * Removes a resource from disk. |