From 7de95983b30ca414c04bb3f877b67c1b7e9d6fa0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 14 Jan 2016 18:49:57 +0100 Subject: Introduced flushMessageQueue to get rid of the processAll/sync flags in the query object --- common/clientapi.cpp | 16 ++++++++++++++++ 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 Store::synchronize(const Akonadi2::Query &query) .template then([](){}); } +KAsync::Job Store::flushMessageQueue(const QByteArrayList &resourceIdentifier) +{ + Trace() << "flushMessageQueue" << resourceIdentifier; + return KAsync::iterate(resourceIdentifier) + .template each([](const QByteArray &resource, KAsync::Future &future) { + Trace() << "Flushing message queue " << resource; + auto resourceAccess = QSharedPointer::create(resource); + resourceAccess->open(); + resourceAccess->synchronizeResource(false, true).then([&future, resourceAccess]() { + future.setFinished(); + }).exec(); + }) + //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) + .template then([](){}); +} + template KAsync::Job Store::fetchOne(const Akonadi2::Query &query) { diff --git a/common/clientapi.h b/common/clientapi.h index f1c3bc6..eff8e8d 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -72,6 +72,11 @@ public: template static KAsync::Job remove(const DomainType &domainObject); + /** + * Synchronize data to local cache. + */ + static KAsync::Job synchronize(const Akonadi2::Query &query); + /** * Shutdown resource. */ @@ -87,9 +92,9 @@ public: static KAsync::Job start(const QByteArray &resourceIdentifier); /** - * Synchronize data to local cache. + * Flushes any pending messages to disk */ - static KAsync::Job synchronize(const Akonadi2::Query &query); + static KAsync::Job flushMessageQueue(const QByteArrayList &resourceIdentifier); /** * Removes a resource from disk. -- cgit v1.2.3