From 9ea268a6d0f4054c31b2729ecd6cfcc9d07a2d6a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 24 Mar 2017 22:15:18 +0100 Subject: Implemented notification support in the model. This will allow us to fold things like progress and sync status directly into the model. Usecases are mail download progress and folder sync progress. Ideally we would also solve the resource/account state through this. --- common/synchronizer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'common/synchronizer.cpp') diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 4ed6e3a..ec896ed 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -292,13 +292,14 @@ void Synchronizer::flushComplete(const QByteArray &flushId) } } -void Synchronizer::emitNotification(Notification::NoticationType type, int code, const QString &message, const QByteArray &id) +void Synchronizer::emitNotification(Notification::NoticationType type, int code, const QString &message, const QByteArray &id, const QByteArrayList &entities) { Sink::Notification n; n.id = id; n.type = type; n.message = message; n.code = code; + n.entities = entities; emit notify(n); } @@ -328,6 +329,7 @@ KAsync::Job Synchronizer::processRequest(const SyncRequest &request) return KAsync::start([this, request] { SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query; emitNotification(Notification::Status, ApplicationDomain::BusyStatus, "Synchronization has started.", request.requestId); + emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.query.ids()); }).then(synchronizeWithSource(request.query)).then([this] { //Commit after every request, so implementations only have to commit more if they add a lot of data. commit(); @@ -335,10 +337,12 @@ KAsync::Job Synchronizer::processRequest(const SyncRequest &request) if (error) { //Emit notification with error SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage; + emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.query.ids()); emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId); return KAsync::error(error); } else { SinkLogCtx(mLogCtx) << "Done Synchronizing"; + emitNotification(Notification::Info, ApplicationDomain::SyncSuccess, {}, {}, request.query.ids()); emitNotification(Notification::Status, ApplicationDomain::ConnectedStatus, "Synchronization has ended.", request.requestId); return KAsync::null(); } -- cgit v1.2.3