diff options
author | Damien Caliste <dcaliste@free.fr> | 2025-02-18 15:42:53 +0100 |
---|---|---|
committer | Damien Caliste <dcaliste@free.fr> | 2025-02-21 12:46:55 +0100 |
commit | c13edadfdf8e70504400548391f220dd313ccce6 (patch) | |
tree | c7d03845a068bae5c5a333bac576f03b90354b3a | |
parent | 84bd6288a7212e38686b9fbf373e694945e7dc0f (diff) |
Report client error even when establishing idle connections
The errorOccurred signal is only emitted for client
session, and not for idle connections (there are
reporting via the client itself, which emits
restartPushEmail signal for idle errors).
It is thus necessary to report any error the client
is emitting. If the client session was launched to
establish idle connections and these sessions are not
running, then one should retry to reestablish the
idle connections later.
Without the patch, in case of a non responding server
(connection to a captive portal without network
granted yet), the client error was not reported when
the connection could not be established. It was
accepted wrongly as succeeded when a new attempt to establish
idle connections was made and Source::retrievalCompleted()
was emitted when queueing the idle folder for scan.
But with the retry timeout becoming larger and larger,
the strategy expiry timeout finally kicked in and the
service was fully restarted.
Change-Id: I206e77f221d2a7c4bdfcee1952dbe1127431e6d6
Reviewed-by: Pekka Vuorela <pvuorela@iki.fi>
-rw-r--r-- | src/plugins/messageservices/imap/imapclient.cpp | 4 | ||||
-rw-r--r-- | src/plugins/messageservices/imap/imapclient.h | 2 | ||||
-rw-r--r-- | src/plugins/messageservices/imap/imapservice.cpp | 22 | ||||
-rw-r--r-- | src/plugins/messageservices/imap/imapservice.h | 2 |
4 files changed, 13 insertions, 17 deletions
diff --git a/src/plugins/messageservices/imap/imapclient.cpp b/src/plugins/messageservices/imap/imapclient.cpp index 7e05f5f0..e389b31a 100644 --- a/src/plugins/messageservices/imap/imapclient.cpp +++ b/src/plugins/messageservices/imap/imapclient.cpp @@ -657,7 +657,7 @@ void ImapClient::commandTransition(ImapCommand command, OperationStatus status) // Start / stop idle connections, to keep only idles monitor(idleFolders); - if (idlesEstablished()) { + if (isPushEmailEstablished()) { // Login is postponed after idle connections, see // IMAP_Idle_Continuation logIn(); @@ -1678,7 +1678,7 @@ void ImapClient::updateFolderCountStatus(QMailFolder *folder) folder->setStatus(QMailFolder::PartialContent, (count < folder->serverCount())); } -bool ImapClient::idlesEstablished() +bool ImapClient::isPushEmailEstablished() { QMailAccountConfiguration config(account()); ImapConfiguration imapCfg(config); diff --git a/src/plugins/messageservices/imap/imapclient.h b/src/plugins/messageservices/imap/imapclient.h index 1cea00a2..900fb94f 100644 --- a/src/plugins/messageservices/imap/imapclient.h +++ b/src/plugins/messageservices/imap/imapclient.h @@ -83,7 +83,7 @@ public: QMailMessageKey trashKey(const QMailFolderId &folderId) const; QStringList deletedMessages(const QMailFolderId &folderId) const; - bool idlesEstablished(); + bool isPushEmailEstablished(); void stopIdleConnections() { monitor(QMailFolderIdList()); } QMailFolderIdList configurationIdleFolderIds(); void removeAllFromBuffer(QMailMessage *message); diff --git a/src/plugins/messageservices/imap/imapservice.cpp b/src/plugins/messageservices/imap/imapservice.cpp index 5287232e..3c7e5ebd 100644 --- a/src/plugins/messageservices/imap/imapservice.cpp +++ b/src/plugins/messageservices/imap/imapservice.cpp @@ -1663,27 +1663,21 @@ void ImapService::initiatePushEmail() _source->setPushIntervalTimer(60); // minutes } -bool ImapService::pushEmailEstablished() +void ImapService::retryPushEmail() { - if (!_establishingPushEmail) - return true; - if (!_client) - return false; - if (_client->idlesEstablished()) - return true; - const int oneHour = 60*60; qMailLog(Messaging) << "Push email connection could not be established. Reattempting to establish in" << _pushRetry << "seconds"; _restartPushEmailTimer->start(_pushRetry*1000); _pushRetry = qMin(oneHour, _pushRetry * 2); - return false; } void ImapService::errorOccurred(int code, const QString &text) { - if (!pushEmailEstablished()) - return; + if (_establishingPushEmail + && (!_client || !_client->isPushEmailEstablished())) { + retryPushEmail(); + } _source->retrievalTerminated(); updateStatus(code, text, _accountId); emit actionCompleted(false); @@ -1691,8 +1685,10 @@ void ImapService::errorOccurred(int code, const QString &text) void ImapService::errorOccurred(QMailServiceAction::Status::ErrorCode code, const QString &text) { - if (!pushEmailEstablished()) - return; + if (_establishingPushEmail + && (!_client || !_client->isPushEmailEstablished())) { + retryPushEmail(); + } _source->retrievalTerminated(); updateStatus(code, text, _accountId); emit actionCompleted(false); diff --git a/src/plugins/messageservices/imap/imapservice.h b/src/plugins/messageservices/imap/imapservice.h index 14e0722a..e5c62d15 100644 --- a/src/plugins/messageservices/imap/imapservice.h +++ b/src/plugins/messageservices/imap/imapservice.h @@ -58,7 +58,6 @@ public: QMailMessageSource &source() const override; bool available() const override; - bool pushEmailEstablished(); public slots: bool cancelOperation(QMailServiceAction::Status::ErrorCode code, const QString &text) override; @@ -88,6 +87,7 @@ private: friend class Source; bool accountPushEnabled(); + void retryPushEmail(); void setPersistentConnectionStatus(bool status); void enablePushEmail(); void disablePushEmail(); |