From c924f3118c499760f5376a6ddc9e6baf529fd0d7 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 10 Jan 2017 18:26:41 +0100 Subject: Simplify jobs For some reason this also makes the synchronization to throw an error on login failure again. Something with the job error propagation is not quite right. --- examples/imapresource/imapresource.cpp | 35 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'examples') 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: KAsync::Job synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE { + auto imap = QSharedPointer::create(mServer, mPort); if (query.type() == ApplicationDomain::getTypeName()) { - return KAsync::start([this]() { - auto imap = QSharedPointer::create(mServer, mPort); - auto job = login(imap); - job = job.then>([this, imap]() { - auto folderList = QSharedPointer>::create(); - return imap->fetchFolders([folderList](const Folder &folder) { - *folderList << folder; - }) - .onError([](const KAsync::Error &error) { - SinkWarning() << "Folder list sync failed."; - }) - .syncThen>([this, folderList]() { - synchronizeFolders(*folderList); - commit(); - return *folderList; - }); + return login(imap) + .then>([=]() { + auto folderList = QSharedPointer>::create(); + return imap->fetchFolders([folderList](const Folder &folder) { + *folderList << folder; + }) + .onError([](const KAsync::Error &error) { + SinkWarning() << "Folder list sync failed."; + }) + .syncThen>([this, folderList]() { + synchronizeFolders(*folderList); + commit(); + return *folderList; }); - return job; }); } else if (query.type() == ApplicationDomain::getTypeName()) { //TODO @@ -462,7 +459,6 @@ public: //* apply the date filter to the fetch //if we have no folder filter: //* fetch list of folders from server directly and sync (because we have no guarantee that the folder sync was already processed by the pipeline). - auto imap = QSharedPointer::create(mServer, mPort); return login(imap) .then([=] () -> KAsync::Job { if (!query.ids().isEmpty()) { @@ -493,9 +489,6 @@ public: if ((progress % 100) == 0) { commit(); } - }) - .syncThen([=]() { - commit(); }); } else { //Otherwise we sync the folder(s) -- cgit v1.2.3