From 3fa1766af3fa85067d4b2d48c8410e6c201ae323 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 12 Jun 2016 02:11:02 +0200 Subject: Moving of mails between folders --- examples/imapresource/imapserverproxy.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'examples/imapresource/imapserverproxy.cpp') diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index db68a53..49711a9 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -219,6 +220,15 @@ KAsync::Job ImapServerProxy::expunge(const KIMAP::ImapSet &set) return runJob(job); } +KAsync::Job ImapServerProxy::copy(const KIMAP::ImapSet &set, const QString &newMailbox) +{ + auto copy = new KIMAP::CopyJob(mSession); + copy->setSequenceSet(set); + copy->setUidBased(true); + copy->setMailBox(newMailbox); + return runJob(copy); +} + KAsync::Job ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback) { auto fetch = new KIMAP::FetchJob(mSession); @@ -304,6 +314,12 @@ KAsync::Job ImapServerProxy::remove(const QString &mailbox, const QByteArr return remove(mailbox, set); } + +KAsync::Job ImapServerProxy::move(const QString &mailbox, const KIMAP::ImapSet &set, const QString &newMailbox) +{ + return select(mailbox).then(copy(set, newMailbox)).then(store(set, QByteArrayList() << Flags::Deleted)).then(expunge(set)); +} + KAsync::Job ImapServerProxy::createSubfolder(const QString &parentMailbox, const QString &folderName) { auto folder = QSharedPointer::create(); -- cgit v1.2.3