Commit 21ff8860 authored by Ahmad Samir's avatar Ahmad Samir Committed by Sandro Knauß
Browse files

Port to PMF signal/slot syntax

parent a6a5fb4d
Pipeline #174300 passed with stage
in 3 minutes and 43 seconds
......@@ -82,7 +82,7 @@ void FakeServer::newConnection()
QMutexLocker locker(&m_mutex);
m_clientSockets << m_tcpServer->nextPendingConnection();
connect(m_clientSockets.last(), SIGNAL(readyRead()), this, SLOT(dataAvailable()));
connect(m_clientSockets.last(), &QTcpSocket::readyRead, this, &FakeServer::dataAvailable);
m_clientParsers << new KIMAP::ImapStreamParser(m_clientSockets.last(), true);
QVERIFY(m_clientSockets.size() <= m_scenarios.size());
......@@ -112,7 +112,7 @@ void FakeServer::run()
qFatal("Unable to start the server");
}
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
connect(m_tcpServer, &QTcpServer::newConnection, this, &FakeServer::newConnection);
exec();
......
......@@ -100,8 +100,8 @@ void SslServer::incomingConnection(qintptr handle)
socket->sslConfiguration().addCaCertificates(QList<QSslCertificate>() << ssl_cert);
socket->setPeerVerifyMode(QSslSocket::VerifyNone);
socket->ignoreSslErrors();
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
connect(socket, qOverload<const QList<QSslError> &>(&QSslSocket::sslErrors), this, &SslServer::sslErrors);
connect(socket, &QAbstractSocket::errorOccurred, this, &SslServer::error);
if (!mWaitForStartTls) {
socket->startServerEncryption();
}
......
......@@ -186,7 +186,7 @@ private Q_SLOTS:
auto job = new KIMAP::ListJob(&session);
job->setIncludeUnsubscribed(unsubscribed);
QSignalSpy spy(job, SIGNAL(mailBoxesReceived(const QList<KIMAP::MailBoxDescriptor> &, const QList<QList<QByteArray>> &)));
QSignalSpy spy(job, &KIMAP::ListJob::mailBoxesReceived);
bool result = job->exec();
QEXPECT_FAIL("bad", "Expected failure on BAD response", Continue);
......
......@@ -38,7 +38,7 @@ private Q_SLOTS:
fakeServer.setScenario(QList<QByteArray>() << FakeServer::greeting());
fakeServer.startAndWait();
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
QSignalSpy spy(&s, SIGNAL(stateChanged(KIMAP::Session::State, KIMAP::Session::State)));
QSignalSpy spy(&s, &KIMAP::Session::stateChanged);
QCOMPARE((int)s.state(), (int)KIMAP::Session::Disconnected);
QTest::qWait(600);
QCOMPARE((int)s.state(), (int)KIMAP::Session::NotAuthenticated);
......@@ -53,9 +53,9 @@ private Q_SLOTS:
KIMAP::Session s(QStringLiteral("0.0.0.0"), 1234);
s.setTimeout(1); // 1 second timeout
QSignalSpy spyFail(&s, SIGNAL(connectionFailed()));
QSignalSpy spyLost(&s, SIGNAL(connectionLost()));
QSignalSpy spyState(&s, SIGNAL(stateChanged(KIMAP::Session::State, KIMAP::Session::State)));
QSignalSpy spyFail(&s, &KIMAP::Session::connectionFailed);
QSignalSpy spyLost(&s, &KIMAP::Session::connectionLost);
QSignalSpy spyState(&s, &KIMAP::Session::stateChanged);
QCOMPARE((int)s.state(), (int)KIMAP::Session::Disconnected);
......@@ -83,9 +83,9 @@ private Q_SLOTS:
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
s.setTimeout(2);
QSignalSpy spyFail(&s, SIGNAL(connectionFailed()));
QSignalSpy spyLost(&s, SIGNAL(connectionLost()));
QSignalSpy spyState(&s, SIGNAL(stateChanged(KIMAP::Session::State, KIMAP::Session::State)));
QSignalSpy spyFail(&s, &KIMAP::Session::connectionFailed);
QSignalSpy spyLost(&s, &KIMAP::Session::connectionLost);
QSignalSpy spyState(&s, &KIMAP::Session::stateChanged);
QCOMPARE((int)s.state(), (int)KIMAP::Session::Disconnected);
// Wait 1.8 second. Since the timeout is set to 2 seconds, the socket should be still
......@@ -112,7 +112,7 @@ private Q_SLOTS:
fakeServer.startAndWait();
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
QSignalSpy spy(&s, SIGNAL(stateChanged(KIMAP::Session::State, KIMAP::Session::State)));
QSignalSpy spy(&s, &KIMAP::Session::stateChanged);
QCOMPARE((int)s.state(), (int)KIMAP::Session::Disconnected);
QTest::qWait(500);
QCOMPARE((int)s.state(), (int)KIMAP::Session::Authenticated);
......@@ -130,13 +130,13 @@ private Q_SLOTS:
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
auto j1 = new MockJob(&s);
connect(j1, SIGNAL(result(KJob *)), this, SLOT(jobDone(KJob *)));
connect(j1, &KJob::result, this, &SessionTest::jobDone);
auto j2 = new MockJob(&s);
connect(j2, SIGNAL(result(KJob *)), this, SLOT(jobDone(KJob *)));
connect(j2, &KJob::result, this, &SessionTest::jobDone);
auto j3 = new MockJob(&s);
connect(j3, SIGNAL(result(KJob *)), this, SLOT(jobDone(KJob *)));
connect(j3, &KJob::result, this, &SessionTest::jobDone);
auto j4 = new MockJob(&s);
connect(j4, SIGNAL(result(KJob *)), this, SLOT(jobDone(KJob *)));
connect(j4, &KJob::result, this, &SessionTest::jobDone);
j4->start();
j2->start();
......@@ -161,7 +161,7 @@ private Q_SLOTS:
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
QSignalSpy queueSpy(&s, SIGNAL(jobQueueSizeChanged(int)));
QSignalSpy queueSpy(&s, &KIMAP::Session::jobQueueSizeChanged);
QCOMPARE(s.jobQueueSize(), 0);
......@@ -169,7 +169,7 @@ private Q_SLOTS:
auto j2 = new MockJob(&s);
auto j3 = new MockJob(&s);
auto j4 = new MockJob(&s);
connect(j4, SIGNAL(result(KJob *)), &m_eventLoop, SLOT(quit()));
connect(j4, &KJob::result, &m_eventLoop, &QEventLoop::quit);
QCOMPARE(s.jobQueueSize(), 0);
......@@ -227,9 +227,9 @@ private Q_SLOTS:
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
QSignalSpy spyFail(&s, SIGNAL(connectionFailed()));
QSignalSpy spyLost(&s, SIGNAL(connectionLost()));
QSignalSpy spyState(&s, SIGNAL(stateChanged(KIMAP::Session::State, KIMAP::Session::State)));
QSignalSpy spyFail(&s, &KIMAP::Session::connectionFailed);
QSignalSpy spyLost(&s, &KIMAP::Session::connectionLost);
QSignalSpy spyState(&s, &KIMAP::Session::stateChanged);
auto mock = new MockJob(&s);
mock->setCommand("DUMMY");
......@@ -254,16 +254,16 @@ private Q_SLOTS:
s.setTimeout(1);
auto j1 = new MockJob(&s);
QSignalSpy spyResult1(j1, SIGNAL(result(KJob *)));
QSignalSpy spyDestroyed1(j1, SIGNAL(destroyed()));
QSignalSpy spyResult1(j1, &KJob::result);
QSignalSpy spyDestroyed1(j1, &QObject::destroyed);
auto j2 = new MockJob(&s);
QSignalSpy spyResult2(j2, SIGNAL(result(KJob *)));
QSignalSpy spyDestroyed2(j2, SIGNAL(destroyed()));
QSignalSpy spyResult2(j2, &KJob::result);
QSignalSpy spyDestroyed2(j2, &QObject::destroyed);
auto j3 = new MockJob(&s);
QSignalSpy spyResult3(j3, SIGNAL(result(KJob *)));
QSignalSpy spyDestroyed3(j3, SIGNAL(destroyed()));
QSignalSpy spyResult3(j3, &KJob::result);
QSignalSpy spyDestroyed3(j3, &QObject::destroyed);
j1->start();
j2->start();
......@@ -297,9 +297,9 @@ private Q_SLOTS:
KIMAP::Session s(QStringLiteral("127.0.0.1"), 5989);
QSignalSpy spyFail(&s, SIGNAL(connectionFailed()));
QSignalSpy spyLost(&s, SIGNAL(connectionLost()));
QSignalSpy spyState(&s, SIGNAL(stateChanged(KIMAP::Session::State, KIMAP::Session::State)));
QSignalSpy spyFail(&s, &KIMAP::Session::connectionFailed);
QSignalSpy spyLost(&s, &KIMAP::Session::connectionLost);
QSignalSpy spyState(&s, &KIMAP::Session::stateChanged);
auto mock = new MockJob(&s);
mock->setTimeout(5000);
......
......@@ -97,7 +97,9 @@ FetchJob::FetchJob(Session *session)
: Job(*new FetchJobPrivate(this, session, i18n("Fetch")))
{
Q_D(FetchJob);
connect(&d->emitPendingsTimer, SIGNAL(timeout()), this, SLOT(emitPendings()));
connect(&d->emitPendingsTimer, &QTimer::timeout, this, [d]() {
d->emitPendings();
});
}
void FetchJob::setSequenceSet(const ImapSet &set)
......
......@@ -65,9 +65,13 @@ IdleJob::IdleJob(Session *session)
: Job(*new IdleJobPrivate(this, session, i18nc("name of the idle job", "Idle")))
{
Q_D(IdleJob);
connect(&d->emitStatsTimer, SIGNAL(timeout()), this, SLOT(emitStats()));
connect(&d->emitStatsTimer, &QTimer::timeout, this, [d]() {
d->emitStats();
});
connect(this, SIGNAL(result(KJob *)), this, SLOT(resetTimeout()));
connect(this, &KJob::result, this, [d]() {
d->resetTimeout();
});
}
IdleJob::~IdleJob()
......
......@@ -59,7 +59,9 @@ ListJob::ListJob(Session *session)
: Job(*new ListJobPrivate(this, session, i18n("List")))
{
Q_D(ListJob);
connect(&d->emitPendingsTimer, SIGNAL(timeout()), this, SLOT(emitPendings()));
connect(&d->emitPendingsTimer, &QTimer::timeout, this, [d]() {
d->emitPendings();
});
}
ListJob::~ListJob()
......
......@@ -187,7 +187,9 @@ void LoginJob::doStart()
}
// Get notified once encryption is successfully negotiated
connect(d->sessionInternal(), SIGNAL(encryptionNegotiationResult(bool)), this, SLOT(sslResponse(bool)));
connect(d->sessionInternal(), &KIMAP::SessionPrivate::encryptionNegotiationResult, this, [d](bool result) {
d->sslResponse(result);
});
// Trigger encryption negotiation only if needed
EncryptionMode encryptionMode = d->encryptionMode;
......
......@@ -91,7 +91,7 @@ int main(int argc, char **argv)
qDebug() << "Start idling...";
auto idle = new IdleJob(&session);
QObject::connect(idle, SIGNAL(mailBoxStats(KIMAP::IdleJob *, QString, int, int)), idle, SLOT(stop()));
QObject::connect(idle, &KIMAP::IdleJob::mailBoxStats, idle, &KIMAP::IdleJob::stop);
idle->exec();
qDebug() << "Idling done for" << idle->lastMailBox() << "message count:" << idle->lastMessageCount() << "recent count:" << idle->lastRecentCount();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment