diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-28 09:26:50 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-28 09:26:50 +0200 |
commit | 547e5e29cbfc12474ab45768ff0d9342882b2633 (patch) | |
tree | 6728cb767b5c3a2ce450a6621815cc7fd8c0bd96 /examples | |
parent | 8b69affc452cd828824ee77653f40d4c4f8d0658 (diff) | |
download | sink-547e5e29cbfc12474ab45768ff0d9342882b2633.tar.gz sink-547e5e29cbfc12474ab45768ff0d9342882b2633.zip |
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).
Diffstat (limited to 'examples')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
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: | |||
382 | { | 382 | { |
383 | QList<Synchronizer::SyncRequest> list; | 383 | QList<Synchronizer::SyncRequest> list; |
384 | if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { | 384 | if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { |
385 | list << Synchronizer::SyncRequest{applyMailDefaults(query)}; | 385 | auto request = Synchronizer::SyncRequest{applyMailDefaults(query)}; |
386 | if (query.hasFilter(ApplicationDomain::Mail::Folder::name)) { | ||
387 | request.applicableEntities << query.getFilter(ApplicationDomain::Mail::Folder::name).value.toByteArray(); | ||
388 | } | ||
389 | list << request; | ||
386 | } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { | 390 | } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { |
387 | list << Synchronizer::SyncRequest{query}; | 391 | list << Synchronizer::SyncRequest{query}; |
388 | } else { | 392 | } else { |
@@ -556,8 +560,6 @@ public: | |||
556 | SinkLog() << "Syncing folder " << folder.path(); | 560 | SinkLog() << "Syncing folder " << folder.path(); |
557 | //Emit notification that the folder is being synced. | 561 | //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. | 562 | //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}); | ||
561 | QDate dateFilter; | 563 | QDate dateFilter; |
562 | auto filter = query.getFilter<ApplicationDomain::Mail::Date>(); | 564 | auto filter = query.getFilter<ApplicationDomain::Mail::Date>(); |
563 | if (filter.value.canConvert<QDate>()) { | 565 | if (filter.value.canConvert<QDate>()) { |
@@ -565,13 +567,8 @@ public: | |||
565 | SinkLog() << " with date-range " << dateFilter; | 567 | SinkLog() << " with date-range " << dateFilter; |
566 | } | 568 | } |
567 | return synchronizeFolder(imap, folder, dateFilter, syncHeaders) | 569 | return synchronizeFolder(imap, folder, dateFilter, syncHeaders) |
568 | .then([=](const KAsync::Error &error) { | 570 | .onError([=](const KAsync::Error &error) { |
569 | if (error) { | 571 | SinkWarning() << "Failed to sync folder: " << folder.path() << "Error: " << error.errorMessage; |
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 | } | ||
575 | }); | 572 | }); |
576 | }); | 573 | }); |
577 | }); | 574 | }); |