summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/libraries/qmfclient/qmailmessageset.cpp4
-rw-r--r--src/libraries/qmfmessageserver/qmailmessagebuffer.cpp3
-rw-r--r--src/libraries/qmfmessageserver/qmailmessageservice.cpp16
-rw-r--r--src/libraries/qmfmessageserver/qmailmessageservice.h8
-rw-r--r--src/libraries/qmfmessageserver/qmailstoreaccountfilter.cpp24
-rw-r--r--src/libraries/qmfmessageserver/qmailtransport.cpp74
-rw-r--r--src/libraries/qmfmessageserver/qmailtransport.h29
-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
-rw-r--r--src/plugins/messageservices/pop/popclient.cpp46
-rw-r--r--src/plugins/messageservices/pop/popclient.h5
-rw-r--r--src/plugins/messageservices/pop/popservice.cpp38
-rw-r--r--src/plugins/messageservices/pop/popservice.h4
-rw-r--r--src/plugins/messageservices/smtp/smtpclient.cpp61
-rw-r--r--src/plugins/messageservices/smtp/smtpclient.h10
-rw-r--r--src/plugins/messageservices/smtp/smtpservice.cpp9
-rw-r--r--src/plugins/messageservices/smtp/smtpservice.h5
-rw-r--r--src/tools/messageserver/messageserver.cpp2
-rw-r--r--src/tools/messageserver/servicehandler.cpp24
-rw-r--r--tests/tst_imap/tst_imap.cpp2
-rw-r--r--tests/tst_pop/tst_pop.cpp10
-rw-r--r--tests/tst_smtp/tst_smtp.cpp4
29 files changed, 384 insertions, 368 deletions
diff --git a/src/libraries/qmfclient/qmailmessageset.cpp b/src/libraries/qmfclient/qmailmessageset.cpp
index 867826cb..72242950 100644
--- a/src/libraries/qmfclient/qmailmessageset.cpp
+++ b/src/libraries/qmfclient/qmailmessageset.cpp
@@ -1179,7 +1179,7 @@ QMailMessageSetModel::QMailMessageSetModel(QObject *parent)
: QAbstractItemModel(parent),
QMailMessageSetContainer(new QMailMessageSetModelPrivate)
{
- QTimer::singleShot(0, this, SLOT(delayedInit()));
+ QTimer::singleShot(0, this, &QMailMessageSetModel::delayedInit);
}
/*! \internal */
@@ -1438,7 +1438,7 @@ void QMailMessageSetModel::testForResync()
Q_D(QMailMessageSetModel);
if (d->_updateState == QMailMessageSetModelPrivate::Detect) {
- QTimer::singleShot(0, this, SLOT(ceasePropagatingUpdates()));
+ QTimer::singleShot(0, this, &QMailMessageSetModel::ceasePropagatingUpdates);
d->_updateState = QMailMessageSetModelPrivate::Detected;
}
}
diff --git a/src/libraries/qmfmessageserver/qmailmessagebuffer.cpp b/src/libraries/qmfmessageserver/qmailmessagebuffer.cpp
index 48d7915c..54b68ea1 100644
--- a/src/libraries/qmfmessageserver/qmailmessagebuffer.cpp
+++ b/src/libraries/qmfmessageserver/qmailmessagebuffer.cpp
@@ -64,7 +64,8 @@ QMailMessageBuffer::QMailMessageBuffer(QObject *parent)
: QObject(parent), d(new QMailMessageBufferPrivate)
{
d->messageTimer.setSingleShot(true);
- connect(&d->messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout()));
+ connect(&d->messageTimer, &QTimer::timeout,
+ this, &QMailMessageBuffer::messageTimeout);
d->lastFlushTimePerMessage = 0;
diff --git a/src/libraries/qmfmessageserver/qmailmessageservice.cpp b/src/libraries/qmfmessageserver/qmailmessageservice.cpp
index ff399ac0..b999b299 100644
--- a/src/libraries/qmfmessageserver/qmailmessageservice.cpp
+++ b/src/libraries/qmfmessageserver/qmailmessageservice.cpp
@@ -746,7 +746,7 @@ bool QMailMessageSource::synchronize(const QMailAccountId &accountId)
bool QMailMessageSource::deleteMessages(const QMailMessageIdList &ids)
{
d->_ids = ids;
- QTimer::singleShot(0, this, SLOT(deleteMessages()));
+ QTimer::singleShot(0, this, &QMailMessageSource::deletePendingMessages);
return true;
}
@@ -765,7 +765,7 @@ bool QMailMessageSource::copyMessages(const QMailMessageIdList &ids, const QMail
{
d->_ids = ids;
d->_destinationId = destinationId;
- QTimer::singleShot(0, this, SLOT(copyMessages()));
+ QTimer::singleShot(0, this, &QMailMessageSource::copyPendingMessages);
return true;
}
@@ -784,7 +784,7 @@ bool QMailMessageSource::moveMessages(const QMailMessageIdList &ids, const QMail
{
d->_ids = ids;
d->_destinationId = destinationId;
- QTimer::singleShot(0, this, SLOT(moveMessages()));
+ QTimer::singleShot(0, this, &QMailMessageSource::movePendingMessages);
return true;
}
@@ -807,7 +807,7 @@ bool QMailMessageSource::flagMessages(const QMailMessageIdList &ids, quint64 set
d->_ids = ids;
d->_setMask = setMask;
d->_unsetMask = unsetMask;
- QTimer::singleShot(0, this, SLOT(flagMessages()));
+ QTimer::singleShot(0, this, &QMailMessageSource::flagPendingMessages);
return true;
}
@@ -1112,7 +1112,7 @@ void QMailMessageSource::notImplemented()
}
/*! \internal */
-void QMailMessageSource::deleteMessages()
+void QMailMessageSource::deletePendingMessages()
{
uint total = d->_ids.count();
emit d->_service->progressChanged(0, total);
@@ -1136,7 +1136,7 @@ void QMailMessageSource::deleteMessages()
}
/*! \internal */
-void QMailMessageSource::copyMessages()
+void QMailMessageSource::copyPendingMessages()
{
bool successful(true);
@@ -1191,7 +1191,7 @@ void QMailMessageSource::copyMessages()
}
/*! \internal */
-void QMailMessageSource::moveMessages()
+void QMailMessageSource::movePendingMessages()
{
uint total = d->_ids.count();
emit d->_service->progressChanged(0, total);
@@ -1218,7 +1218,7 @@ void QMailMessageSource::moveMessages()
}
/*! \internal */
-void QMailMessageSource::flagMessages()
+void QMailMessageSource::flagPendingMessages()
{
uint total = d->_ids.count();
emit d->_service->progressChanged(0, total);
diff --git a/src/libraries/qmfmessageserver/qmailmessageservice.h b/src/libraries/qmfmessageserver/qmailmessageservice.h
index 4de2d6e3..a4483f6c 100644
--- a/src/libraries/qmfmessageserver/qmailmessageservice.h
+++ b/src/libraries/qmfmessageserver/qmailmessageservice.h
@@ -206,10 +206,10 @@ Q_SIGNALS:
void protocolResponse(const QString &response, const QVariantMap &data, quint64 action);
protected Q_SLOTS:
- void deleteMessages();
- void copyMessages();
- void moveMessages();
- void flagMessages();
+ void deletePendingMessages();
+ void copyPendingMessages();
+ void movePendingMessages();
+ void flagPendingMessages();
protected:
QMailMessageSource(QMailMessageService *service);
diff --git a/src/libraries/qmfmessageserver/qmailstoreaccountfilter.cpp b/src/libraries/qmfmessageserver/qmailstoreaccountfilter.cpp
index b9a9a675..a7c9097c 100644
--- a/src/libraries/qmfmessageserver/qmailstoreaccountfilter.cpp
+++ b/src/libraries/qmfmessageserver/qmailstoreaccountfilter.cpp
@@ -249,21 +249,21 @@ bool QMailStoreEvents::initConnections()
}
if (QMailStore *store = QMailStore::instance()) {
- connect(store, SIGNAL(accountsUpdated(QMailAccountIdList)), this, SLOT(accountsUpdated(QMailAccountIdList)));
- connect(store, SIGNAL(accountContentsModified(QMailAccountIdList)), this, SLOT(accountContentsModified(QMailAccountIdList)));
+ connect(store, &QMailStore::accountsUpdated, this, &QMailStoreEvents::accountsUpdated);
+ connect(store, &QMailStore::accountContentsModified, this, &QMailStoreEvents::accountContentsModified);
- connect(store, SIGNAL(messagesAdded(QMailMessageIdList)), this, SLOT(messagesAdded(QMailMessageIdList)));
- connect(store, SIGNAL(messagesRemoved(QMailMessageIdList)), this, SLOT(messagesRemoved(QMailMessageIdList)));
- connect(store, SIGNAL(messagesUpdated(QMailMessageIdList)), this, SLOT(messagesUpdated(QMailMessageIdList)));
- connect(store, SIGNAL(messageContentsModified(QMailMessageIdList)), this, SLOT(messageContentsModified(QMailMessageIdList)));
+ connect(store, &QMailStore::messagesAdded, this, &QMailStoreEvents::messagesAdded);
+ connect(store, &QMailStore::messagesRemoved, this, &QMailStoreEvents::messagesRemoved);
+ connect(store, &QMailStore::messagesUpdated, this, &QMailStoreEvents::messagesUpdated);
+ connect(store, &QMailStore::messageContentsModified, this, &QMailStoreEvents::messageContentsModified);
- connect(store, SIGNAL(foldersAdded(QMailFolderIdList)), this, SLOT(foldersAdded(QMailFolderIdList)));
- connect(store, SIGNAL(foldersRemoved(QMailFolderIdList)), this, SLOT(foldersRemoved(QMailFolderIdList)));
- connect(store, SIGNAL(foldersUpdated(QMailFolderIdList)), this, SLOT(foldersUpdated(QMailFolderIdList)));
- connect(store, SIGNAL(folderContentsModified(QMailFolderIdList)), this, SLOT(folderContentsModified(QMailFolderIdList)));
+ connect(store, &QMailStore::foldersAdded, this, &QMailStoreEvents::foldersAdded);
+ connect(store, &QMailStore::foldersRemoved, this, &QMailStoreEvents::foldersRemoved);
+ connect(store, &QMailStore::foldersUpdated, this, &QMailStoreEvents::foldersUpdated);
+ connect(store, &QMailStore::folderContentsModified, this, &QMailStoreEvents::folderContentsModified);
- connect(store, SIGNAL(messageRemovalRecordsAdded(QMailAccountIdList)), this, SLOT(messageRemovalRecordsAdded(QMailAccountIdList)));
- connect(store, SIGNAL(messageRemovalRecordsRemoved(QMailAccountIdList)), this, SLOT(messageRemovalRecordsRemoved(QMailAccountIdList)));
+ connect(store, &QMailStore::messageRemovalRecordsAdded, this, &QMailStoreEvents::messageRemovalRecordsAdded);
+ connect(store, &QMailStore::messageRemovalRecordsRemoved, this, &QMailStoreEvents::messageRemovalRecordsRemoved);
}
return true;
diff --git a/src/libraries/qmfmessageserver/qmailtransport.cpp b/src/libraries/qmfmessageserver/qmailtransport.cpp
index 34fbe237..b469f69a 100644
--- a/src/libraries/qmfmessageserver/qmailtransport.cpp
+++ b/src/libraries/qmfmessageserver/qmailtransport.cpp
@@ -33,13 +33,8 @@
#include "qmailtransport.h"
-#include <QFile>
-#include <QTimer>
-#include <QSslSocket>
#include <QSslError>
-
#include <QNetworkProxy>
-#include <QUrl>
#include <qmaillog.h>
#include <qmailnamespace.h>
@@ -126,15 +121,16 @@ qint64 QMailTransport::Socket::bytesSinceMark() const
Creates a transport object with the supplied object \a name.
*/
QMailTransport::QMailTransport(const char* name)
- : mName(name),
- mConnected(false),
- mInUse(false),
- mAcceptUntrustedCertificates(false)
+ : mSocket(nullptr)
+ , encryption(Encrypt_NONE)
+ , mStream(nullptr)
+ , mName(name)
+ , mConnected(false)
+ , mInUse(false)
+ , mAcceptUntrustedCertificates(false)
{
- encryption = Encrypt_NONE;
- mSocket = 0;
- mStream = 0;
- connect( &connectToHostTimeOut, SIGNAL(timeout()), this, SLOT(hostConnectionTimeOut()) );
+ connect(&connectToHostTimeOut, &QTimer::timeout,
+ this, &QMailTransport::hostConnectionTimeOut);
}
/*! \internal */
@@ -190,9 +186,9 @@ void QMailTransport::createSocket(EncryptType encryptType)
encryption = encryptType;
connect(mSocket, &QSslSocket::encrypted, this, &QMailTransport::encryptionEstablished);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- connect(mSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(connectionFailed(QList<QSslError>)));
+ connect(mSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(handleSslErrors(QList<QSslError>)));
#else
- connect(mSocket, &QSslSocket::sslErrors, this, &QMailTransport::connectionFailed);
+ connect(mSocket, &QSslSocket::sslErrors, this, &QMailTransport::handleSslErrors);
#endif
const int bufferLimit = 101*1024; // Limit memory used when downloading
@@ -200,9 +196,9 @@ void QMailTransport::createSocket(EncryptType encryptType)
mSocket->setObjectName(QString::fromUtf8(mName) + QString::fromLatin1("-socket"));
connect(mSocket, &QAbstractSocket::connected, this, &QMailTransport::connectionEstablished);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
+ connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleSocketError(QAbstractSocket::SocketError)));
#else
- connect(mSocket, &QAbstractSocket::errorOccurred, this, &QMailTransport::socketError);
+ connect(mSocket, &QAbstractSocket::errorOccurred, this, &QMailTransport::handleSocketError);
#endif
connect(mSocket, &QAbstractSocket::readyRead, this, &QMailTransport::readyRead);
connect(mSocket, &QAbstractSocket::bytesWritten, this, &QMailTransport::bytesWritten);
@@ -211,9 +207,9 @@ void QMailTransport::createSocket(EncryptType encryptType)
}
/*!
- Opens a connection to the supplied \a url and \a port, using the specified \a encryptionType.
+ Opens a connection to the supplied \a hostName and \a port, using the specified \a encryptionType.
*/
-void QMailTransport::open(const QString& url, int port, EncryptType encryptionType)
+void QMailTransport::open(const QString &hostName, int port, EncryptType encryptionType)
{
if (mSocket && mSocket->isOpen()) {
qCWarning(lcMessaging) << "Failed to open connection - already open!";
@@ -225,14 +221,14 @@ void QMailTransport::open(const QString& url, int port, EncryptType encryptionTy
const int threeMin = 3 * 60 * 1000;
connectToHostTimeOut.start(threeMin); // even this seems way too long?
createSocket(encryptionType);
- emit updateStatus(tr("DNS lookup"));
+ emit statusChanged(tr("DNS lookup"));
- qCDebug(lcMessaging) << "Opening connection - " << url << ':' << port
+ qCDebug(lcMessaging) << "Opening connection - " << hostName << ':' << port
<< (encryptionType == Encrypt_SSL ? " SSL" : (encryptionType == Encrypt_TLS ? " TLS" : ""));
if (mailEncryption() == Encrypt_SSL)
- mSocket->connectToHostEncrypted(url, port);
+ mSocket->connectToHostEncrypted(hostName, port);
else
- mSocket->connectToHost(url, port);
+ mSocket->connectToHost(hostName, port);
}
void QMailTransport::setAcceptUntrustedCertificates(bool accept)
@@ -275,7 +271,7 @@ void QMailTransport::close()
/*!
Returns true if a connection has been established.
*/
-bool QMailTransport::connected() const
+bool QMailTransport::isConnected() const
{
return mConnected;
}
@@ -311,7 +307,7 @@ QDataStream& QMailTransport::stream()
/*!
Returns the socket object allowing state to be accessed and manipulated.
*/
-QAbstractSocket& QMailTransport::socket()
+QSslSocket& QMailTransport::socket()
{
Q_ASSERT(mSocket);
return *mSocket;
@@ -355,7 +351,7 @@ void QMailTransport::connectionEstablished()
connectToHostTimeOut.stop();
if (mailEncryption() == Encrypt_NONE) {
mConnected = true;
- emit updateStatus(tr("Connected"));
+ emit statusChanged(tr("Connected"));
}
qCDebug(lcMessaging) << mName << ": connection established";
@@ -366,7 +362,7 @@ void QMailTransport::connectionEstablished()
void QMailTransport::hostConnectionTimeOut()
{
connectToHostTimeOut.stop();
- errorHandling(QAbstractSocket::SocketTimeoutError, tr("Connection timed out"));
+ reportSocketError(QAbstractSocket::SocketTimeoutError, tr("Connection timed out"));
}
/*! \internal */
@@ -374,7 +370,7 @@ void QMailTransport::encryptionEstablished()
{
if (mailEncryption() != Encrypt_NONE) {
mConnected = true;
- emit updateStatus(tr("Connected"));
+ emit statusChanged(tr("Connected"));
}
qCDebug(lcMessaging) << mName << ": Secure connection established";
@@ -382,7 +378,7 @@ void QMailTransport::encryptionEstablished()
}
/*! \internal */
-void QMailTransport::connectionFailed(const QList<QSslError>& errors)
+void QMailTransport::handleSslErrors(const QList<QSslError>& errors)
{
QMailServiceAction::Status::ErrorCode errorCode = classifyCertificateErrors(errors);
@@ -395,8 +391,8 @@ void QMailTransport::connectionFailed(const QList<QSslError>& errors)
mInUse = false;
mSocket->abort();
- emit updateStatus(tr("Error occurred"));
- emit sslErrorOccured(errorCode, tr("Socket error"));
+ emit statusChanged(tr("Error occurred"));
+ emit sslErrorOccurred(errorCode);
}
}
@@ -433,25 +429,25 @@ QMailServiceAction::Status::ErrorCode QMailTransport::classifyCertificateErrors(
}
/*! \internal */
-void QMailTransport::errorHandling(int status, QString msg)
+void QMailTransport::reportSocketError(int status, QString msg)
{
connectToHostTimeOut.stop();
mConnected = false;
mInUse = false;
mSocket->abort();
- emit updateStatus(tr("Error occurred"));
+ emit statusChanged(tr("Error occurred"));
// Socket errors run from -1; offset this value by +2
- emit errorOccurred(status + 2, msg);
+ emit socketErrorOccurred(status + 2, msg);
}
/*! \internal */
-void QMailTransport::socketError(QAbstractSocket::SocketError status)
+void QMailTransport::handleSocketError(QAbstractSocket::SocketError status)
{
qCWarning(lcMessaging) << "socketError:" << static_cast<int>(status)
<< ':' << mSocket->errorString();
- errorHandling(static_cast<int>(status), tr("Socket error"));
+ reportSocketError(static_cast<int>(status), tr("Socket error"));
}
/*!
@@ -485,15 +481,15 @@ QMailTransport::EncryptType QMailTransport::mailEncryption() const
*/
/*!
- \fn void QMailTransport::errorOccurred(int status, QString text);
+ \fn void QMailTransport::socketErrorOccurred(int status, const QString &text);
This signal is emitted when an error is encountered.
- The value of \a status corresponds to a value of QSslSocket::SocketError, and \a text
+ The value of \a status corresponds to a value of QAbstractSocket::SocketError, and \a text
contains a textual annotation where possible.
*/
/*!
- \fn void QMailTransport::updateStatus(const QString &status);
+ \fn void QMailTransport::statusChanged(const QString &status);
This signal is emitted when a change in status is reported. The new status is described by \a status.
*/
diff --git a/src/libraries/qmfmessageserver/qmailtransport.h b/src/libraries/qmfmessageserver/qmailtransport.h
index 7d6a92fc..0abd91d4 100644
--- a/src/libraries/qmfmessageserver/qmailtransport.h
+++ b/src/libraries/qmfmessageserver/qmailtransport.h
@@ -38,7 +38,7 @@
#include <qmailserviceaction.h>
#include <QObject>
-#include <QAbstractSocket>
+#include <QSslSocket>
#include <QTimer>
#include <QSslError>
@@ -64,7 +64,7 @@ public:
virtual ~QMailTransport();
// Open a connection to the specified server
- void open(const QString& url, int port, EncryptType encryptionType);
+ void open(const QString &hostName, int port, EncryptType encryptionType);
void setAcceptUntrustedCertificates(bool accept);
bool acceptUntrustedCertificates() const;
@@ -76,7 +76,7 @@ public:
void close();
// True if a connection has been established with the desired enryption type
- bool connected() const;
+ bool isConnected() const;
bool isEncrypted() const;
@@ -85,7 +85,7 @@ public:
// Access a stream to write to the mail server (must have an open connection)
QDataStream& stream();
- QAbstractSocket& socket();
+ QSslSocket& socket();
// Read line-oriented data from the transport (must have an open connection)
bool canReadLine() const;
@@ -102,25 +102,20 @@ Q_SIGNALS:
void readyRead();
void bytesWritten(qint64 transmitted);
- void errorOccurred(int status, QString);
- void updateStatus(const QString &);
- void sslErrorOccured(QMailServiceAction::Status::ErrorCode, QString);
+ void statusChanged(const QString &statusText);
+ void socketErrorOccurred(int status, const QString &message);
+ void sslErrorOccurred(QMailServiceAction::Status::ErrorCode error);
-public Q_SLOTS:
- void errorHandling(int errorCode, QString msg);
- void socketError(QAbstractSocket::SocketError error);
-
-protected Q_SLOTS:
+private Q_SLOTS:
+ void handleSocketError(QAbstractSocket::SocketError error);
void connectionEstablished();
void hostConnectionTimeOut();
void encryptionEstablished();
- void connectionFailed(const QList<QSslError>& errors);
-
-protected:
- // Override to modify certificate error handling
- virtual QMailServiceAction::Status::ErrorCode classifyCertificateErrors(const QList<QSslError>& errors);
+ void handleSslErrors(const QList<QSslError>& errors);
private:
+ void reportSocketError(int errorCode, QString msg);
+ QMailServiceAction::Status::ErrorCode classifyCertificateErrors(const QList<QSslError>& errors);
void createSocket(EncryptType encryptType);
EncryptType mailEncryption() const;
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:
diff --git a/src/plugins/messageservices/pop/popclient.cpp b/src/plugins/messageservices/pop/popclient.cpp
index e29e7d67..bdefe138 100644
--- a/src/plugins/messageservices/pop/popclient.cpp
+++ b/src/plugins/messageservices/pop/popclient.cpp
@@ -81,8 +81,8 @@ PopClient::PopClient(const QMailAccountId &id, QObject* parent)
credentials(QMailCredentialsFactory::getCredentialsHandlerForAccount(config))
{
inactiveTimer.setSingleShot(true);
- connect(&inactiveTimer, SIGNAL(timeout()), this, SLOT(connectionInactive()));
- connect(QMailMessageBuffer::instance(), SIGNAL(flushed()), this, SLOT(messageBufferFlushed()));
+ connect(&inactiveTimer, &QTimer::timeout, this, &PopClient::connectionInactive);
+ connect(QMailMessageBuffer::instance(), &QMailMessageBuffer::flushed, this, &PopClient::messageBufferFlushed);
setupAccount();
setupFolders();
@@ -110,12 +110,15 @@ void PopClient::createTransport()
// Set up the transport
transport = new QMailTransport("POP");
- connect(transport, SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString)));
- connect(transport, SIGNAL(connected(QMailTransport::EncryptType)), this, SLOT(connected(QMailTransport::EncryptType)));
- connect(transport, SIGNAL(errorOccurred(int,QString)), this, SLOT(transportError(int,QString)));
- connect(transport, SIGNAL(readyRead()), this, SLOT(incomingData()));
- connect(transport, SIGNAL(sslErrorOccured(QMailServiceAction::Status::ErrorCode,QString)),
- this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString)));
+ connect(transport, &QMailTransport::statusChanged, this, &PopClient::statusChanged);
+ connect(transport, &QMailTransport::connected, this, &PopClient::connected);
+ connect(transport, &QMailTransport::socketErrorOccurred, this, &PopClient::transportError);
+ connect(transport, &QMailTransport::readyRead, this, &PopClient::incomingData);
+ connect(transport, &QMailTransport::sslErrorOccurred,
+ [](QMailServiceAction::Status::ErrorCode errorCode) {
+ // at least report this
+ qCWarning(lcPOP) << "POP encountered SSL error" << errorCode;
+ });
}
}
@@ -123,12 +126,7 @@ void PopClient::deleteTransport()
{
if (transport) {
// Need to immediately disconnect these signals or slots may try to use null transport object
- disconnect(transport, SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString)));
- disconnect(transport, SIGNAL(connected(QMailTransport::EncryptType)), this, SLOT(connected(QMailTransport::EncryptType)));
- disconnect(transport, SIGNAL(errorOccurred(int,QString)), this, SLOT(transportError(int,QString)));
- disconnect(transport, SIGNAL(readyRead()), this, SLOT(incomingData()));
- disconnect(transport, SIGNAL(sslErrorOccured(QMailServiceAction::Status::ErrorCode,QString)),
- this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString)));
+ disconnect(transport, nullptr, this, nullptr);
// A Qt socket remains in an unusuable state for a short time after closing,
// thus it can't be immediately reused
@@ -163,7 +161,7 @@ void PopClient::newConnection()
testing = false;
pendingDeletes = false;
lastStatusTimer.start();
- if (transport && transport->connected()) {
+ if (transport && transport->isConnected()) {
if (selected) {
// Re-use the existing connection
inactiveTimer.stop();
@@ -195,7 +193,7 @@ void PopClient::newConnection()
messageCount = 0;
}
- if (transport && transport->connected() && selected) {
+ if (transport && transport->isConnected() && selected) {
if (deleting) {
uidlIntegrityCheck();
}
@@ -379,7 +377,7 @@ void PopClient::connected(QMailTransport::EncryptType encryptType)
PopConfiguration popCfg(config);
if (popCfg.mailEncryption() == encryptType) {
qCDebug(lcPOP) << "Connected";
- emit updateStatus(tr("Connected"));
+ emit statusChanged(tr("Connected"));
}
if ((popCfg.mailEncryption() != QMailTransport::Encrypt_SSL) && (status == TLS)) {
@@ -401,7 +399,7 @@ void PopClient::closeConnection()
inactiveTimer.stop();
if (transport) {
- if (transport->connected()) {
+ if (transport->isConnected()) {
if ( status == Exit ) {
// We have already sent our quit command
transport->close();
@@ -736,7 +734,7 @@ void PopClient::nextAction()
{
qCDebug(lcPOP) << "connected, checking credentials status" << credentials->status();
if (credentials->status() == QMailCredentialsInterface::Ready) {
- emit updateStatus(tr("Logging in"));
+ emit statusChanged(tr("Logging in"));
// Get the login command sequence to use
authCommands = PopAuthenticator::getAuthentication(PopConfiguration(config),
@@ -817,14 +815,14 @@ void PopClient::nextAction()
if (msgNum != -1) {
if (!selected) {
if (messageCount == 1) {
- emit updateStatus(tr("Previewing", "Previewing <no of messages>") + QChar(' ') + QString::number(newUids.count()));
+ emit statusChanged(tr("Previewing", "Previewing <no of messages>") + QChar(' ') + QString::number(newUids.count()));
}
if (lastStatusTimer.elapsed() > 1000) {
lastStatusTimer.start();
emit progressChanged(messageCount, newUids.count());
}
} else {
- emit updateStatus(tr("Completing %1 / %2").arg(messageCount).arg(selectionMap.count()));
+ emit statusChanged(tr("Completing %1 / %2").arg(messageCount).arg(selectionMap.count()));
}
QString temp = QString::number(msgNum);
@@ -840,7 +838,7 @@ void PopClient::nextAction()
// No more messages to be fetched - are there any to be deleted?
if (!obsoleteUids.isEmpty()) {
qCDebug(lcPOP) << qPrintable(QString::number(obsoleteUids.count()) + " messages in mailbox to be deleted");
- emit updateStatus(tr("Removing old messages"));
+ emit statusChanged(tr("Removing old messages"));
nextStatus = DeleteMessage;
} else {
@@ -868,7 +866,7 @@ void PopClient::nextAction()
// on device before removing mail from external mail server
QMailStore::instance()->ensureDurability();
int pos = msgPosFromUidl(messageUid);
- emit updateStatus(tr("Removing message from server"));
+ emit statusChanged(tr("Removing message from server"));
nextCommand = ("DELE " + QString::number(pos));
nextStatus = DeleAfterRetr;
} else {
@@ -953,7 +951,7 @@ void PopClient::nextAction()
case Quit:
{
qCDebug(lcPOP) << "[" << config.id() << "]" << "logging out.";
- emit updateStatus(tr("Logging out"));
+ emit statusChanged(tr("Logging out"));
nextStatus = Exit;
nextCommand = "QUIT";
waitForInput = true;
diff --git a/src/plugins/messageservices/pop/popclient.h b/src/plugins/messageservices/pop/popclient.h
index 7db305bc..79c5b37e 100644
--- a/src/plugins/messageservices/pop/popclient.h
+++ b/src/plugins/messageservices/pop/popclient.h
@@ -83,10 +83,9 @@ public:
void removeAllFromBuffer(QMailMessage *message);
signals:
- void connectionError(QMailServiceAction::Status::ErrorCode status, const QString &msg);
void errorOccurred(int, const QString &);
void errorOccurred(QMailServiceAction::Status::ErrorCode, const QString &);
- void updateStatus(const QString &);
+ void statusChanged(const QString &);
void messageActionCompleted(const QString &uid);
@@ -95,7 +94,7 @@ signals:
void allMessagesReceived();
-protected slots:
+private slots:
void messageBufferFlushed();
void connected(QMailTransport::EncryptType encryptType);
void transportError(int, QString msg);
diff --git a/src/plugins/messageservices/pop/popservice.cpp b/src/plugins/messageservices/pop/popservice.cpp
index be05bd0b..2a6a2244 100644
--- a/src/plugins/messageservices/pop/popservice.cpp
+++ b/src/plugins/messageservices/pop/popservice.cpp
@@ -55,9 +55,9 @@ public:
_queuedMailCheckInProgress(false)
{
connect(&_service->_client, SIGNAL(allMessagesReceived()), this, SIGNAL(newMessagesAvailable()));
- connect(&_service->_client, SIGNAL(messageActionCompleted(QString)), this, SLOT(messageActionCompleted(QString)));
- connect(&_service->_client, SIGNAL(retrievalCompleted()), this, SLOT(retrievalCompleted()));
- connect(&_intervalTimer, SIGNAL(timeout()), this, SLOT(queueMailCheck()));
+ connect(&_service->_client, &PopClient::messageActionCompleted, this, &Source::messageActionCompleted);
+ connect(&_service->_client, &PopClient::retrievalCompleted, this, &Source::retrievalCompleted);
+ connect(&_intervalTimer, &QTimer::timeout, this, &Source::queueMailCheck);
}
void setIntervalTimer(int interval)
@@ -103,7 +103,8 @@ private:
QTimer _intervalTimer;
};
-bool PopService::Source::retrieveFolderList(const QMailAccountId &accountId, const QMailFolderId &folderId, bool descending)
+bool PopService::Source::retrieveFolderList(const QMailAccountId &accountId, const QMailFolderId &folderId,
+ bool descending)
{
if (!accountId.isValid()) {
_service->errorOccurred(QMailServiceAction::Status::ErrInvalidData, tr("No account specified"));
@@ -116,8 +117,8 @@ bool PopService::Source::retrieveFolderList(const QMailAccountId &accountId, con
_unavailable = true;
} else {
// Just report success
- _service->updateStatus(QString());
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ _service->handleStatusChange(QString());
+ QTimer::singleShot(0, this, &Source::retrievalCompleted);
}
return true;
@@ -125,7 +126,8 @@ bool PopService::Source::retrieveFolderList(const QMailAccountId &accountId, con
Q_UNUSED(folderId)
}
-bool PopService::Source::retrieveMessageLists(const QMailAccountId &accountId, const QMailFolderIdList &folderIds, uint minimum, const QMailMessageSortKey &sort)
+bool PopService::Source::retrieveMessageLists(const QMailAccountId &accountId, const QMailFolderIdList &folderIds,
+ uint minimum, const QMailMessageSortKey &sort)
{
if (folderIds.isEmpty()) {
_service->errorOccurred(QMailServiceAction::Status::ErrInvalidData, tr("No folders specified"));
@@ -135,7 +137,8 @@ bool PopService::Source::retrieveMessageLists(const QMailAccountId &accountId, c
return retrieveMessageList(accountId, QMailFolderId(), minimum, sort);
}
-bool PopService::Source::retrieveMessageList(const QMailAccountId &accountId, const QMailFolderId &folderId, uint minimum, const QMailMessageSortKey &sort)
+bool PopService::Source::retrieveMessageList(const QMailAccountId &accountId, const QMailFolderId &folderId,
+ uint minimum, const QMailMessageSortKey &sort)
{
if (!accountId.isValid()) {
_service->errorOccurred(QMailServiceAction::Status::ErrInvalidData, tr("No account specified"));
@@ -152,8 +155,8 @@ bool PopService::Source::retrieveMessageList(const QMailAccountId &accountId, co
if (!_service->_client.synchronizationEnabled(folderId)) {
// Just report success
- _service->updateStatus(QString());
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ _service->handleStatusChange(QString());
+ QTimer::singleShot(0, this, &Source::retrievalCompleted);
return true;
}
@@ -165,7 +168,8 @@ bool PopService::Source::retrieveMessageList(const QMailAccountId &accountId, co
Q_UNUSED(sort)
}
-bool PopService::Source::retrieveMessages(const QMailMessageIdList &messageIds, QMailRetrievalAction::RetrievalSpecification spec)
+bool PopService::Source::retrieveMessages(const QMailMessageIdList &messageIds,
+ QMailRetrievalAction::RetrievalSpecification spec)
{
if (messageIds.isEmpty()) {
_service->errorOccurred(QMailServiceAction::Status::ErrInvalidData, tr("No messages to retrieve"));
@@ -174,7 +178,7 @@ bool PopService::Source::retrieveMessages(const QMailMessageIdList &messageIds,
if (spec == QMailRetrievalAction::Flags) {
// Just report success
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::retrievalCompleted);
return true;
}
@@ -199,7 +203,7 @@ bool PopService::Source::exportUpdates(const QMailAccountId &accountId)
}
// Just report success
- QTimer::singleShot(0, this, SLOT(retrievalCompleted()));
+ QTimer::singleShot(0, this, &Source::retrievalCompleted);
return true;
}
@@ -312,9 +316,9 @@ PopService::PopService(const QMailAccountId &accountId)
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(QMailStore::instance(), SIGNAL(accountsUpdated(const QMailAccountIdList&)),
- this, SLOT(accountsUpdated(const QMailAccountIdList&)));
+ connect(&_client, &PopClient::statusChanged, this, &PopService::handleStatusChange);
+ connect(QMailStore::instance(), &QMailStore::accountsUpdated,
+ this, &PopService::accountsUpdated);
QMailAccountConfiguration accountCfg(accountId);
PopConfiguration popCfg(accountCfg);
@@ -373,7 +377,7 @@ void PopService::errorOccurred(QMailServiceAction::Status::ErrorCode code, const
emit actionCompleted(false);
}
-void PopService::updateStatus(const QString &text)
+void PopService::handleStatusChange(const QString &text)
{
updateStatus(QMailServiceAction::Status::ErrNoError, text, _client.accountId());
}
diff --git a/src/plugins/messageservices/pop/popservice.h b/src/plugins/messageservices/pop/popservice.h
index f67b08b7..ed0270d9 100644
--- a/src/plugins/messageservices/pop/popservice.h
+++ b/src/plugins/messageservices/pop/popservice.h
@@ -58,11 +58,11 @@ public:
public slots:
bool cancelOperation(QMailServiceAction::Status::ErrorCode code, const QString &text) override;
-protected slots:
+private slots:
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);
void accountsUpdated(const QMailAccountIdList &ids);
private:
diff --git a/src/plugins/messageservices/smtp/smtpclient.cpp b/src/plugins/messageservices/smtp/smtpclient.cpp
index f437a0c7..9be40d99 100644
--- a/src/plugins/messageservices/smtp/smtpclient.cpp
+++ b/src/plugins/messageservices/smtp/smtpclient.cpp
@@ -167,18 +167,21 @@ void SmtpClient::openTransport()
// Set up the transport
transport = new QMailTransport("SMTP");
- connect(transport, SIGNAL(readyRead()),
- this, SLOT(readyRead()));
- connect(transport, SIGNAL(connected(QMailTransport::EncryptType)),
- this, SLOT(connected(QMailTransport::EncryptType)));
- connect(transport, SIGNAL(bytesWritten(qint64)),
- this, SLOT(sent(qint64)));
- connect(transport, SIGNAL(updateStatus(QString)),
- this, SIGNAL(updateStatus(QString)));
- connect(transport, SIGNAL(errorOccurred(int,QString)),
- this, SLOT(transportError(int,QString)));
- connect(transport, SIGNAL(sslErrorOccured(QMailServiceAction::Status::ErrorCode,QString)),
- this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString)));
+ connect(transport, &QMailTransport::readyRead,
+ this, &SmtpClient::readyRead);
+ connect(transport, &QMailTransport::connected,
+ this, &SmtpClient::handleConnected);
+ connect(transport, &QMailTransport::bytesWritten,
+ this, &SmtpClient::handleSent);
+ connect(transport, &QMailTransport::statusChanged,
+ this, &SmtpClient::statusChanged);
+ connect(transport, &QMailTransport::socketErrorOccurred,
+ this, &SmtpClient::transportError);
+ connect(transport, &QMailTransport::sslErrorOccurred,
+ [](QMailServiceAction::Status::ErrorCode errorCode) {
+ // at least report this
+ qCWarning(lcSMTP) << "SMTP encountered SSL error" << errorCode;
+ });
}
status = Init;
@@ -278,13 +281,13 @@ QMailServiceAction::Status::ErrorCode SmtpClient::addMail(const QMailMessage& ma
return QMailServiceAction::Status::ErrNoError;
}
-void SmtpClient::connected(QMailTransport::EncryptType encryptType)
+void SmtpClient::handleConnected(QMailTransport::EncryptType encryptType)
{
delete authTimeout;
authTimeout = new QTimer;
authTimeout->setSingleShot(true);
- connect(authTimeout, SIGNAL(timeout()), this, SLOT(authExpired()));
+ connect(authTimeout, &QTimer::timeout, this, &SmtpClient::authExpired);
const int timeout = 40 * 1000;
authTimeout->setInterval(timeout);
authTimeout->start();
@@ -292,7 +295,7 @@ void SmtpClient::connected(QMailTransport::EncryptType encryptType)
SmtpConfiguration smtpCfg(config);
if (smtpCfg.smtpEncryption() == encryptType) {
qCDebug(lcSMTP) << "Connected";
- emit updateStatus(tr("Connected"));
+ emit statusChanged(tr("Connected"));
}
if ((smtpCfg.smtpEncryption() == QMailTransport::Encrypt_TLS) && (status == TLS)) {
@@ -311,7 +314,7 @@ void SmtpClient::transportError(int errorCode, QString msg)
operationFailed(errorCode, msg);
}
-void SmtpClient::sent(qint64 size)
+void SmtpClient::handleSent(qint64 size)
{
if (sendingId.isValid() && messageLength) {
SendMap::const_iterator it = m_sendUnits.find(sendingId);
@@ -724,7 +727,7 @@ void SmtpClient::nextAction(const QString &response)
sendCommand("MAIL FROM:" + email.from);
status = Recv;
- emit updateStatus(tr("Sending: %1").arg(email.mail.subject().simplified()));
+ emit statusChanged(tr("Sending: %1").arg(email.mail.subject().simplified()));
break;
}
case Recv:
@@ -822,10 +825,13 @@ void SmtpClient::nextAction(const QString &response)
// written each time so there is no need to allocate large buffers to hold everything.
temporaryFile->seek(0);
waitingForBytes = 0;
- if (transport->isEncrypted())
- connect(&(transport->socket()), SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(sendMoreData(qint64)));
- else
- connect(transport, SIGNAL(bytesWritten(qint64)), this, SLOT(sendMoreData(qint64)));
+ if (transport->isEncrypted()) {
+ connect(&(transport->socket()), &QSslSocket::encryptedBytesWritten,
+ this, &SmtpClient::sendMoreData);
+ } else {
+ connect(transport, &QMailTransport::bytesWritten,
+ this, &SmtpClient::sendMoreData);
+ }
// trigger the sending of the first block of data
sendMoreData(0);
@@ -916,7 +922,7 @@ void SmtpClient::nextAction(const QString &response)
if (sentCount) {
sendList.clear();
- emit updateStatus(tr("Sent %n messages", "", sentCount));
+ emit statusChanged(tr("Sent %n messages", "", sentCount));
}
emit sendCompleted();
break;
@@ -1068,10 +1074,13 @@ void SmtpClient::authExpired()
void SmtpClient::stopTransferring()
{
if (temporaryFile) {
- if (transport->isEncrypted())
- disconnect(&(transport->socket()), SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(sendMoreData(qint64)));
- else
- disconnect(transport, SIGNAL(bytesWritten(qint64)), this, SLOT(sendMoreData(qint64)));
+ if (transport->isEncrypted()) {
+ disconnect(&(transport->socket()), &QSslSocket::encryptedBytesWritten,
+ this, &SmtpClient::sendMoreData);
+ } else {
+ disconnect(transport, &QMailTransport::bytesWritten,
+ this, &SmtpClient::sendMoreData);
+ }
delete temporaryFile;
temporaryFile = nullptr;
status = Sent;
diff --git a/src/plugins/messageservices/smtp/smtpclient.h b/src/plugins/messageservices/smtp/smtpclient.h
index 62e6309a..4a2993ee 100644
--- a/src/plugins/messageservices/smtp/smtpclient.h
+++ b/src/plugins/messageservices/smtp/smtpclient.h
@@ -79,23 +79,21 @@ public:
QMailServiceAction::Status::ErrorCode addMail(const QMailMessage& mail);
signals:
- void connectionError(QMailServiceAction::Status::ErrorCode status, const QString &msg);
void errorOccurred(int, const QString &);
void errorOccurred(const QMailServiceAction::Status &, const QString &);
- void updateStatus(const QString &);
+ void statusChanged(const QString &);
void progressChanged(uint, uint);
void messageTransmitted(const QMailMessageId&);
void sendCompleted();
void fetchCapabilitiesFinished();
-protected slots:
- void connected(QMailTransport::EncryptType encryptType);
+private slots:
+ void handleConnected(QMailTransport::EncryptType encryptType);
void transportError(int, QString msg);
void readyRead();
- void sent(qint64);
+ void handleSent(qint64);
-private slots:
void sendMoreData(qint64);
void authExpired();
void onCredentialsStatusChanged();
diff --git a/src/plugins/messageservices/smtp/smtpservice.cpp b/src/plugins/messageservices/smtp/smtpservice.cpp
index 7a944246..b9925aa4 100644
--- a/src/plugins/messageservices/smtp/smtpservice.cpp
+++ b/src/plugins/messageservices/smtp/smtpservice.cpp
@@ -49,8 +49,8 @@ public:
: QMailMessageSink(service),
_service(service)
{
- connect(&_service->_client, SIGNAL(messageTransmitted(QMailMessageId)), this, SLOT(messageTransmitted(QMailMessageId)));
- connect(&_service->_client, SIGNAL(sendCompleted()), this, SLOT(sendCompleted()));
+ connect(&_service->_client, &SmtpClient::messageTransmitted, this, &Sink::messageTransmitted);
+ connect(&_service->_client, &SmtpClient::sendCompleted, this, &Sink::sendCompleted);
}
public slots:
@@ -106,10 +106,9 @@ SmtpService::SmtpService(const QMailAccountId &accountId)
_capabilityFetchTimeout(0)
{
connect(&_client, SIGNAL(progressChanged(uint, uint)), this, SIGNAL(progressChanged(uint, uint)));
-
connect(&_client, SIGNAL(errorOccurred(int, QString)), this, SLOT(errorOccurred(int, QString)));
connect(&_client, SIGNAL(errorOccurred(QMailServiceAction::Status, QString)), this, SLOT(errorOccurred(QMailServiceAction::Status, QString)));
- connect(&_client, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(QString)));
+ connect(&_client, &SmtpClient::statusChanged, this, &SmtpService::handleStatusChange);
fetchCapabilities();
}
@@ -206,7 +205,7 @@ void SmtpService::errorOccurred(const QMailServiceAction::Status & status, const
emit actionCompleted(false);
}
-void SmtpService::updateStatus(const QString &text)
+void SmtpService::handleStatusChange(const QString &text)
{
updateStatus(QMailServiceAction::Status::ErrNoError, text, _client.account());
}
diff --git a/src/plugins/messageservices/smtp/smtpservice.h b/src/plugins/messageservices/smtp/smtpservice.h
index 078a3818..6f137987 100644
--- a/src/plugins/messageservices/smtp/smtpservice.h
+++ b/src/plugins/messageservices/smtp/smtpservice.h
@@ -60,13 +60,12 @@ public:
public slots:
bool cancelOperation(QMailServiceAction::Status::ErrorCode code, const QString &text) override;
-protected slots:
+private slots:
void errorOccurred(int code, const QString &text);
void errorOccurred(const QMailServiceAction::Status & status, const QString &text);
- void updateStatus(const QString& text);
+ void handleStatusChange(const QString& text);
-private slots:
void fetchCapabilities();
void onCapabilitiesFetched();
diff --git a/src/tools/messageserver/messageserver.cpp b/src/tools/messageserver/messageserver.cpp
index 3e445382..70357171 100644
--- a/src/tools/messageserver/messageserver.cpp
+++ b/src/tools/messageserver/messageserver.cpp
@@ -155,7 +155,7 @@ bool MessageServer::init()
this, &MessageServer::retrievalCompleted);
// clean up any temporary messages that were not cleaned up by clients
- QTimer::singleShot(0, this, SLOT(cleanupTemporaryMessages()));
+ QTimer::singleShot(0, this, &MessageServer::cleanupTemporaryMessages);
emit handler->actionsListed(QMailActionDataList());
diff --git a/src/tools/messageserver/servicehandler.cpp b/src/tools/messageserver/servicehandler.cpp
index bd048d1b..b582ab36 100644
--- a/src/tools/messageserver/servicehandler.cpp
+++ b/src/tools/messageserver/servicehandler.cpp
@@ -1025,7 +1025,7 @@ void ServiceHandler::enqueueRequest(Request *req, quint64 action,
_requestsFile.flush();
}
- QTimer::singleShot(0, this, SLOT(dispatchRequest()));
+ QTimer::singleShot(0, this, &ServiceHandler::dispatchRequest);
}
namespace {
@@ -1121,7 +1121,7 @@ void ServiceHandler::dispatchRequest()
if (mActionExpiry.isEmpty()) {
// Start the expiry timer. Convert to milliseconds, and avoid shooting too early
const int expiryMs = ExpirySeconds * 1000;
- QTimer::singleShot(expiryMs + 50, this, SLOT(expireAction()));
+ QTimer::singleShot(expiryMs + 50, this, &ServiceHandler::expireAction);
}
mActionExpiry.append(request->action);
} else {
@@ -1232,7 +1232,7 @@ void ServiceHandler::expireAction()
// milliseconds until it expires
quint64 nextShot(nextExpiry <= now ? 0 : (nextExpiry - now) * 1000 + 50);
- QTimer::singleShot(nextShot, this, SLOT(expireAction()));
+ QTimer::singleShot(nextShot, this, &ServiceHandler::expireAction);
return;
} else {
expiryIt = mActionExpiry.erase(expiryIt); // Just remove this non-existent action
@@ -1294,7 +1294,7 @@ void ServiceHandler::cancelTransfer(quint64 action)
mActiveActions.erase(it);
// See if there are more actions
- QTimer::singleShot(0, this, SLOT(dispatchRequest()));
+ QTimer::singleShot(0, this, &ServiceHandler::dispatchRequest);
} else {
// See if this is a pending request that we can abort
auto it = mRequests.begin(), end = mRequests.end();
@@ -2722,7 +2722,7 @@ void ServiceHandler::searchMessages(quint64 action, const QMailMessageKey &filte
// Schedule this search
mSearches.append(MessageSearch(action, searchIds, bodyText));
- QTimer::singleShot(0, this, SLOT(continueSearch()));
+ QTimer::singleShot(0, this, &ServiceHandler::continueSearch);
}
}
@@ -2773,7 +2773,7 @@ bool ServiceHandler::dispatchSearchMessages(Request *req)
mSearches.append(MessageSearch(request->action,
QMailStore::instance()->queryMessages(request->filter, request->sort),
request->bodyText));
- QTimer::singleShot(0, this, SLOT(continueSearch()));
+ QTimer::singleShot(0, this, &ServiceHandler::continueSearch);
}
}
}
@@ -2799,7 +2799,7 @@ void ServiceHandler::cancelLocalSearch(quint64 action) // cancel local search
void ServiceHandler::shutdown()
{
- QTimer::singleShot(0, QCoreApplication::instance(), SLOT(quit()));
+ QTimer::singleShot(0, QCoreApplication::instance(), &QCoreApplication::quit);
}
void ServiceHandler::listActions()
@@ -2952,7 +2952,7 @@ void ServiceHandler::handleActionCompleted(bool success, QMailMessageService *se
// See if there are pending requests
- QTimer::singleShot(0, this, SLOT(dispatchRequest()));
+ QTimer::singleShot(0, this, &ServiceHandler::dispatchRequest);
}
void ServiceHandler::emitMessagesTransmitted(const QMailMessageIdList& ml, quint64 a)
@@ -3139,7 +3139,7 @@ void ServiceHandler::onAvailabilityChanged(bool available)
mUnavailableServices.remove(service);
// See if there are pending requests that can now be dispatched
- QTimer::singleShot(0, this, SLOT(dispatchRequest()));
+ QTimer::singleShot(0, this, &ServiceHandler::dispatchRequest);
} else {
mUnavailableServices.insert(service);
}
@@ -3202,7 +3202,7 @@ void ServiceHandler::onActionCompleted(bool success)
qCWarning(lcMessaging) << "Would not determine server/action completing";
// See if there are pending requests
- QTimer::singleShot(0, this, SLOT(dispatchRequest()));
+ QTimer::singleShot(0, this, &ServiceHandler::dispatchRequest);
}
void ServiceHandler::reportFailure(quint64 action, QMailServiceAction::Status::ErrorCode code, const QString &text,
@@ -3264,10 +3264,10 @@ void ServiceHandler::continueSearch()
mSearches.removeFirst();
if (!mSearches.isEmpty())
- QTimer::singleShot(0, this, SLOT(continueSearch()));
+ QTimer::singleShot(0, this, &ServiceHandler::continueSearch);
}
} else {
- QTimer::singleShot(0, this, SLOT(continueSearch()));
+ QTimer::singleShot(0, this, &ServiceHandler::continueSearch);
}
}
}
diff --git a/tests/tst_imap/tst_imap.cpp b/tests/tst_imap/tst_imap.cpp
index 04855e86..36f55f32 100644
--- a/tests/tst_imap/tst_imap.cpp
+++ b/tests/tst_imap/tst_imap.cpp
@@ -112,7 +112,7 @@ void tst_ImapClient::test_connection()
{
ConnectionStrategy strategy;
QSignalSpy completed(mClient, &ImapClient::retrievalCompleted);
- QSignalSpy updateStatus(mClient, &ImapClient::updateStatus);
+ QSignalSpy updateStatus(mClient, &ImapClient::statusChanged);
mClient->setStrategy(&strategy);
mClient->newConnection();
diff --git a/tests/tst_pop/tst_pop.cpp b/tests/tst_pop/tst_pop.cpp
index 9d24e119..7e6a0ee3 100644
--- a/tests/tst_pop/tst_pop.cpp
+++ b/tests/tst_pop/tst_pop.cpp
@@ -56,10 +56,6 @@ private:
PopClient *mClient = nullptr;
};
-QTEST_MAIN(tst_PopClient)
-
-#include "tst_pop.moc"
-
void tst_PopClient::initTestCase()
{
QMailAccount account;
@@ -94,7 +90,7 @@ void tst_PopClient::cleanupTestCase()
void tst_PopClient::test_connection()
{
QSignalSpy completed(mClient, &PopClient::retrievalCompleted);
- QSignalSpy updateStatus(mClient, &PopClient::updateStatus);
+ QSignalSpy updateStatus(mClient, &PopClient::statusChanged);
mClient->testConnection();
QVERIFY(!completed.wait(250)); // Fails with wrong credentials
@@ -105,3 +101,7 @@ void tst_PopClient::test_connection()
QCOMPARE(updateStatus.takeFirst().first().toString(), QString::fromLatin1("Connected"));
QCOMPARE(updateStatus.takeFirst().first().toString(), QString::fromLatin1("Logging in"));
}
+
+QTEST_MAIN(tst_PopClient)
+
+#include "tst_pop.moc"
diff --git a/tests/tst_smtp/tst_smtp.cpp b/tests/tst_smtp/tst_smtp.cpp
index 99d534af..5784e7c0 100644
--- a/tests/tst_smtp/tst_smtp.cpp
+++ b/tests/tst_smtp/tst_smtp.cpp
@@ -88,7 +88,7 @@ void tst_SmtpClient::cleanupTestCase()
void tst_SmtpClient::test_connection()
{
QSignalSpy completed(mClient, &SmtpClient::sendCompleted);
- QSignalSpy updateStatus(mClient, &SmtpClient::updateStatus);
+ QSignalSpy updateStatus(mClient, &SmtpClient::statusChanged);
mClient->newConnection();
QVERIFY(completed.wait());
@@ -102,7 +102,7 @@ void tst_SmtpClient::test_connection()
void tst_SmtpClient::test_auth()
{
QSignalSpy completed(mClient, &SmtpClient::sendCompleted);
- QSignalSpy updateStatus(mClient, &SmtpClient::updateStatus);
+ QSignalSpy updateStatus(mClient, &SmtpClient::statusChanged);
QMailAccountConfiguration config(mClient->account());
SmtpConfigurationEditor smtp(&config);