summaryrefslogtreecommitdiffstats
path: root/examples/imapresource
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-27 11:49:07 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-27 11:49:07 +0200
commit8b69affc452cd828824ee77653f40d4c4f8d0658 (patch)
tree74232168ad724c2253f29ff0fa707580bbf030f1 /examples/imapresource
parentf99a8084b875815dc18ae67eeaed3919e8249463 (diff)
downloadsink-8b69affc452cd828824ee77653f40d4c4f8d0658.tar.gz
sink-8b69affc452cd828824ee77653f40d4c4f8d0658.zip
Emit notifications while a folder is being synced
Diffstat (limited to 'examples/imapresource')
-rw-r--r--examples/imapresource/imapresource.cpp13
1 files 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:
554 return KAsync::value(folders) 554 return KAsync::value(folders)
555 .serialEach<void>([=](const Folder &folder) { 555 .serialEach<void>([=](const Folder &folder) {
556 SinkLog() << "Syncing folder " << folder.path(); 556 SinkLog() << "Syncing folder " << folder.path();
557 //Emit notification that the folder is being synced.
558 //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.
559 const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRid(folder));
560 emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, {folderLocalId});
557 QDate dateFilter; 561 QDate dateFilter;
558 auto filter = query.getFilter<ApplicationDomain::Mail::Date>(); 562 auto filter = query.getFilter<ApplicationDomain::Mail::Date>();
559 if (filter.value.canConvert<QDate>()) { 563 if (filter.value.canConvert<QDate>()) {
@@ -561,8 +565,13 @@ public:
561 SinkLog() << " with date-range " << dateFilter; 565 SinkLog() << " with date-range " << dateFilter;
562 } 566 }
563 return synchronizeFolder(imap, folder, dateFilter, syncHeaders) 567 return synchronizeFolder(imap, folder, dateFilter, syncHeaders)
564 .onError([folder](const KAsync::Error &error) { 568 .then([=](const KAsync::Error &error) {
565 SinkWarning() << "Failed to sync folder: " << folder.path() << "Error: " << error.errorMessage; 569 if (error) {
570 SinkWarning() << "Failed to sync folder: " << folder.path() << "Error: " << error.errorMessage;
571 emitNotification(Notification::Info, ApplicationDomain::SyncError, {}, {}, {folderLocalId});
572 } else {
573 emitNotification(Notification::Info, ApplicationDomain::SyncSuccess, {}, {}, {folderLocalId});
574 }
566 }); 575 });
567 }); 576 });
568 }); 577 });