core: Fix capability messages for repeat CAP LS
authorShane Synan <digitalcircuit36939@gmail.com>
Mon, 27 Jan 2020 06:24:06 +0000 (01:24 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 12 Apr 2020 11:14:19 +0000 (13:14 +0200)
Fix capability negotiation messages for manually running "/CAP LS",
and for when the server provides capabilities but Quassel does not
support any of them.

Before, running "/CAP LS" after negotiation would erroneously print
"* No capabilities available"
Now, running "/CAP LS" provides a summary of the current situation,
"* No additional capabilities are supported (found: a-aa, b-bb, c-cc;
   currently enabled: a-aa, b-bb)"

src/core/corenetwork.cpp

index 646a44e..8dccbd5 100644 (file)
@@ -1267,16 +1267,37 @@ void CoreNetwork::retryCapsIndividually()
 
 void CoreNetwork::beginCapNegotiation()
 {
-    // Don't begin negotiation if no capabilities are queued to request
     if (!capNegotiationInProgress()) {
-        // If the server doesn't have any capabilities, but supports CAP LS, continue on with the
-        // normal connection.
+        // No capabilities are queued for request, determine the reason why
+        QString capStatusMsg;
+        if (caps().empty()) {
+            // The server doesn't provide any capabilities, but supports CAP LS
+            capStatusMsg = tr("No capabilities available");
+        }
+        else if (capsEnabled().empty()) {
+            // The server supports capabilities (caps() is not empty) but Quassel doesn't support
+            // anything offered.  This should be uncommon.
+            capStatusMsg =
+                    tr("None of the capabilities provided by the server are supported (found: %1)")
+                    .arg(caps().join(", "));
+        }
+        else {
+            // Quassel has enabled some capabilities, but there are no further capabilities that can
+            // be negotiated.
+            // (E.g. the user has manually run "/cap ls 302" after initial negotiation.)
+            capStatusMsg =
+                    tr("No additional capabilities are supported (found: %1; currently enabled: %2)")
+                    .arg(caps().join(", "), capsEnabled().join(", "));
+        }
+        // Inform the user of the situation
         showMessage(NetworkInternalMessage(
             Message::Server,
             BufferInfo::StatusBuffer,
             "",
-            tr("No capabilities available")
+            capStatusMsg
         ));
+
+        // End any ongoing capability negotiation, allowing connection to continue
         endCapNegotiation();
         return;
     }