/***************************************************************************
- * Copyright (C) 2005-2013 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include <QHostAddress>
+
#include "authhandler.h"
AuthHandler::AuthHandler(QObject *parent)
: QObject(parent),
- _state(UnconnectedState),
_socket(0),
_disconnectedSent(false)
{
}
-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;
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)