summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapresource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r--examples/imapresource/imapresource.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index c195cfb..be8ade5 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -433,25 +433,22 @@ public:
433 433
434 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE 434 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE
435 { 435 {
436 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort);
436 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { 437 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) {
437 return KAsync::start<void>([this]() { 438 return login(imap)
438 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 439 .then<QVector<Folder>>([=]() {
439 auto job = login(imap); 440 auto folderList = QSharedPointer<QVector<Folder>>::create();
440 job = job.then<QVector<Folder>>([this, imap]() { 441 return imap->fetchFolders([folderList](const Folder &folder) {
441 auto folderList = QSharedPointer<QVector<Folder>>::create(); 442 *folderList << folder;
442 return imap->fetchFolders([folderList](const Folder &folder) { 443 })
443 *folderList << folder; 444 .onError([](const KAsync::Error &error) {
444 }) 445 SinkWarning() << "Folder list sync failed.";
445 .onError([](const KAsync::Error &error) { 446 })
446 SinkWarning() << "Folder list sync failed."; 447 .syncThen<QVector<Folder>>([this, folderList]() {
447 }) 448 synchronizeFolders(*folderList);
448 .syncThen<QVector<Folder>>([this, folderList]() { 449 commit();
449 synchronizeFolders(*folderList); 450 return *folderList;
450 commit();
451 return *folderList;
452 });
453 }); 451 });
454 return job;
455 }); 452 });
456 } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { 453 } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) {
457 //TODO 454 //TODO
@@ -462,7 +459,6 @@ public:
462 //* apply the date filter to the fetch 459 //* apply the date filter to the fetch
463 //if we have no folder filter: 460 //if we have no folder filter:
464 //* fetch list of folders from server directly and sync (because we have no guarantee that the folder sync was already processed by the pipeline). 461 //* fetch list of folders from server directly and sync (because we have no guarantee that the folder sync was already processed by the pipeline).
465 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort);
466 return login(imap) 462 return login(imap)
467 .then<void>([=] () -> KAsync::Job<void> { 463 .then<void>([=] () -> KAsync::Job<void> {
468 if (!query.ids().isEmpty()) { 464 if (!query.ids().isEmpty()) {
@@ -493,9 +489,6 @@ public:
493 if ((progress % 100) == 0) { 489 if ((progress % 100) == 0) {
494 commit(); 490 commit();
495 } 491 }
496 })
497 .syncThen<void>([=]() {
498 commit();
499 }); 492 });
500 } else { 493 } else {
501 //Otherwise we sync the folder(s) 494 //Otherwise we sync the folder(s)