summaryrefslogtreecommitdiffstats
path: root/examples/imapresource
diff options
context:
space:
mode:
Diffstat (limited to 'examples/imapresource')
-rw-r--r--examples/imapresource/CMakeLists.txt7
-rw-r--r--examples/imapresource/imapresource.cpp18
-rw-r--r--examples/imapresource/imapserverproxy.cpp142
-rw-r--r--examples/imapresource/imapserverproxy.h38
-rw-r--r--examples/imapresource/tests/imapserverproxytest.cpp24
5 files changed, 114 insertions, 115 deletions
diff --git a/examples/imapresource/CMakeLists.txt b/examples/imapresource/CMakeLists.txt
index d5320a6..15a720d 100644
--- a/examples/imapresource/CMakeLists.txt
+++ b/examples/imapresource/CMakeLists.txt
@@ -3,15 +3,14 @@ project(sink_resource_imap)
3add_definitions(-DQT_PLUGIN) 3add_definitions(-DQT_PLUGIN)
4include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 4include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
5 5
6find_package(KF5 COMPONENTS REQUIRED Mime IMAP KIO) 6find_package(KF5 COMPONENTS REQUIRED Mime)
7find_package(KF5CoreAddons REQUIRED) 7find_package(KIMAP2 0.0.1 REQUIRED)
8 8
9include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 9include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
10 10
11add_library(${PROJECT_NAME} SHARED facade.cpp imapresource.cpp domainadaptor.cpp imapserverproxy.cpp) 11add_library(${PROJECT_NAME} SHARED facade.cpp imapresource.cpp domainadaptor.cpp imapserverproxy.cpp)
12qt5_use_modules(${PROJECT_NAME} Core Network) 12qt5_use_modules(${PROJECT_NAME} Core Network)
13#We need CoreAddons for KJob and KIOCore for KTcpSocket. Both used in KIMAP 13target_link_libraries(${PROJECT_NAME} sink KF5::Mime KIMAP2)
14target_link_libraries(${PROJECT_NAME} sink KF5::Mime KF5::IMAP KF5::CoreAddons KF5::KIOCore)
15 14
16install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH}) 15install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH})
17 16
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index f78376a..da87bdb 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -344,7 +344,7 @@ public:
344 const QString mailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId); 344 const QString mailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId);
345 const auto uid = uidFromMailRid(oldRemoteId); 345 const auto uid = uidFromMailRid(oldRemoteId);
346 SinkTrace() << "Removing a mail: " << oldRemoteId << "in the mailbox: " << mailbox; 346 SinkTrace() << "Removing a mail: " << oldRemoteId << "in the mailbox: " << mailbox;
347 KIMAP::ImapSet set; 347 KIMAP2::ImapSet set;
348 set.add(uid); 348 set.add(uid);
349 return login.then(imap->remove(mailbox, set)) 349 return login.then(imap->remove(mailbox, set))
350 .syncThen<QByteArray>([imap, oldRemoteId] { 350 .syncThen<QByteArray>([imap, oldRemoteId] {
@@ -373,7 +373,7 @@ public:
373 const QString oldMailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId); 373 const QString oldMailbox = syncStore().resolveLocalId(ENTITY_TYPE_FOLDER, folderId);
374 QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage()); 374 QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage());
375 QDateTime internalDate = mail.getDate(); 375 QDateTime internalDate = mail.getDate();
376 KIMAP::ImapSet set; 376 KIMAP2::ImapSet set;
377 set.add(uid); 377 set.add(uid);
378 return login.then(imap->append(mailbox, content, flags, internalDate)) 378 return login.then(imap->append(mailbox, content, flags, internalDate))
379 .addToContext(imap) 379 .addToContext(imap)
@@ -384,7 +384,7 @@ public:
384 }); 384 });
385 } else { 385 } else {
386 SinkTrace() << "Updating flags only."; 386 SinkTrace() << "Updating flags only.";
387 KIMAP::ImapSet set; 387 KIMAP2::ImapSet set;
388 set.add(uid); 388 set.add(uid);
389 return login.then(imap->select(mailbox)) 389 return login.then(imap->select(mailbox))
390 .addToContext(imap) 390 .addToContext(imap)
@@ -548,13 +548,13 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in
548 const auto uid = uidFromMailRid(mailRemoteId); 548 const auto uid = uidFromMailRid(mailRemoteId);
549 SinkTrace() << "Mail remote id: " << folderRemoteId << mailRemoteId << mail.identifier() << folder.identifier(); 549 SinkTrace() << "Mail remote id: " << folderRemoteId << mailRemoteId << mail.identifier() << folder.identifier();
550 550
551 KIMAP::ImapSet set; 551 KIMAP2::ImapSet set;
552 set.add(uid); 552 set.add(uid);
553 if (set.isEmpty()) { 553 if (set.isEmpty()) {
554 return KAsync::error<void>(1, "Couldn't determine uid of mail."); 554 return KAsync::error<void>(1, "Couldn't determine uid of mail.");
555 } 555 }
556 KIMAP::FetchJob::FetchScope scope; 556 KIMAP2::FetchJob::FetchScope scope;
557 scope.mode = KIMAP::FetchJob::FetchScope::Full; 557 scope.mode = KIMAP2::FetchJob::FetchScope::Full;
558 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 558 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort);
559 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); 559 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create();
560 SinkTrace() << "Connecting to:" << mServer << mPort; 560 SinkTrace() << "Connecting to:" << mServer << mPort;
@@ -618,9 +618,9 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in
618 SinkWarning() << "Error in index: " << error.message << property; 618 SinkWarning() << "Error in index: " << error.message << property;
619 }); 619 });
620 620
621 auto set = KIMAP::ImapSet::fromImapSequenceSet("1:*"); 621 auto set = KIMAP2::ImapSet::fromImapSequenceSet("1:*");
622 KIMAP::FetchJob::FetchScope scope; 622 KIMAP2::FetchJob::FetchScope scope;
623 scope.mode = KIMAP::FetchJob::FetchScope::Headers; 623 scope.mode = KIMAP2::FetchJob::FetchScope::Headers;
624 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); 624 auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort);
625 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); 625 auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create();
626 return imap->login(mUser, mPassword) 626 return imap->login(mUser, mPassword)
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index 921eeff..25cbc57 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -22,18 +22,18 @@
22#include <QFile> 22#include <QFile>
23#include <QTcpSocket> 23#include <QTcpSocket>
24#include <QTimer> 24#include <QTimer>
25#include <KIMAP/KIMAP/LoginJob> 25#include <KIMAP2/LoginJob>
26#include <kimap/namespacejob.h> 26#include <KIMAP2/NamespaceJob>
27#include <KIMAP/KIMAP/SelectJob> 27#include <KIMAP2/SelectJob>
28#include <KIMAP/KIMAP/AppendJob> 28#include <KIMAP2/AppendJob>
29#include <KIMAP/KIMAP/CreateJob> 29#include <KIMAP2/CreateJob>
30#include <KIMAP/KIMAP/CopyJob> 30#include <KIMAP2/CopyJob>
31#include <KIMAP/KIMAP/RenameJob> 31#include <KIMAP2/RenameJob>
32#include <KIMAP/KIMAP/DeleteJob> 32#include <KIMAP2/DeleteJob>
33#include <KIMAP/KIMAP/StoreJob> 33#include <KIMAP2/StoreJob>
34#include <KIMAP/KIMAP/ExpungeJob> 34#include <KIMAP2/ExpungeJob>
35#include <KIMAP/KIMAP/CapabilitiesJob> 35#include <KIMAP2/CapabilitiesJob>
36#include <KIMAP/KIMAP/SearchJob> 36#include <KIMAP2/SearchJob>
37 37
38#include <KCoreAddons/KJob> 38#include <KCoreAddons/KJob>
39 39
@@ -90,9 +90,9 @@ static KAsync::Job<void> runJob(KJob *job)
90 }); 90 });
91} 91}
92 92
93ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port) : mSession(new KIMAP::Session(serverUrl, qint16(port))) 93ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port) : mSession(new KIMAP2::Session(serverUrl, qint16(port)))
94{ 94{
95 QObject::connect(mSession, &KIMAP::Session::sslErrors, [this](const QList<QSslError> &errors) { 95 QObject::connect(mSession, &KIMAP2::Session::sslErrors, [this](const QList<QSslError> &errors) {
96 SinkLog() << "Got ssl error: " << errors; 96 SinkLog() << "Got ssl error: " << errors;
97 mSession->ignoreErrors(errors); 97 mSession->ignoreErrors(errors);
98 }); 98 });
@@ -106,21 +106,21 @@ ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port) : mSession(
106 106
107KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) 107KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password)
108{ 108{
109 auto loginJob = new KIMAP::LoginJob(mSession); 109 auto loginJob = new KIMAP2::LoginJob(mSession);
110 loginJob->setUserName(username); 110 loginJob->setUserName(username);
111 loginJob->setPassword(password); 111 loginJob->setPassword(password);
112 loginJob->setAuthenticationMode(KIMAP::LoginJob::Plain); 112 loginJob->setAuthenticationMode(KIMAP2::LoginJob::Plain);
113 if (mSession->port() == 143) { 113 if (mSession->port() == 143) {
114 loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true); 114 loginJob->setEncryptionMode(QSsl::TlsV1_0OrLater, true);
115 } else { 115 } else {
116 loginJob->setEncryptionMode(QSsl::AnyProtocol, false); 116 loginJob->setEncryptionMode(QSsl::AnyProtocol, false);
117 } 117 }
118 118
119 auto capabilitiesJob = new KIMAP::CapabilitiesJob(mSession); 119 auto capabilitiesJob = new KIMAP2::CapabilitiesJob(mSession);
120 QObject::connect(capabilitiesJob, &KIMAP::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) { 120 QObject::connect(capabilitiesJob, &KIMAP2::CapabilitiesJob::capabilitiesReceived, &mGuard, [this](const QStringList &capabilities) {
121 mCapabilities = capabilities; 121 mCapabilities = capabilities;
122 }); 122 });
123 auto namespaceJob = new KIMAP::NamespaceJob(mSession); 123 auto namespaceJob = new KIMAP2::NamespaceJob(mSession);
124 124
125 return runJob(loginJob).then(runJob(capabilitiesJob)).syncThen<void>([this](){ 125 return runJob(loginJob).then(runJob(capabilitiesJob)).syncThen<void>([this](){
126 SinkTrace() << "Supported capabilities: " << mCapabilities; 126 SinkTrace() << "Supported capabilities: " << mCapabilities;
@@ -152,7 +152,7 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString
152 152
153KAsync::Job<SelectResult> ImapServerProxy::select(const QString &mailbox) 153KAsync::Job<SelectResult> ImapServerProxy::select(const QString &mailbox)
154{ 154{
155 auto select = new KIMAP::SelectJob(mSession); 155 auto select = new KIMAP2::SelectJob(mSession);
156 select->setMailBox(mailbox); 156 select->setMailBox(mailbox);
157 select->setCondstoreEnabled(mCapabilities.contains("CONDSTORE")); 157 select->setCondstoreEnabled(mCapabilities.contains("CONDSTORE"));
158 return runJob<SelectResult>(select, [select](KJob* job) -> SelectResult { 158 return runJob<SelectResult>(select, [select](KJob* job) -> SelectResult {
@@ -162,46 +162,46 @@ KAsync::Job<SelectResult> ImapServerProxy::select(const QString &mailbox)
162 162
163KAsync::Job<qint64> ImapServerProxy::append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags, const QDateTime &internalDate) 163KAsync::Job<qint64> ImapServerProxy::append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags, const QDateTime &internalDate)
164{ 164{
165 auto append = new KIMAP::AppendJob(mSession); 165 auto append = new KIMAP2::AppendJob(mSession);
166 append->setMailBox(mailbox); 166 append->setMailBox(mailbox);
167 append->setContent(content); 167 append->setContent(content);
168 append->setFlags(flags); 168 append->setFlags(flags);
169 append->setInternalDate(internalDate); 169 append->setInternalDate(internalDate);
170 return runJob<qint64>(append, [](KJob *job) -> qint64{ 170 return runJob<qint64>(append, [](KJob *job) -> qint64{
171 return static_cast<KIMAP::AppendJob*>(job)->uid(); 171 return static_cast<KIMAP2::AppendJob*>(job)->uid();
172 }); 172 });
173} 173}
174 174
175KAsync::Job<void> ImapServerProxy::store(const KIMAP::ImapSet &set, const QList<QByteArray> &flags) 175KAsync::Job<void> ImapServerProxy::store(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags)
176{ 176{
177 return storeFlags(set, flags); 177 return storeFlags(set, flags);
178} 178}
179 179
180KAsync::Job<void> ImapServerProxy::storeFlags(const KIMAP::ImapSet &set, const QList<QByteArray> &flags) 180KAsync::Job<void> ImapServerProxy::storeFlags(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags)
181{ 181{
182 auto store = new KIMAP::StoreJob(mSession); 182 auto store = new KIMAP2::StoreJob(mSession);
183 store->setUidBased(true); 183 store->setUidBased(true);
184 store->setMode(KIMAP::StoreJob::SetFlags); 184 store->setMode(KIMAP2::StoreJob::SetFlags);
185 store->setSequenceSet(set); 185 store->setSequenceSet(set);
186 store->setFlags(flags); 186 store->setFlags(flags);
187 return runJob(store); 187 return runJob(store);
188} 188}
189 189
190KAsync::Job<void> ImapServerProxy::addFlags(const KIMAP::ImapSet &set, const QList<QByteArray> &flags) 190KAsync::Job<void> ImapServerProxy::addFlags(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags)
191{ 191{
192 auto store = new KIMAP::StoreJob(mSession); 192 auto store = new KIMAP2::StoreJob(mSession);
193 store->setUidBased(true); 193 store->setUidBased(true);
194 store->setMode(KIMAP::StoreJob::AppendFlags); 194 store->setMode(KIMAP2::StoreJob::AppendFlags);
195 store->setSequenceSet(set); 195 store->setSequenceSet(set);
196 store->setFlags(flags); 196 store->setFlags(flags);
197 return runJob(store); 197 return runJob(store);
198} 198}
199 199
200KAsync::Job<void> ImapServerProxy::removeFlags(const KIMAP::ImapSet &set, const QList<QByteArray> &flags) 200KAsync::Job<void> ImapServerProxy::removeFlags(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags)
201{ 201{
202 auto store = new KIMAP::StoreJob(mSession); 202 auto store = new KIMAP2::StoreJob(mSession);
203 store->setUidBased(true); 203 store->setUidBased(true);
204 store->setMode(KIMAP::StoreJob::RemoveFlags); 204 store->setMode(KIMAP2::StoreJob::RemoveFlags);
205 store->setSequenceSet(set); 205 store->setSequenceSet(set);
206 store->setFlags(flags); 206 store->setFlags(flags);
207 return runJob(store); 207 return runJob(store);
@@ -209,14 +209,14 @@ KAsync::Job<void> ImapServerProxy::removeFlags(const KIMAP::ImapSet &set, const
209 209
210KAsync::Job<void> ImapServerProxy::create(const QString &mailbox) 210KAsync::Job<void> ImapServerProxy::create(const QString &mailbox)
211{ 211{
212 auto create = new KIMAP::CreateJob(mSession); 212 auto create = new KIMAP2::CreateJob(mSession);
213 create->setMailBox(mailbox); 213 create->setMailBox(mailbox);
214 return runJob(create); 214 return runJob(create);
215} 215}
216 216
217KAsync::Job<void> ImapServerProxy::rename(const QString &mailbox, const QString &newMailbox) 217KAsync::Job<void> ImapServerProxy::rename(const QString &mailbox, const QString &newMailbox)
218{ 218{
219 auto rename = new KIMAP::RenameJob(mSession); 219 auto rename = new KIMAP2::RenameJob(mSession);
220 rename->setSourceMailBox(mailbox); 220 rename->setSourceMailBox(mailbox);
221 rename->setDestinationMailBox(newMailbox); 221 rename->setDestinationMailBox(newMailbox);
222 return runJob(rename); 222 return runJob(rename);
@@ -224,68 +224,68 @@ KAsync::Job<void> ImapServerProxy::rename(const QString &mailbox, const QString
224 224
225KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox) 225KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox)
226{ 226{
227 auto job = new KIMAP::DeleteJob(mSession); 227 auto job = new KIMAP2::DeleteJob(mSession);
228 job->setMailBox(mailbox); 228 job->setMailBox(mailbox);
229 return runJob(job); 229 return runJob(job);
230} 230}
231 231
232KAsync::Job<void> ImapServerProxy::expunge() 232KAsync::Job<void> ImapServerProxy::expunge()
233{ 233{
234 auto job = new KIMAP::ExpungeJob(mSession); 234 auto job = new KIMAP2::ExpungeJob(mSession);
235 return runJob(job); 235 return runJob(job);
236} 236}
237 237
238KAsync::Job<void> ImapServerProxy::expunge(const KIMAP::ImapSet &set) 238KAsync::Job<void> ImapServerProxy::expunge(const KIMAP2::ImapSet &set)
239{ 239{
240 //FIXME implement UID EXPUNGE 240 //FIXME implement UID EXPUNGE
241 auto job = new KIMAP::ExpungeJob(mSession); 241 auto job = new KIMAP2::ExpungeJob(mSession);
242 return runJob(job); 242 return runJob(job);
243} 243}
244 244
245KAsync::Job<void> ImapServerProxy::copy(const KIMAP::ImapSet &set, const QString &newMailbox) 245KAsync::Job<void> ImapServerProxy::copy(const KIMAP2::ImapSet &set, const QString &newMailbox)
246{ 246{
247 auto copy = new KIMAP::CopyJob(mSession); 247 auto copy = new KIMAP2::CopyJob(mSession);
248 copy->setSequenceSet(set); 248 copy->setSequenceSet(set);
249 copy->setUidBased(true); 249 copy->setUidBased(true);
250 copy->setMailBox(newMailbox); 250 copy->setMailBox(newMailbox);
251 return runJob(copy); 251 return runJob(copy);
252} 252}
253 253
254KAsync::Job<void> ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback) 254KAsync::Job<void> ImapServerProxy::fetch(const KIMAP2::ImapSet &set, KIMAP2::FetchJob::FetchScope scope, FetchCallback callback)
255{ 255{
256 auto fetch = new KIMAP::FetchJob(mSession); 256 auto fetch = new KIMAP2::FetchJob(mSession);
257 fetch->setSequenceSet(set); 257 fetch->setSequenceSet(set);
258 fetch->setUidBased(true); 258 fetch->setUidBased(true);
259 fetch->setScope(scope); 259 fetch->setScope(scope);
260 QObject::connect(fetch, static_cast<void(KIMAP::FetchJob::*)(const QString &, 260 QObject::connect(fetch, static_cast<void(KIMAP2::FetchJob::*)(const QString &,
261 const QMap<qint64,qint64> &, 261 const QMap<qint64,qint64> &,
262 const QMap<qint64,qint64> &, 262 const QMap<qint64,qint64> &,
263 const QMap<qint64,KIMAP::MessageAttribute> &, 263 const QMap<qint64,KIMAP2::MessageAttribute> &,
264 const QMap<qint64,KIMAP::MessageFlags> &, 264 const QMap<qint64,KIMAP2::MessageFlags> &,
265 const QMap<qint64,KIMAP::MessagePtr> &)>(&KIMAP::FetchJob::headersReceived), 265 const QMap<qint64,KIMAP2::MessagePtr> &)>(&KIMAP2::FetchJob::headersReceived),
266 callback); 266 callback);
267 return runJob(fetch); 267 return runJob(fetch);
268} 268}
269 269
270KAsync::Job<QVector<qint64>> ImapServerProxy::search(const KIMAP::ImapSet &set) 270KAsync::Job<QVector<qint64>> ImapServerProxy::search(const KIMAP2::ImapSet &set)
271{ 271{
272 auto search = new KIMAP::SearchJob(mSession); 272 auto search = new KIMAP2::SearchJob(mSession);
273 search->setTerm(KIMAP::Term(KIMAP::Term::Uid, set)); 273 search->setTerm(KIMAP2::Term(KIMAP2::Term::Uid, set));
274 search->setUidBased(true); 274 search->setUidBased(true);
275 return runJob<QVector<qint64>>(search, [](KJob *job) -> QVector<qint64> { 275 return runJob<QVector<qint64>>(search, [](KJob *job) -> QVector<qint64> {
276 return static_cast<KIMAP::SearchJob*>(job)->results(); 276 return static_cast<KIMAP2::SearchJob*>(job)->results();
277 }); 277 });
278} 278}
279 279
280KAsync::Job<void> ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, const std::function<void(const QVector<Message> &)> &callback) 280KAsync::Job<void> ImapServerProxy::fetch(const KIMAP2::ImapSet &set, KIMAP2::FetchJob::FetchScope scope, const std::function<void(const QVector<Message> &)> &callback)
281{ 281{
282 return fetch(set, scope, 282 return fetch(set, scope,
283 [callback](const QString &mailbox, 283 [callback](const QString &mailbox,
284 const QMap<qint64,qint64> &uids, 284 const QMap<qint64,qint64> &uids,
285 const QMap<qint64,qint64> &sizes, 285 const QMap<qint64,qint64> &sizes,
286 const QMap<qint64,KIMAP::MessageAttribute> &attrs, 286 const QMap<qint64,KIMAP2::MessageAttribute> &attrs,
287 const QMap<qint64,KIMAP::MessageFlags> &flags, 287 const QMap<qint64,KIMAP2::MessageFlags> &flags,
288 const QMap<qint64,KIMAP::MessagePtr> &messages) { 288 const QMap<qint64,KIMAP2::MessagePtr> &messages) {
289 QVector<Message> list; 289 QVector<Message> list;
290 for (const auto &id : uids.keys()) { 290 for (const auto &id : uids.keys()) {
291 list << Message{uids.value(id), sizes.value(id), attrs.value(id), flags.value(id), messages.value(id)}; 291 list << Message{uids.value(id), sizes.value(id), attrs.value(id), flags.value(id), messages.value(id)};
@@ -302,17 +302,17 @@ QStringList ImapServerProxy::getCapabilities() const
302KAsync::Job<QList<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbox, const qint64 minUid) 302KAsync::Job<QList<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbox, const qint64 minUid)
303{ 303{
304 auto list = QSharedPointer<QList<qint64>>::create(); 304 auto list = QSharedPointer<QList<qint64>>::create();
305 KIMAP::FetchJob::FetchScope scope; 305 KIMAP2::FetchJob::FetchScope scope;
306 scope.mode = KIMAP::FetchJob::FetchScope::Flags; 306 scope.mode = KIMAP2::FetchJob::FetchScope::Flags;
307 307
308 //Fetch headers of all messages 308 //Fetch headers of all messages
309 return fetch(KIMAP::ImapSet(minUid, 0), scope, 309 return fetch(KIMAP2::ImapSet(minUid, 0), scope,
310 [list](const QString &mailbox, 310 [list](const QString &mailbox,
311 const QMap<qint64,qint64> &uids, 311 const QMap<qint64,qint64> &uids,
312 const QMap<qint64,qint64> &sizes, 312 const QMap<qint64,qint64> &sizes,
313 const QMap<qint64,KIMAP::MessageAttribute> &attrs, 313 const QMap<qint64,KIMAP2::MessageAttribute> &attrs,
314 const QMap<qint64,KIMAP::MessageFlags> &flags, 314 const QMap<qint64,KIMAP2::MessageFlags> &flags,
315 const QMap<qint64,KIMAP::MessagePtr> &messages) { 315 const QMap<qint64,KIMAP2::MessagePtr> &messages) {
316 SinkTrace() << "Received " << uids.size() << " headers from " << mailbox; 316 SinkTrace() << "Received " << uids.size() << " headers from " << mailbox;
317 SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); 317 SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size();
318 318
@@ -331,32 +331,32 @@ KAsync::Job<QList<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbox,
331 331
332KAsync::Job<QVector<qint64>> ImapServerProxy::fetchUids(const QString &mailbox) 332KAsync::Job<QVector<qint64>> ImapServerProxy::fetchUids(const QString &mailbox)
333{ 333{
334 return select(mailbox).then<QVector<qint64>>(search(KIMAP::ImapSet(1, 0))); 334 return select(mailbox).then<QVector<qint64>>(search(KIMAP2::ImapSet(1, 0)));
335} 335}
336 336
337KAsync::Job<void> ImapServerProxy::list(KIMAP::ListJob::Option option, const std::function<void(const QList<KIMAP::MailBoxDescriptor> &mailboxes,const QList<QList<QByteArray> > &flags)> &callback) 337KAsync::Job<void> ImapServerProxy::list(KIMAP2::ListJob::Option option, const std::function<void(const QList<KIMAP2::MailBoxDescriptor> &mailboxes,const QList<QList<QByteArray> > &flags)> &callback)
338{ 338{
339 auto listJob = new KIMAP::ListJob(mSession); 339 auto listJob = new KIMAP2::ListJob(mSession);
340 listJob->setOption(option); 340 listJob->setOption(option);
341 // listJob->setQueriedNamespaces(serverNamespaces()); 341 // listJob->setQueriedNamespaces(serverNamespaces());
342 QObject::connect(listJob, &KIMAP::ListJob::mailBoxesReceived, 342 QObject::connect(listJob, &KIMAP2::ListJob::mailBoxesReceived,
343 listJob, callback); 343 listJob, callback);
344 return runJob(listJob); 344 return runJob(listJob);
345} 345}
346 346
347KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const KIMAP::ImapSet &set) 347KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const KIMAP2::ImapSet &set)
348{ 348{
349 return select(mailbox).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge(set)); 349 return select(mailbox).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge(set));
350} 350}
351 351
352KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const QByteArray &imapSet) 352KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const QByteArray &imapSet)
353{ 353{
354 const auto set = KIMAP::ImapSet::fromImapSequenceSet(imapSet); 354 const auto set = KIMAP2::ImapSet::fromImapSequenceSet(imapSet);
355 return remove(mailbox, set); 355 return remove(mailbox, set);
356} 356}
357 357
358 358
359KAsync::Job<void> ImapServerProxy::move(const QString &mailbox, const KIMAP::ImapSet &set, const QString &newMailbox) 359KAsync::Job<void> ImapServerProxy::move(const QString &mailbox, const KIMAP2::ImapSet &set, const QString &newMailbox)
360{ 360{
361 return select(mailbox).then<void>(copy(set, newMailbox)).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge(set)); 361 return select(mailbox).then<void>(copy(set, newMailbox)).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge(set));
362} 362}
@@ -397,7 +397,7 @@ KAsync::Job<QString> ImapServerProxy::renameSubfolder(const QString &oldMailbox,
397KAsync::Job<void> ImapServerProxy::fetchFolders(std::function<void(const QVector<Folder> &)> callback) 397KAsync::Job<void> ImapServerProxy::fetchFolders(std::function<void(const QVector<Folder> &)> callback)
398{ 398{
399 SinkTrace() << "Fetching folders"; 399 SinkTrace() << "Fetching folders";
400 return list(KIMAP::ListJob::IncludeUnsubscribed, [callback](const QList<KIMAP::MailBoxDescriptor> &mailboxes, const QList<QList<QByteArray> > &flags){ 400 return list(KIMAP2::ListJob::IncludeUnsubscribed, [callback](const QList<KIMAP2::MailBoxDescriptor> &mailboxes, const QList<QList<QByteArray> > &flags){
401 QVector<Folder> list; 401 QVector<Folder> list;
402 for (int i = 0; i < mailboxes.size(); i++) { 402 for (int i = 0; i < mailboxes.size(); i++) {
403 const auto mailbox = mailboxes[i]; 403 const auto mailbox = mailboxes[i];
@@ -443,11 +443,11 @@ KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, qint64 ui
443 callback(QVector<Message>()); 443 callback(QVector<Message>());
444 return KAsync::null<void>(); 444 return KAsync::null<void>();
445 } 445 }
446 KIMAP::FetchJob::FetchScope scope; 446 KIMAP2::FetchJob::FetchScope scope;
447 scope.parts.clear(); 447 scope.parts.clear();
448 scope.mode = KIMAP::FetchJob::FetchScope::Full; 448 scope.mode = KIMAP2::FetchJob::FetchScope::Full;
449 449
450 KIMAP::ImapSet set; 450 KIMAP2::ImapSet set;
451 set.add(uidsToFetch.toVector()); 451 set.add(uidsToFetch.toVector());
452 auto count = QSharedPointer<int>::create(); 452 auto count = QSharedPointer<int>::create();
453 return fetch(set, scope, [=](const QVector<Message> &messages) { 453 return fetch(set, scope, [=](const QVector<Message> &messages) {
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 70dfa58..9adce3d 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -22,9 +22,9 @@
22#include <Async/Async> 22#include <Async/Async>
23 23
24#include <KMime/KMime/KMimeMessage> 24#include <KMime/KMime/KMimeMessage>
25#include <KIMAP/KIMAP/ListJob> 25#include <KIMAP2/ListJob>
26#include <KIMAP/KIMAP/Session> 26#include <KIMAP2/Session>
27#include <KIMAP/KIMAP/FetchJob> 27#include <KIMAP2/FetchJob>
28 28
29namespace Imap { 29namespace Imap {
30 30
@@ -82,7 +82,7 @@ struct SelectResult {
82}; 82};
83 83
84class ImapServerProxy { 84class ImapServerProxy {
85 KIMAP::Session *mSession; 85 KIMAP2::Session *mSession;
86 QStringList mCapabilities; 86 QStringList mCapabilities;
87 87
88 QSet<QString> mPersonalNamespaces; 88 QSet<QString> mPersonalNamespaces;
@@ -99,36 +99,36 @@ public:
99 KAsync::Job<void> login(const QString &username, const QString &password); 99 KAsync::Job<void> login(const QString &username, const QString &password);
100 KAsync::Job<SelectResult> select(const QString &mailbox); 100 KAsync::Job<SelectResult> select(const QString &mailbox);
101 KAsync::Job<qint64> append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags = QList<QByteArray>(), const QDateTime &internalDate = QDateTime()); 101 KAsync::Job<qint64> append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags = QList<QByteArray>(), const QDateTime &internalDate = QDateTime());
102 KAsync::Job<void> store(const KIMAP::ImapSet &set, const QList<QByteArray> &flags); 102 KAsync::Job<void> store(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags);
103 KAsync::Job<void> storeFlags(const KIMAP::ImapSet &set, const QList<QByteArray> &flags); 103 KAsync::Job<void> storeFlags(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags);
104 KAsync::Job<void> addFlags(const KIMAP::ImapSet &set, const QList<QByteArray> &flags); 104 KAsync::Job<void> addFlags(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags);
105 KAsync::Job<void> removeFlags(const KIMAP::ImapSet &set, const QList<QByteArray> &flags); 105 KAsync::Job<void> removeFlags(const KIMAP2::ImapSet &set, const QList<QByteArray> &flags);
106 KAsync::Job<void> create(const QString &mailbox); 106 KAsync::Job<void> create(const QString &mailbox);
107 KAsync::Job<void> rename(const QString &mailbox, const QString &newMailbox); 107 KAsync::Job<void> rename(const QString &mailbox, const QString &newMailbox);
108 KAsync::Job<void> remove(const QString &mailbox); 108 KAsync::Job<void> remove(const QString &mailbox);
109 KAsync::Job<void> expunge(); 109 KAsync::Job<void> expunge();
110 KAsync::Job<void> expunge(const KIMAP::ImapSet &set); 110 KAsync::Job<void> expunge(const KIMAP2::ImapSet &set);
111 KAsync::Job<void> copy(const KIMAP::ImapSet &set, const QString &newMailbox); 111 KAsync::Job<void> copy(const KIMAP2::ImapSet &set, const QString &newMailbox);
112 KAsync::Job<QVector<qint64>> search(const KIMAP::ImapSet &set); 112 KAsync::Job<QVector<qint64>> search(const KIMAP2::ImapSet &set);
113 113
114 typedef std::function<void(const QString &, 114 typedef std::function<void(const QString &,
115 const QMap<qint64,qint64> &, 115 const QMap<qint64,qint64> &,
116 const QMap<qint64,qint64> &, 116 const QMap<qint64,qint64> &,
117 const QMap<qint64,KIMAP::MessageAttribute> &, 117 const QMap<qint64,KIMAP2::MessageAttribute> &,
118 const QMap<qint64,KIMAP::MessageFlags> &, 118 const QMap<qint64,KIMAP2::MessageFlags> &,
119 const QMap<qint64,KIMAP::MessagePtr> &)> FetchCallback; 119 const QMap<qint64,KIMAP2::MessagePtr> &)> FetchCallback;
120 120
121 KAsync::Job<void> fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback); 121 KAsync::Job<void> fetch(const KIMAP2::ImapSet &set, KIMAP2::FetchJob::FetchScope scope, FetchCallback callback);
122 KAsync::Job<void> fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, const std::function<void(const QVector<Message> &)> &callback); 122 KAsync::Job<void> fetch(const KIMAP2::ImapSet &set, KIMAP2::FetchJob::FetchScope scope, const std::function<void(const QVector<Message> &)> &callback);
123 KAsync::Job<void> list(KIMAP::ListJob::Option option, const std::function<void(const QList<KIMAP::MailBoxDescriptor> &mailboxes,const QList<QList<QByteArray> > &flags)> &callback); 123 KAsync::Job<void> list(KIMAP2::ListJob::Option option, const std::function<void(const QList<KIMAP2::MailBoxDescriptor> &mailboxes,const QList<QList<QByteArray> > &flags)> &callback);
124 124
125 QStringList getCapabilities() const; 125 QStringList getCapabilities() const;
126 126
127 //Composed calls that do login etc. 127 //Composed calls that do login etc.
128 KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox, qint64 minUid = 1); 128 KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox, qint64 minUid = 1);
129 KAsync::Job<void> remove(const QString &mailbox, const KIMAP::ImapSet &set); 129 KAsync::Job<void> remove(const QString &mailbox, const KIMAP2::ImapSet &set);
130 KAsync::Job<void> remove(const QString &mailbox, const QByteArray &imapSet); 130 KAsync::Job<void> remove(const QString &mailbox, const QByteArray &imapSet);
131 KAsync::Job<void> move(const QString &mailbox, const KIMAP::ImapSet &set, const QString &newMailbox); 131 KAsync::Job<void> move(const QString &mailbox, const KIMAP2::ImapSet &set, const QString &newMailbox);
132 KAsync::Job<QString> createSubfolder(const QString &parentMailbox, const QString &folderName); 132 KAsync::Job<QString> createSubfolder(const QString &parentMailbox, const QString &folderName);
133 KAsync::Job<QString> renameSubfolder(const QString &mailbox, const QString &newName); 133 KAsync::Job<QString> renameSubfolder(const QString &mailbox, const QString &newName);
134 KAsync::Job<QVector<qint64>> fetchUids(const QString &mailbox); 134 KAsync::Job<QVector<qint64>> fetchUids(const QString &mailbox);
diff --git a/examples/imapresource/tests/imapserverproxytest.cpp b/examples/imapresource/tests/imapserverproxytest.cpp
index 80dcbea..21c2248 100644
--- a/examples/imapresource/tests/imapserverproxytest.cpp
+++ b/examples/imapresource/tests/imapserverproxytest.cpp
@@ -73,16 +73,16 @@ private slots:
73 ImapServerProxy imap("localhost", 993); 73 ImapServerProxy imap("localhost", 993);
74 VERIFYEXEC(imap.login("doe", "doe")); 74 VERIFYEXEC(imap.login("doe", "doe"));
75 75
76 KIMAP::FetchJob::FetchScope scope; 76 KIMAP2::FetchJob::FetchScope scope;
77 scope.mode = KIMAP::FetchJob::FetchScope::Headers; 77 scope.mode = KIMAP2::FetchJob::FetchScope::Headers;
78 int count = 0; 78 int count = 0;
79 auto job = imap.select("INBOX.test").then<void>(imap.fetch(KIMAP::ImapSet::fromImapSequenceSet("1:*"), scope, 79 auto job = imap.select("INBOX.test").then<void>(imap.fetch(KIMAP2::ImapSet::fromImapSequenceSet("1:*"), scope,
80 [&count](const QString &mailbox, 80 [&count](const QString &mailbox,
81 const QMap<qint64,qint64> &uids, 81 const QMap<qint64,qint64> &uids,
82 const QMap<qint64,qint64> &sizes, 82 const QMap<qint64,qint64> &sizes,
83 const QMap<qint64,KIMAP::MessageAttribute> &attrs, 83 const QMap<qint64,KIMAP2::MessageAttribute> &attrs,
84 const QMap<qint64,KIMAP::MessageFlags> &flags, 84 const QMap<qint64,KIMAP2::MessageFlags> &flags,
85 const QMap<qint64,KIMAP::MessagePtr> &messages) { 85 const QMap<qint64,KIMAP2::MessagePtr> &messages) {
86 SinkTrace() << "Received " << uids.size() << " messages from " << mailbox; 86 SinkTrace() << "Received " << uids.size() << " messages from " << mailbox;
87 SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); 87 SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size();
88 count += uids.size(); 88 count += uids.size();
@@ -98,16 +98,16 @@ private slots:
98 VERIFYEXEC(imap.login("doe", "doe")); 98 VERIFYEXEC(imap.login("doe", "doe"));
99 VERIFYEXEC(imap.remove("INBOX.test", "1:*")); 99 VERIFYEXEC(imap.remove("INBOX.test", "1:*"));
100 100
101 KIMAP::FetchJob::FetchScope scope; 101 KIMAP2::FetchJob::FetchScope scope;
102 scope.mode = KIMAP::FetchJob::FetchScope::Headers; 102 scope.mode = KIMAP2::FetchJob::FetchScope::Headers;
103 int count = 0; 103 int count = 0;
104 auto job = imap.select("INBOX.test").then<void>(imap.fetch(KIMAP::ImapSet::fromImapSequenceSet("1:*"), scope, 104 auto job = imap.select("INBOX.test").then<void>(imap.fetch(KIMAP2::ImapSet::fromImapSequenceSet("1:*"), scope,
105 [&count](const QString &mailbox, 105 [&count](const QString &mailbox,
106 const QMap<qint64,qint64> &uids, 106 const QMap<qint64,qint64> &uids,
107 const QMap<qint64,qint64> &sizes, 107 const QMap<qint64,qint64> &sizes,
108 const QMap<qint64,KIMAP::MessageAttribute> &attrs, 108 const QMap<qint64,KIMAP2::MessageAttribute> &attrs,
109 const QMap<qint64,KIMAP::MessageFlags> &flags, 109 const QMap<qint64,KIMAP2::MessageFlags> &flags,
110 const QMap<qint64,KIMAP::MessagePtr> &messages) { 110 const QMap<qint64,KIMAP2::MessagePtr> &messages) {
111 SinkTrace() << "Received " << uids.size() << " messages from " << mailbox; 111 SinkTrace() << "Received " << uids.size() << " messages from " << mailbox;
112 SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size(); 112 SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size();
113 count += uids.size(); 113 count += uids.size();