X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fnetworkconnection.cpp;h=d177d4c1ed866383af222eee2f21da83a754f193;hp=5d279655529ef800c399fb4aef86307bfb3a6282;hb=f7379184b7c0ae4e53d7470809f84e2ad3239ec1;hpb=034708a59ca1ee3195263a90941a2b145c520fef diff --git a/src/core/networkconnection.cpp b/src/core/networkconnection.cpp index 5d279655..d177d4c1 100644 --- a/src/core/networkconnection.cpp +++ b/src/core/networkconnection.cpp @@ -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); } } @@ -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) {