summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-14 11:17:47 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-15 16:14:19 +0200
commitca9c54670cc2d26386c80a2aeed2c999313ec362 (patch)
tree71cddc6a175be007aade113b8e19aed0360c7f29 /examples/imapresource/imapresource.cpp
parent25fdab9836b1fdd248d3d36c00a96740093cd749 (diff)
downloadsink-ca9c54670cc2d26386c80a2aeed2c999313ec362.tar.gz
sink-ca9c54670cc2d26386c80a2aeed2c999313ec362.zip
New kimap2 syntax
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r--examples/imapresource/imapresource.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index c26dc39..63ae07b 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -298,15 +298,15 @@ public:
298 .then<QVector<Folder>>([this, imap]() { 298 .then<QVector<Folder>>([this, imap]() {
299 auto folderList = QSharedPointer<QVector<Folder>>::create(); 299 auto folderList = QSharedPointer<QVector<Folder>>::create();
300 SinkLog() << "Login was successful"; 300 SinkLog() << "Login was successful";
301 return imap->fetchFolders([this, &imap, folderList](const QVector<Folder> &folders) { 301 return imap->fetchFolders([folderList](const Folder &folder) {
302 synchronizeFolders(folders); 302 *folderList << folder;
303 commit();
304 *folderList << folders;
305 }) 303 })
306 .onError([](const KAsync::Error &error) { 304 .onError([](const KAsync::Error &error) {
307 SinkWarning() << "Folder list sync failed."; 305 SinkWarning() << "Folder list sync failed.";
308 }) 306 })
309 .syncThen<QVector<Folder>>([folderList]() { 307 .syncThen<QVector<Folder>>([this, folderList]() {
308 synchronizeFolders(*folderList);
309 commit();
310 return *folderList; 310 return *folderList;
311 }); 311 });
312 }) 312 })
@@ -440,12 +440,10 @@ public:
440 } else { //We try to merge special purpose folders first 440 } else { //We try to merge special purpose folders first
441 auto specialPurposeFolders = QSharedPointer<QHash<QByteArray, QString>>::create(); 441 auto specialPurposeFolders = QSharedPointer<QHash<QByteArray, QString>>::create();
442 auto mergeJob = imap->login(mUser, mPassword) 442 auto mergeJob = imap->login(mUser, mPassword)
443 .then<void>(imap->fetchFolders([=](const QVector<Imap::Folder> &folders) { 443 .then<void>(imap->fetchFolders([=](const Imap::Folder &folder) {
444 for (const auto &f : folders) { 444 if (SpecialPurpose::isSpecialPurposeFolderName(folder.pathParts.last())) {
445 if (SpecialPurpose::isSpecialPurposeFolderName(f.pathParts.last())) { 445 specialPurposeFolders->insert(SpecialPurpose::getSpecialPurposeType(folder.pathParts.last()), folder.path);
446 specialPurposeFolders->insert(SpecialPurpose::getSpecialPurposeType(f.pathParts.last()), f.path); 446 };
447 };
448 }
449 })) 447 }))
450 .then<void>([specialPurposeFolders, folder, imap, parentFolder, rid]() -> KAsync::Job<void> { 448 .then<void>([specialPurposeFolders, folder, imap, parentFolder, rid]() -> KAsync::Job<void> {
451 for (const auto &purpose : folder.getSpecialPurpose()) { 449 for (const auto &purpose : folder.getSpecialPurpose()) {
@@ -661,11 +659,9 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in
661 659
662 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 660 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort);
663 auto inspectionJob = imap->login(mUser, mPassword) 661 auto inspectionJob = imap->login(mUser, mPassword)
664 .then<void>(imap->fetchFolders([=](const QVector<Imap::Folder> &folders) { 662 .then<void>(imap->fetchFolders([=](const Imap::Folder &f) {
665 for (const auto &f : folders) { 663 *folderByPath << f.normalizedPath();
666 *folderByPath << f.normalizedPath(); 664 *folderByName << f.pathParts.last();
667 *folderByName << f.pathParts.last();
668 }
669 })) 665 }))
670 .then<void>([this, folderByName, folderByPath, folder, remoteId, imap]() { 666 .then<void>([this, folderByName, folderByPath, folder, remoteId, imap]() {
671 if (!folderByName->contains(folder.getName())) { 667 if (!folderByName->contains(folder.getName())) {