From: Shane Synan Date: Sun, 4 Dec 2016 05:43:10 +0000 (-0600) Subject: Add capAvailable to Network akin to capEnabled X-Git-Tag: travis-deploy-test~319 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=b2c3e61e5888741644b24f5b3701a6311ec631dd Add capAvailable to Network akin to capEnabled Add capAvailable to Network, checking if the server advertised the given capability. This mimics capEnabled, but applies regardless of whether or not Quassel requested the capability. This is useful for showing elsewhere whether or not a certain capability could've been requested. Use this in Network::saslMaybeSupports to avoid falsely claiming SASL support when the SASL capability wasn't advertised. This matches the behavior of CoreNetwork. --- diff --git a/src/common/network.cpp b/src/common/network.cpp index cb4adb5c..885cc50b 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -243,6 +243,14 @@ QString Network::support(const QString ¶m) const bool Network::saslMaybeSupports(const QString &saslMechanism) const { + if (!capAvailable(IrcCap::SASL)) { + // If SASL's not advertised at all, it's likely the mechanism isn't supported, as per specs. + // Unfortunately, we don't know for sure, but Quassel won't request SASL without it being + // advertised, anyways. + // This may also occur if the network's disconnected or negotiation hasn't yet happened. + return false; + } + // Get the SASL capability value QString saslCapValue = capValue(IrcCap::SASL); // SASL mechanisms are only specified in capability values as part of SASL 3.2. In SASL 3.1, diff --git a/src/common/network.h b/src/common/network.h index a56b0935..5ad42e9f 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -263,6 +263,19 @@ public : bool supports(const QString ¶m) const { return _supports.contains(param); } QString support(const QString ¶m) const; + /** + * Checks if a given capability is advertised by the server. + * + * These results aren't valid if the network is disconnected or capability negotiation hasn't + * happened, and some servers might not correctly advertise capabilities. Don't treat this as + * a guarentee. + * + * @param[in] capability Name of capability + * @returns True if connected and advertised by the server, otherwise false + */ + inline bool capAvailable(const QString &capability) const { return _caps.contains(capability.toLower()); } + // IRCv3 specs all use lowercase capability names + /** * Checks if a given capability is acknowledged and active. *