diff options
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 14 |
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 | ||