From fcc89a201a06ede057dae86d4591199bf69fab50 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 21 Apr 2017 17:31:22 +0200 Subject: Make sure we always have a complete hierarchy from the IMAP server --- examples/imapresource/imapserverproxy.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'examples/imapresource/imapserverproxy.cpp') diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 08a0081..d3ad2d4 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -457,10 +457,23 @@ bool Imap::flagsContain(const QByteArray &f, const QByteArrayList &flags) return caseInsensitiveContains(f, flags); } +static void reportFolder(const Folder &f, QSharedPointer> reportedList, std::function callback) { + if (!reportedList->contains(f.path())) { + reportedList->insert(f.path()); + auto c = f; + c.noselect = true; + callback(c); + if (!f.parentPath().isEmpty()){ + reportFolder(f.parentFolder(), reportedList, callback); + } + } +} + KAsync::Job ImapServerProxy::fetchFolders(std::function callback) { SinkTrace() << "Fetching folders"; auto subscribedList = QSharedPointer>::create() ; + auto reportedList = QSharedPointer>::create() ; return list(KIMAP2::ListJob::NoOption, [=](const KIMAP2::MailBoxDescriptor &mailbox, const QList &){ *subscribedList << mailbox.name; }).then(list(KIMAP2::ListJob::IncludeUnsubscribed, [=](const KIMAP2::MailBoxDescriptor &mailbox, const QList &flags) { @@ -471,17 +484,24 @@ KAsync::Job ImapServerProxy::fetchFolders(std::functioncontains(folder.parentPath())) { + reportFolder(folder.parentFolder(), reportedList, callback); + } + reportedList->insert(folder.path()); + callback(folder); })); } -- cgit v1.2.3