From 6a072b2dcf23cbcdb210f2bd5c273ea0f425b188 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 29 Nov 2016 11:27:04 +0100 Subject: The synchronization call can be sync. ... because we really just enqueue the request and then wait for the notification. --- common/commandprocessor.cpp | 48 +++++---------------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'common/commandprocessor.cpp') diff --git a/common/commandprocessor.cpp b/common/commandprocessor.cpp index fccff22..8eb0ef1 100644 --- a/common/commandprocessor.cpp +++ b/common/commandprocessor.cpp @@ -128,17 +128,7 @@ void CommandProcessor::processSynchronizeCommand(const QByteArray &data) QDataStream stream(&data, QIODevice::ReadOnly); stream >> query; } - synchronizeWithSource(query) - .then([timer](const KAsync::Error &error) { - if (error) { - SinkWarning() << "Sync failed: " << error.errorMessage; - return KAsync::error(error); - } else { - SinkTrace() << "Sync took " << Sink::Log::TraceTime(timer->elapsed()); - return KAsync::null(); - } - }) - .exec(); + mSynchronizer->synchronize(query); } else { SinkWarning() << "received invalid command"; } @@ -156,34 +146,6 @@ void CommandProcessor::processSynchronizeCommand(const QByteArray &data) // loadResource().setLowerBoundRevision(lowerBoundRevision()); // } -KAsync::Job CommandProcessor::synchronizeWithSource(const Sink::QueryBase &query) -{ - return KAsync::start([this, query] { - Sink::Notification n; - n.id = "sync"; - n.type = Sink::Notification::Status; - n.message = "Synchronization has started."; - n.code = Sink::ApplicationDomain::BusyStatus; - emit notify(n); - - SinkLog() << " Synchronizing"; - return mSynchronizer->synchronize(query) - .then([this](const KAsync::Error &error) { - if (!error) { - SinkLog() << "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); - return KAsync::null(); - } - return KAsync::error(error); - }); - }); -} - void CommandProcessor::setOldestUsedRevision(qint64 revision) { mLowerBoundRevision = revision; @@ -337,17 +299,17 @@ void CommandProcessor::setSynchronizer(const QSharedPointer &synch QObject::connect(mSynchronizer.data(), &Synchronizer::replayingChanges, [this]() { Sink::Notification n; n.id = "changereplay"; - n.type = Sink::Notification::Status; + n.type = Notification::Status; n.message = "Replaying changes."; - n.code = Sink::ApplicationDomain::BusyStatus; + n.code = ApplicationDomain::BusyStatus; emit notify(n); }); QObject::connect(mSynchronizer.data(), &Synchronizer::changesReplayed, [this]() { Sink::Notification n; n.id = "changereplay"; - n.type = Sink::Notification::Status; + n.type = Notification::Status; n.message = "All changes have been replayed."; - n.code = Sink::ApplicationDomain::ConnectedStatus; + n.code = ApplicationDomain::ConnectedStatus; emit notify(n); }); -- cgit v1.2.3