summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapresource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-21 21:28:23 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-15 16:14:19 +0200
commit9a9bb39f7641a818434cafa0dae0c8aa47124c0b (patch)
tree3da0b8642fb73f1fe8762291a7b3a8ed171444d6 /examples/imapresource/imapresource.cpp
parent07d9eaaa97dfa63bb3ff9767c6b2e152ad8a04e0 (diff)
downloadsink-9a9bb39f7641a818434cafa0dae0c8aa47124c0b.tar.gz
sink-9a9bb39f7641a818434cafa0dae0c8aa47124c0b.zip
Incremental fetch of mails
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r--examples/imapresource/imapresource.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index 3ad80f9..e199ea1 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -233,13 +233,23 @@ public:
233 return KAsync::null<void>(); 233 return KAsync::null<void>();
234 }) 234 })
235 .then<void, KAsync::Job<void>>([this, folder, imap]() { 235 .then<void, KAsync::Job<void>>([this, folder, imap]() {
236 auto uidNext = 0; 236 SinkTrace() << "About to fetch mail";
237 return imap->fetchMessages(folder, uidNext, [this, folder](const QVector<Message> &messages) { 237 const auto uidNext = syncStore().readValue(folder.normalizedPath().toUtf8() + "uidnext").toLongLong();
238 auto maxUid = QSharedPointer<qint64>::create(0);
239 return imap->fetchMessages(folder, uidNext, [this, folder, maxUid](const QVector<Message> &messages) {
238 SinkTrace() << "Got mail"; 240 SinkTrace() << "Got mail";
241 for (const auto &m : messages) {
242 if (*maxUid < m.uid) {
243 *maxUid = m.uid;
244 }
245 }
239 synchronizeMails(folder.normalizedPath(), messages); 246 synchronizeMails(folder.normalizedPath(), messages);
240 }, 247 },
241 [](int progress, int total) { 248 [](int progress, int total) {
242 SinkTrace() << "Progress: " << progress << " out of " << total; 249 SinkTrace() << "Progress: " << progress << " out of " << total;
250 })
251 .then<void>([this, maxUid, folder]() {
252 syncStore().writeValue(folder.normalizedPath().toUtf8() + "uidnext", QByteArray::number(*maxUid));
243 }); 253 });
244 }); 254 });
245 255