summaryrefslogtreecommitdiffstats
path: root/common/synchronizer.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-21 23:13:38 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-21 23:51:24 +0100
commit1d713d9e2dbaf27de9da087f9270d260dfc40c31 (patch)
tree666d8edd42e44df3eaa674a35b6e938b99c2f4b4 /common/synchronizer.h
parent0adba61a00491b96dadaa6d4719cb46831356222 (diff)
downloadsink-1d713d9e2dbaf27de9da087f9270d260dfc40c31.tar.gz
sink-1d713d9e2dbaf27de9da087f9270d260dfc40c31.zip
Folded the SourceWriteback into the Synchronizer.
By concentrating all communication to the source in one place we get rid of several oddities. * Quite a bit of duplication since both need access to the synchronizationStore and the source. * We currently have an akward locking in place because both classes access the ync store. This is not easier to resolve cleanly. * The live of resource implementers becomes easier. * An implementation could elect to not use changereplay and always do a full sync... (maybe?)
Diffstat (limited to 'common/synchronizer.h')
-rw-r--r--common/synchronizer.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/common/synchronizer.h b/common/synchronizer.h
index 47518ee..0a51f54 100644
--- a/common/synchronizer.h
+++ b/common/synchronizer.h
@@ -27,6 +27,8 @@
27#include <messagequeue.h> 27#include <messagequeue.h>
28#include <storage.h> 28#include <storage.h>
29#include <storage/entitystore.h> 29#include <storage/entitystore.h>
30#include "changereplay.h"
31#include "remoteidmap.h"
30 32
31namespace Sink { 33namespace Sink {
32class RemoteIdMap; 34class RemoteIdMap;
@@ -34,8 +36,9 @@ class RemoteIdMap;
34/** 36/**
35 * Synchronize and add what we don't already have to local queue 37 * Synchronize and add what we don't already have to local queue
36 */ 38 */
37class SINK_EXPORT Synchronizer 39class SINK_EXPORT Synchronizer : public ChangeReplay
38{ 40{
41 Q_OBJECT
39public: 42public:
40 Synchronizer(const Sink::ResourceContext &resourceContext); 43 Synchronizer(const Sink::ResourceContext &resourceContext);
41 virtual ~Synchronizer(); 44 virtual ~Synchronizer();
@@ -53,6 +56,16 @@ public:
53 Sink::Storage::DataStore::Transaction &syncTransaction(); 56 Sink::Storage::DataStore::Transaction &syncTransaction();
54 57
55protected: 58protected:
59 ///Base implementation calls the replay$Type calls
60 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE;
61 virtual bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE;
62
63protected:
64 ///Implement to write back changes to the server
65 virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Mail &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &);
66 virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Folder &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &);
67
68protected:
56 ///Calls the callback to enqueue the command 69 ///Calls the callback to enqueue the command
57 void enqueueCommand(int commandId, const QByteArray &data); 70 void enqueueCommand(int commandId, const QByteArray &data);
58 71