From: Shane Synan Date: Thu, 9 Jun 2016 11:38:38 +0000 (-0400) Subject: Allow prioritizing QUIT over other commands X-Git-Tag: travis-deploy-test~460 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=3966090a1e7093c417560f7ee13ab310215d9ccd Allow prioritizing QUIT over other commands Add a forceImmediate flag to issueQuit, allowing the QUIT command to jump the command queue. A future update will prioritize QUIT when core is shutting down so other messages won't block showing the user's quit message. Don't prioritize QUIT normally in case the user sends some messages, thinks they've all been delivered, then sends a QUIT. (Eventually, Quassel should display queued messages differently from messages that have been sent) Closes GH-201. --- diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index f622eea0..d8cb2bf4 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -222,7 +222,8 @@ void CoreNetwork::connectToIrc(bool reconnecting) } -void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason, bool withReconnect) +void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason, bool withReconnect, + bool forceImmediate) { _quitRequested = requested; // see socketDisconnected(); if (!withReconnect) { @@ -250,7 +251,7 @@ void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason, bool socketDisconnected(); } else { if (socket.state() == QAbstractSocket::ConnectedState) { - userInputHandler()->issueQuit(_quitReason); + userInputHandler()->issueQuit(_quitReason, forceImmediate); } else { socket.close(); } diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 669b6675..d596c538 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -156,7 +156,18 @@ public slots: void setPingInterval(int interval); void connectToIrc(bool reconnecting = false); - void disconnectFromIrc(bool requested = true, const QString &reason = QString(), bool withReconnect = false); + /** + * Disconnect from the IRC server. + * + * Begin disconnecting from the IRC server, including optionally reconnecting. + * + * @param requested If true, user requested this disconnect; don't try to reconnect + * @param reason Reason for quitting, defaulting to the user-configured quit reason + * @param withReconnect Reconnect to the network after disconnecting (e.g. ping timeout) + * @param forceImmediate Immediately disconnect from network, skipping queue of other commands + */ + void disconnectFromIrc(bool requested = true, const QString &reason = QString(), + bool withReconnect = false, bool forceImmediate = false); void userInput(BufferInfo bufferInfo, QString msg); diff --git a/src/core/coreuserinputhandler.cpp b/src/core/coreuserinputhandler.cpp index b5c82c1b..a978fe2b 100644 --- a/src/core/coreuserinputhandler.cpp +++ b/src/core/coreuserinputhandler.cpp @@ -581,9 +581,10 @@ void CoreUserInputHandler::handleQuit(const BufferInfo &bufferInfo, const QStrin } -void CoreUserInputHandler::issueQuit(const QString &reason) +void CoreUserInputHandler::issueQuit(const QString &reason, bool forceImmediate) { - emit putCmd("QUIT", serverEncode(reason)); + // If needing an immediate QUIT (e.g. core shutdown), prepend this to the queue + emit putCmd("QUIT", serverEncode(reason), QByteArray(), forceImmediate); } diff --git a/src/core/coreuserinputhandler.h b/src/core/coreuserinputhandler.h index 5f7b83f9..821d185b 100644 --- a/src/core/coreuserinputhandler.h +++ b/src/core/coreuserinputhandler.h @@ -79,7 +79,13 @@ public slots: void defaultHandler(QString cmd, const BufferInfo &bufferInfo, const QString &text); - void issueQuit(const QString &reason); + /** + * Send a QUIT to the IRC server, optionally skipping the command queue. + * + * @param reason Reason for quitting, often displayed to other IRC clients + * @param forceImmediate Immediately quit, skipping queue of other commands + */ + void issueQuit(const QString &reason, bool forceImmediate = false); void issueAway(const QString &msg, bool autoCheck = true); protected: