summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/synchronizer.cpp6
-rw-r--r--common/synchronizer.h4
-rw-r--r--examples/imapresource/imapresource.cpp17
3 files changed, 13 insertions, 14 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index ec896ed..329841b 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -329,7 +329,7 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
329 return KAsync::start([this, request] { 329 return KAsync::start([this, request] {
330 SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query; 330 SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query;
331 emitNotification(Notification::Status, ApplicationDomain::BusyStatus, "Synchronization has started.", request.requestId); 331 emitNotification(Notification::Status, ApplicationDomain::BusyStatus, "Synchronization has started.", request.requestId);
332 emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.query.ids()); 332 emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.applicableEntities);
333 }).then(synchronizeWithSource(request.query)).then([this] { 333 }).then(synchronizeWithSource(request.query)).then([this] {
334 //Commit after every request, so implementations only have to commit more if they add a lot of data. 334 //Commit after every request, so implementations only have to commit more if they add a lot of data.
335 commit(); 335 commit();
@@ -337,12 +337,12 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
337 if (error) { 337 if (error) {
338 //Emit notification with error 338 //Emit notification with error
339 SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage; 339 SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage;
340 emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.query.ids()); 340 emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.applicableEntities);
341 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId); 341 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId);
342 return KAsync::error(error); 342 return KAsync::error(error);
343 } else { 343 } else {
344 SinkLogCtx(mLogCtx) << "Done Synchronizing"; 344 SinkLogCtx(mLogCtx) << "Done Synchronizing";
345 emitNotification(Notification::Info, ApplicationDomain::SyncSuccess, {}, {}, request.query.ids()); 345 emitNotification(Notification::Info, ApplicationDomain::SyncSuccess, {}, {}, request.applicableEntities);
346 emitNotification(Notification::Status, ApplicationDomain::ConnectedStatus, "Synchronization has ended.", request.requestId); 346 emitNotification(Notification::Status, ApplicationDomain::ConnectedStatus, "Synchronization has ended.", request.requestId);
347 return KAsync::null(); 347 return KAsync::null();
348 } 348 }
diff --git a/common/synchronizer.h b/common/synchronizer.h
index e3dbddc..751542d 100644
--- a/common/synchronizer.h
+++ b/common/synchronizer.h
@@ -134,7 +134,8 @@ protected:
134 : requestId(requestId_), 134 : requestId(requestId_),
135 requestType(Synchronization), 135 requestType(Synchronization),
136 options(o), 136 options(o),
137 query(q) 137 query(q),
138 applicableEntities(q.ids())
138 { 139 {
139 } 140 }
140 141
@@ -155,6 +156,7 @@ protected:
155 RequestType requestType; 156 RequestType requestType;
156 RequestOptions options = NoOptions; 157 RequestOptions options = NoOptions;
157 Sink::QueryBase query; 158 Sink::QueryBase query;
159 QByteArrayList applicableEntities;
158 }; 160 };
159 161
160 /** 162 /**
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 });