diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-12 11:45:15 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-12 11:45:15 +0100 |
commit | 7daeec83233c522980d5e477fee82045de57f77d (patch) | |
tree | 5e03d11d23c764eb03f27393fcc37c0529405e10 /examples | |
parent | af8baff21529b5bc47725da3e9e00ec81e5b6f1b (diff) | |
download | sink-7daeec83233c522980d5e477fee82045de57f77d.tar.gz sink-7daeec83233c522980d5e477fee82045de57f77d.zip |
syncThen is no longer necessary
Diffstat (limited to 'examples')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 40 | ||||
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 14 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 4 | ||||
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 2 |
4 files changed, 30 insertions, 30 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index a204f4c..c608b04 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -116,7 +116,7 @@ public: | |||
116 | if (!parentFolderRid.isEmpty()) { | 116 | if (!parentFolderRid.isEmpty()) { |
117 | folder.setParent(syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, parentFolderRid)); | 117 | folder.setParent(syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, parentFolderRid)); |
118 | } | 118 | } |
119 | createOrModify(ApplicationDomain::getTypeName<ApplicationDomain::Folder>, remoteId, folder); | 119 | createOrModify(ApplicationDomain::getTypeName<ApplicationDomain::Folder>(), remoteId, folder); |
120 | return remoteId; | 120 | return remoteId; |
121 | } | 121 | } |
122 | 122 | ||
@@ -244,14 +244,14 @@ public: | |||
244 | 244 | ||
245 | modify(ENTITY_TYPE_MAIL, remoteId, mail); | 245 | modify(ENTITY_TYPE_MAIL, remoteId, mail); |
246 | }) | 246 | }) |
247 | .syncThen<void, SelectResult>([=](const SelectResult &selectResult) { | 247 | .then([=](const SelectResult &selectResult) { |
248 | SinkLogCtx(mLogCtx) << "Flags updated. New changedsince value: " << selectResult.highestModSequence; | 248 | SinkLogCtx(mLogCtx) << "Flags updated. New changedsince value: " << selectResult.highestModSequence; |
249 | syncStore().writeValue(folderRemoteId, "changedsince", QByteArray::number(selectResult.highestModSequence)); | 249 | syncStore().writeValue(folderRemoteId, "changedsince", QByteArray::number(selectResult.highestModSequence)); |
250 | }); | 250 | }); |
251 | } else { | 251 | } else { |
252 | //We hit this path on initial sync and simply record the current changedsince value | 252 | //We hit this path on initial sync and simply record the current changedsince value |
253 | return imap->select(imap->mailboxFromFolder(folder)) | 253 | return imap->select(imap->mailboxFromFolder(folder)) |
254 | .syncThen<void, SelectResult>([=](const SelectResult &selectResult) { | 254 | .then([=](const SelectResult &selectResult) { |
255 | SinkLogCtx(mLogCtx) << "No flags to update. New changedsince value: " << selectResult.highestModSequence; | 255 | SinkLogCtx(mLogCtx) << "No flags to update. New changedsince value: " << selectResult.highestModSequence; |
256 | syncStore().writeValue(folderRemoteId, "changedsince", QByteArray::number(selectResult.highestModSequence)); | 256 | syncStore().writeValue(folderRemoteId, "changedsince", QByteArray::number(selectResult.highestModSequence)); |
257 | }); | 257 | }); |
@@ -303,7 +303,7 @@ public: | |||
303 | commit(); | 303 | commit(); |
304 | } | 304 | } |
305 | }) | 305 | }) |
306 | .syncThen<void>([=]() { | 306 | .then([=]() { |
307 | SinkLogCtx(mLogCtx) << "UIDMAX: " << *maxUid << folder.path(); | 307 | SinkLogCtx(mLogCtx) << "UIDMAX: " << *maxUid << folder.path(); |
308 | if (*maxUid > 0) { | 308 | if (*maxUid > 0) { |
309 | syncStore().writeValue(folderRemoteId, "uidnext", QByteArray::number(*maxUid)); | 309 | syncStore().writeValue(folderRemoteId, "uidnext", QByteArray::number(*maxUid)); |
@@ -345,7 +345,7 @@ public: | |||
345 | } | 345 | } |
346 | }); | 346 | }); |
347 | }) | 347 | }) |
348 | .syncThen<void>([=]() { | 348 | .then([=]() { |
349 | SinkLogCtx(mLogCtx) << "Headers fetched: " << folder.path(); | 349 | SinkLogCtx(mLogCtx) << "Headers fetched: " << folder.path(); |
350 | syncStore().writeValue(folderRemoteId, "headersFetched", "true"); | 350 | syncStore().writeValue(folderRemoteId, "headersFetched", "true"); |
351 | commit(); | 351 | commit(); |
@@ -359,7 +359,7 @@ public: | |||
359 | //Finally remove messages that are no longer existing on the server. | 359 | //Finally remove messages that are no longer existing on the server. |
360 | .then<void>([=]() { | 360 | .then<void>([=]() { |
361 | //TODO do an examine with QRESYNC and remove VANISHED messages if supported instead | 361 | //TODO do an examine with QRESYNC and remove VANISHED messages if supported instead |
362 | return imap->fetchUids(folder).syncThen<void, QVector<qint64>>([=](const QVector<qint64> &uids) { | 362 | return imap->fetchUids(folder).then([=](const QVector<qint64> &uids) { |
363 | SinkTraceCtx(mLogCtx) << "Syncing removals: " << folder.path(); | 363 | SinkTraceCtx(mLogCtx) << "Syncing removals: " << folder.path(); |
364 | synchronizeRemovals(folderRemoteId, uids.toList().toSet()); | 364 | synchronizeRemovals(folderRemoteId, uids.toList().toSet()); |
365 | commit(); | 365 | commit(); |
@@ -425,7 +425,7 @@ public: | |||
425 | .onError([](const KAsync::Error &error) { | 425 | .onError([](const KAsync::Error &error) { |
426 | SinkWarning() << "Folder list sync failed."; | 426 | SinkWarning() << "Folder list sync failed."; |
427 | }) | 427 | }) |
428 | .syncThen<QVector<Folder>>([folderList]() { return *folderList; } ); | 428 | .then([folderList]() { return *folderList; } ); |
429 | } | 429 | } |
430 | } | 430 | } |
431 | 431 | ||
@@ -439,7 +439,7 @@ public: | |||
439 | return imap->fetchFolders([folderList](const Folder &folder) { | 439 | return imap->fetchFolders([folderList](const Folder &folder) { |
440 | *folderList << folder; | 440 | *folderList << folder; |
441 | }) | 441 | }) |
442 | .syncThen<void>([this, folderList]() { | 442 | .then([this, folderList]() { |
443 | synchronizeFolders(*folderList); | 443 | synchronizeFolders(*folderList); |
444 | }); | 444 | }); |
445 | }) | 445 | }) |
@@ -537,7 +537,7 @@ public: | |||
537 | QDateTime internalDate = mail.getDate(); | 537 | QDateTime internalDate = mail.getDate(); |
538 | job = login.then(imap->append(mailbox, content, flags, internalDate)) | 538 | job = login.then(imap->append(mailbox, content, flags, internalDate)) |
539 | .addToContext(imap) | 539 | .addToContext(imap) |
540 | .syncThen<QByteArray, qint64>([mail](qint64 uid) { | 540 | .then([mail](qint64 uid) { |
541 | const auto remoteId = assembleMailRid(mail, uid); | 541 | const auto remoteId = assembleMailRid(mail, uid); |
542 | SinkTrace() << "Finished creating a new mail: " << remoteId; | 542 | SinkTrace() << "Finished creating a new mail: " << remoteId; |
543 | return remoteId; | 543 | return remoteId; |
@@ -550,7 +550,7 @@ public: | |||
550 | KIMAP2::ImapSet set; | 550 | KIMAP2::ImapSet set; |
551 | set.add(uid); | 551 | set.add(uid); |
552 | job = login.then(imap->remove(mailbox, set)) | 552 | job = login.then(imap->remove(mailbox, set)) |
553 | .syncThen<QByteArray>([imap, oldRemoteId] { | 553 | .then([imap, oldRemoteId] { |
554 | SinkTrace() << "Finished removing a mail: " << oldRemoteId; | 554 | SinkTrace() << "Finished removing a mail: " << oldRemoteId; |
555 | return QByteArray(); | 555 | return QByteArray(); |
556 | }); | 556 | }); |
@@ -586,7 +586,7 @@ public: | |||
586 | job = login.then(imap->select(mailbox)) | 586 | job = login.then(imap->select(mailbox)) |
587 | .addToContext(imap) | 587 | .addToContext(imap) |
588 | .then(imap->storeFlags(set, flags)) | 588 | .then(imap->storeFlags(set, flags)) |
589 | .syncThen<QByteArray>([=] { | 589 | .then([=] { |
590 | SinkTrace() << "Finished modifying mail"; | 590 | SinkTrace() << "Finished modifying mail"; |
591 | return oldRemoteId; | 591 | return oldRemoteId; |
592 | }); | 592 | }); |
@@ -616,13 +616,13 @@ public: | |||
616 | SinkTrace() << "Creating a new folder: " << parentFolder << folder.getName(); | 616 | SinkTrace() << "Creating a new folder: " << parentFolder << folder.getName(); |
617 | auto rid = QSharedPointer<QByteArray>::create(); | 617 | auto rid = QSharedPointer<QByteArray>::create(); |
618 | auto createFolder = login.then<QString>(imap->createSubfolder(parentFolder, folder.getName())) | 618 | auto createFolder = login.then<QString>(imap->createSubfolder(parentFolder, folder.getName())) |
619 | .syncThen<void, QString>([imap, rid](const QString &createdFolder) { | 619 | .then([imap, rid](const QString &createdFolder) { |
620 | SinkTrace() << "Finished creating a new folder: " << createdFolder; | 620 | SinkTrace() << "Finished creating a new folder: " << createdFolder; |
621 | *rid = createdFolder.toUtf8(); | 621 | *rid = createdFolder.toUtf8(); |
622 | }); | 622 | }); |
623 | if (folder.getSpecialPurpose().isEmpty()) { | 623 | if (folder.getSpecialPurpose().isEmpty()) { |
624 | return createFolder | 624 | return createFolder |
625 | .syncThen<QByteArray>([rid](){ | 625 | .then([rid](){ |
626 | return *rid; | 626 | return *rid; |
627 | }); | 627 | }); |
628 | } else { //We try to merge special purpose folders first | 628 | } else { //We try to merge special purpose folders first |
@@ -644,13 +644,13 @@ public: | |||
644 | } | 644 | } |
645 | SinkTrace() << "No match found for merging, creating a new folder"; | 645 | SinkTrace() << "No match found for merging, creating a new folder"; |
646 | return imap->createSubfolder(parentFolder, folder.getName()) | 646 | return imap->createSubfolder(parentFolder, folder.getName()) |
647 | .syncThen<void, QString>([imap, rid](const QString &createdFolder) { | 647 | .then([imap, rid](const QString &createdFolder) { |
648 | SinkTrace() << "Finished creating a new folder: " << createdFolder; | 648 | SinkTrace() << "Finished creating a new folder: " << createdFolder; |
649 | *rid = createdFolder.toUtf8(); | 649 | *rid = createdFolder.toUtf8(); |
650 | }); | 650 | }); |
651 | 651 | ||
652 | }) | 652 | }) |
653 | .syncThen<QByteArray>([rid](){ | 653 | .then([rid](){ |
654 | return *rid; | 654 | return *rid; |
655 | }); | 655 | }); |
656 | return mergeJob; | 656 | return mergeJob; |
@@ -658,7 +658,7 @@ public: | |||
658 | } else if (operation == Sink::Operation_Removal) { | 658 | } else if (operation == Sink::Operation_Removal) { |
659 | SinkTrace() << "Removing a folder: " << oldRemoteId; | 659 | SinkTrace() << "Removing a folder: " << oldRemoteId; |
660 | return login.then<void>(imap->remove(oldRemoteId)) | 660 | return login.then<void>(imap->remove(oldRemoteId)) |
661 | .syncThen<QByteArray>([oldRemoteId, imap]() { | 661 | .then([oldRemoteId, imap]() { |
662 | SinkTrace() << "Finished removing a folder: " << oldRemoteId; | 662 | SinkTrace() << "Finished removing a folder: " << oldRemoteId; |
663 | return QByteArray(); | 663 | return QByteArray(); |
664 | }); | 664 | }); |
@@ -666,11 +666,11 @@ public: | |||
666 | SinkTrace() << "Renaming a folder: " << oldRemoteId << folder.getName(); | 666 | SinkTrace() << "Renaming a folder: " << oldRemoteId << folder.getName(); |
667 | auto rid = QSharedPointer<QByteArray>::create(); | 667 | auto rid = QSharedPointer<QByteArray>::create(); |
668 | return login.then<QString>(imap->renameSubfolder(oldRemoteId, folder.getName())) | 668 | return login.then<QString>(imap->renameSubfolder(oldRemoteId, folder.getName())) |
669 | .syncThen<void, QString>([imap, rid](const QString &createdFolder) { | 669 | .then([imap, rid](const QString &createdFolder) { |
670 | SinkTrace() << "Finished renaming a folder: " << createdFolder; | 670 | SinkTrace() << "Finished renaming a folder: " << createdFolder; |
671 | *rid = createdFolder.toUtf8(); | 671 | *rid = createdFolder.toUtf8(); |
672 | }) | 672 | }) |
673 | .syncThen<QByteArray>([rid](){ | 673 | .then([rid](){ |
674 | return *rid; | 674 | return *rid; |
675 | }); | 675 | }); |
676 | } | 676 | } |
@@ -731,7 +731,7 @@ protected: | |||
731 | SinkTrace() << "as:" << mUser; | 731 | SinkTrace() << "as:" << mUser; |
732 | auto inspectionJob = imap->login(mUser, mPassword) | 732 | auto inspectionJob = imap->login(mUser, mPassword) |
733 | .then<Imap::SelectResult>(imap->select(folderRemoteId)) | 733 | .then<Imap::SelectResult>(imap->select(folderRemoteId)) |
734 | .syncThen<void, Imap::SelectResult>([](Imap::SelectResult){}) | 734 | .then([](Imap::SelectResult){}) |
735 | .then<void>(imap->fetch(set, scope, [imap, messageByUid](const Imap::Message &message) { | 735 | .then<void>(imap->fetch(set, scope, [imap, messageByUid](const Imap::Message &message) { |
736 | messageByUid->insert(message.uid, message); | 736 | messageByUid->insert(message.uid, message); |
737 | })); | 737 | })); |
@@ -792,7 +792,7 @@ protected: | |||
792 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 792 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); |
793 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); | 793 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); |
794 | return imap->login(mUser, mPassword) | 794 | return imap->login(mUser, mPassword) |
795 | .then<void>(imap->select(remoteId).syncThen<void>([](){})) | 795 | .then<void>(imap->select(remoteId).then([](){})) |
796 | .then<void>(imap->fetch(set, scope, [=](const Imap::Message message) { | 796 | .then<void>(imap->fetch(set, scope, [=](const Imap::Message message) { |
797 | messageByUid->insert(message.uid, message); | 797 | messageByUid->insert(message.uid, message); |
798 | })) | 798 | })) |
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index c16021e..a98483b 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp | |||
@@ -130,7 +130,7 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString | |||
130 | }); | 130 | }); |
131 | auto namespaceJob = new KIMAP2::NamespaceJob(mSession); | 131 | auto namespaceJob = new KIMAP2::NamespaceJob(mSession); |
132 | 132 | ||
133 | return runJob(loginJob).then(runJob(capabilitiesJob)).syncThen<void>([this](){ | 133 | return runJob(loginJob).then(runJob(capabilitiesJob)).then([this](){ |
134 | SinkTrace() << "Supported capabilities: " << mCapabilities; | 134 | SinkTrace() << "Supported capabilities: " << mCapabilities; |
135 | QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; | 135 | QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; |
136 | for (const auto &requiredExtension : requiredExtensions) { | 136 | for (const auto &requiredExtension : requiredExtensions) { |
@@ -139,7 +139,7 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString | |||
139 | //TODO fail the job | 139 | //TODO fail the job |
140 | } | 140 | } |
141 | } | 141 | } |
142 | }).then(runJob(namespaceJob)).syncThen<void>([this, namespaceJob] { | 142 | }).then(runJob(namespaceJob)).then([this, namespaceJob] { |
143 | for (const auto &ns :namespaceJob->personalNamespaces()) { | 143 | for (const auto &ns :namespaceJob->personalNamespaces()) { |
144 | mPersonalNamespaces << ns.name; | 144 | mPersonalNamespaces << ns.name; |
145 | mPersonalNamespaceSeparator = ns.separator; | 145 | mPersonalNamespaceSeparator = ns.separator; |
@@ -324,7 +324,7 @@ KAsync::Job<QVector<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbo | |||
324 | 324 | ||
325 | list->append(result.uid); | 325 | list->append(result.uid); |
326 | }) | 326 | }) |
327 | .syncThen<QVector<qint64>>([list](){ | 327 | .then([list](){ |
328 | return *list; | 328 | return *list; |
329 | }); | 329 | }); |
330 | } | 330 | } |
@@ -378,7 +378,7 @@ KAsync::Job<QString> ImapServerProxy::createSubfolder(const QString &parentMailb | |||
378 | } | 378 | } |
379 | SinkTrace() << "Creating subfolder: " << *folder; | 379 | SinkTrace() << "Creating subfolder: " << *folder; |
380 | return create(*folder) | 380 | return create(*folder) |
381 | .syncThen<QString>([=]() { | 381 | .then([=]() { |
382 | return *folder; | 382 | return *folder; |
383 | }); | 383 | }); |
384 | }); | 384 | }); |
@@ -393,7 +393,7 @@ KAsync::Job<QString> ImapServerProxy::renameSubfolder(const QString &oldMailbox, | |||
393 | auto folder = QSharedPointer<QString>::create(parts.join(mPersonalNamespaceSeparator) + mPersonalNamespaceSeparator + newName); | 393 | auto folder = QSharedPointer<QString>::create(parts.join(mPersonalNamespaceSeparator) + mPersonalNamespaceSeparator + newName); |
394 | SinkTrace() << "Renaming subfolder: " << oldMailbox << *folder; | 394 | SinkTrace() << "Renaming subfolder: " << oldMailbox << *folder; |
395 | return rename(oldMailbox, *folder) | 395 | return rename(oldMailbox, *folder) |
396 | .syncThen<QString>([=]() { | 396 | .then([=]() { |
397 | return *folder; | 397 | return *folder; |
398 | }); | 398 | }); |
399 | }); | 399 | }); |
@@ -436,7 +436,7 @@ KAsync::Job<SelectResult> ImapServerProxy::fetchFlags(const Folder &folder, cons | |||
436 | scope.mode = KIMAP2::FetchJob::FetchScope::Flags; | 436 | scope.mode = KIMAP2::FetchJob::FetchScope::Flags; |
437 | scope.changedSince = changedsince; | 437 | scope.changedSince = changedsince; |
438 | 438 | ||
439 | return fetch(set, scope, callback).syncThen<SelectResult>([selectResult] { | 439 | return fetch(set, scope, callback).then([selectResult] { |
440 | return selectResult; | 440 | return selectResult; |
441 | }); | 441 | }); |
442 | }); | 442 | }); |
@@ -503,7 +503,7 @@ KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, const QVe | |||
503 | callback(message); | 503 | callback(message); |
504 | }); | 504 | }); |
505 | }) | 505 | }) |
506 | .syncThen<void>([time]() { | 506 | .then([time]() { |
507 | SinkTrace() << "The fetch took: " << Sink::Log::TraceTime(time->elapsed()); | 507 | SinkTrace() << "The fetch took: " << Sink::Log::TraceTime(time->elapsed()); |
508 | }); | 508 | }); |
509 | } | 509 | } |
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 6ddb5d2..3d299b4 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -369,11 +369,11 @@ public: | |||
369 | }); | 369 | }); |
370 | 370 | ||
371 | if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { | 371 | if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { |
372 | job = job.syncThen<void>([this] { | 372 | job = job.then([this] { |
373 | synchronizeFolders(); | 373 | synchronizeFolders(); |
374 | }); | 374 | }); |
375 | } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { | 375 | } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { |
376 | job = job.syncThen<void>([this, query] { | 376 | job = job.then([this, query] { |
377 | QStringList folders; | 377 | QStringList folders; |
378 | if (query.hasFilter<ApplicationDomain::Mail::Folder>()) { | 378 | if (query.hasFilter<ApplicationDomain::Mail::Folder>()) { |
379 | auto folderFilter = query.getFilter<ApplicationDomain::Mail::Folder>(); | 379 | auto folderFilter = query.getFilter<ApplicationDomain::Mail::Folder>(); |
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index e475139..a4622f3 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp | |||
@@ -118,7 +118,7 @@ public: | |||
118 | }); | 118 | }); |
119 | }); | 119 | }); |
120 | } | 120 | } |
121 | job = job.syncThen<void>([&future](const KAsync::Error &) { | 121 | job = job.then([&future](const KAsync::Error &) { |
122 | future.setFinished(); | 122 | future.setFinished(); |
123 | }); | 123 | }); |
124 | job.exec(); | 124 | job.exec(); |