From b4df9eb5f1f4a0ac2b1272fc34d4b8aad473008b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 5 Jul 2016 15:22:10 +0200 Subject: Prepare for making the resource status available --- common/genericresource.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'common/genericresource.cpp') 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 [=]() { Log_area("resource.inspection") << "Inspection was successful: " << inspectionType << inspectionId << entityId; Sink::Notification n; - n.type = Sink::Commands::NotificationType_Inspection; + n.type = Sink::Notification::Inspection; n.id = inspectionId; - n.code = Sink::Commands::NotificationCode_Success; + n.code = Sink::Notification::Success; emit notify(n); }, [=](int code, const QString &message) { Warning_area("resource.inspection") << "Inspection failed: " << inspectionType << inspectionId << entityId << message; Sink::Notification n; - n.type = Sink::Commands::NotificationType_Inspection; + n.type = Sink::Notification::Inspection; n.message = message; n.id = inspectionId; - n.code = Sink::Commands::NotificationCode_Failure; + n.code = Sink::Notification::Failure; emit notify(n); }) .exec(); @@ -283,6 +283,23 @@ GenericResource::GenericResource(const QByteArray &resourceType, const QByteArra QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); mClientLowerBoundRevision = mPipeline->cleanedUpRevision(); + QObject::connect(mChangeReplay.data(), &ChangeReplay::replayingChanges, [this]() { + Sink::Notification n; + n.id = "changereplay"; + n.type = Sink::Notification::Status; + n.message = "Replaying changes."; + n.code = Sink::ApplicationDomain::BusyStatus; + emit notify(n); + }); + QObject::connect(mChangeReplay.data(), &ChangeReplay::changesReplayed, [this]() { + Sink::Notification n; + n.id = "changereplay"; + n.type = Sink::Notification::Status; + n.message = "All changes have been replayed."; + n.code = Sink::ApplicationDomain::ConnectedStatus; + emit notify(n); + }); + mCommitQueueTimer.setInterval(sCommitInterval); mCommitQueueTimer.setSingleShot(true); QObject::connect(&mCommitQueueTimer, &QTimer::timeout, &mUserQueue, &MessageQueue::commit); @@ -399,12 +416,27 @@ void GenericResource::processCommand(int commandId, const QByteArray &data) KAsync::Job GenericResource::synchronizeWithSource() { return KAsync::start([this](KAsync::Future &future) { + + Sink::Notification n; + n.id = "sync"; + n.type = Sink::Notification::Status; + n.message = "Synchronization has started."; + n.code = Sink::ApplicationDomain::BusyStatus; + emit notify(n); + Log() << " Synchronizing"; // Changereplay would deadlock otherwise when trying to open the synchronization store enableChangeReplay(false); mSynchronizer->synchronize() .then([this, &future]() { Log() << "Done Synchronizing"; + Sink::Notification n; + n.id = "sync"; + n.type = Sink::Notification::Status; + n.message = "Synchronization has ended."; + n.code = Sink::ApplicationDomain::ConnectedStatus; + emit notify(n); + enableChangeReplay(true); future.setFinished(); }, [this, &future](int errorCode, const QString &error) { -- cgit v1.2.3