aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppStun.cpp
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/QXmppStun.cpp
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/QXmppStun.cpp')
-rw-r--r--src/base/QXmppStun.cpp81
1 files changed, 28 insertions, 53 deletions
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;
}