diff options
-rw-r--r-- | common/resourceaccess.cpp | 8 | ||||
-rw-r--r-- | common/resourceaccess.h | 3 | ||||
-rw-r--r-- | dummyresource/facade.cpp | 6 |
3 files changed, 12 insertions, 5 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 31b9e79..9fb0d4c 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -161,9 +161,13 @@ void ResourceAccess::sendCommand(int commandId, flatbuffers::FlatBufferBuilder & | |||
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | void ResourceAccess::synchronizeResource(const std::function<void()> &resultHandler) | 164 | Async::Job<void> ResourceAccess::synchronizeResource() |
165 | { | 165 | { |
166 | sendCommand(Commands::SynchronizeCommand, resultHandler); | 166 | return Async::start<void>([this](Async::Future<void> &f) { |
167 | sendCommand(Commands::SynchronizeCommand, [&f]() { | ||
168 | f.setFinished(); | ||
169 | }); | ||
170 | }); | ||
167 | } | 171 | } |
168 | 172 | ||
169 | void ResourceAccess::open() | 173 | void ResourceAccess::open() |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index d79c993..d45ebde 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <QTimer> | 25 | #include <QTimer> |
26 | 26 | ||
27 | #include <flatbuffers/flatbuffers.h> | 27 | #include <flatbuffers/flatbuffers.h> |
28 | #include <async/src/async.h> | ||
28 | 29 | ||
29 | namespace Akonadi2 | 30 | namespace Akonadi2 |
30 | { | 31 | { |
@@ -43,7 +44,7 @@ public: | |||
43 | //TODO use jobs | 44 | //TODO use jobs |
44 | void sendCommand(int commandId, const std::function<void()> &callback = std::function<void()>()); | 45 | void sendCommand(int commandId, const std::function<void()> &callback = std::function<void()>()); |
45 | void sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb, const std::function<void()> &callback); | 46 | void sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb, const std::function<void()> &callback); |
46 | void synchronizeResource(const std::function<void()> &resultHandler); | 47 | Async::Job<void> synchronizeResource(); |
47 | 48 | ||
48 | public Q_SLOTS: | 49 | public Q_SLOTS: |
49 | void open(); | 50 | void open(); |
diff --git a/dummyresource/facade.cpp b/dummyresource/facade.cpp index b4d98c6..5320216 100644 --- a/dummyresource/facade.cpp +++ b/dummyresource/facade.cpp | |||
@@ -95,8 +95,10 @@ void DummyResourceFacade::synchronizeResource(const std::function<void()> &conti | |||
95 | //TODO check if a sync is necessary | 95 | //TODO check if a sync is necessary |
96 | //TODO Only sync what was requested | 96 | //TODO Only sync what was requested |
97 | //TODO timeout | 97 | //TODO timeout |
98 | mResourceAccess->open(); | 98 | mResourceAccess->synchronizeResource().then<void>([continuation](Async::Future<void> &f){ |
99 | mResourceAccess->synchronizeResource(continuation); | 99 | continuation(); |
100 | f.setFinished(); | ||
101 | }).exec(); | ||
100 | } | 102 | } |
101 | 103 | ||
102 | void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback, const std::function<void()> &completeCallback) | 104 | void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback, const std::function<void()> &completeCallback) |