summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/imapresource/imapresource.cpp9
-rw-r--r--examples/imapresource/imapserverproxy.cpp16
-rw-r--r--examples/imapresource/imapserverproxy.h2
3 files changed, 24 insertions, 3 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index aca1c01..8cbb9fa 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -491,8 +491,11 @@ public:
491 flags << Imap::Flags::Flagged; 491 flags << Imap::Flags::Flagged;
492 } 492 }
493 493
494 const bool messageChanged = changedProperties.contains(Sink::ApplicationDomain::Mail::MimeMessage::name); 494 const bool messageMoved = changedProperties.contains(ApplicationDomain::Mail::Folder::name);
495 if (messageChanged) { 495 const bool messageChanged = changedProperties.contains(ApplicationDomain::Mail::MimeMessage::name);
496 if (messageChanged || messageMoved) {
497 const auto folderId = folderIdFromMailRid(oldRemoteId);
498 const QString oldMailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId);
496 QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage()); 499 QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage());
497 QDateTime internalDate = mail.getDate(); 500 QDateTime internalDate = mail.getDate();
498 auto rid = QSharedPointer<QByteArray>::create(); 501 auto rid = QSharedPointer<QByteArray>::create();
@@ -504,7 +507,7 @@ public:
504 Trace() << "Finished creating a modified mail: " << remoteId; 507 Trace() << "Finished creating a modified mail: " << remoteId;
505 *rid = remoteId; 508 *rid = remoteId;
506 }) 509 })
507 .then(imap->remove(mailbox, set)) 510 .then(imap->remove(oldMailbox, set))
508 .then<QByteArray>([rid, imap]() { 511 .then<QByteArray>([rid, imap]() {
509 return *rid; 512 return *rid;
510 }); 513 });
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 @@
25#include <KIMAP/KIMAP/SelectJob> 25#include <KIMAP/KIMAP/SelectJob>
26#include <KIMAP/KIMAP/AppendJob> 26#include <KIMAP/KIMAP/AppendJob>
27#include <KIMAP/KIMAP/CreateJob> 27#include <KIMAP/KIMAP/CreateJob>
28#include <KIMAP/KIMAP/CopyJob>
28#include <KIMAP/KIMAP/RenameJob> 29#include <KIMAP/KIMAP/RenameJob>
29#include <KIMAP/KIMAP/DeleteJob> 30#include <KIMAP/KIMAP/DeleteJob>
30#include <KIMAP/KIMAP/StoreJob> 31#include <KIMAP/KIMAP/StoreJob>
@@ -219,6 +220,15 @@ KAsync::Job<void> ImapServerProxy::expunge(const KIMAP::ImapSet &set)
219 return runJob(job); 220 return runJob(job);
220} 221}
221 222
223KAsync::Job<void> ImapServerProxy::copy(const KIMAP::ImapSet &set, const QString &newMailbox)
224{
225 auto copy = new KIMAP::CopyJob(mSession);
226 copy->setSequenceSet(set);
227 copy->setUidBased(true);
228 copy->setMailBox(newMailbox);
229 return runJob(copy);
230}
231
222KAsync::Job<void> ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback) 232KAsync::Job<void> ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback)
223{ 233{
224 auto fetch = new KIMAP::FetchJob(mSession); 234 auto fetch = new KIMAP::FetchJob(mSession);
@@ -304,6 +314,12 @@ KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const QByteArr
304 return remove(mailbox, set); 314 return remove(mailbox, set);
305} 315}
306 316
317
318KAsync::Job<void> ImapServerProxy::move(const QString &mailbox, const KIMAP::ImapSet &set, const QString &newMailbox)
319{
320 return select(mailbox).then<void>(copy(set, newMailbox)).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge(set));
321}
322
307KAsync::Job<QString> ImapServerProxy::createSubfolder(const QString &parentMailbox, const QString &folderName) 323KAsync::Job<QString> ImapServerProxy::createSubfolder(const QString &parentMailbox, const QString &folderName)
308{ 324{
309 auto folder = QSharedPointer<QString>::create(); 325 auto folder = QSharedPointer<QString>::create();
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 67ff000..95ed704 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -93,6 +93,7 @@ public:
93 KAsync::Job<void> remove(const QString &mailbox); 93 KAsync::Job<void> remove(const QString &mailbox);
94 KAsync::Job<void> expunge(); 94 KAsync::Job<void> expunge();
95 KAsync::Job<void> expunge(const KIMAP::ImapSet &set); 95 KAsync::Job<void> expunge(const KIMAP::ImapSet &set);
96 KAsync::Job<void> copy(const KIMAP::ImapSet &set, const QString &newMailbox);
96 97
97 typedef std::function<void(const QString &, 98 typedef std::function<void(const QString &,
98 const QMap<qint64,qint64> &, 99 const QMap<qint64,qint64> &,
@@ -109,6 +110,7 @@ public:
109 KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox); 110 KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox);
110 KAsync::Job<void> remove(const QString &mailbox, const KIMAP::ImapSet &set); 111 KAsync::Job<void> remove(const QString &mailbox, const KIMAP::ImapSet &set);
111 KAsync::Job<void> remove(const QString &mailbox, const QByteArray &imapSet); 112 KAsync::Job<void> remove(const QString &mailbox, const QByteArray &imapSet);
113 KAsync::Job<void> move(const QString &mailbox, const KIMAP::ImapSet &set, const QString &newMailbox);
112 KAsync::Job<QString> createSubfolder(const QString &parentMailbox, const QString &folderName); 114 KAsync::Job<QString> createSubfolder(const QString &parentMailbox, const QString &folderName);
113 KAsync::Job<QString> renameSubfolder(const QString &mailbox, const QString &newName); 115 KAsync::Job<QString> renameSubfolder(const QString &mailbox, const QString &newName);
114 116