Allow prioritizing QUIT over other commands
authorShane Synan <digitalcircuit36939@gmail.com>
Thu, 9 Jun 2016 11:38:38 +0000 (07:38 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 5 Sep 2016 17:21:59 +0000 (19:21 +0200)
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.

src/core/corenetwork.cpp
src/core/corenetwork.h
src/core/coreuserinputhandler.cpp
src/core/coreuserinputhandler.h

index f622eea..d8cb2bf 100644 (file)
@@ -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) {
 {
     _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) {
         socketDisconnected();
     } else {
         if (socket.state() == QAbstractSocket::ConnectedState) {
-            userInputHandler()->issueQuit(_quitReason);
+            userInputHandler()->issueQuit(_quitReason, forceImmediate);
         } else {
             socket.close();
         }
         } else {
             socket.close();
         }
index 669b667..d596c53 100644 (file)
@@ -156,7 +156,18 @@ public slots:
     void setPingInterval(int interval);
 
     void connectToIrc(bool reconnecting = false);
     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);
 
 
     void userInput(BufferInfo bufferInfo, QString msg);
 
index b5c82c1..a978fe2 100644 (file)
@@ -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);
 }
 
 
 }
 
 
index 5f7b83f..821d185 100644 (file)
@@ -79,7 +79,13 @@ public slots:
 
     void defaultHandler(QString cmd, const BufferInfo &bufferInfo, const QString &text);
 
 
     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:
     void issueAway(const QString &msg, bool autoCheck = true);
 
 protected: