From 524e405f645edb6231f9b16fafc1f9ca36af8237 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 20 May 2017 11:28:02 +0200 Subject: Avoid notifcations for requests that do nothing, progress with folderid --- examples/imapresource/imapresource.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'examples') 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: return flags; } - void synchronizeMails(const QByteArray &folderRid, const Message &message) + void synchronizeMails(const QByteArray &folderRid, const QByteArray &folderLocalId, const Message &message) { auto time = QSharedPointer::create(); time->start(); SinkTraceCtx(mLogCtx) << "Importing new mail." << folderRid; - const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRid); - const auto remoteId = assembleMailRid(folderLocalId, message.uid); Q_ASSERT(message.msg); @@ -315,14 +313,15 @@ public: SinkTraceCtx(mLogCtx) << "Uids to fetch: " << filteredAndSorted; bool headersOnly = false; + const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRemoteId); return imap->fetchMessages(folder, filteredAndSorted, headersOnly, [=](const Message &m) { if (*maxUid < m.uid) { *maxUid = m.uid; } - synchronizeMails(folderRemoteId, m); + synchronizeMails(folderRemoteId, folderLocalId, m); }, - [this, maxUid, folder](int progress, int total) { - reportProgress(progress, total); + [=](int progress, int total) { + reportProgress(progress, total, QByteArrayList{} << folderLocalId); //commit every 10 messages if ((progress % 10) == 0) { commit(); @@ -359,11 +358,12 @@ public: SinkLogCtx(mLogCtx) << "Fetching headers for: " << toFetch; bool headersOnly = true; + const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRemoteId); return imap->fetchMessages(folder, toFetch, headersOnly, [=](const Message &m) { - synchronizeMails(folderRemoteId, m); + synchronizeMails(folderRemoteId, folderLocalId, m); }, [=](int progress, int total) { - reportProgress(progress, total); + reportProgress(progress, total, QByteArrayList{} << folderLocalId); //commit every 100 messages if ((progress % 100) == 0) { commit(); @@ -567,11 +567,12 @@ public: } SinkLog() << "Fetching messages: " << toFetch << folderRemoteId; bool headersOnly = false; + const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, folderRemoteId); return imap->fetchMessages(Folder{folderRemoteId}, toFetch, headersOnly, [=](const Message &m) { - synchronizeMails(folderRemoteId, m); + synchronizeMails(folderRemoteId, folderLocalId, m); }, [=](int progress, int total) { - reportProgress(progress, total); + reportProgress(progress, total, QByteArrayList{} << folderLocalId); //commit every 100 messages if ((progress % 100) == 0) { commit(); -- cgit v1.2.3