X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fauthhandler.cpp;h=7c2905dddc6bd166c4480aead8d04f73cfd7b412;hb=bc544f569faedea50c7715844a2261872796c683;hp=bd5bbc456eb3cd1de8e6e7c406292d68f84f4a10;hpb=9d54503555534a2c554f09a33df6afa33d6308ec;p=quassel.git diff --git a/src/common/authhandler.cpp b/src/common/authhandler.cpp index bd5bbc45..7c2905dd 100644 --- a/src/common/authhandler.cpp +++ b/src/common/authhandler.cpp @@ -18,11 +18,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include + #include "authhandler.h" AuthHandler::AuthHandler(QObject *parent) : QObject(parent), - _state(UnconnectedState), _socket(0), _disconnectedSent(false) { @@ -30,21 +31,6 @@ AuthHandler::AuthHandler(QObject *parent) } -AuthHandler::State AuthHandler::state() const -{ - return _state; -} - - -void AuthHandler::setState(AuthHandler::State state) -{ - if (_state != state) { - _state = state; - emit stateChanged(state); - } -} - - QTcpSocket *AuthHandler::socket() const { return _socket; @@ -54,12 +40,21 @@ QTcpSocket *AuthHandler::socket() const void AuthHandler::setSocket(QTcpSocket *socket) { _socket = socket; - connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SIGNAL(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); } +bool AuthHandler::isLocal() const +{ + if (socket()) { + if (socket()->peerAddress() == QHostAddress::LocalHost || socket()->peerAddress() == QHostAddress::LocalHostIPv6) + return true; + } + return false; +} + + // Some errors (e.g. connection refused) don't trigger a disconnected() from the socket, so send this explicitly // (but make sure it's only sent once!) void AuthHandler::onSocketError(QAbstractSocket::SocketError error)