Commit acb25497 authored by flypig's avatar flypig

Merge branch 'jb47389-upstream-patches' into 'master'

Apply upstream patches for folder sync

See merge request !37
parents 3dba346f 00f846c7
From e3cb15294cb3ec8a2d127b50cc3d9e79839ae2c7 Mon Sep 17 00:00:00 2001
From: Damien Caliste <dcaliste@free.fr>
Date: Fri, 24 Jan 2020 16:28:37 +0100
Subject: [PATCH] Follow the synchronizationEnabled flag when folders are not specified
If the synchronizationEnabled flag is set to false, a variety
of strategy, like search, folder listing, will not search in
such folders. This is maybe a too restrictive usage of this
flag. This patch change the behavior of this flag to act on
synchronization strategies only, when desired.
It activates it only for message retrieval in all folders.
Change-Id: Iebec872984c7e2650167ae585b06bfa3d8cd6990
---
diff --git a/src/plugins/messageservices/imap/imapservice.cpp b/src/plugins/messageservices/imap/imapservice.cpp
index eca22f7..339d44e 100644
--- a/src/plugins/messageservices/imap/imapservice.cpp
+++ b/src/plugins/messageservices/imap/imapservice.cpp
@@ -213,6 +213,7 @@
_service->_client->strategyContext()->foldersOnlyStrategy.setBase(folderId);
_service->_client->strategyContext()->foldersOnlyStrategy.setQuickList(!folderId.isValid());
_service->_client->strategyContext()->foldersOnlyStrategy.setDescending(descending);
+ _service->_client->strategyContext()->foldersOnlyStrategy.setIgnoreSyncFlag(true);
appendStrategy(&_service->_client->strategyContext()->foldersOnlyStrategy);
if(!_unavailable)
return initiateStrategy();
@@ -304,6 +305,7 @@
_service->_client->strategyContext()->retrieveMessageListStrategy.setOperation(_service->_client->strategyContext(), QMailRetrievalAction::Auto);
_service->_client->strategyContext()->retrieveMessageListStrategy.selectedFoldersAppend(folderIds);
+ _service->_client->strategyContext()->retrieveMessageListStrategy.setIgnoreSyncFlag(!_folderIds.isEmpty());
appendStrategy(&_service->_client->strategyContext()->retrieveMessageListStrategy);
if(!_unavailable)
return initiateStrategy();
@@ -496,6 +498,7 @@
_service->_client->strategyContext()->retrieveAllStrategy.setQuickList(false);
_service->_client->strategyContext()->retrieveAllStrategy.setDescending(true);
_service->_client->strategyContext()->retrieveAllStrategy.setOperation(_service->_client->strategyContext(), QMailRetrievalAction::Auto);
+ _service->_client->strategyContext()->retrieveAllStrategy.setIgnoreSyncFlag(false);
appendStrategy(&_service->_client->strategyContext()->retrieveAllStrategy);
if(!_unavailable)
return initiateStrategy();
@@ -571,6 +574,7 @@
_service->_client->strategyContext()->synchronizeAccountStrategy.setQuickList(false);
_service->_client->strategyContext()->synchronizeAccountStrategy.setDescending(true);
_service->_client->strategyContext()->synchronizeAccountStrategy.setOperation(_service->_client->strategyContext(), QMailRetrievalAction::Auto);
+ _service->_client->strategyContext()->synchronizeAccountStrategy.setIgnoreSyncFlag(false);
appendStrategy(&_service->_client->strategyContext()->synchronizeAccountStrategy);
if(!_unavailable)
return initiateStrategy();
diff --git a/src/plugins/messageservices/imap/imapstrategy.cpp b/src/plugins/messageservices/imap/imapstrategy.cpp
index 916afdf..142fd0c 100644
--- a/src/plugins/messageservices/imap/imapstrategy.cpp
+++ b/src/plugins/messageservices/imap/imapstrategy.cpp
@@ -2208,15 +2208,13 @@
bool ImapFolderListStrategy::nextFolder()
{
- while (!_mailboxIds.isEmpty()) {
+ if (!_mailboxIds.isEmpty()) {
QMailFolderId folderId(_mailboxIds.takeFirst());
// Process this folder
setCurrentMailbox(folderId);
- // Bypass any folder for which synchronization is disabled
- if (synchronizationEnabled(_currentMailbox))
- return true;
+ return true;
}
return false;
@@ -2233,11 +2231,6 @@
context->progressChanged(++_processed, _processable);
}
-bool ImapFolderListStrategy::synchronizationEnabled(const QMailFolder &folder) const
-{
- return folder.status() & QMailFolder::SynchronizationEnabled;
-}
-
void ImapFolderListStrategy::folderListCompleted(ImapStrategyContextBase *context)
{
// We have retrieved all the folders - process any messages
@@ -2369,6 +2362,27 @@
}
}
+void ImapSynchronizeBaseStrategy::setIgnoreSyncFlag(bool ignoreSyncFlag)
+{
+ _ignoreSyncFlag = ignoreSyncFlag;
+}
+
+bool ImapSynchronizeBaseStrategy::synchronizationEnabled(const QMailFolder &folder) const
+{
+ return _ignoreSyncFlag || (folder.status() & QMailFolder::SynchronizationEnabled);
+}
+
+bool ImapSynchronizeBaseStrategy::nextFolder()
+{
+ while (ImapFolderListStrategy::nextFolder()) {
+ // Bypass any folder for which synchronization is disabled
+ if (synchronizationEnabled(_currentMailbox))
+ return true;
+ }
+
+ return false;
+}
+
bool ImapSynchronizeBaseStrategy::selectNextPreviewFolder(ImapStrategyContextBase *context)
{
if (_retrieveUids.isEmpty()) {
diff --git a/src/plugins/messageservices/imap/imapstrategy.h b/src/plugins/messageservices/imap/imapstrategy.h
index 1f418e4..260fd58 100644
--- a/src/plugins/messageservices/imap/imapstrategy.h
+++ b/src/plugins/messageservices/imap/imapstrategy.h
@@ -396,7 +396,6 @@
virtual void processNextFolder(ImapStrategyContextBase *context);
virtual bool nextFolder();
virtual void processFolder(ImapStrategyContextBase *context);
- virtual bool synchronizationEnabled(const QMailFolder &folder) const;
void updateUndiscoveredCount(ImapStrategyContextBase *context);
@@ -457,19 +456,23 @@
class ImapSynchronizeBaseStrategy : public ImapFolderListStrategy
{
public:
- ImapSynchronizeBaseStrategy() {}
+ ImapSynchronizeBaseStrategy() : _ignoreSyncFlag(false) {}
virtual ~ImapSynchronizeBaseStrategy() {}
virtual void newConnection(ImapStrategyContextBase *context);
virtual bool messageFetched(ImapStrategyContextBase *context, QMailMessage &message);
virtual void messageFlushed(ImapStrategyContextBase *context, QMailMessage &message);
+ virtual void setIgnoreSyncFlag(bool ignoreSyncFlag);
protected:
virtual void handleLogin(ImapStrategyContextBase *context);
virtual void handleSelect(ImapStrategyContextBase *context);
virtual void handleUidFetch(ImapStrategyContextBase *context);
+ virtual bool nextFolder();
+ virtual bool synchronizationEnabled(const QMailFolder &folder) const;
+
virtual void previewDiscoveredMessages(ImapStrategyContextBase *context);
virtual bool selectNextPreviewFolder(ImapStrategyContextBase *context);
@@ -486,6 +489,7 @@
int _outstandingPreviews;
private:
+ bool _ignoreSyncFlag;
uint _progress;
uint _total;
};
From 1bb1394a3501b593bc2ce0c42b13720cc67a9609 Mon Sep 17 00:00:00 2001
From: David Llewellyn-Jones <david.llewellyn-jones@jolla.com>
Date: Fri, 07 Feb 2020 19:29:59 +0200
Subject: [PATCH] Set new IMAP folders to inherit SynchronizationEnabled flag
When new folders are received from the server, the client-side
SynchronizationEnabled flag must be set for them. Previously they were
always set to true, but if they're inside a folder that isn't being
synced, this probably doesn't reflect the user's intent.
This change makes it so that for IMAP any new folders received from the
server will have the SynchronizationEnabled flag set to whatever value
their parent has it set to. If they have no parent (i.e. are in the root
folder) then the flag is set to true as before.
Change-Id: If43d5e2b4469a402d203841c04cc4b1b30ffc3b1
---
diff --git a/src/plugins/messageservices/imap/imapclient.cpp b/src/plugins/messageservices/imap/imapclient.cpp
index a710d48..7a6c80a 100644
--- a/src/plugins/messageservices/imap/imapclient.cpp
+++ b/src/plugins/messageservices/imap/imapclient.cpp
@@ -822,8 +822,11 @@
// This element needs to be created
QMailFolder folder(mailboxPath, parentId, _config.id());
folder.setDisplayName(QMailCodec::decodeModifiedUtf7(*it));
- folder.setStatus(QMailFolder::SynchronizationEnabled, true);
folder.setStatus(QMailFolder::Incoming, true);
+ // Set synchronization flag the same as parent folder, or true if there's no parent
+ bool synchronize = parentId.isValid() ?
+ QMailFolder(parentId).status() & QMailFolder::SynchronizationEnabled : true;
+ folder.setStatus(QMailFolder::SynchronizationEnabled, synchronize);
// The reported flags pertain to the listed folder only
QString folderFlags;
......@@ -47,6 +47,8 @@ Patch16: 0016-Revert-Fix-bundled-zlib-detection.patch
Patch17: 0017-Add-signature-settings-in-account.patch
Patch18: 0018-Use-socket-s-local-address-for-HELO-and-EHLO-message.patch
Patch19: 0019-Use-EightBit-encoding-instead-of-Base64-for-text-typ.patch
Patch20: 0020-Follow-the-synchronizationEnabled-flag-when-folders.patch
Patch21: 0021-Set-new-IMAP-folders-to-inherit-SynchronizationEnab.patch
%description
The Qt Messaging Framework, QMF, consists of a C++ library and daemon server
......@@ -171,6 +173,8 @@ This package contains the tests for Qt Messaging Framework (QMF).
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%build
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment