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/imapresource/imapresource.cpp | |
parent | af8baff21529b5bc47725da3e9e00ec81e5b6f1b (diff) | |
download | sink-7daeec83233c522980d5e477fee82045de57f77d.tar.gz sink-7daeec83233c522980d5e477fee82045de57f77d.zip |
syncThen is no longer necessary
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 40 |
1 files changed, 20 insertions, 20 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 | })) |