summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapserverproxy.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-14 11:17:47 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-15 16:14:19 +0200
commitca9c54670cc2d26386c80a2aeed2c999313ec362 (patch)
tree71cddc6a175be007aade113b8e19aed0360c7f29 /examples/imapresource/imapserverproxy.cpp
parent25fdab9836b1fdd248d3d36c00a96740093cd749 (diff)
downloadsink-ca9c54670cc2d26386c80a2aeed2c999313ec362.tar.gz
sink-ca9c54670cc2d26386c80a2aeed2c999313ec362.zip
New kimap2 syntax
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r--examples/imapresource/imapserverproxy.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index b14ebd2..a75825e 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -295,6 +295,8 @@ KAsync::Job<QList<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbox,
295 //Fetch headers of all messages 295 //Fetch headers of all messages
296 return fetch(KIMAP2::ImapSet(minUid, 0), scope, 296 return fetch(KIMAP2::ImapSet(minUid, 0), scope,
297 [list](const KIMAP2::FetchJob::Result &result) { 297 [list](const KIMAP2::FetchJob::Result &result) {
298 // SinkTrace() << "Received " << uids.size() << " headers from " << mailbox;
299 // SinkTrace() << uids.size() << sizes.size() << attrs.size() << flags.size() << messages.size();
298 300
299 //TODO based on the data available here, figure out which messages to actually fetch 301 //TODO based on the data available here, figure out which messages to actually fetch
300 //(we only fetched headers and structure so far) 302 //(we only fetched headers and structure so far)
@@ -312,12 +314,12 @@ KAsync::Job<QVector<qint64>> ImapServerProxy::fetchUids(const QString &mailbox)
312 return select(mailbox).then<QVector<qint64>>(search(KIMAP2::ImapSet(1, 0))); 314 return select(mailbox).then<QVector<qint64>>(search(KIMAP2::ImapSet(1, 0)));
313} 315}
314 316
315KAsync::Job<void> ImapServerProxy::list(KIMAP2::ListJob::Option option, const std::function<void(const QList<KIMAP2::MailBoxDescriptor> &mailboxes,const QList<QList<QByteArray> > &flags)> &callback) 317KAsync::Job<void> ImapServerProxy::list(KIMAP2::ListJob::Option option, const std::function<void(const KIMAP2::MailBoxDescriptor &mailboxes, const QList<QByteArray> &flags)> &callback)
316{ 318{
317 auto listJob = new KIMAP2::ListJob(mSession); 319 auto listJob = new KIMAP2::ListJob(mSession);
318 listJob->setOption(option); 320 listJob->setOption(option);
319 // listJob->setQueriedNamespaces(serverNamespaces()); 321 // listJob->setQueriedNamespaces(serverNamespaces());
320 QObject::connect(listJob, &KIMAP2::ListJob::mailBoxesReceived, 322 QObject::connect(listJob, &KIMAP2::ListJob::resultReceived,
321 listJob, callback); 323 listJob, callback);
322 return runJob(listJob); 324 return runJob(listJob);
323} 325}
@@ -372,19 +374,13 @@ KAsync::Job<QString> ImapServerProxy::renameSubfolder(const QString &oldMailbox,
372 }); 374 });
373} 375}
374 376
375KAsync::Job<void> ImapServerProxy::fetchFolders(std::function<void(const QVector<Folder> &)> callback) 377KAsync::Job<void> ImapServerProxy::fetchFolders(std::function<void(const Folder &)> callback)
376{ 378{
377 SinkTrace() << "Fetching folders"; 379 SinkTrace() << "Fetching folders";
378 return list(KIMAP2::ListJob::IncludeUnsubscribed, [callback](const QList<KIMAP2::MailBoxDescriptor> &mailboxes, const QList<QList<QByteArray> > &flags){ 380 return list(KIMAP2::ListJob::IncludeUnsubscribed, [callback](const KIMAP2::MailBoxDescriptor &mailbox, const QList<QByteArray> &flags){
379 QVector<Folder> list; 381 bool noselect = flags.contains(QByteArray(FolderFlags::Noselect).toLower()) || flags.contains(QByteArray(FolderFlags::Noselect));
380 for (int i = 0; i < mailboxes.size(); i++) { 382 SinkLog() << "Found mailbox: " << mailbox.name << flags << FolderFlags::Noselect << noselect;
381 const auto mailbox = mailboxes[i]; 383 callback(Folder{mailbox.name.split(mailbox.separator), mailbox.name, mailbox.separator, noselect});
382 const auto mailboxFlags = flags[i];
383 bool noselect = mailboxFlags.contains(QByteArray(FolderFlags::Noselect).toLower()) || mailboxFlags.contains(QByteArray(FolderFlags::Noselect));
384 SinkLog() << "Found mailbox: " << mailbox.name << mailboxFlags << FolderFlags::Noselect << noselect;
385 list << Folder{mailbox.name.split(mailbox.separator), mailbox.name, mailbox.separator, noselect};
386 }
387 callback(list);
388 }); 384 });
389} 385}
390 386