return false;
if (currentAccount().isInternal())
return true;
- if (_peer->isLocal())
- return true;
+ if (_authHandler)
+ return _authHandler->isLocal();
+ if (_peer)
+ return _peer->isLocal();
return false;
}
-void CoreConnection::socketStateChanged(QAbstractSocket::SocketState socketState)
-{
- QString text;
-
- switch (socketState) {
- case QAbstractSocket::UnconnectedState:
- text = tr("Disconnected");
- break;
- case QAbstractSocket::HostLookupState:
- text = tr("Looking up %1...").arg(currentAccount().hostName());
- break;
- case QAbstractSocket::ConnectingState:
- text = tr("Connecting to %1...").arg(currentAccount().hostName());
- break;
- case QAbstractSocket::ConnectedState:
- text = tr("Connected to %1").arg(currentAccount().hostName());
- break;
- case QAbstractSocket::ClosingState:
- text = tr("Disconnecting from %1...").arg(currentAccount().hostName());
- break;
- default:
- break;
- }
-
- if (!text.isEmpty())
- emit progressTextChanged(text);
-
- setState(socketState);
-}
-
-
-void CoreConnection::setState(QAbstractSocket::SocketState socketState)
-{
- ConnectionState state;
-
- switch (socketState) {
- case QAbstractSocket::UnconnectedState:
- state = Disconnected;
- break;
- case QAbstractSocket::HostLookupState:
- case QAbstractSocket::ConnectingState:
- case QAbstractSocket::ConnectedState: // we'll set it to Connected in connectionReady()
- state = Connecting;
- break;
- default:
- state = Disconnected;
- }
-
- setState(state);
-}
-
-
void CoreConnection::onConnectionReady()
{
setState(Connected);
void CoreConnection::coreSocketDisconnected()
{
+ setState(Disconnected);
_wasReconnect = false;
resetConnection(_wantReconnect);
- // FIXME handle disconnects gracefully
}
emit connectionMsg(tr("Disconnected from core."));
emit encrypted(false);
+ setState(Disconnected);
// initiate if a reconnect if appropriate
CoreConnectionSettings s;
return;
}
- resetConnection(false);
-
if (currentAccount().isInternal()) {
if (Quassel::runMode() != Quassel::Monolithic) {
qWarning() << "Cannot connect to internal core in client-only mode!";
_peer = peer;
Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership
emit connectToInternalCore(peer);
+ setState(Connected);
return;
}
connect(_authHandler, SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
connect(_authHandler, SIGNAL(connectionReady()), SLOT(onConnectionReady()));
- connect(_authHandler, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)), SLOT(socketStateChanged(QAbstractSocket::SocketState)));
connect(_authHandler, SIGNAL(socketError(QAbstractSocket::SocketError,QString)), SLOT(coreSocketError(QAbstractSocket::SocketError,QString)));
connect(_authHandler, SIGNAL(transferProgress(int,int)), SLOT(updateProgress(int,int)));
connect(_authHandler, SIGNAL(requestDisconnect(QString,bool)), SLOT(disconnectFromCore(QString,bool)));
connect(_authHandler, SIGNAL(loginSuccessful(CoreAccount)), SLOT(onLoginSuccessful(CoreAccount)));
connect(_authHandler, SIGNAL(handshakeComplete(RemotePeer*,Protocol::SessionState)), SLOT(onHandshakeComplete(RemotePeer*,Protocol::SessionState)));
+ setState(Connecting);
_authHandler->connectToCore();
}
_peer = peer;
connect(peer, SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
- connect(peer, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)), SLOT(socketStateChanged(QAbstractSocket::SocketState)));
+ connect(peer, SIGNAL(statusMessage(QString)), SIGNAL(connectionMsg(QString)));
connect(peer, SIGNAL(socketError(QAbstractSocket::SocketError,QString)), SLOT(coreSocketError(QAbstractSocket::SocketError,QString)));
Client::signalProxy()->addPeer(_peer); // sigproxy takes ownership of the peer!