+QString NetworkInfo::skipCapsToString() const {
+ // Sort the list of capabilities when rendering to a string. This isn't required as
+ // Network::setSkipCaps() will sort as well, but this looks nicer when displayed to the user.
+ // This also results in the list being sorted before storing in the database, too.
+ auto sortedSkipCaps = skipCaps;
+ sortedSkipCaps.sort();
+
+ // IRCv3 capabilities are transmitted space-separated, so it should be safe to assume spaces
+ // won't ever be inside them
+ //
+ // See https://ircv3.net/specs/core/capability-negotiation
+ return sortedSkipCaps.join(" ");
+}
+
+void NetworkInfo::skipCapsFromString(const QString& flattenedSkipCaps) {
+ // IRCv3 capabilities should all use lowercase capability names, though it's not strictly
+ // required by the specification. Quassel currently converts all caps to lowercase before doing
+ // any comparisons.
+ //
+ // This would only become an issue if two capabilities have the same name and only differ by
+ // case, or if an IRC server transmits an uppercase capability and compares case-sensitively.
+ //
+ // (QString::toLower() is always done in the C locale, so locale-dependent case-sensitivity
+ // won't ever be an issue, thankfully.)
+ //
+ // See Network::addCap(), Network::acknowledgeCap(), and friends
+ // And https://ircv3.net/specs/core/capability-negotiation
+ skipCaps = flattenedSkipCaps.toLower().split(" ", QString::SplitBehavior::SkipEmptyParts);
+}
+