diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 94ca27a..533dea3 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -184,14 +184,12 @@ public: | |||
184 | return flags; | 184 | return flags; |
185 | } | 185 | } |
186 | 186 | ||
187 | void synchronizeMails(const QByteArray &folderRid, const Message &message) | 187 | void synchronizeMails(const QByteArray &folderRid, const QByteArray &folderLocalId, const Message &message) |
188 | { | 188 | { |
189 | auto time = QSharedPointer<QTime>::create(); | 189 | auto time = QSharedPointer<QTime>::create(); |
190 | time->start(); | 190 | time->start(); |
191 | SinkTraceCtx(mLogCtx) << "Importing new mail." << folderRid; | 191 | SinkTraceCtx(mLogCtx) << "Importing new mail." << folderRid; |
192 | 192 | ||
193 | const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRid); | ||
194 | |||
195 | const auto remoteId = assembleMailRid(folderLocalId, message.uid); | 193 | const auto remoteId = assembleMailRid(folderLocalId, message.uid); |
196 | 194 | ||
197 | Q_ASSERT(message.msg); | 195 | Q_ASSERT(message.msg); |
@@ -315,14 +313,15 @@ public: | |||
315 | SinkTraceCtx(mLogCtx) << "Uids to fetch: " << filteredAndSorted; | 313 | SinkTraceCtx(mLogCtx) << "Uids to fetch: " << filteredAndSorted; |
316 | 314 | ||
317 | bool headersOnly = false; | 315 | bool headersOnly = false; |
316 | const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRemoteId); | ||
318 | return imap->fetchMessages(folder, filteredAndSorted, headersOnly, [=](const Message &m) { | 317 | return imap->fetchMessages(folder, filteredAndSorted, headersOnly, [=](const Message &m) { |
319 | if (*maxUid < m.uid) { | 318 | if (*maxUid < m.uid) { |
320 | *maxUid = m.uid; | 319 | *maxUid = m.uid; |
321 | } | 320 | } |
322 | synchronizeMails(folderRemoteId, m); | 321 | synchronizeMails(folderRemoteId, folderLocalId, m); |
323 | }, | 322 | }, |
324 | [this, maxUid, folder](int progress, int total) { | 323 | [=](int progress, int total) { |
325 | reportProgress(progress, total); | 324 | reportProgress(progress, total, QByteArrayList{} << folderLocalId); |
326 | //commit every 10 messages | 325 | //commit every 10 messages |
327 | if ((progress % 10) == 0) { | 326 | if ((progress % 10) == 0) { |
328 | commit(); | 327 | commit(); |
@@ -359,11 +358,12 @@ public: | |||
359 | SinkLogCtx(mLogCtx) << "Fetching headers for: " << toFetch; | 358 | SinkLogCtx(mLogCtx) << "Fetching headers for: " << toFetch; |
360 | 359 | ||
361 | bool headersOnly = true; | 360 | bool headersOnly = true; |
361 | const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRemoteId); | ||
362 | return imap->fetchMessages(folder, toFetch, headersOnly, [=](const Message &m) { | 362 | return imap->fetchMessages(folder, toFetch, headersOnly, [=](const Message &m) { |
363 | synchronizeMails(folderRemoteId, m); | 363 | synchronizeMails(folderRemoteId, folderLocalId, m); |
364 | }, | 364 | }, |
365 | [=](int progress, int total) { | 365 | [=](int progress, int total) { |
366 | reportProgress(progress, total); | 366 | reportProgress(progress, total, QByteArrayList{} << folderLocalId); |
367 | //commit every 100 messages | 367 | //commit every 100 messages |
368 | if ((progress % 100) == 0) { | 368 | if ((progress % 100) == 0) { |
369 | commit(); | 369 | commit(); |
@@ -567,11 +567,12 @@ public: | |||
567 | } | 567 | } |
568 | SinkLog() << "Fetching messages: " << toFetch << folderRemoteId; | 568 | SinkLog() << "Fetching messages: " << toFetch << folderRemoteId; |
569 | bool headersOnly = false; | 569 | bool headersOnly = false; |
570 | const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRemoteId); | ||
570 | return imap->fetchMessages(Folder{folderRemoteId}, toFetch, headersOnly, [=](const Message &m) { | 571 | return imap->fetchMessages(Folder{folderRemoteId}, toFetch, headersOnly, [=](const Message &m) { |
571 | synchronizeMails(folderRemoteId, m); | 572 | synchronizeMails(folderRemoteId, folderLocalId, m); |
572 | }, | 573 | }, |
573 | [=](int progress, int total) { | 574 | [=](int progress, int total) { |
574 | reportProgress(progress, total); | 575 | reportProgress(progress, total, QByteArrayList{} << folderLocalId); |
575 | //commit every 100 messages | 576 | //commit every 100 messages |
576 | if ((progress % 100) == 0) { | 577 | if ((progress % 100) == 0) { |
577 | commit(); | 578 | commit(); |