summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/commandprocessor.cpp18
-rw-r--r--common/synchronizer.cpp31
2 files changed, 29 insertions, 20 deletions
diff --git a/common/commandprocessor.cpp b/common/commandprocessor.cpp
index 2d9e93c..3507ef1 100644
--- a/common/commandprocessor.cpp
+++ b/common/commandprocessor.cpp
@@ -295,24 +295,6 @@ void CommandProcessor::setSynchronizer(const QSharedPointer<Synchronizer> &synch
295 mSynchronizer->setup([this](int commandId, const QByteArray &data) { 295 mSynchronizer->setup([this](int commandId, const QByteArray &data) {
296 enqueueCommand(mSynchronizerQueue, commandId, data); 296 enqueueCommand(mSynchronizerQueue, commandId, data);
297 }, mSynchronizerQueue); 297 }, mSynchronizerQueue);
298
299 QObject::connect(mSynchronizer.data(), &Synchronizer::replayingChanges, [this]() {
300 Sink::Notification n;
301 n.id = "changereplay";
302 n.type = Notification::Status;
303 n.message = "Replaying changes.";
304 n.code = ApplicationDomain::BusyStatus;
305 emit notify(n);
306 });
307 QObject::connect(mSynchronizer.data(), &Synchronizer::changesReplayed, [this]() {
308 Sink::Notification n;
309 n.id = "changereplay";
310 n.type = Notification::Status;
311 n.message = "All changes have been replayed.";
312 n.code = ApplicationDomain::ConnectedStatus;
313 emit notify(n);
314 });
315
316 QObject::connect(mSynchronizer.data(), &Synchronizer::notify, this, &CommandProcessor::notify); 298 QObject::connect(mSynchronizer.data(), &Synchronizer::notify, this, &CommandProcessor::notify);
317 setOldestUsedRevision(mSynchronizer->getLastReplayedRevision()); 299 setOldestUsedRevision(mSynchronizer->getLastReplayedRevision());
318} 300}
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index 329841b..d3de20b 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -337,8 +337,12 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
337 if (error) { 337 if (error) {
338 //Emit notification with error 338 //Emit notification with error
339 SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage; 339 SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage;
340 if (error.errorCode == ApplicationDomain::ConnectionError) {
341 emitNotification(Notification::Status, ApplicationDomain::OfflineStatus, "Synchronization has ended.", request.requestId);
342 } else {
343 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId);
344 }
340 emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.applicableEntities); 345 emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.applicableEntities);
341 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId);
342 return KAsync::error(error); 346 return KAsync::error(error);
343 } else { 347 } else {
344 SinkLogCtx(mLogCtx) << "Done Synchronizing"; 348 SinkLogCtx(mLogCtx) << "Done Synchronizing";
@@ -363,7 +367,30 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
363 } 367 }
364 }); 368 });
365 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) { 369 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) {
366 return replayNextRevision(); 370 if (ChangeReplay::allChangesReplayed()) {
371 return KAsync::null();
372 } else {
373 return KAsync::start([this, request] {
374 SinkLogCtx(mLogCtx) << "Replaying changes.";
375 emitNotification(Notification::Status, ApplicationDomain::BusyStatus, "Changereplay has started.", "changereplay");
376 })
377 .then(replayNextRevision())
378 .then<void>([this, request](const KAsync::Error &error) {
379 if (error) {
380 SinkWarningCtx(mLogCtx) << "Changereplay failed: " << error.errorMessage;
381 if (error.errorCode == ApplicationDomain::ConnectionError) {
382 emitNotification(Notification::Status, ApplicationDomain::OfflineStatus, "Changereplay has ended.", "changereplay");
383 } else {
384 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Changereplay has ended.", "changereplay");
385 }
386 return KAsync::error(error);
387 } else {
388 SinkLogCtx(mLogCtx) << "Done replaying changes";
389 emitNotification(Notification::Status, ApplicationDomain::ConnectedStatus, "All changes have been replayed.", "changereplay");
390 return KAsync::null();
391 }
392 });
393 }
367 } else { 394 } else {
368 SinkWarningCtx(mLogCtx) << "Unknown request type: " << request.requestType; 395 SinkWarningCtx(mLogCtx) << "Unknown request type: " << request.requestType;
369 return KAsync::error(KAsync::Error{"Unknown request type."}); 396 return KAsync::error(KAsync::Error{"Unknown request type."});