From 00b029d3947bc751893d735a495b03ea8796e139 Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Mon, 27 Jan 2020 01:24:06 -0500 Subject: [PATCH] core: Fix capability messages for repeat CAP LS 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 | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 646a44eb..8dccbd5d 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -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; } -- 2.20.1