From 8b69affc452cd828824ee77653f40d4c4f8d0658 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 27 Mar 2017 11:49:07 +0200 Subject: Emit notifications while a folder is being synced --- examples/imapresource/imapresource.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 077795a..eef0de0 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -554,6 +554,10 @@ public: return KAsync::value(folders) .serialEach([=](const Folder &folder) { SinkLog() << "Syncing folder " << folder.path(); + //Emit notification that the folder is being synced. + //The synchronizer can't do that because it has no concept of the folder filter on a mail sync scope meaning that the folder is being synchronized. + const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRid(folder)); + emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, {folderLocalId}); QDate dateFilter; auto filter = query.getFilter(); if (filter.value.canConvert()) { @@ -561,8 +565,13 @@ public: SinkLog() << " with date-range " << dateFilter; } return synchronizeFolder(imap, folder, dateFilter, syncHeaders) - .onError([folder](const KAsync::Error &error) { - SinkWarning() << "Failed to sync folder: " << folder.path() << "Error: " << error.errorMessage; + .then([=](const KAsync::Error &error) { + if (error) { + SinkWarning() << "Failed to sync folder: " << folder.path() << "Error: " << error.errorMessage; + emitNotification(Notification::Info, ApplicationDomain::SyncError, {}, {}, {folderLocalId}); + } else { + emitNotification(Notification::Info, ApplicationDomain::SyncSuccess, {}, {}, {folderLocalId}); + } }); }); }); -- cgit v1.2.3