diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-21 23:13:38 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-21 23:51:24 +0100 |
commit | 1d713d9e2dbaf27de9da087f9270d260dfc40c31 (patch) | |
tree | 666d8edd42e44df3eaa674a35b6e938b99c2f4b4 /common/synchronizer.h | |
parent | 0adba61a00491b96dadaa6d4719cb46831356222 (diff) | |
download | sink-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.h | 15 |
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 | ||
31 | namespace Sink { | 33 | namespace Sink { |
32 | class RemoteIdMap; | 34 | class 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 | */ |
37 | class SINK_EXPORT Synchronizer | 39 | class SINK_EXPORT Synchronizer : public ChangeReplay |
38 | { | 40 | { |
41 | Q_OBJECT | ||
39 | public: | 42 | public: |
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 | ||
55 | protected: | 58 | protected: |
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 | |||
63 | protected: | ||
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 | |||
68 | protected: | ||
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 | ||