From fd7cff5da4b33be1e7606c516f7dda00397600b8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 14 Nov 2016 13:25:44 +0100 Subject: Made the use of the folder struct a bit more expressive --- examples/imapresource/imapresource.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'examples/imapresource/imapresource.cpp') 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: [&folderList](const QByteArray &remoteId) -> bool { // folderList.contains(remoteId) for (const auto &folderPath : folderList) { - if (folderPath.path == remoteId) { + if (folderPath.path() == remoteId) { return true; } } @@ -128,7 +128,7 @@ public: ); for (const auto &f : folderList) { - createFolder(f.pathParts.last(), f.path, f.parentPath(), "folder"); + createFolder(f.name(), f.path(), f.parentPath(), "folder"); } } @@ -190,12 +190,12 @@ public: KAsync::Job synchronizeFolder(QSharedPointer imap, const Imap::Folder &folder) { QSet uids; - SinkLog() << "Synchronizing mails" << folder.normalizedPath(); + SinkLog() << "Synchronizing mails" << folder.path(); auto capabilities = imap->getCapabilities(); bool canDoIncrementalRemovals = false; return KAsync::start([=]() { //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. - SinkLog() << "About to update flags" << folder.normalizedPath(); + SinkLog() << "About to update flags" << folder.path(); auto uidNext = syncStore().readValue(folder.normalizedPath().toUtf8() + "uidnext").toLongLong(); const auto changedsince = syncStore().readValue(folder.normalizedPath().toUtf8() + "changedsince").toLongLong(); return imap->fetchFlags(folder, KIMAP2::ImapSet(1, qMax(uidNext, qint64(1))), changedsince, [this, folder](const Message &message) { @@ -361,7 +361,10 @@ public: if (folder.noselect) { return KAsync::null(); } - return synchronizeFolder(imap, folder); + return synchronizeFolder(imap, folder) + .onError([folder](const KAsync::Error &error) { + SinkWarning() << "Failed to sync folder: ." << folder.normalizedPath(); + }); }); return job; @@ -492,8 +495,8 @@ public: auto specialPurposeFolders = QSharedPointer>::create(); auto mergeJob = imap->login(mUser, mPassword) .then(imap->fetchFolders([=](const Imap::Folder &folder) { - if (SpecialPurpose::isSpecialPurposeFolderName(folder.pathParts.last())) { - specialPurposeFolders->insert(SpecialPurpose::getSpecialPurposeType(folder.pathParts.last()), folder.path); + if (SpecialPurpose::isSpecialPurposeFolderName(folder.name())) { + specialPurposeFolders->insert(SpecialPurpose::getSpecialPurposeType(folder.name()), folder.path()); }; })) .then([specialPurposeFolders, folder, imap, parentFolder, rid]() -> KAsync::Job { @@ -707,7 +710,7 @@ KAsync::Job ImapResource::inspect(int inspectionType, const QByteArray &in auto inspectionJob = imap->login(mUser, mPassword) .then(imap->fetchFolders([=](const Imap::Folder &f) { *folderByPath << f.normalizedPath(); - *folderByName << f.pathParts.last(); + *folderByName << f.name(); })) .then([this, folderByName, folderByPath, folder, remoteId, imap]() { if (!folderByName->contains(folder.getName())) { -- cgit v1.2.3