summaryrefslogtreecommitdiffstats
path: root/common/genericresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-05 15:22:10 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-05 15:22:10 +0200
commitb4df9eb5f1f4a0ac2b1272fc34d4b8aad473008b (patch)
tree9abf529061432031afefd6a8bfa821a9779f763d /common/genericresource.cpp
parentf9379318d801df204cc50385c5eca1f28e91755e (diff)
downloadsink-b4df9eb5f1f4a0ac2b1272fc34d4b8aad473008b.tar.gz
sink-b4df9eb5f1f4a0ac2b1272fc34d4b8aad473008b.zip
Prepare for making the resource status available
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r--common/genericresource.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp
index c06c22a..5522174 100644
--- a/common/genericresource.cpp
+++ b/common/genericresource.cpp
@@ -260,18 +260,18 @@ GenericResource::GenericResource(const QByteArray &resourceType, const QByteArra
260 [=]() { 260 [=]() {
261 Log_area("resource.inspection") << "Inspection was successful: " << inspectionType << inspectionId << entityId; 261 Log_area("resource.inspection") << "Inspection was successful: " << inspectionType << inspectionId << entityId;
262 Sink::Notification n; 262 Sink::Notification n;
263 n.type = Sink::Commands::NotificationType_Inspection; 263 n.type = Sink::Notification::Inspection;
264 n.id = inspectionId; 264 n.id = inspectionId;
265 n.code = Sink::Commands::NotificationCode_Success; 265 n.code = Sink::Notification::Success;
266 emit notify(n); 266 emit notify(n);
267 }, 267 },
268 [=](int code, const QString &message) { 268 [=](int code, const QString &message) {
269 Warning_area("resource.inspection") << "Inspection failed: " << inspectionType << inspectionId << entityId << message; 269 Warning_area("resource.inspection") << "Inspection failed: " << inspectionType << inspectionId << entityId << message;
270 Sink::Notification n; 270 Sink::Notification n;
271 n.type = Sink::Commands::NotificationType_Inspection; 271 n.type = Sink::Notification::Inspection;
272 n.message = message; 272 n.message = message;
273 n.id = inspectionId; 273 n.id = inspectionId;
274 n.code = Sink::Commands::NotificationCode_Failure; 274 n.code = Sink::Notification::Failure;
275 emit notify(n); 275 emit notify(n);
276 }) 276 })
277 .exec(); 277 .exec();
@@ -283,6 +283,23 @@ GenericResource::GenericResource(const QByteArray &resourceType, const QByteArra
283 QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); 283 QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated);
284 mClientLowerBoundRevision = mPipeline->cleanedUpRevision(); 284 mClientLowerBoundRevision = mPipeline->cleanedUpRevision();
285 285
286 QObject::connect(mChangeReplay.data(), &ChangeReplay::replayingChanges, [this]() {
287 Sink::Notification n;
288 n.id = "changereplay";
289 n.type = Sink::Notification::Status;
290 n.message = "Replaying changes.";
291 n.code = Sink::ApplicationDomain::BusyStatus;
292 emit notify(n);
293 });
294 QObject::connect(mChangeReplay.data(), &ChangeReplay::changesReplayed, [this]() {
295 Sink::Notification n;
296 n.id = "changereplay";
297 n.type = Sink::Notification::Status;
298 n.message = "All changes have been replayed.";
299 n.code = Sink::ApplicationDomain::ConnectedStatus;
300 emit notify(n);
301 });
302
286 mCommitQueueTimer.setInterval(sCommitInterval); 303 mCommitQueueTimer.setInterval(sCommitInterval);
287 mCommitQueueTimer.setSingleShot(true); 304 mCommitQueueTimer.setSingleShot(true);
288 QObject::connect(&mCommitQueueTimer, &QTimer::timeout, &mUserQueue, &MessageQueue::commit); 305 QObject::connect(&mCommitQueueTimer, &QTimer::timeout, &mUserQueue, &MessageQueue::commit);
@@ -399,12 +416,27 @@ void GenericResource::processCommand(int commandId, const QByteArray &data)
399KAsync::Job<void> GenericResource::synchronizeWithSource() 416KAsync::Job<void> GenericResource::synchronizeWithSource()
400{ 417{
401 return KAsync::start<void>([this](KAsync::Future<void> &future) { 418 return KAsync::start<void>([this](KAsync::Future<void> &future) {
419
420 Sink::Notification n;
421 n.id = "sync";
422 n.type = Sink::Notification::Status;
423 n.message = "Synchronization has started.";
424 n.code = Sink::ApplicationDomain::BusyStatus;
425 emit notify(n);
426
402 Log() << " Synchronizing"; 427 Log() << " Synchronizing";
403 // Changereplay would deadlock otherwise when trying to open the synchronization store 428 // Changereplay would deadlock otherwise when trying to open the synchronization store
404 enableChangeReplay(false); 429 enableChangeReplay(false);
405 mSynchronizer->synchronize() 430 mSynchronizer->synchronize()
406 .then<void>([this, &future]() { 431 .then<void>([this, &future]() {
407 Log() << "Done Synchronizing"; 432 Log() << "Done Synchronizing";
433 Sink::Notification n;
434 n.id = "sync";
435 n.type = Sink::Notification::Status;
436 n.message = "Synchronization has ended.";
437 n.code = Sink::ApplicationDomain::ConnectedStatus;
438 emit notify(n);
439
408 enableChangeReplay(true); 440 enableChangeReplay(true);
409 future.setFinished(); 441 future.setFinished();
410 }, [this, &future](int errorCode, const QString &error) { 442 }, [this, &future](int errorCode, const QString &error) {