diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-14 13:25:44 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-14 14:35:19 +0100 |
commit | fd7cff5da4b33be1e7606c516f7dda00397600b8 (patch) | |
tree | a8664dbed85bca9399189f91e9ed7bad68894c4b /examples/imapresource/imapresource.cpp | |
parent | bcbde00d40d618eabba263f28bb88c713cbffb5e (diff) | |
download | sink-fd7cff5da4b33be1e7606c516f7dda00397600b8.tar.gz sink-fd7cff5da4b33be1e7606c516f7dda00397600b8.zip |
Made the use of the folder struct a bit more expressive
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 302d681..d3949ae 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -119,7 +119,7 @@ public: | |||
119 | [&folderList](const QByteArray &remoteId) -> bool { | 119 | [&folderList](const QByteArray &remoteId) -> bool { |
120 | // folderList.contains(remoteId) | 120 | // folderList.contains(remoteId) |
121 | for (const auto &folderPath : folderList) { | 121 | for (const auto &folderPath : folderList) { |
122 | if (folderPath.path == remoteId) { | 122 | if (folderPath.path() == remoteId) { |
123 | return true; | 123 | return true; |
124 | } | 124 | } |
125 | } | 125 | } |
@@ -128,7 +128,7 @@ public: | |||
128 | ); | 128 | ); |
129 | 129 | ||
130 | for (const auto &f : folderList) { | 130 | for (const auto &f : folderList) { |
131 | createFolder(f.pathParts.last(), f.path, f.parentPath(), "folder"); | 131 | createFolder(f.name(), f.path(), f.parentPath(), "folder"); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
@@ -190,12 +190,12 @@ public: | |||
190 | KAsync::Job<void> synchronizeFolder(QSharedPointer<ImapServerProxy> imap, const Imap::Folder &folder) | 190 | KAsync::Job<void> synchronizeFolder(QSharedPointer<ImapServerProxy> imap, const Imap::Folder &folder) |
191 | { | 191 | { |
192 | QSet<qint64> uids; | 192 | QSet<qint64> uids; |
193 | SinkLog() << "Synchronizing mails" << folder.normalizedPath(); | 193 | SinkLog() << "Synchronizing mails" << folder.path(); |
194 | auto capabilities = imap->getCapabilities(); | 194 | auto capabilities = imap->getCapabilities(); |
195 | bool canDoIncrementalRemovals = false; | 195 | bool canDoIncrementalRemovals = false; |
196 | return KAsync::start<void>([=]() { | 196 | return KAsync::start<void>([=]() { |
197 | //First we fetch flag changes for all messages. Since we don't know which messages are locally available we just get everything and only apply to what we have. | 197 | //First we fetch flag changes for all messages. Since we don't know which messages are locally available we just get everything and only apply to what we have. |
198 | SinkLog() << "About to update flags" << folder.normalizedPath(); | 198 | SinkLog() << "About to update flags" << folder.path(); |
199 | auto uidNext = syncStore().readValue(folder.normalizedPath().toUtf8() + "uidnext").toLongLong(); | 199 | auto uidNext = syncStore().readValue(folder.normalizedPath().toUtf8() + "uidnext").toLongLong(); |
200 | const auto changedsince = syncStore().readValue(folder.normalizedPath().toUtf8() + "changedsince").toLongLong(); | 200 | const auto changedsince = syncStore().readValue(folder.normalizedPath().toUtf8() + "changedsince").toLongLong(); |
201 | return imap->fetchFlags(folder, KIMAP2::ImapSet(1, qMax(uidNext, qint64(1))), changedsince, [this, folder](const Message &message) { | 201 | return imap->fetchFlags(folder, KIMAP2::ImapSet(1, qMax(uidNext, qint64(1))), changedsince, [this, folder](const Message &message) { |
@@ -361,7 +361,10 @@ public: | |||
361 | if (folder.noselect) { | 361 | if (folder.noselect) { |
362 | return KAsync::null<void>(); | 362 | return KAsync::null<void>(); |
363 | } | 363 | } |
364 | return synchronizeFolder(imap, folder); | 364 | return synchronizeFolder(imap, folder) |
365 | .onError([folder](const KAsync::Error &error) { | ||
366 | SinkWarning() << "Failed to sync folder: ." << folder.normalizedPath(); | ||
367 | }); | ||
365 | }); | 368 | }); |
366 | 369 | ||
367 | return job; | 370 | return job; |
@@ -492,8 +495,8 @@ public: | |||
492 | auto specialPurposeFolders = QSharedPointer<QHash<QByteArray, QString>>::create(); | 495 | auto specialPurposeFolders = QSharedPointer<QHash<QByteArray, QString>>::create(); |
493 | auto mergeJob = imap->login(mUser, mPassword) | 496 | auto mergeJob = imap->login(mUser, mPassword) |
494 | .then<void>(imap->fetchFolders([=](const Imap::Folder &folder) { | 497 | .then<void>(imap->fetchFolders([=](const Imap::Folder &folder) { |
495 | if (SpecialPurpose::isSpecialPurposeFolderName(folder.pathParts.last())) { | 498 | if (SpecialPurpose::isSpecialPurposeFolderName(folder.name())) { |
496 | specialPurposeFolders->insert(SpecialPurpose::getSpecialPurposeType(folder.pathParts.last()), folder.path); | 499 | specialPurposeFolders->insert(SpecialPurpose::getSpecialPurposeType(folder.name()), folder.path()); |
497 | }; | 500 | }; |
498 | })) | 501 | })) |
499 | .then<void>([specialPurposeFolders, folder, imap, parentFolder, rid]() -> KAsync::Job<void> { | 502 | .then<void>([specialPurposeFolders, folder, imap, parentFolder, rid]() -> KAsync::Job<void> { |
@@ -707,7 +710,7 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in | |||
707 | auto inspectionJob = imap->login(mUser, mPassword) | 710 | auto inspectionJob = imap->login(mUser, mPassword) |
708 | .then<void>(imap->fetchFolders([=](const Imap::Folder &f) { | 711 | .then<void>(imap->fetchFolders([=](const Imap::Folder &f) { |
709 | *folderByPath << f.normalizedPath(); | 712 | *folderByPath << f.normalizedPath(); |
710 | *folderByName << f.pathParts.last(); | 713 | *folderByName << f.name(); |
711 | })) | 714 | })) |
712 | .then<void>([this, folderByName, folderByPath, folder, remoteId, imap]() { | 715 | .then<void>([this, folderByName, folderByPath, folder, remoteId, imap]() { |
713 | if (!folderByName->contains(folder.getName())) { | 716 | if (!folderByName->contains(folder.getName())) { |