X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fauthhandler.cpp;h=7172a60070b58a781e5e0bd667f9ce60386f4251;hp=bd5bbc456eb3cd1de8e6e7c406292d68f84f4a10;hb=b06a827aea68b050bf23c37e0162189a94595ee9;hpb=9d54503555534a2c554f09a33df6afa33d6308ec diff --git a/src/common/authhandler.cpp b/src/common/authhandler.cpp index bd5bbc45..7172a600 100644 --- a/src/common/authhandler.cpp +++ b/src/common/authhandler.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2016 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -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)