diff options
Diffstat (limited to 'common/synchronizer.h')
-rw-r--r-- | common/synchronizer.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/common/synchronizer.h b/common/synchronizer.h index 120a8a5..b1ee122 100644 --- a/common/synchronizer.h +++ b/common/synchronizer.h | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "sink_export.h" | 22 | #include "sink_export.h" |
23 | #include <QObject> | 23 | #include <QObject> |
24 | #include <QStack> | ||
24 | #include <KAsync/Async> | 25 | #include <KAsync/Async> |
25 | #include <domainadaptor.h> | 26 | #include <domainadaptor.h> |
26 | #include <query.h> | 27 | #include <query.h> |
@@ -73,9 +74,9 @@ protected: | |||
73 | protected: | 74 | protected: |
74 | ///Implement to write back changes to the server | 75 | ///Implement to write back changes to the server |
75 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Contact &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); | 76 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Contact &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); |
77 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Addressbook &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); | ||
76 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Mail &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); | 78 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Mail &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); |
77 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Folder &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); | 79 | virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Folder &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &); |
78 | |||
79 | protected: | 80 | protected: |
80 | ///Calls the callback to enqueue the command | 81 | ///Calls the callback to enqueue the command |
81 | void enqueueCommand(int commandId, const QByteArray &data); | 82 | void enqueueCommand(int commandId, const QByteArray &data); |
@@ -134,7 +135,8 @@ protected: | |||
134 | : requestId(requestId_), | 135 | : requestId(requestId_), |
135 | requestType(Synchronization), | 136 | requestType(Synchronization), |
136 | options(o), | 137 | options(o), |
137 | query(q) | 138 | query(q), |
139 | applicableEntities(q.ids()) | ||
138 | { | 140 | { |
139 | } | 141 | } |
140 | 142 | ||
@@ -155,6 +157,7 @@ protected: | |||
155 | RequestType requestType; | 157 | RequestType requestType; |
156 | RequestOptions options = NoOptions; | 158 | RequestOptions options = NoOptions; |
157 | Sink::QueryBase query; | 159 | Sink::QueryBase query; |
160 | QByteArrayList applicableEntities; | ||
158 | }; | 161 | }; |
159 | 162 | ||
160 | /** | 163 | /** |
@@ -175,9 +178,28 @@ protected: | |||
175 | */ | 178 | */ |
176 | virtual QList<Synchronizer::SyncRequest> getSyncRequests(const Sink::QueryBase &query); | 179 | virtual QList<Synchronizer::SyncRequest> getSyncRequests(const Sink::QueryBase &query); |
177 | 180 | ||
181 | /** | ||
182 | * This allows the synchronizer to merge new requests with existing requests in the queue. | ||
183 | */ | ||
184 | virtual void mergeIntoQueue(const Synchronizer::SyncRequest &request, QList<Synchronizer::SyncRequest> &queue); | ||
185 | |||
186 | void emitNotification(Notification::NoticationType type, int code, const QString &message, const QByteArray &id = QByteArray{}, const QByteArrayList &entiteis = QByteArrayList{}); | ||
187 | |||
188 | /** | ||
189 | * Report progress for current task | ||
190 | */ | ||
191 | void reportProgress(int progress, int total); | ||
192 | |||
178 | protected: | 193 | protected: |
179 | Sink::Log::Context mLogCtx; | 194 | Sink::Log::Context mLogCtx; |
195 | |||
180 | private: | 196 | private: |
197 | QStack<ApplicationDomain::Status> mCurrentState; | ||
198 | void setStatusFromResult(const KAsync::Error &error, const QString &s, const QByteArray &requestId); | ||
199 | void setStatus(ApplicationDomain::Status busy, const QString &reason, const QByteArray requestId); | ||
200 | void resetStatus(const QByteArray requestId); | ||
201 | void setBusy(bool busy, const QString &reason, const QByteArray requestId); | ||
202 | |||
181 | void modifyIfChanged(Storage::EntityStore &store, const QByteArray &bufferType, const QByteArray &sinkId, const Sink::ApplicationDomain::ApplicationDomainType &entity); | 203 | void modifyIfChanged(Storage::EntityStore &store, const QByteArray &bufferType, const QByteArray &sinkId, const Sink::ApplicationDomain::ApplicationDomainType &entity); |
182 | KAsync::Job<void> processRequest(const SyncRequest &request); | 204 | KAsync::Job<void> processRequest(const SyncRequest &request); |
183 | KAsync::Job<void> processSyncQueue(); | 205 | KAsync::Job<void> processSyncQueue(); |