summaryrefslogtreecommitdiffstats
path: root/common/clientapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/clientapi.cpp')
-rw-r--r--common/clientapi.cpp23
1 files changed, 16 insertions, 7 deletions
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<QByteArray> Store::getResources(const QList<QByteArray> &resourceFilter, c
69 return resources; 69 return resources;
70} 70}
71 71
72void Store::shutdown(const QByteArray &identifier) 72KAsync::Job<void> Store::shutdown(const QByteArray &identifier)
73{ 73{
74 Trace() << "shutdown"; 74 Trace() << "shutdown";
75 ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](const QSharedPointer<QLocalSocket> &socket, KAsync::Future<void> &future) { 75 return ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) {
76 //We can't currently reuse the socket 76 //We can't currently reuse the socket
77 socket->close(); 77 socket->close();
78 auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier); 78 auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier);
@@ -83,15 +83,24 @@ void Store::shutdown(const QByteArray &identifier)
83 }, 83 },
84 [](int, const QString &) { 84 [](int, const QString &) {
85 //Resource isn't started, nothing to shutdown 85 //Resource isn't started, nothing to shutdown
86 }).exec().waitForFinished(); 86 })
87 //FIXME JOBAPI this is only required because we don't care about the return value of connectToServer
88 .template then<void>([](){});
87} 89}
88 90
89void Store::synchronize(const QByteArray &identifier) 91KAsync::Job<void> Store::synchronize(const Akonadi2::Query &query)
90{ 92{
91 Trace() << "synchronize"; 93 Trace() << "synchronize";
92 auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier); 94 return KAsync::iterate(query.resources)
93 resourceAccess->open(); 95 .template each<void, QByteArray>([query](const QByteArray &resource, KAsync::Future<void> &future) {
94 resourceAccess->synchronizeResource(true, false).exec().waitForFinished(); 96 auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(resource);
97 resourceAccess->open();
98 resourceAccess->synchronizeResource(true, false).then<void>([&future]() {
99 future.setFinished();
100 }).exec();
101 })
102 //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)
103 .template then<void>([](){});
95} 104}
96 105
97} // namespace Akonadi2 106} // namespace Akonadi2