Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jb47389-upstream-patches' into 'master'
Apply upstream patches for folder sync See merge request mer-core/messagingframework!37
- Loading branch information
Showing
3 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
159 changes: 159 additions & 0 deletions
159
rpm/0020-Follow-the-synchronizationEnabled-flag-when-folders.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
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; | ||
}; |
35 changes: 35 additions & 0 deletions
35
rpm/0021-Set-new-IMAP-folders-to-inherit-SynchronizationEnab.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters