From 3fc8ce958fc244e64a3a3a92f3b1440aae04133b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 25 Jan 2015 11:23:08 +0100 Subject: 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. --- common/CMakeLists.txt | 1 + common/clientapi.h | 3 ++- common/commands/synchronize.fbs | 8 ++++++++ common/resource.cpp | 5 +++++ common/resource.h | 1 + common/resourceaccess.cpp | 8 ++++++-- common/resourceaccess.h | 2 +- 7 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 common/commands/synchronize.fbs (limited to 'common') 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( commands/handshake commands/modifyentity commands/revisionupdate + commands/synchronize domain/event entity 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; class Query { public: - Query() : syncOnDemand(true) {} + Query() : syncOnDemand(true), processAll(false) {} //Could also be a propertyFilter QStringList resources; //Could also be a propertyFilter @@ -307,6 +307,7 @@ public: //Properties to retrieve QSet requestedProperties; bool syncOnDemand; + bool processAll; }; 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 @@ +namespace Akonadi2; + +table Synchronize { + sourceSync: bool; //Synchronize with source + localSync: bool; //Ensure all queues are processed so the local state is up-to date. +} + +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 Resource::synchronizeWithSource(Pipeline *pipeline) }); } +Async::Job Resource::processAllMessages() +{ + return Async::null(); +} + class ResourceFactory::Private { 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: virtual void processCommand(int commandId, const QByteArray &data, uint size, Pipeline *pipeline); virtual Async::Job synchronizeWithSource(Pipeline *pipeline); + virtual Async::Job processAllMessages(); virtual void configurePipeline(Pipeline *pipeline); 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 @@ #include "common/commandcompletion_generated.h" #include "common/handshake_generated.h" #include "common/revisionupdate_generated.h" +#include "common/synchronize_generated.h" #include #include @@ -186,9 +187,12 @@ Async::Job ResourceAccess::sendCommand(int commandId, flatbuffers::FlatBu }); } -Async::Job ResourceAccess::synchronizeResource() +Async::Job ResourceAccess::synchronizeResource(bool sourceSync, bool localSync) { - return sendCommand(Commands::SynchronizeCommand); + auto command = Akonadi2::CreateSynchronize(d->fbb, sourceSync, localSync); + Akonadi2::FinishSynchronizeBuffer(d->fbb, command); + return sendCommand(Commands::SynchronizeCommand, d->fbb); + d->fbb.Clear(); } 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: Async::Job sendCommand(int commandId); Async::Job sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb); - Async::Job synchronizeResource(); + Async::Job synchronizeResource(bool remoteSync, bool localSync); public Q_SLOTS: void open(); -- cgit v1.2.3