diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-25 11:23:08 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-25 11:23:08 +0100 |
commit | 3fc8ce958fc244e64a3a3a92f3b1440aae04133b (patch) | |
tree | 4ba2b3ca3ee6a17e7f3e7ce67d6ca934626cad7a /common | |
parent | 9b744da32e64d8a6cd342faba8fc3232884d60f2 (diff) | |
download | sink-3fc8ce958fc244e64a3a3a92f3b1440aae04133b.tar.gz sink-3fc8ce958fc244e64a3a3a92f3b1440aae04133b.zip |
A way to ensure all messages have been processed.
As queries become reactive this should become less important. We can then just wait until
all results become available. For tests it is in either case useful though.
Diffstat (limited to 'common')
-rw-r--r-- | common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | common/clientapi.h | 3 | ||||
-rw-r--r-- | common/commands/synchronize.fbs | 8 | ||||
-rw-r--r-- | common/resource.cpp | 5 | ||||
-rw-r--r-- | common/resource.h | 1 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 8 | ||||
-rw-r--r-- | common/resourceaccess.h | 2 |
7 files changed, 24 insertions, 4 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3d3a2b7..18bcad0 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -7,6 +7,7 @@ generate_flatbuffers( | |||
7 | commands/handshake | 7 | commands/handshake |
8 | commands/modifyentity | 8 | commands/modifyentity |
9 | commands/revisionupdate | 9 | commands/revisionupdate |
10 | commands/synchronize | ||
10 | domain/event | 11 | domain/event |
11 | entity | 12 | entity |
12 | metadata | 13 | metadata |
diff --git a/common/clientapi.h b/common/clientapi.h index 659ae91..55fbed1 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -297,7 +297,7 @@ using namespace async; | |||
297 | class Query | 297 | class Query |
298 | { | 298 | { |
299 | public: | 299 | public: |
300 | Query() : syncOnDemand(true) {} | 300 | Query() : syncOnDemand(true), processAll(false) {} |
301 | //Could also be a propertyFilter | 301 | //Could also be a propertyFilter |
302 | QStringList resources; | 302 | QStringList resources; |
303 | //Could also be a propertyFilter | 303 | //Could also be a propertyFilter |
@@ -307,6 +307,7 @@ public: | |||
307 | //Properties to retrieve | 307 | //Properties to retrieve |
308 | QSet<QString> requestedProperties; | 308 | QSet<QString> requestedProperties; |
309 | bool syncOnDemand; | 309 | bool syncOnDemand; |
310 | bool processAll; | ||
310 | }; | 311 | }; |
311 | 312 | ||
312 | 313 | ||
diff --git a/common/commands/synchronize.fbs b/common/commands/synchronize.fbs new file mode 100644 index 0000000..d2d0364 --- /dev/null +++ b/common/commands/synchronize.fbs | |||
@@ -0,0 +1,8 @@ | |||
1 | namespace Akonadi2; | ||
2 | |||
3 | table Synchronize { | ||
4 | sourceSync: bool; //Synchronize with source | ||
5 | localSync: bool; //Ensure all queues are processed so the local state is up-to date. | ||
6 | } | ||
7 | |||
8 | root_type Synchronize; | ||
diff --git a/common/resource.cpp b/common/resource.cpp index db08c4f..e158a40 100644 --- a/common/resource.cpp +++ b/common/resource.cpp | |||
@@ -60,6 +60,11 @@ Async::Job<void> Resource::synchronizeWithSource(Pipeline *pipeline) | |||
60 | }); | 60 | }); |
61 | } | 61 | } |
62 | 62 | ||
63 | Async::Job<void> Resource::processAllMessages() | ||
64 | { | ||
65 | return Async::null<void>(); | ||
66 | } | ||
67 | |||
63 | class ResourceFactory::Private | 68 | class ResourceFactory::Private |
64 | { | 69 | { |
65 | public: | 70 | public: |
diff --git a/common/resource.h b/common/resource.h index 52a28a6..bcce229 100644 --- a/common/resource.h +++ b/common/resource.h | |||
@@ -35,6 +35,7 @@ public: | |||
35 | 35 | ||
36 | virtual void processCommand(int commandId, const QByteArray &data, uint size, Pipeline *pipeline); | 36 | virtual void processCommand(int commandId, const QByteArray &data, uint size, Pipeline *pipeline); |
37 | virtual Async::Job<void> synchronizeWithSource(Pipeline *pipeline); | 37 | virtual Async::Job<void> synchronizeWithSource(Pipeline *pipeline); |
38 | virtual Async::Job<void> processAllMessages(); | ||
38 | 39 | ||
39 | virtual void configurePipeline(Pipeline *pipeline); | 40 | virtual void configurePipeline(Pipeline *pipeline); |
40 | 41 | ||
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 73a01ca..5d067c5 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "common/commandcompletion_generated.h" | 25 | #include "common/commandcompletion_generated.h" |
26 | #include "common/handshake_generated.h" | 26 | #include "common/handshake_generated.h" |
27 | #include "common/revisionupdate_generated.h" | 27 | #include "common/revisionupdate_generated.h" |
28 | #include "common/synchronize_generated.h" | ||
28 | 29 | ||
29 | #include <QCoreApplication> | 30 | #include <QCoreApplication> |
30 | #include <QDebug> | 31 | #include <QDebug> |
@@ -186,9 +187,12 @@ Async::Job<void> ResourceAccess::sendCommand(int commandId, flatbuffers::FlatBu | |||
186 | }); | 187 | }); |
187 | } | 188 | } |
188 | 189 | ||
189 | Async::Job<void> ResourceAccess::synchronizeResource() | 190 | Async::Job<void> ResourceAccess::synchronizeResource(bool sourceSync, bool localSync) |
190 | { | 191 | { |
191 | return sendCommand(Commands::SynchronizeCommand); | 192 | auto command = Akonadi2::CreateSynchronize(d->fbb, sourceSync, localSync); |
193 | Akonadi2::FinishSynchronizeBuffer(d->fbb, command); | ||
194 | return sendCommand(Commands::SynchronizeCommand, d->fbb); | ||
195 | d->fbb.Clear(); | ||
192 | } | 196 | } |
193 | 197 | ||
194 | void ResourceAccess::open() | 198 | void ResourceAccess::open() |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index a9e8c47..fbdd992 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -43,7 +43,7 @@ public: | |||
43 | 43 | ||
44 | Async::Job<void> sendCommand(int commandId); | 44 | Async::Job<void> sendCommand(int commandId); |
45 | Async::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb); | 45 | Async::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb); |
46 | Async::Job<void> synchronizeResource(); | 46 | Async::Job<void> synchronizeResource(bool remoteSync, bool localSync); |
47 | 47 | ||
48 | public Q_SLOTS: | 48 | public Q_SLOTS: |
49 | void open(); | 49 | void open(); |