summaryrefslogtreecommitdiffstats
path: root/src/plugins/messageservices/imap
diff options
context:
space:
mode:
authorPekka Vuorela <pvuorela@iki.fi>2025-12-08 09:50:53 +0200
committerPekka Vuorela <pvuorela@iki.fi>2025-12-11 11:32:13 +0200
commite503dedbf6d73dc22a7ed32a78806075da589ae7 (patch)
tree273b0df42f5214a554f785c3f6f4a9f8ca36cfa3 /src/plugins/messageservices/imap
parent15a73fae6aaffbedc287359fba119e57613a2ed1 (diff)
Clean up service plugin signal connections - minor API changes
The states and signals were painful to follow due to bad naming and excessive overloading. Here: - Renamed some API to avoid overloading, help readability and allow new connect() syntax without resolving the overloads. - updateStatus() signals and slots renamed a bit to make it clearer what is a signal and what is a slot. And avoiding overloading QMailMessageService::updateStatus() to simplify signal connection. - Cleaned up QMailTranport API. It's not doing urls but hostnames and the signals were especially hard to follow - Use the new connect() syntax in messageserver side - Avoiding some protected: / virtual methods when there's nothing even able to inherit the class. - At least print SSL errors instead of signal that's not connected anywhere. - Some minor simplifications and code style adjustments. The SSL error handling is still funny but at least a bit easier to track. Change-Id: If168e15ef068fedee46b9401d695ed5dae7962ba Reviewed-by: <matti.viljanen@kapsi.fi> Reviewed-by: Damien Caliste <dcaliste@free.fr> Reviewed-by: Pekka Vuorela <pvuorela@iki.fi>
Diffstat (limited to 'src/plugins/messageservices/imap')
-rw-r--r--src/plugins/messageservices/imap/imapclient.cpp167
-rw-r--r--src/plugins/messageservices/imap/imapclient.h10
-rw-r--r--src/plugins/messageservices/imap/imapprotocol.cpp84
-rw-r--r--src/plugins/messageservices/imap/imapprotocol.h13
-rw-r--r--src/plugins/messageservices/imap/imapservice.cpp62
-rw-r--r--src/plugins/messageservices/imap/imapservice.h16
-rw-r--r--src/plugins/messageservices/imap/imapstrategy.cpp2
-rw-r--r--src/plugins/messageservices/imap/serviceactionqueue.cpp6
-rw-r--r--src/plugins/messageservices/imap/serviceactionqueue.h14
9 files changed, 196 insertions, 178 deletions
diff --git a/src/plugins/messageservices/imap/imapclient.cpp b/src/plugins/messageservices/imap/imapclient.cpp
index a722ca52..59a562c3 100644
--- a/src/plugins/messageservices/imap/imapclient.cpp
+++ b/src/plugins/messageservices/imap/imapclient.cpp
@@ -173,7 +173,8 @@ namespace {
}
}
-class IdleProtocol : public ImapProtocol {
+class IdleProtocol : public ImapProtocol
+{
Q_OBJECT
public:
@@ -187,11 +188,11 @@ signals:
void idleFlagsChangedNotification(QMailFolderId);
void transportError();
-protected slots:
- virtual void idleContinuation(ImapCommand, const QString &);
- virtual void idleCommandTransition(ImapCommand, OperationStatus);
- virtual void idleRenew();
- virtual void idleTransportError();
+private slots:
+ void idleContinuation(ImapCommand, const QString &);
+ void idleCommandTransition(ImapCommand, OperationStatus);
+ void idleRenew();
+ void idleTransportError();
void logIn();
void onCredentialsStatusChanged();
@@ -209,16 +210,16 @@ IdleProtocol::IdleProtocol(ImapClient *client, const QMailFolder &folder, QMailC
, _folder(folder)
, _credentials(credentials)
{
- connect(this, SIGNAL(continuationRequired(ImapCommand, QString)),
- this, SLOT(idleContinuation(ImapCommand, QString)) );
- connect(this, SIGNAL(completed(ImapCommand, OperationStatus)),
- this, SLOT(idleCommandTransition(ImapCommand, OperationStatus)) );
- connect(this, SIGNAL(connectionError(int,QString)),
- this, SLOT(idleTransportError()) );
- connect(this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString)),
- this, SLOT(idleTransportError()) );
- connect(_client, SIGNAL(sessionError()),
- this, SLOT(idleTransportError()) );
+ connect(this, &IdleProtocol::continuationRequired,
+ this, &IdleProtocol::idleContinuation);
+ connect(this, &IdleProtocol::completed,
+ this, &IdleProtocol::idleCommandTransition);
+ connect(this, &IdleProtocol::socketError,
+ [this](int, const QString &) { idleTransportError(); });
+ connect(this, &IdleProtocol::connectionError,
+ [this](QMailServiceAction::Status::ErrorCode, const QString&) { idleTransportError(); });
+ connect(_client, &ImapClient::sessionError,
+ this, &IdleProtocol::idleTransportError);
_timeoutTimer.setSingleShot(true);
_timeoutTimer.setInterval(30 * 1000);
@@ -390,52 +391,53 @@ ImapClient::ImapClient(const QMailAccountId &id, QObject* parent)
_protocol.setObjectName(QString("%1").arg(count));
_strategyContext = new ImapStrategyContext(this);
_strategyContext->setStrategy(&_strategyContext->synchronizeAccountStrategy);
- connect(&_protocol, SIGNAL(completed(ImapCommand, OperationStatus)),
- this, SLOT(commandCompleted(ImapCommand, OperationStatus)) );
- connect(&_protocol, SIGNAL(mailboxListed(QString,QString)),
- this, SLOT(mailboxListed(QString,QString)));
- connect(&_protocol, SIGNAL(messageFetched(QMailMessage&, const QString &, bool)),
- this, SLOT(messageFetched(QMailMessage&, const QString &, bool)) );
- connect(&_protocol, SIGNAL(dataFetched(QString, QString, QString, int)),
- this, SLOT(dataFetched(QString, QString, QString, int)) );
- connect(&_protocol, SIGNAL(partHeaderFetched(QString, QString, QString, int)),
- this, SLOT(partHeaderFetched(QString, QString, QString, int)) );
- connect(&_protocol, SIGNAL(nonexistentUid(QString)),
- this, SLOT(nonexistentUid(QString)) );
- connect(&_protocol, SIGNAL(messageStored(QString)),
- this, SLOT(messageStored(QString)) );
- connect(&_protocol, SIGNAL(messageCopied(QString, QString)),
- this, SLOT(messageCopied(QString, QString)) );
- connect(&_protocol, SIGNAL(messageCreated(QMailMessageId, QString)),
- this, SLOT(messageCreated(QMailMessageId, QString)) );
- connect(&_protocol, SIGNAL(downloadSize(QString, int)),
- this, SLOT(downloadSize(QString, int)) );
- connect(&_protocol, SIGNAL(urlAuthorized(QString)),
- this, SLOT(urlAuthorized(QString)) );
- connect(&_protocol, SIGNAL(folderCreated(QString, bool)),
- this, SLOT(folderCreated(QString, bool)));
- connect(&_protocol, SIGNAL(folderDeleted(QMailFolder, bool)),
- this, SLOT(folderDeleted(QMailFolder, bool)));
- connect(&_protocol, SIGNAL(folderRenamed(QMailFolder, QString, bool)),
- this, SLOT(folderRenamed(QMailFolder, QString, bool)));
- connect(&_protocol, SIGNAL(folderMoved(QMailFolder, QString, QMailFolderId, bool)),
- this, SLOT(folderMoved(QMailFolder, QString, QMailFolderId, bool)));
- connect(&_protocol, SIGNAL(updateStatus(QString)),
- this, SLOT(transportStatus(QString)) );
- connect(&_protocol, SIGNAL(connectionError(int,QString)),
- this, SLOT(transportError(int,QString)) );
- connect(&_protocol, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString)),
- this, SLOT(transportError(QMailServiceAction::Status::ErrorCode,QString)) );
+ connect(&_protocol, &ImapProtocol::completed,
+ this, &ImapClient::commandCompleted);
+ connect(&_protocol, &ImapProtocol::mailboxListed,
+ this, &ImapClient::mailboxListed);
+ connect(&_protocol, &ImapProtocol::messageFetched,
+ this, &ImapClient::messageFetched);
+ connect(&_protocol, &ImapProtocol::dataFetched,
+ this, &ImapClient::dataFetched);
+ connect(&_protocol, &ImapProtocol::partHeaderFetched,
+ this, &ImapClient::partHeaderFetched);
+ connect(&_protocol, &ImapProtocol::nonexistentUid,
+ this, &ImapClient::nonexistentUid);
+ connect(&_protocol, &ImapProtocol::messageStored,
+ this, &ImapClient::messageStored);
+ connect(&_protocol, &ImapProtocol::messageCopied,
+ this, &ImapClient::messageCopied);
+ connect(&_protocol, &ImapProtocol::messageCreated,
+ this, &ImapClient::messageCreated);
+ connect(&_protocol, &ImapProtocol::downloadSize,
+ this, &ImapClient::downloadSize);
+ connect(&_protocol, &ImapProtocol::urlAuthorized,
+ this, &ImapClient::urlAuthorized);
+ connect(&_protocol, &ImapProtocol::folderCreated,
+ this, &ImapClient::folderCreated);
+ connect(&_protocol, &ImapProtocol::folderDeleted,
+ this, &ImapClient::folderDeleted);
+ connect(&_protocol, &ImapProtocol::folderRenamed,
+ this, &ImapClient::folderRenamed);
+ connect(&_protocol, &ImapProtocol::folderMoved,
+ this, &ImapClient::folderMoved);
+ connect(&_protocol, &ImapProtocol::statusChanged,
+ this, &ImapClient::statusChanged);
+ connect(&_protocol, &ImapProtocol::socketError,
+ this, &ImapClient::handleSocketConnectionError);
+ connect(&_protocol, &ImapProtocol::connectionError,
+ this, &ImapClient::handleConnectionError);
_inactiveTimer.setSingleShot(true);
- connect(&_inactiveTimer, SIGNAL(timeout()),
- this, SLOT(connectionInactive()));
+ connect(&_inactiveTimer, &QTimer::timeout,
+ this, &ImapClient::connectionInactive);
_idleTimer.setSingleShot(true);
_idleTimer.setInterval(28 * 60 * 1000);
connect(&_idleTimer, &QTimer::timeout, this, &ImapClient::renewPushEmail);
- connect(QMailMessageBuffer::instance(), SIGNAL(flushed()), this, SLOT(messageBufferFlushed()));
+ connect(QMailMessageBuffer::instance(), &QMailMessageBuffer::flushed,
+ this, &ImapClient::messageBufferFlushed);
setupAccount();
}
@@ -580,7 +582,7 @@ void ImapClient::commandTransition(ImapCommand command, OperationStatus status)
// missing the IDLE capability.
// Currently idle connections must be established before main connection will
// service requests.
- emit updateStatus( tr("Checking capabilities" ) );
+ emit statusChanged( tr("Checking capabilities" ) );
_protocol.sendCapability();
break;
@@ -599,7 +601,7 @@ void ImapClient::commandTransition(ImapCommand command, OperationStatus status)
if (ImapAuthenticator::useEncryption(ImapConfiguration(config),
_protocol.capabilities())) {
// Switch to encrypted mode
- emit updateStatus( tr("Starting TLS" ) );
+ emit statusChanged(tr("Starting TLS"));
_protocol.sendStartTLS();
break;
}
@@ -636,7 +638,7 @@ void ImapClient::commandTransition(ImapCommand command, OperationStatus status)
// After logging in server capabilities reported may change so we need to request
// capabilities again, unless already received in an unsolicited response
if (!_protocol.receivedCapabilities()) {
- emit updateStatus( tr("Checking capabilities" ) );
+ emit statusChanged(tr("Checking capabilities"));
_protocol.sendCapability();
break;
}
@@ -668,7 +670,7 @@ void ImapClient::commandTransition(ImapCommand command, OperationStatus status)
// This is a noop when IDLE is already established
// for the given folders
monitor(configurationIdleFolderIds());
- emit updateStatus( tr("Logging in idle connection" ) );
+ emit statusChanged(tr("Logging in idle connection"));
}
bool compressCapable(_protocol.capabilities().contains("COMPRESS=DEFLATE", Qt::CaseInsensitive));
@@ -701,7 +703,8 @@ void ImapClient::commandTransition(ImapCommand command, OperationStatus status)
case IMAP_Noop:
{
QMailAccountConfiguration config(_accountId);
- _inactiveTimer.start(_closeCount ? MaxTimeBeforeNoop : ImapConfiguration(config).timeTillLogout() % MaxTimeBeforeNoop);
+ _inactiveTimer.start(_closeCount ? MaxTimeBeforeNoop
+ : ImapConfiguration(config).timeTillLogout() % MaxTimeBeforeNoop);
break;
}
@@ -938,7 +941,7 @@ void ImapClient::messageFetched(QMailMessage& mail, const QString &detachedFilen
_classifier.classifyMessage(&mail);
- QMailMessage *bufferMessage(new QMailMessage(mail));
+ QMailMessage *bufferMessage = new QMailMessage(mail);
_bufferedMessages.append(bufferMessage);
if (_strategyContext->messageFetched(*bufferMessage)) {
removeAllFromBuffer(bufferMessage);
@@ -1455,14 +1458,14 @@ QMailAccountId ImapClient::account() const
return _accountId;
}
-void ImapClient::transportError(int code, const QString &msg)
+void ImapClient::handleSocketConnectionError(int code, const QString &msg)
{
operationFailed(code, msg);
}
-void ImapClient::transportError(QMailServiceAction::Status::ErrorCode code, const QString &msg)
+void ImapClient::handleConnectionError(QMailServiceAction::Status::ErrorCode code, const QString &message)
{
- operationFailed(code, msg);
+ operationFailed(code, message);
}
void ImapClient::closeConnection()
@@ -1473,11 +1476,6 @@ void ImapClient::closeConnection()
}
}
-void ImapClient::transportStatus(const QString& status)
-{
- emit updateStatus(status);
-}
-
void ImapClient::cancelTransfer(QMailServiceAction::Status::ErrorCode code, const QString &text)
{
operationFailed(code, text);
@@ -1510,7 +1508,7 @@ void ImapClient::connectionInactive()
if (_closeCount == 0) {
_rapidClosing = false;
if ( _protocol.connected()) {
- emit updateStatus( tr("Logging out") );
+ emit statusChanged( tr("Logging out") );
_protocol.sendLogout();
// Client MUST read tagged response, but if connection hangs in logout state newConnection will autoClose.
} else {
@@ -1683,10 +1681,10 @@ void ImapClient::monitor(const QMailFolderIdList &mailboxIds)
protocol->setObjectName(QString("I:%1").arg(count));
_monitored.insert(id, protocol);
_waitingForIdleFolderIds.append(id);
- connect(protocol, SIGNAL(idleNewMailNotification(QMailFolderId)),
- this, SIGNAL(idleNewMailNotification(QMailFolderId)));
- connect(protocol, SIGNAL(idleFlagsChangedNotification(QMailFolderId)),
- this, SIGNAL(idleFlagsChangedNotification(QMailFolderId)));
+ connect(protocol, &IdleProtocol::idleNewMailNotification,
+ this, &ImapClient::idleNewMailNotification);
+ connect(protocol, &IdleProtocol::idleFlagsChangedNotification,
+ this, &ImapClient::idleFlagsChangedNotification);
connect(protocol, &IdleProtocol::transportError,
this, &ImapClient::pushEmailError);
protocol->open(imapCfg);
@@ -1702,16 +1700,19 @@ void ImapClient::messageBufferFlushed()
void ImapClient::removeAllFromBuffer(QMailMessage *message)
{
- if (message) {
- QMultiMap<QMailMessageId, QString>::const_iterator i = detachedTempFiles.find(message->id());
- while (i != detachedTempFiles.end() && i.key() == message->id()) {
- if (!(*i).isEmpty() && QFile::exists(*i)) {
- QFile::remove(*i);
- }
- ++i;
+ if (!message) {
+ return;
+ }
+
+ QMultiMap<QMailMessageId, QString>::const_iterator it = detachedTempFiles.find(message->id());
+ while (it != detachedTempFiles.end() && it.key() == message->id()) {
+ if (!(*it).isEmpty() && QFile::exists(*it)) {
+ QFile::remove(*it);
}
- detachedTempFiles.remove(message->id());
+ ++it;
}
+ detachedTempFiles.remove(message->id());
+
int i = 0;
while ((i = _bufferedMessages.indexOf(message, i)) != -1) {
delete _bufferedMessages.at(i);
@@ -1721,7 +1722,7 @@ void ImapClient::removeAllFromBuffer(QMailMessage *message)
void ImapClient::logIn()
{
- emit updateStatus( tr("Logging in" ) );
+ emit statusChanged(tr("Logging in"));
if (_credentials->status() == QMailCredentialsInterface::Ready) {
QMailAccountConfiguration config(_accountId);
_protocol.sendLogin(config, _credentials);
diff --git a/src/plugins/messageservices/imap/imapclient.h b/src/plugins/messageservices/imap/imapclient.h
index 5956900f..6851e0a4 100644
--- a/src/plugins/messageservices/imap/imapclient.h
+++ b/src/plugins/messageservices/imap/imapclient.h
@@ -94,7 +94,7 @@ public:
signals:
void errorOccurred(int, const QString &);
void errorOccurred(QMailServiceAction::Status::ErrorCode, const QString &);
- void updateStatus(const QString &);
+ void statusChanged(const QString &);
void pushEmailError();
void renewPushEmail();
@@ -115,8 +115,8 @@ signals:
void sessionError();
public slots:
- void transportError(int, const QString &msg);
- void transportError(QMailServiceAction::Status::ErrorCode, const QString &msg);
+ void handleSocketConnectionError(int, const QString &msg);
+ void handleConnectionError(QMailServiceAction::Status::ErrorCode, const QString &message);
void mailboxListed(const QString &, const QString &);
void messageFetched(QMailMessage& mail, const QString &detachedFilename, bool structureOnly);
@@ -133,12 +133,11 @@ public slots:
void folderRenamed(const QMailFolder &folder, const QString &newName, bool success);
void folderMoved(const QMailFolder &folder, const QString &newName, const QMailFolderId &newParentId, bool success);
-protected slots:
+private slots:
void connectionInactive();
void commandCompleted(ImapCommand, OperationStatus);
void checkCommandResponse(ImapCommand, OperationStatus);
void commandTransition(ImapCommand, OperationStatus);
- void transportStatus(const QString& status);
void messageBufferFlushed();
void onCredentialsStatusChanged();
@@ -158,6 +157,7 @@ private:
void updateFolderCountStatus(QMailFolder *folder);
static const int MaxTimeBeforeNoop = 60 * 1000; // 1 minute (this must be >= 1ms)
+
QMailAccountId _accountId;
ImapProtocol _protocol;
diff --git a/src/plugins/messageservices/imap/imapprotocol.cpp b/src/plugins/messageservices/imap/imapprotocol.cpp
index 9c5f96cf..c16339e1 100644
--- a/src/plugins/messageservices/imap/imapprotocol.cpp
+++ b/src/plugins/messageservices/imap/imapprotocol.cpp
@@ -3260,29 +3260,29 @@ ImapProtocol::ImapProtocol()
_authenticated(false),
_receivedCapabilities(false)
{
- connect(&_incomingDataTimer, SIGNAL(timeout()), this, SLOT(incomingData()));
- connect(&_fsm->listState, SIGNAL(mailboxListed(QString, QString)),
- this, SIGNAL(mailboxListed(QString, QString)));
- connect(&_fsm->genUrlAuthState, SIGNAL(urlAuthorized(QString)),
- this, SIGNAL(urlAuthorized(QString)));
- connect(&_fsm->appendState, SIGNAL(messageCreated(QMailMessageId, QString)),
- this, SIGNAL(messageCreated(QMailMessageId, QString)));
- connect(&_fsm->uidFetchState, SIGNAL(downloadSize(QString, int)),
- this, SIGNAL(downloadSize(QString, int)));
- connect(&_fsm->uidFetchState, SIGNAL(nonexistentUid(QString)),
- this, SIGNAL(nonexistentUid(QString)));
- connect(&_fsm->uidStoreState, SIGNAL(messageStored(QString)),
- this, SIGNAL(messageStored(QString)));
- connect(&_fsm->uidCopyState, SIGNAL(messageCopied(QString, QString)),
- this, SIGNAL(messageCopied(QString, QString)));
- connect(&_fsm->createState, SIGNAL(folderCreated(QString, bool)),
- this, SIGNAL(folderCreated(QString, bool)));
- connect(&_fsm->deleteState, SIGNAL(folderDeleted(QMailFolder, bool)),
- this, SIGNAL(folderDeleted(QMailFolder, bool)));
- connect(&_fsm->renameState, SIGNAL(folderRenamed(QMailFolder, QString, bool)),
- this, SIGNAL(folderRenamed(QMailFolder, QString, bool)));
- connect(&_fsm->moveState, SIGNAL(folderMoved(QMailFolder, QString, QMailFolderId, bool)),
- this, SIGNAL(folderMoved(QMailFolder, QString, QMailFolderId, bool)));
+ connect(&_incomingDataTimer, &QTimer::timeout, this, &ImapProtocol::incomingData);
+ connect(&_fsm->listState, &ListState::mailboxListed,
+ this, &ImapProtocol::mailboxListed);
+ connect(&_fsm->genUrlAuthState, &GenUrlAuthState::urlAuthorized,
+ this, &ImapProtocol::urlAuthorized);
+ connect(&_fsm->appendState, &AppendState::messageCreated,
+ this, &ImapProtocol::messageCreated);
+ connect(&_fsm->uidFetchState, &UidFetchState::downloadSize,
+ this, &ImapProtocol::downloadSize);
+ connect(&_fsm->uidFetchState, &UidFetchState::nonexistentUid,
+ this, &ImapProtocol::nonexistentUid);
+ connect(&_fsm->uidStoreState, &UidStoreState::messageStored,
+ this, &ImapProtocol::messageStored);
+ connect(&_fsm->uidCopyState, &UidCopyState::messageCopied,
+ this, &ImapProtocol::messageCopied);
+ connect(&_fsm->createState, &CreateState::folderCreated,
+ this, &ImapProtocol::folderCreated);
+ connect(&_fsm->deleteState, &DeleteState::folderDeleted,
+ this, &ImapProtocol::folderDeleted);
+ connect(&_fsm->renameState, &RenameState::folderRenamed,
+ this, &ImapProtocol::folderRenamed);
+ connect(&_fsm->moveState, &MoveState::folderMoved,
+ this, &ImapProtocol::folderMoved);
}
ImapProtocol::~ImapProtocol()
@@ -3318,19 +3318,20 @@ bool ImapProtocol::open( const ImapConfiguration& config, qint64 bufferSize)
if (!_transport) {
_transport = new ImapTransport("IMAP");
- connect(_transport, SIGNAL(updateStatus(QString)),
- this, SIGNAL(updateStatus(QString)));
- connect(_transport, SIGNAL(errorOccurred(int,QString)),
- this, SLOT(errorHandling(int,QString)));
- connect(_transport, SIGNAL(connected(QMailTransport::EncryptType)),
- this, SLOT(connected(QMailTransport::EncryptType)));
- connect(_transport, SIGNAL(readyRead()),
- this, SLOT(incomingData()));
- connect(_transport, SIGNAL(sslErrorOccured(QMailServiceAction::Status::ErrorCode,QString)),
- this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString)));
+ connect(_transport, &ImapTransport::statusChanged,
+ this, &ImapProtocol::statusChanged);
+ connect(_transport, &ImapTransport::connected,
+ this, &ImapProtocol::handleConnected);
+ connect(_transport, &ImapTransport::readyRead,
+ this, &ImapProtocol::incomingData);
+ connect(_transport, &ImapTransport::socketErrorOccurred,
+ this, &ImapProtocol::handleSocketError);
+ connect(_transport, &ImapTransport::sslErrorOccurred,
+ this, &ImapProtocol::handleSslError);
}
- qCDebug(lcIMAP) << objectName() << "About to open connection" << config.mailUserName() << config.mailServer(); // useful to see object name
+ qCDebug(lcIMAP) << objectName() << "About to open connection" << config.mailUserName()
+ << config.mailServer(); // useful to see object name
_transport->setAcceptUntrustedCertificates(config.acceptUntrustedCertificates());
_transport->open(config.mailServer(), config.mailPort(), static_cast<QMailTransport::EncryptType>(config.mailEncryption()));
@@ -3356,7 +3357,7 @@ void ImapProtocol::close()
bool ImapProtocol::connected() const
{
- return (_transport && _transport->connected());
+ return (_transport && _transport->isConnected());
}
bool ImapProtocol::encrypted() const
@@ -3654,22 +3655,29 @@ void ImapProtocol::sendEnable(const QString &extensions)
_fsm->setState(&_fsm->enableState);
}
-void ImapProtocol::connected(QMailTransport::EncryptType encryptType)
+void ImapProtocol::handleConnected(QMailTransport::EncryptType encryptType)
{
if (encryptType == QMailTransport::Encrypt_TLS) {
emit completed(IMAP_StartTLS, OpOk);
}
}
-void ImapProtocol::errorHandling(int status, QString msg)
+void ImapProtocol::handleSocketError(int status, const QString &message)
{
_mailbox = ImapMailboxProperties();
+ QString msg = message;
if (msg.isEmpty())
msg = tr("Connection failed");
if (_fsm->command() != IMAP_Logout)
- emit connectionError(status, msg);
+ emit socketError(status, msg);
+}
+
+void ImapProtocol::handleSslError(QMailServiceAction::Status::ErrorCode error)
+{
+ // maybe silly string, but used to be like that in qmailtransport
+ emit connectionError(error, tr("Socket error"));
}
void ImapProtocol::sendData(const QString &cmd, bool maskDebug)
diff --git a/src/plugins/messageservices/imap/imapprotocol.h b/src/plugins/messageservices/imap/imapprotocol.h
index 41f2409e..c2af4ef7 100644
--- a/src/plugins/messageservices/imap/imapprotocol.h
+++ b/src/plugins/messageservices/imap/imapprotocol.h
@@ -122,7 +122,6 @@ enum OperationStatus {
OpBad,
};
-class Email;
class ImapConfiguration;
class ImapTransport;
class ImapContextFSM;
@@ -235,10 +234,11 @@ signals:
void continuationRequired(ImapCommand, const QString &);
void completed(ImapCommand, OperationStatus);
- void updateStatus(const QString &);
+ void statusChanged(const QString &);
- void connectionError(int status, const QString &msg);
- void connectionError(QMailServiceAction::Status::ErrorCode status, const QString &msg);
+ void socketError(int status, const QString &message);
+ // this is mostly ssl or transport in use
+ void connectionError(QMailServiceAction::Status::ErrorCode status, const QString &message);
// Possibly unilateral notifications related to currently selected folder
void exists(int);
@@ -249,8 +249,9 @@ signals:
void noModSeq();
protected slots:
- void connected(QMailTransport::EncryptType encryptType);
- void errorHandling(int status, QString msg);
+ void handleConnected(QMailTransport::EncryptType encryptType);
+ void handleSocketError(int status, const QString &message);
+ void handleSslError(QMailServiceAction::Status::ErrorCode error);
void incomingData();
private:
diff --git a/src/plugins/messageservices/imap/imapservice.cpp b/src/plugins/messageservices/imap/imapservice.cpp
index a0a88241..b998e06b 100644
--- a/src/plugins/messageservices/imap/imapservice.cpp
+++ b/src/plugins/messageservices/imap/imapservice.cpp
@@ -47,6 +47,7 @@
namespace {
const QString serviceKey("imap4");
+int ThirtySeconds = 30;
}
@@ -65,18 +66,19 @@ public:
_setMask(0),
_unsetMask(0)
{
- connect(&_intervalTimer, SIGNAL(timeout()), this, SLOT(intervalCheck()));
- connect(&_pushIntervalTimer, SIGNAL(timeout()), this, SLOT(pushIntervalCheck()));
- connect(&_strategyExpiryTimer, SIGNAL(timeout()), this, SLOT(expireStrategy()));
+ connect(&_intervalTimer, &QTimer::timeout, this, &Source::intervalCheck);
+ connect(&_pushIntervalTimer, &QTimer::timeout, this, &Source::pushIntervalCheck);
+ connect(&_strategyExpiryTimer, &QTimer::timeout, this, &Source::expireStrategy);
}
- void initClientConnections() {
+ void initClientConnections()
+ {
connect(_service->_client, SIGNAL(allMessagesReceived()), this, SIGNAL(newMessagesAvailable()));
- connect(_service->_client, SIGNAL(messageCopyCompleted(QMailMessage&, QMailMessage)), this, SLOT(messageCopyCompleted(QMailMessage&, QMailMessage)));
- connect(_service->_client, SIGNAL(messageActionCompleted(QString)), this, SLOT(messageActionCompleted(QString)));
- connect(_service->_client, SIGNAL(retrievalCompleted()), this, SLOT(retrievalCompleted()));
- connect(_service->_client, SIGNAL(idleNewMailNotification(QMailFolderId)), this, SLOT(queueMailCheck(QMailFolderId)));
- connect(_service->_client, SIGNAL(idleFlagsChangedNotification(QMailFolderId)), this, SLOT(queueFlagsChangedCheck(QMailFolderId)));
+ connect(_service->_client, &ImapClient::messageCopyCompleted, this, &Source::messageCopyCompleted);
+ connect(_service->_client, &ImapClient::messageActionCompleted, this, &Source::handleMessageActionCompleted);
+ connect(_service->_client, &ImapClient::retrievalCompleted, this, &Source::handleRetrievalCompleted);
+ connect(_service->_client, &ImapClient::idleNewMailNotification, this, &Source::queueMailCheck);
+ connect(_service->_client, &ImapClient::idleFlagsChangedNotification, this, &Source::queueFlagsChangedCheck);
connect(_service->_client, SIGNAL(matchingMessageIds(QMailMessageIdList)), this, SIGNAL(matchingMessageIds(QMailMessageIdList)));
connect(_service->_client, SIGNAL(remainingMessagesCount(uint)), this, SIGNAL(remainingMessagesCount(uint)));
connect(_service->_client, SIGNAL(messagesCount(uint)), this, SIGNAL(messagesCount(uint)));
@@ -146,8 +148,8 @@ public slots:
bool prepareMessages(const QList<QPair<QMailMessagePart::Location, QMailMessagePart::Location> > &ids) override;
void messageCopyCompleted(QMailMessage &message, const QMailMessage &original);
- void messageActionCompleted(const QString &uid);
- void retrievalCompleted();
+ void handleMessageActionCompleted(const QString &uid);
+ void handleRetrievalCompleted();
void retrievalTerminated();
void intervalCheck();
void pushIntervalCheck();
@@ -229,7 +231,7 @@ bool ImapService::Source::retrieveMessageLists(const QMailAccountId &accountId,
}
if (ids.isEmpty()) {
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
return true;
}
@@ -257,7 +259,7 @@ bool ImapService::Source::retrieveNewMessages(const QMailAccountId &accountId, c
}
if (ids.isEmpty()) {
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
return true;
}
@@ -384,7 +386,7 @@ bool ImapService::Source::retrieveMessagePart(const QMailMessagePart::Location &
QMailMessage msg(partLocation.containingMessageId());
if (!msg.contains(partLocation) || msg.partAt(partLocation).contentAvailable()) {
// Already retrieved (or invalid)
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
return true;
}
@@ -422,7 +424,7 @@ bool ImapService::Source::retrieveMessageRange(const QMailMessageId &messageId,
QMailMessage msg(messageId);
if (msg.contentAvailable()) {
// Already retrieved
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
return true;
}
@@ -466,7 +468,7 @@ bool ImapService::Source::retrieveMessagePartRange(const QMailMessagePart::Locat
QMailMessage msg(partLocation.containingMessageId());
if (!msg.contains(partLocation) || msg.partAt(partLocation).contentAvailable()) {
// Already retrieved (or invalid)
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
return true;
}
@@ -705,7 +707,7 @@ bool ImapService::Source::moveMessages(const QMailMessageIdList &messageIds, con
}
if (serverMessages.isEmpty()) {
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
}
return true;
}
@@ -900,9 +902,9 @@ bool ImapService::Source::flagMessages(const QMailMessageIdList &messageIds, qui
}
}
- //ensure retrievalCompleted gets called when a strategy has not been used (i.e. local read flag change)
- //otherwise actionCompleted does not get signaled to messageserver and service becomes permanently unavailable
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ // ensure handleRetrievalCompleted gets called when a strategy has not been used (i.e. local read flag change)
+ // otherwise actionCompleted does not get signaled to messageserver and service becomes permanently unavailable
+ QTimer::singleShot(0, this, &Source::handleRetrievalCompleted);
return true;
}
@@ -1238,7 +1240,7 @@ void ImapService::Source::messageCopyCompleted(QMailMessage &message, const QMai
Q_UNUSED(original);
}
-void ImapService::Source::messageActionCompleted(const QString &uid)
+void ImapService::Source::handleMessageActionCompleted(const QString &uid)
{
if (uid.startsWith("id:")) {
emit messageActionCompleted(QMailMessageIdList() << QMailMessageId(uid.mid(3).toULongLong()));
@@ -1250,7 +1252,7 @@ void ImapService::Source::messageActionCompleted(const QString &uid)
}
}
-void ImapService::Source::retrievalCompleted()
+void ImapService::Source::handleRetrievalCompleted()
{
_strategyExpiryTimer.stop();
_unavailable = false;
@@ -1348,7 +1350,7 @@ void ImapService::Source::queueMailCheck(QMailFolderId folderId)
_service->_client->requestRapidClose();
if (folderId.isValid()) {
- retrievalCompleted(); // move onto retrieveMessageList stage
+ handleRetrievalCompleted(); // move onto retrieveMessageList stage
} else {
_actionQueue.append(new RetrieveFolderListCommand(_service->accountId(), folderId, true)); // Convenient for user to export pending changes also
}
@@ -1411,9 +1413,9 @@ ImapService::ImapService(const QMailAccountId &accountId)
if (account.status() & QMailAccount::Enabled) {
enable();
}
- connect(_restartPushEmailTimer, SIGNAL(timeout()), this, SLOT(restartPushEmail()));
- connect(QMailStore::instance(), SIGNAL(accountsUpdated(const QMailAccountIdList&)),
- this, SLOT(accountsUpdated(const QMailAccountIdList&)));
+ connect(_restartPushEmailTimer, &QTimer::timeout, this, &ImapService::restartPushEmail);
+ connect(QMailStore::instance(), &QMailStore::accountsUpdated,
+ this, &ImapService::accountsUpdated);
}
void ImapService::enable()
@@ -1427,7 +1429,7 @@ void ImapService::enable()
connect(_client, SIGNAL(errorOccurred(int, QString)), this, SLOT(errorOccurred(int, QString)));
connect(_client, SIGNAL(errorOccurred(QMailServiceAction::Status::ErrorCode, QString)),
this, SLOT(errorOccurred(QMailServiceAction::Status::ErrorCode, QString)));
- connect(_client, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(QString)));
+ connect(_client, &ImapClient::statusChanged, this, &ImapService::handleStatusChange);
connect(_client, &ImapClient::pushEmailError, this, &ImapService::retryPushEmail);
QMailAccountConfiguration accountCfg(_accountId);
@@ -1633,7 +1635,7 @@ void ImapService::errorOccurred(QMailServiceAction::Status::ErrorCode code, cons
emit actionCompleted(false);
}
-void ImapService::updateStatus(const QString &text)
+void ImapService::handleStatusChange(const QString &text)
{
updateStatus(QMailServiceAction::Status::ErrNoError, text, _accountId);
}
@@ -1643,8 +1645,8 @@ void ImapService::createIdleSession()
// Fail after 10 sec if no network reply is received
_networkSessionTimer->setSingleShot(true);
_networkSessionTimer->setInterval(10000);
- connect(_networkSessionTimer, SIGNAL(timeout()),
- this, SLOT(onSessionConnectionTimeout()));
+ connect(_networkSessionTimer, &QTimer::timeout,
+ this, &ImapService::onSessionConnectionTimeout);
openIdleSession();
}
diff --git a/src/plugins/messageservices/imap/imapservice.h b/src/plugins/messageservices/imap/imapservice.h
index 727c2b0f..0e6973da 100644
--- a/src/plugins/messageservices/imap/imapservice.h
+++ b/src/plugins/messageservices/imap/imapservice.h
@@ -61,21 +61,19 @@ public:
public slots:
bool cancelOperation(QMailServiceAction::Status::ErrorCode code, const QString &text) override;
- virtual void restartPushEmail();
- virtual void initiatePushEmail();
-protected slots:
- virtual void accountsUpdated(const QMailAccountIdList &ids);
+private slots:
+ void restartPushEmail();
+ void accountsUpdated(const QMailAccountIdList &ids);
void errorOccurred(int code, const QString &text);
void errorOccurred(QMailServiceAction::Status::ErrorCode code, const QString &text);
- void updateStatus(const QString& text);
+ void handleStatusChange(const QString &text);
// Only used for IMAP IDLE, network session for other request types are managed by the caller.
void createIdleSession();
void openIdleSession();
void closeIdleSession();
-private slots:
void onOnlineStateChanged(bool isOnline);
void onSessionOpened();
void onSessionStateChanged(IdleNetworkSession::State status);
@@ -86,6 +84,7 @@ private:
class Source;
friend class Source;
+ void initiatePushEmail();
bool accountPushEnabled();
void retryPushEmail();
void setPersistentConnectionStatus(bool status);
@@ -101,9 +100,8 @@ private:
int _pushRetry;
bool _accountWasPushEnabled;
QStringList _previousPushFolders;
- enum { ThirtySeconds = 30 };
- IdleNetworkSession *_networkSession; // IDLE network session
- QTimer *_networkSessionTimer;
+ IdleNetworkSession *_networkSession; // IDLE network session
+ QTimer *_networkSessionTimer;
};
class ImapServicePlugin : public QMailMessageServicePlugin
diff --git a/src/plugins/messageservices/imap/imapstrategy.cpp b/src/plugins/messageservices/imap/imapstrategy.cpp
index 694bdbf8..5a951d80 100644
--- a/src/plugins/messageservices/imap/imapstrategy.cpp
+++ b/src/plugins/messageservices/imap/imapstrategy.cpp
@@ -463,7 +463,7 @@ QMailAccountId ImapStrategyContextBase::accountId()
void ImapStrategyContextBase::updateStatus(const QString &text)
{
- emit _client->updateStatus(text);
+ emit _client->statusChanged(text);
}
void ImapStrategyContextBase::progressChanged(uint progress, uint total)
diff --git a/src/plugins/messageservices/imap/serviceactionqueue.cpp b/src/plugins/messageservices/imap/serviceactionqueue.cpp
index 792b9baa..9a557dbc 100644
--- a/src/plugins/messageservices/imap/serviceactionqueue.cpp
+++ b/src/plugins/messageservices/imap/serviceactionqueue.cpp
@@ -38,7 +38,7 @@
ServiceActionQueue::ServiceActionQueue()
: _running(false)
{
- QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(executeNextCommand()));
+ QObject::connect(&_timer, &QTimer::timeout, this, &ServiceActionQueue::executeNextCommand);
}
// Takes ownership of *command.
@@ -61,8 +61,8 @@ void ServiceActionQueue::executeNextCommand()
}
_running = true;
ServiceActionCommand *command(_commands.first());
- QObject::connect(command->action(), SIGNAL(activityChanged(QMailServiceAction::Activity)),
- this, SLOT(activityChanged(QMailServiceAction::Activity)));
+ QObject::connect(command->action(), &QMailServiceAction::activityChanged,
+ this, &ServiceActionQueue::activityChanged);
command->execute();
}
diff --git a/src/plugins/messageservices/imap/serviceactionqueue.h b/src/plugins/messageservices/imap/serviceactionqueue.h
index e021d243..3586bb1c 100644
--- a/src/plugins/messageservices/imap/serviceactionqueue.h
+++ b/src/plugins/messageservices/imap/serviceactionqueue.h
@@ -42,7 +42,12 @@
class ServiceActionCommand
{
public:
- virtual ~ServiceActionCommand() { if (!_action.isNull()) _action->deleteLater(); }
+ virtual ~ServiceActionCommand()
+ {
+ if (!_action.isNull())
+ _action->deleteLater();
+ }
+
virtual void execute() = 0;
QPointer<QMailServiceAction> action() { return _action; }
@@ -56,6 +61,7 @@ class ServiceActionQueue : public QObject
public:
ServiceActionQueue();
+
void append(ServiceActionCommand *command);
void clear();
@@ -94,7 +100,8 @@ private:
class RetrieveMessageListCommand : public ServiceActionCommand
{
public:
- RetrieveMessageListCommand(const QMailAccountId &accountId, const QMailFolderId &folderId, uint minimum = 0, const QMailMessageSortKey &sort = QMailMessageSortKey());
+ RetrieveMessageListCommand(const QMailAccountId &accountId, const QMailFolderId &folderId, uint minimum = 0,
+ const QMailMessageSortKey &sort = QMailMessageSortKey());
void execute() override;
private:
@@ -107,7 +114,8 @@ private:
class RetrieveMessageListsCommand : public ServiceActionCommand
{
public:
- RetrieveMessageListsCommand(const QMailAccountId &accountId, const QMailFolderIdList &folderIds, uint minimum = 0, const QMailMessageSortKey &sort = QMailMessageSortKey());
+ RetrieveMessageListsCommand(const QMailAccountId &accountId, const QMailFolderIdList &folderIds, uint minimum = 0,
+ const QMailMessageSortKey &sort = QMailMessageSortKey());
void execute() override;
private: