Fix minor stylistic issues with the code
[quassel.git] / src / common / network.h
index a56b093..8a81021 100644 (file)
@@ -172,10 +172,37 @@ public :
     //Network::ConnectionState connectionState() const;
     inline int connectionState() const { return _connectionState; }
 
+    /**@{*/
+    /**
+     * Translates a user’s prefix to the channelmode associated with it.
+     * @param prefix Prefix to be translated.
+     */
     QString prefixToMode(const QString &prefix) const;
     inline QString prefixToMode(const QCharRef &prefix) const { return prefixToMode(QString(prefix)); }
+    inline QString prefixesToModes(const QString &prefix) const {
+        QString modes;
+        for (QChar c : prefix) {
+            modes += prefixToMode(c);
+        }
+        return modes;
+    }
+    /**@}*/
+
+    /**@{*/
+    /**
+     * Translates a user’s prefix to the channelmode associated with it.
+     * @param prefix Prefix to be translated.
+     */
     QString modeToPrefix(const QString &mode) const;
     inline QString modeToPrefix(const QCharRef &mode) const { return modeToPrefix(QString(mode)); }
+    inline QString modesToPrefixes(const QString &mode) const {
+        QString prefixes;
+        for (QChar c : mode) {
+            prefixes += modeToPrefix(c);
+        }
+        return prefixes;
+    }
+    /**@}*/
 
     ChannelModeType channelModeType(const QString &mode);
     inline ChannelModeType channelModeType(const QCharRef &mode) { return channelModeType(QString(mode)); }
@@ -263,6 +290,19 @@ public :
     bool supports(const QString &param) const { return _supports.contains(param); }
     QString support(const QString &param) 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.
      *