From 25d08af0851b56db664cee7f6463532d7c103d33 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 31 Oct 2015 21:08:39 +0100 Subject: Fixed shutdown and synchronize commands --- common/clientapi.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'common/clientapi.cpp') diff --git a/common/clientapi.cpp b/common/clientapi.cpp index aa3abb4..f99ebb8 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp @@ -69,10 +69,10 @@ QList Store::getResources(const QList &resourceFilter, c return resources; } -void Store::shutdown(const QByteArray &identifier) +KAsync::Job Store::shutdown(const QByteArray &identifier) { Trace() << "shutdown"; - ResourceAccess::connectToServer(identifier).then>([identifier](const QSharedPointer &socket, KAsync::Future &future) { + return ResourceAccess::connectToServer(identifier).then>([identifier](QSharedPointer socket, KAsync::Future &future) { //We can't currently reuse the socket socket->close(); auto resourceAccess = QSharedPointer::create(identifier); @@ -83,15 +83,24 @@ void Store::shutdown(const QByteArray &identifier) }, [](int, const QString &) { //Resource isn't started, nothing to shutdown - }).exec().waitForFinished(); + }) + //FIXME JOBAPI this is only required because we don't care about the return value of connectToServer + .template then([](){}); } -void Store::synchronize(const QByteArray &identifier) +KAsync::Job Store::synchronize(const Akonadi2::Query &query) { Trace() << "synchronize"; - auto resourceAccess = QSharedPointer::create(identifier); - resourceAccess->open(); - resourceAccess->synchronizeResource(true, false).exec().waitForFinished(); + return KAsync::iterate(query.resources) + .template each([query](const QByteArray &resource, KAsync::Future &future) { + auto resourceAccess = QSharedPointer::create(resource); + resourceAccess->open(); + resourceAccess->synchronizeResource(true, false).then([&future]() { + 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([](){}); } } // namespace Akonadi2 -- cgit v1.2.3