X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fnetworkconnection.cpp;h=d177d4c1ed866383af222eee2f21da83a754f193;hb=335e1e55ee8df69b37b1b4d839950ced9ac08cc4;hp=5815a9100d2bd07a20e4ff60a09351f3c2251543;hpb=8f50c6cce47eaae781de54eabb0dbff3cfc8b451;p=quassel.git diff --git a/src/core/networkconnection.cpp b/src/core/networkconnection.cpp index 5815a910..d177d4c1 100644 --- a/src/core/networkconnection.cpp +++ b/src/core/networkconnection.cpp @@ -179,11 +179,11 @@ void NetworkConnection::connectToIrc(bool reconnecting) { QVariantList serverList = network()->serverList(); Identity *identity = coreSession()->identity(network()->identity()); if(!serverList.count()) { - quWarning() << "Server list empty, ignoring connect request!"; + qWarning() << "Server list empty, ignoring connect request!"; return; } if(!identity) { - quWarning() << "Invalid identity configures, ignoring connect request!"; + qWarning() << "Invalid identity configures, ignoring connect request!"; return; } // use a random server? @@ -253,19 +253,24 @@ void NetworkConnection::sendPerform() { if(!joinString.isEmpty()) userInputHandler()->handleJoin(statusBuf, joinString); } -void NetworkConnection::disconnectFromIrc(bool requested) { +void NetworkConnection::disconnectFromIrc(bool requested, const QString &reason) { _quitRequested = requested; // see socketDisconnected(); _autoReconnectTimer.stop(); _autoReconnectCount = 0; // prohibiting auto reconnect displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Disconnecting.")); if(socket.state() == QAbstractSocket::UnconnectedState) { socketDisconnected(); - } else if(socket.state() < QAbstractSocket::ConnectedState) { + } else if(socket.state() < QAbstractSocket::ConnectedState || !requested) { + // we might be in a state waiting for a timeout... + // or (!requested) this is a core shutdown... + // in both cases we don't really care... set a disconnected state socket.close(); - // we might be in a state waiting for a timeout... we don't care... set a disconnected state socketDisconnected(); } else { - _socketCloseTimer.start(10000); // the irc server has 10 seconds to close the socket + // quit gracefully if it's user requested quit + userInputHandler()->issueQuit(reason); + // the irc server has 10 seconds to close the socket + _socketCloseTimer.start(10000); } } @@ -278,7 +283,7 @@ void NetworkConnection::socketHasData() { void NetworkConnection::socketError(QAbstractSocket::SocketError) { _previousConnectionAttemptFailed = true; - quWarning() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString())); + qWarning() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString())); emit connectionError(socket.errorString()); emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Connection failure: %1").arg(socket.errorString())); network()->emitConnectionError(socket.errorString()); @@ -335,7 +340,7 @@ void NetworkConnection::socketInitialized() { //emit connected(networkId()); initialize first! Identity *identity = coreSession()->identity(network()->identity()); if(!identity) { - quError() << "Identity invalid!"; + qCritical() << "Identity invalid!"; disconnectFromIrc(); return; } @@ -381,7 +386,13 @@ void NetworkConnection::socketDisconnected() { _autoWhoInProgress.clear(); _socketCloseTimer.stop(); - + + IrcUser *me = network()->me(); + if(me) { + foreach(QString channel, me->channels()) + emit displayMsg(Message::Quit, BufferInfo::ChannelBuffer, channel, "", me->hostmask()); + } + network()->setConnected(false); emit disconnected(networkId()); if(_quitRequested) { @@ -398,7 +409,7 @@ void NetworkConnection::socketDisconnected() { void NetworkConnection::doAutoReconnect() { if(connectionState() != Network::Disconnected && connectionState() != Network::Reconnecting) { - quWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!"; + qWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!"; return; } if(_autoReconnectCount > 0) _autoReconnectCount--;