X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fremotepeer.cpp;h=f2439fc2548df1ea9c4452510969421919fa1133;hb=e55d141896130c9b82bfae60e23078b8b765d85e;hp=fcfc7ee442af7c253d0657811437597ab609e340;hpb=64cf9f9b8a737dad5f29447805d4004cfd03c454;p=quassel.git diff --git a/src/common/remotepeer.cpp b/src/common/remotepeer.cpp index fcfc7ee4..f2439fc2 100644 --- a/src/common/remotepeer.cpp +++ b/src/common/remotepeer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -40,9 +40,10 @@ RemotePeer::RemotePeer(::AuthHandler *authHandler, QTcpSocket *socket, QObject * _lag(0) { socket->setParent(this); - connect(socket, SIGNAL(disconnected()), SIGNAL(disconnected())); - connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SIGNAL(socketStateChanged(QAbstractSocket::SocketState))); + connect(socket, SIGNAL(readyRead()), SLOT(onSocketDataAvailable())); + connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SLOT(onSocketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); + connect(socket, SIGNAL(disconnected()), SIGNAL(disconnected())); #ifdef HAVE_SSL QSslSocket *sslSocket = qobject_cast(socket); @@ -51,6 +52,19 @@ RemotePeer::RemotePeer(::AuthHandler *authHandler, QTcpSocket *socket, QObject * #endif connect(_heartBeatTimer, SIGNAL(timeout()), SLOT(sendHeartBeat())); + + // It's possible that more data has already arrived during the handshake, so readyRead() wouldn't be triggered. + // However, we can't call a virtual function from the ctor, so let's do it asynchronously. + if (socket->bytesAvailable()) + QTimer::singleShot(0, this, SLOT(onSocketDataAvailable())); +} + + +void RemotePeer::onSocketStateChanged(QAbstractSocket::SocketState state) +{ + if (state == QAbstractSocket::ClosingState) { + emit statusMessage(tr("Disconnecting...")); + } }