From 547e5e29cbfc12474ab45768ff0d9342882b2633 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 28 Mar 2017 09:26:50 +0200 Subject: Track the entities that this request applies to directly in the syncrequest That way we can do the notification emitting in the synchronizer and it keeps working even if the login already fails (so the synchronizing code would never be executed). --- examples/imapresource/imapresource.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'examples/imapresource') diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index eef0de0..175f75a 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -382,7 +382,11 @@ public: { QList list; if (query.type() == ApplicationDomain::getTypeName()) { - list << Synchronizer::SyncRequest{applyMailDefaults(query)}; + auto request = Synchronizer::SyncRequest{applyMailDefaults(query)}; + if (query.hasFilter(ApplicationDomain::Mail::Folder::name)) { + request.applicableEntities << query.getFilter(ApplicationDomain::Mail::Folder::name).value.toByteArray(); + } + list << request; } else if (query.type() == ApplicationDomain::getTypeName()) { list << Synchronizer::SyncRequest{query}; } else { @@ -556,8 +560,6 @@ public: 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()) { @@ -565,13 +567,8 @@ public: SinkLog() << " with date-range " << dateFilter; } return synchronizeFolder(imap, folder, dateFilter, syncHeaders) - .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}); - } + .onError([=](const KAsync::Error &error) { + SinkWarning() << "Failed to sync folder: " << folder.path() << "Error: " << error.errorMessage; }); }); }); -- cgit v1.2.3