X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientauthhandler.cpp;h=668c4a47ccaec9d0fadc4af05f70c98d2988a14c;hp=a3fc870d84343b761329fb683acd0bc5093f0070;hb=900cce213a6ed000b7131a05a0dec7d04b35b023;hpb=39328183a6a87c6eb10a9dbbffcd5d65bf154a1f diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index a3fc870d..668c4a47 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -32,6 +32,7 @@ #include "clientsettings.h" #include "logmessage.h" #include "peerfactory.h" +#include "util.h" using namespace Protocol; @@ -58,7 +59,7 @@ void ClientAuthHandler::connectToCore() CoreAccountSettings s; #ifdef HAVE_SSL - QSslSocket *socket = new QSslSocket(this); + auto *socket = new QSslSocket(this); // make sure the warning is shown if we happen to connect without SSL support later s.setAccountValue("ShowNoClientSslWarning", true); #else @@ -96,9 +97,9 @@ void ClientAuthHandler::connectToCore() #endif setSocket(socket); - connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SLOT(onSocketStateChanged(QAbstractSocket::SocketState))); - connect(socket, SIGNAL(readyRead()), SLOT(onReadyRead())); - connect(socket, SIGNAL(connected()), SLOT(onSocketConnected())); + connect(socket, &QAbstractSocket::stateChanged, this, &ClientAuthHandler::onSocketStateChanged); + connect(socket, &QIODevice::readyRead, this, &ClientAuthHandler::onReadyRead); + connect(socket, &QAbstractSocket::connected, this, &ClientAuthHandler::onSocketConnected); emit statusMessage(tr("Connecting to %1...").arg(_account.accountName())); socket->connectToHost(_account.hostName(), _account.port()); @@ -132,7 +133,7 @@ void ClientAuthHandler::onSocketStateChanged(QAbstractSocket::SocketState socket // The baseclass implementation will make sure to only send the signal once. // However, we do want to prefer a potential socket error signal that may be on route already, so // give this a chance to overtake us by spinning the loop... - QTimer::singleShot(0, this, SLOT(onSocketDisconnected())); + QTimer::singleShot(0, this, &ClientAuthHandler::onSocketDisconnected); } break; default: @@ -161,7 +162,7 @@ void ClientAuthHandler::onSocketDisconnected() if (_probing && _legacy) { // Remote host has closed the connection while probing _probing = false; - disconnect(socket(), SIGNAL(readyRead()), this, SLOT(onReadyRead())); + disconnect(socket(), &QIODevice::readyRead, this, &ClientAuthHandler::onReadyRead); emit statusMessage(tr("Reconnecting in compatibility mode...")); socket()->connectToHost(_account.hostName(), _account.port()); return; @@ -214,9 +215,9 @@ void ClientAuthHandler::onSocketConnected() qDebug() << "Legacy core detected, switching to compatibility mode"; - RemotePeer *peer = PeerFactory::createPeer(PeerFactory::ProtoDescriptor(Protocol::LegacyProtocol, 0), this, socket(), Compressor::NoCompression, this); + auto *peer = PeerFactory::createPeer(PeerFactory::ProtoDescriptor(Protocol::LegacyProtocol, 0), this, socket(), Compressor::NoCompression, this); // Only needed for the legacy peer, as all others check the protocol version before instantiation - connect(peer, SIGNAL(protocolVersionMismatch(int,int)), SLOT(onProtocolVersionMismatch(int,int))); + connect(peer, &RemotePeer::protocolVersionMismatch, this, &ClientAuthHandler::onProtocolVersionMismatch); setPeer(peer); } @@ -231,14 +232,14 @@ void ClientAuthHandler::onReadyRead() return; // make sure to not read more data than needed _probing = false; - disconnect(socket(), SIGNAL(readyRead()), this, SLOT(onReadyRead())); + disconnect(socket(), &QIODevice::readyRead, this, &ClientAuthHandler::onReadyRead); quint32 reply; socket()->read((char *)&reply, 4); reply = qFromBigEndian(reply); - Protocol::Type type = static_cast(reply & 0xff); - quint16 protoFeatures = static_cast(reply>>8 & 0xffff); + auto type = static_cast(reply & 0xff); + auto protoFeatures = static_cast(reply>>8 & 0xffff); _connectionFeatures = static_cast(reply>>24); Compressor::CompressionLevel level; @@ -258,7 +259,7 @@ void ClientAuthHandler::onReadyRead() } if (peer->protocol() == Protocol::LegacyProtocol) { - connect(peer, SIGNAL(protocolVersionMismatch(int,int)), SLOT(onProtocolVersionMismatch(int,int))); + connect(peer, &RemotePeer::protocolVersionMismatch, this, &ClientAuthHandler::onProtocolVersionMismatch); _legacy = true; } @@ -279,7 +280,7 @@ void ClientAuthHandler::setPeer(RemotePeer *peer) qDebug().nospace() << "Using " << qPrintable(peer->protocolName()) << "..."; _peer = peer; - connect(_peer, SIGNAL(transferProgress(int,int)), SIGNAL(transferProgress(int,int))); + connect(_peer, &RemotePeer::transferProgress, this, &ClientAuthHandler::transferProgress); // The legacy protocol enables SSL later, after registration if (!_account.useSsl() || _legacy) @@ -431,10 +432,10 @@ void ClientAuthHandler::checkAndEnableSsl(bool coreSupportsSsl) // Make sure the warning is shown next time we don't have SSL in the core s.setAccountValue("ShowNoCoreSslWarning", true); - QSslSocket *sslSocket = qobject_cast(socket()); + auto *sslSocket = qobject_cast(socket()); Q_ASSERT(sslSocket); - connect(sslSocket, SIGNAL(encrypted()), SLOT(onSslSocketEncrypted())); - connect(sslSocket, SIGNAL(sslErrors(QList)), SLOT(onSslErrors())); + connect(sslSocket, &QSslSocket::encrypted, this, &ClientAuthHandler::onSslSocketEncrypted); + connect(sslSocket, selectOverload&>(&QSslSocket::sslErrors), this, &ClientAuthHandler::onSslErrors); qDebug() << "Starting encryption..."; sslSocket->flush(); sslSocket->startClientEncryption(); @@ -463,7 +464,7 @@ void ClientAuthHandler::checkAndEnableSsl(bool coreSupportsSsl) void ClientAuthHandler::onSslSocketEncrypted() { - QSslSocket *socket = qobject_cast(sender()); + auto *socket = qobject_cast(sender()); Q_ASSERT(socket); if (!socket->sslErrors().count()) { @@ -485,7 +486,7 @@ void ClientAuthHandler::onSslSocketEncrypted() void ClientAuthHandler::onSslErrors() { - QSslSocket *socket = qobject_cast(sender()); + auto *socket = qobject_cast(sender()); Q_ASSERT(socket); CoreAccountSettings s;