aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorJBB <jbb.prv@gmx.de>2020-01-20 00:19:38 +0100
committerLNJ <lnj@kaidan.im>2020-01-20 00:19:38 +0100
commit8557bc3a605e5d2b1a7dae5999501b19c1c99b58 (patch)
treef17fefa61a26e01c99884c7d3e458b8ea70b181b /src/base
parentcccb7675e0eb9d411c736d1ff3f189fb75ef33dd (diff)
downloadqxmpp-8557bc3a605e5d2b1a7dae5999501b19c1c99b58.tar.gz
Port majority of old-style connects (#237)
This provides more type safety and is future-proof.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppLogger.cpp24
-rw-r--r--src/base/QXmppRtpChannel.cpp6
-rw-r--r--src/base/QXmppSocks.cpp16
-rw-r--r--src/base/QXmppStream.cpp22
-rw-r--r--src/base/QXmppStun.cpp81
5 files changed, 55 insertions, 94 deletions
diff --git a/src/base/QXmppLogger.cpp b/src/base/QXmppLogger.cpp
index 0580627d..10ee3471 100644
--- a/src/base/QXmppLogger.cpp
+++ b/src/base/QXmppLogger.cpp
@@ -62,12 +62,12 @@ static QString formatted(QXmppLogger::MessageType type, const QString& text)
static void relaySignals(QXmppLoggable *from, QXmppLoggable *to)
{
- QObject::connect(from, SIGNAL(logMessage(QXmppLogger::MessageType,QString)),
- to, SIGNAL(logMessage(QXmppLogger::MessageType,QString)));
- QObject::connect(from, SIGNAL(setGauge(QString,double)),
- to, SIGNAL(setGauge(QString,double)));
- QObject::connect(from, SIGNAL(updateCounter(QString,qint64)),
- to, SIGNAL(updateCounter(QString,qint64)));
+ QObject::connect(from, &QXmppLoggable::logMessage,
+ to, &QXmppLoggable::logMessage);
+ QObject::connect(from, &QXmppLoggable::setGauge,
+ to, &QXmppLoggable::setGauge);
+ QObject::connect(from, &QXmppLoggable::updateCounter,
+ to, &QXmppLoggable::updateCounter);
}
/// Constructs a new QXmppLoggable.
@@ -93,12 +93,12 @@ void QXmppLoggable::childEvent(QChildEvent *event)
if (event->added()) {
relaySignals(child, this);
} else if (event->removed()) {
- disconnect(child, SIGNAL(logMessage(QXmppLogger::MessageType,QString)),
- this, SIGNAL(logMessage(QXmppLogger::MessageType,QString)));
- disconnect(child, SIGNAL(setGauge(QString,double)),
- this, SIGNAL(setGauge(QString,double)));
- disconnect(child, SIGNAL(updateCounter(QString,qint64)),
- this, SIGNAL(updateCounter(QString,qint64)));
+ disconnect(child, &QXmppLoggable::logMessage,
+ this, &QXmppLoggable::logMessage);
+ disconnect(child, &QXmppLoggable::setGauge,
+ this, &QXmppLoggable::setGauge);
+ disconnect(child, &QXmppLoggable::updateCounter,
+ this, &QXmppLoggable::updateCounter);
}
}
/// \endcond
diff --git a/src/base/QXmppRtpChannel.cpp b/src/base/QXmppRtpChannel.cpp
index 7688ea3a..d4c20fad 100644
--- a/src/base/QXmppRtpChannel.cpp
+++ b/src/base/QXmppRtpChannel.cpp
@@ -251,11 +251,11 @@ QXmppRtpAudioChannel::QXmppRtpAudioChannel(QObject *parent)
{
auto *logParent = qobject_cast<QXmppLoggable*>(parent);
if (logParent) {
- connect(this, SIGNAL(logMessage(QXmppLogger::MessageType,QString)),
- logParent, SIGNAL(logMessage(QXmppLogger::MessageType,QString)));
+ connect(this, &QXmppRtpAudioChannel::logMessage,
+ logParent, &QXmppLoggable::logMessage);
}
d->outgoingTimer = new QTimer(this);
- connect(d->outgoingTimer, SIGNAL(timeout()), this, SLOT(writeDatagram()));
+ connect(d->outgoingTimer, &QTimer::timeout, this, &QXmppRtpAudioChannel::writeDatagram);
// set supported codecs
QXmppJinglePayloadType payload;
diff --git a/src/base/QXmppSocks.cpp b/src/base/QXmppSocks.cpp
index 833b3dac..ce8cdcc3 100644
--- a/src/base/QXmppSocks.cpp
+++ b/src/base/QXmppSocks.cpp
@@ -104,8 +104,8 @@ QXmppSocksClient::QXmppSocksClient(const QString &proxyHost, quint16 proxyPort,
m_proxyPort(proxyPort),
m_step(ConnectState)
{
- connect(this, SIGNAL(connected()), this, SLOT(slotConnected()));
- connect(this, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
+ connect(this, &QAbstractSocket::connected, this, &QXmppSocksClient::slotConnected);
+ connect(this, &QIODevice::readyRead, this, &QXmppSocksClient::slotReadyRead);
}
void QXmppSocksClient::connectToHost(const QString &hostName, quint16 hostPort)
@@ -120,7 +120,7 @@ void QXmppSocksClient::slotConnected()
m_step = ConnectState;
// disconnect from signal
- disconnect(this, SIGNAL(connected()), this, SLOT(slotConnected()));
+ disconnect(this, &QAbstractSocket::connected, this, &QXmppSocksClient::slotConnected);
// send connect to server
QByteArray buffer;
@@ -160,7 +160,7 @@ void QXmppSocksClient::slotReadyRead()
} else if (m_step == CommandState) {
// disconnect from signal
- disconnect(this, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
+ disconnect(this, &QIODevice::readyRead, this, &QXmppSocksClient::slotReadyRead);
// receive CONNECT response
QByteArray buffer = read(3);
@@ -197,10 +197,10 @@ QXmppSocksServer::QXmppSocksServer(QObject *parent)
: QObject(parent)
{
m_server = new QTcpServer(this);
- connect(m_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
+ connect(m_server, &QTcpServer::newConnection, this, &QXmppSocksServer::slotNewConnection);
m_server_v6 = new QTcpServer(this);
- connect(m_server_v6, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
+ connect(m_server_v6, &QTcpServer::newConnection, this, &QXmppSocksServer::slotNewConnection);
}
void QXmppSocksServer::close()
@@ -236,7 +236,7 @@ void QXmppSocksServer::slotNewConnection()
// register socket
m_states.insert(socket, ConnectState);
- connect(socket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
+ connect(socket, &QIODevice::readyRead, this, &QXmppSocksServer::slotReadyRead);
}
void QXmppSocksServer::slotReadyRead()
@@ -292,7 +292,7 @@ void QXmppSocksServer::slotReadyRead()
} else if (m_states.value(socket) == CommandState) {
// disconnect from signals
- disconnect(socket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
+ disconnect(socket, &QIODevice::readyRead, this, &QXmppSocksServer::slotReadyRead);
// receive command
QByteArray buffer = socket->read(3);
diff --git a/src/base/QXmppStream.cpp b/src/base/QXmppStream.cpp
index 68496c93..0a2b0c4b 100644
--- a/src/base/QXmppStream.cpp
+++ b/src/base/QXmppStream.cpp
@@ -173,29 +173,15 @@ QSslSocket *QXmppStream::socket() const
void QXmppStream::setSocket(QSslSocket *socket)
{
- bool check;
- Q_UNUSED(check);
-
d->socket = socket;
if (!d->socket)
return;
// socket events
- check = connect(socket, SIGNAL(connected()),
- this, SLOT(_q_socketConnected()));
- Q_ASSERT(check);
-
- check = connect(socket, SIGNAL(encrypted()),
- this, SLOT(_q_socketEncrypted()));
- Q_ASSERT(check);
-
- check = connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(_q_socketError(QAbstractSocket::SocketError)));
- Q_ASSERT(check);
-
- check = connect(socket, SIGNAL(readyRead()),
- this, SLOT(_q_socketReadyRead()));
- Q_ASSERT(check);
+ connect(socket, &QAbstractSocket::connected, this, &QXmppStream::_q_socketConnected);
+ connect(socket, &QSslSocket::encrypted, this, &QXmppStream::_q_socketEncrypted);
+ connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QSslSocket::error), this, &QXmppStream::_q_socketError);
+ connect(socket, &QIODevice::readyRead, this, &QXmppStream::_q_socketReadyRead);
}
void QXmppStream::_q_socketConnected()
diff --git a/src/base/QXmppStun.cpp b/src/base/QXmppStun.cpp
index e1a17077..5ac859d4 100644
--- a/src/base/QXmppStun.cpp
+++ b/src/base/QXmppStun.cpp
@@ -1111,7 +1111,7 @@ QXmppStunTransaction::QXmppStunTransaction(const QXmppStunMessage &request, QObj
m_tries(0)
{
bool check;
- Q_UNUSED(check);
+ Q_UNUSED(check)
check = connect(this, SIGNAL(writeStun(QXmppStunMessage)),
receiver, SLOT(writeStun(QXmppStunMessage)));
@@ -1124,8 +1124,8 @@ QXmppStunTransaction::QXmppStunTransaction(const QXmppStunMessage &request, QObj
// RTO timer
m_retryTimer = new QTimer(this);
m_retryTimer->setSingleShot(true);
- check = connect(m_retryTimer, SIGNAL(timeout()),
- this, SLOT(retry()));
+ connect(m_retryTimer, &QTimer::timeout,
+ this, &QXmppStunTransaction::retry);
// send packet immediately
m_retryTimer->start(0);
@@ -1182,26 +1182,21 @@ QXmppTurnAllocation::QXmppTurnAllocation(QObject *parent)
m_lifetime(600),
m_state(UnconnectedState)
{
- bool check;
- Q_UNUSED(check);
socket = new QUdpSocket(this);
- check = connect(socket, SIGNAL(readyRead()),
- this, SLOT(readyRead()));
- Q_ASSERT(check);
+ connect(socket, &QIODevice::readyRead,
+ this, &QXmppTurnAllocation::readyRead);
m_timer = new QTimer(this);
m_timer->setSingleShot(true);
- check = connect(m_timer, SIGNAL(timeout()),
- this, SLOT(refresh()));
- Q_ASSERT(check);
+ connect(m_timer, &QTimer::timeout,
+ this, &QXmppTurnAllocation::refresh);
// channels are valid 600s, we refresh every 500s
m_channelTimer = new QTimer(this);
m_channelTimer->setInterval(500 * 1000);
- check = connect(m_channelTimer, SIGNAL(timeout()),
- this, SLOT(refreshChannels()));
- Q_ASSERT(check);
+ connect(m_channelTimer, &QTimer::timeout,
+ this, &QXmppTurnAllocation::refreshChannels);
}
/// Destroys the TURN allocation.
@@ -1585,11 +1580,8 @@ QXmppUdpTransport::QXmppUdpTransport(QUdpSocket *socket, QObject *parent)
: QXmppIceTransport(parent)
, m_socket(socket)
{
- bool check;
- Q_UNUSED(check);
- check = connect(m_socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
- Q_ASSERT(check);
+ connect(m_socket, &QIODevice::readyRead, this, &QXmppUdpTransport::readyRead);
}
QXmppUdpTransport::~QXmppUdpTransport()
@@ -1868,8 +1860,6 @@ void QXmppIceComponentPrivate::performCheck(CandidatePair *pair, bool nominate)
void QXmppIceComponentPrivate::setSockets(QList<QUdpSocket*> sockets)
{
- bool check;
- Q_UNUSED(check);
// clear previous candidates and sockets
localCandidates.clear();
@@ -1884,9 +1874,8 @@ void QXmppIceComponentPrivate::setSockets(QList<QUdpSocket*> sockets)
socket->setParent(q);
auto *transport = new QXmppUdpTransport(socket, q);
- check = QObject::connect(transport, SIGNAL(datagramReceived(QByteArray,QHostAddress,quint16)),
- q, SLOT(handleDatagram(QByteArray,QHostAddress,quint16)));
- Q_ASSERT(check);
+ QObject::connect(transport, &QXmppIceTransport::datagramReceived,
+ q, &QXmppIceComponent::handleDatagram);
QXmppJingleCandidate candidate = transport->localCandidate(component);
@@ -1956,27 +1945,21 @@ void QXmppIceComponentPrivate::writeStun(const QXmppStunMessage &message, QXmppI
QXmppIceComponent::QXmppIceComponent(int component, QXmppIcePrivate *config, QObject *parent)
: QXmppLoggable(parent)
{
- bool check;
- Q_UNUSED(check);
d = new QXmppIceComponentPrivate(component, config, this);
d->timer = new QTimer(this);
d->timer->setInterval(500);
- check = connect(d->timer, SIGNAL(timeout()),
- this, SLOT(checkCandidates()));
- Q_ASSERT(check);
+ connect(d->timer, &QTimer::timeout,
+ this, &QXmppIceComponent::checkCandidates);
d->turnAllocation = new QXmppTurnAllocation(this);
- check = connect(d->turnAllocation, SIGNAL(connected()),
- this, SLOT(turnConnected()));
- Q_ASSERT(check);
- check = connect(d->turnAllocation, SIGNAL(datagramReceived(QByteArray,QHostAddress,quint16)),
- this, SLOT(handleDatagram(QByteArray,QHostAddress,quint16)));
- Q_ASSERT(check);
- check = connect(d->turnAllocation, SIGNAL(disconnected()),
- this, SLOT(updateGatheringState()));
- Q_ASSERT(check);
+ connect(d->turnAllocation, &QXmppTurnAllocation::connected,
+ this, &QXmppIceComponent::turnConnected);
+ connect(d->turnAllocation, &QXmppIceTransport::datagramReceived,
+ this, &QXmppIceComponent::handleDatagram);
+ connect(d->turnAllocation, &QXmppTurnAllocation::disconnected,
+ this, &QXmppIceComponent::updateGatheringState);
// calculate peer-reflexive candidate priority
// see RFC 5245 - 7.1.2.1. PRIORITY and USE-CANDIDATE
@@ -2525,16 +2508,13 @@ QXmppIceConnection::QXmppIceConnection(QObject *parent)
: QXmppLoggable(parent)
, d(new QXmppIceConnectionPrivate())
{
- bool check;
// timer to limit connection time to 30 seconds
d->connectTimer = new QTimer(this);
d->connectTimer->setInterval(30000);
d->connectTimer->setSingleShot(true);
- check = connect(d->connectTimer, SIGNAL(timeout()),
- this, SLOT(slotTimeout()));
- Q_ASSERT(check);
- Q_UNUSED(check);
+ connect(d->connectTimer, &QTimer::timeout,
+ this, &QXmppIceConnection::slotTimeout);
}
QXmppIceConnection::~QXmppIceConnection()
@@ -2558,8 +2538,6 @@ QXmppIceComponent *QXmppIceConnection::component(int component)
void QXmppIceConnection::addComponent(int component)
{
- bool check;
- Q_UNUSED(check);
if (d->components.contains(component)) {
warning(QString("Already have component %1").arg(QString::number(component)));
@@ -2571,17 +2549,14 @@ void QXmppIceConnection::addComponent(int component)
socket->d->setTurnUser(d->turnUser);
socket->d->setTurnPassword(d->turnPassword);
- check = connect(socket, SIGNAL(localCandidatesChanged()),
- this, SIGNAL(localCandidatesChanged()));
- Q_ASSERT(check);
+ connect(socket, &QXmppIceComponent::localCandidatesChanged,
+ this, &QXmppIceConnection::localCandidatesChanged);
- check = connect(socket, SIGNAL(connected()),
- this, SLOT(slotConnected()));
- Q_ASSERT(check);
+ connect(socket, &QXmppIceComponent::connected,
+ this, &QXmppIceConnection::slotConnected);
- check = connect(socket, SIGNAL(gatheringStateChanged()),
- this, SLOT(slotGatheringStateChanged()));
- Q_ASSERT(check);
+ connect(socket, &QXmppIceComponent::gatheringStateChanged,
+ this, &QXmppIceConnection::slotGatheringStateChanged);
d->components[component] = socket;
}