summaryrefslogtreecommitdiffstats
path: root/common/synchronizer.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-04 11:40:24 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-04 11:40:24 +0200
commit6adf9a4734f15a2c0fa199897f76ded4659b83b7 (patch)
tree9f9c22c28e897f973d70dba29ae41bc92be51ce6 /common/synchronizer.cpp
parentfeef3bd5c1562a52c274fa07af51c716e5362054 (diff)
downloadsink-6adf9a4734f15a2c0fa199897f76ded4659b83b7.tar.gz
sink-6adf9a4734f15a2c0fa199897f76ded4659b83b7.zip
Added progress notification
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r--common/synchronizer.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index 3e7bd30..58e5e7a 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -304,9 +304,21 @@ void Synchronizer::emitNotification(Notification::NoticationType type, int code,
304 emit notify(n); 304 emit notify(n);
305} 305}
306 306
307void Synchronizer::emitProgressNotification(Notification::NoticationType type, int progress, int total, const QByteArray &id, const QByteArrayList &entities)
308{
309 Sink::Notification n;
310 n.id = id;
311 n.type = type;
312 n.progress = progress;
313 n.total = total;
314 n.entities = entities;
315 emit notify(n);
316}
317
307void Synchronizer::reportProgress(int progress, int total) 318void Synchronizer::reportProgress(int progress, int total)
308{ 319{
309 SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total; 320 SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total;
321 emitProgressNotification(Notification::Progress, progress, total, mCurrentRequest.requestId, mCurrentRequest.applicableEntities);
310} 322}
311 323
312void Synchronizer::setStatusFromResult(const KAsync::Error &error, const QString &s, const QByteArray &requestId) 324void Synchronizer::setStatusFromResult(const KAsync::Error &error, const QString &s, const QByteArray &requestId)
@@ -465,13 +477,15 @@ KAsync::Job<void> Synchronizer::processSyncQueue()
465 if (request.requestType == Synchronizer::SyncRequest::Synchronization) { 477 if (request.requestType == Synchronizer::SyncRequest::Synchronization) {
466 setBusy(true, "Synchronization has started.", request.requestId); 478 setBusy(true, "Synchronization has started.", request.requestId);
467 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) { 479 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) {
468 setBusy(true, "ChangeReplay has started.", "changereplay"); 480 setBusy(true, "ChangeReplay has started.", request.requestId);
469 } 481 }
482 mCurrentRequest = request;
470 }) 483 })
471 .then(processRequest(request)) 484 .then(processRequest(request))
472 .then<void>([this, request](const KAsync::Error &error) { 485 .then<void>([this, request](const KAsync::Error &error) {
473 SinkTraceCtx(mLogCtx) << "Sync request processed"; 486 SinkTraceCtx(mLogCtx) << "Sync request processed";
474 setBusy(false, {}, request.requestId); 487 setBusy(false, {}, request.requestId);
488 mCurrentRequest = {};
475 mEntityStore->abortTransaction(); 489 mEntityStore->abortTransaction();
476 mSyncTransaction.abort(); 490 mSyncTransaction.abort();
477 mMessageQueue->commit(); 491 mMessageQueue->commit();
@@ -516,7 +530,7 @@ void Synchronizer::revisionChanged()
516 return; 530 return;
517 } 531 }
518 } 532 }
519 mSyncRequestQueue << Synchronizer::SyncRequest{Synchronizer::SyncRequest::ChangeReplay}; 533 mSyncRequestQueue << Synchronizer::SyncRequest{Synchronizer::SyncRequest::ChangeReplay, "changereplay"};
520 processSyncQueue().exec(); 534 processSyncQueue().exec();
521} 535}
522 536