diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-21 21:28:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-15 16:14:19 +0200 |
commit | 9a9bb39f7641a818434cafa0dae0c8aa47124c0b (patch) | |
tree | 3da0b8642fb73f1fe8762291a7b3a8ed171444d6 /examples/imapresource/imapserverproxy.cpp | |
parent | 07d9eaaa97dfa63bb3ff9767c6b2e152ad8a04e0 (diff) | |
download | sink-9a9bb39f7641a818434cafa0dae0c8aa47124c0b.tar.gz sink-9a9bb39f7641a818434cafa0dae0c8aa47124c0b.zip |
Incremental fetch of mails
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 5fffb36..a3d8d16 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp | |||
@@ -338,15 +338,14 @@ QStringList ImapServerProxy::getCapabilities() const | |||
338 | return mCapabilities; | 338 | return mCapabilities; |
339 | } | 339 | } |
340 | 340 | ||
341 | KAsync::Job<QList<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbox) | 341 | KAsync::Job<QList<qint64>> ImapServerProxy::fetchHeaders(const QString &mailbox, const qint64 minUid) |
342 | { | 342 | { |
343 | auto list = QSharedPointer<QList<qint64>>::create(); | 343 | auto list = QSharedPointer<QList<qint64>>::create(); |
344 | KIMAP::FetchJob::FetchScope scope; | 344 | KIMAP::FetchJob::FetchScope scope; |
345 | scope.parts.clear(); | ||
346 | scope.mode = KIMAP::FetchJob::FetchScope::Flags; | 345 | scope.mode = KIMAP::FetchJob::FetchScope::Flags; |
347 | 346 | ||
348 | //Fetch headers of all messages | 347 | //Fetch headers of all messages |
349 | return fetch(KIMAP::ImapSet(1, 0), scope, | 348 | return fetch(KIMAP::ImapSet(minUid, 0), scope, |
350 | [list](const QString &mailbox, | 349 | [list](const QString &mailbox, |
351 | const QMap<qint64,qint64> &uids, | 350 | const QMap<qint64,qint64> &uids, |
352 | const QMap<qint64,qint64> &sizes, | 351 | const QMap<qint64,qint64> &sizes, |
@@ -459,18 +458,18 @@ QString ImapServerProxy::mailboxFromFolder(const Folder &folder) const | |||
459 | 458 | ||
460 | KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, qint64 uidNext, std::function<void(const QVector<Message> &)> callback, std::function<void(int, int)> progress) | 459 | KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, qint64 uidNext, std::function<void(const QVector<Message> &)> callback, std::function<void(int, int)> progress) |
461 | { | 460 | { |
462 | Q_UNUSED(uidNext); | ||
463 | auto time = QSharedPointer<QTime>::create(); | 461 | auto time = QSharedPointer<QTime>::create(); |
464 | time->start(); | 462 | time->start(); |
465 | Q_ASSERT(!mPersonalNamespaceSeparator.isNull()); | 463 | Q_ASSERT(!mPersonalNamespaceSeparator.isNull()); |
466 | return select(mailboxFromFolder(folder)).then<void, KAsync::Job<void>, SelectResult>([this, callback, folder, time, progress, uidNext](const SelectResult &selectResult) -> KAsync::Job<void> { | 464 | return select(mailboxFromFolder(folder)).then<void, KAsync::Job<void>, SelectResult>([this, callback, folder, time, progress, uidNext](const SelectResult &selectResult) -> KAsync::Job<void> { |
467 | 465 | ||
468 | if (selectResult.uidNext == uidNext) { | 466 | SinkLog() << "UIDNEXT " << selectResult.uidNext << uidNext; |
467 | if (selectResult.uidNext == (uidNext + 1)) { | ||
469 | SinkTrace() << "Uidnext didn't change, nothing to do."; | 468 | SinkTrace() << "Uidnext didn't change, nothing to do."; |
470 | return KAsync::null<void>(); | 469 | return KAsync::null<void>(); |
471 | } | 470 | } |
472 | 471 | ||
473 | return fetchHeaders(mailboxFromFolder(folder)).then<void, KAsync::Job<void>, QList<qint64>>([this, callback, time, progress](const QList<qint64> &uidsToFetch){ | 472 | return fetchHeaders(mailboxFromFolder(folder), (uidNext + 1)).then<void, KAsync::Job<void>, QList<qint64>>([this, callback, time, progress](const QList<qint64> &uidsToFetch){ |
474 | SinkTrace() << "Fetched headers"; | 473 | SinkTrace() << "Fetched headers"; |
475 | SinkTrace() << " Total: " << uidsToFetch.size(); | 474 | SinkTrace() << " Total: " << uidsToFetch.size(); |
476 | SinkTrace() << " Uids to fetch: " << uidsToFetch; | 475 | SinkTrace() << " Uids to fetch: " << uidsToFetch; |