-NetworkInfo::NetworkInfo()
-: networkId(0),
- identity(1),
- useRandomServer(false),
- useAutoIdentify(false),
- autoIdentifyService("NickServ"),
- useAutoReconnect(true),
- autoReconnectInterval(60),
- autoReconnectRetries(20),
- unlimitedReconnectRetries(false),
- rejoinChannels(true)
-{
-
-}
-
-bool NetworkInfo::operator==(const NetworkInfo &other) const {
- if(networkId != other.networkId) return false;
- if(networkName != other.networkName) return false;
- if(identity != other.identity) return false;
- if(codecForServer != other.codecForServer) return false;
- if(codecForEncoding != other.codecForEncoding) return false;
- if(codecForDecoding != other.codecForDecoding) return false;
- if(serverList != other.serverList) return false;
- if(useRandomServer != other.useRandomServer) return false;
- if(perform != other.perform) return false;
- if(useAutoIdentify != other.useAutoIdentify) return false;
- if(autoIdentifyService != other.autoIdentifyService) return false;
- if(autoIdentifyPassword != other.autoIdentifyPassword) return false;
- if(useAutoReconnect != other.useAutoReconnect) return false;
- if(autoReconnectInterval != other.autoReconnectInterval) return false;
- if(autoReconnectRetries != other.autoReconnectRetries) return false;
- if(unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
- if(rejoinChannels != other.rejoinChannels) return false;
- return true;
-}
-
-bool NetworkInfo::operator!=(const NetworkInfo &other) const {
- return !(*this == other);
-}
-
-QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) {
- QVariantMap i;
- i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
- i["NetworkName"] = info.networkName;
- i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
- i["CodecForServer"] = info.codecForServer;
- i["CodecForEncoding"] = info.codecForEncoding;
- i["CodecForDecoding"] = info.codecForDecoding;
- i["ServerList"] = toVariantList(info.serverList);
- i["UseRandomServer"] = info.useRandomServer;
- i["Perform"] = info.perform;
- i["UseAutoIdentify"] = info.useAutoIdentify;
- i["AutoIdentifyService"] = info.autoIdentifyService;
- i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
- i["UseAutoReconnect"] = info.useAutoReconnect;
- i["AutoReconnectInterval"] = info.autoReconnectInterval;
- i["AutoReconnectRetries"] = info.autoReconnectRetries;
- i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
- i["RejoinChannels"] = info.rejoinChannels;
- out << i;
- return out;
-}
-
-QDataStream &operator>>(QDataStream &in, NetworkInfo &info) {
- QVariantMap i;
- in >> i;
- info.networkId = i["NetworkId"].value<NetworkId>();
- info.networkName = i["NetworkName"].toString();
- info.identity = i["Identity"].value<IdentityId>();
- info.codecForServer = i["CodecForServer"].toByteArray();
- info.codecForEncoding = i["CodecForEncoding"].toByteArray();
- info.codecForDecoding = i["CodecForDecoding"].toByteArray();
- info.serverList = fromVariantList<Network::Server>(i["ServerList"].toList());
- info.useRandomServer = i["UseRandomServer"].toBool();
- info.perform = i["Perform"].toStringList();
- info.useAutoIdentify = i["UseAutoIdentify"].toBool();
- info.autoIdentifyService = i["AutoIdentifyService"].toString();
- info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
- info.useAutoReconnect = i["UseAutoReconnect"].toBool();
- info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
- info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
- info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
- info.rejoinChannels = i["RejoinChannels"].toBool();
- return in;
-}
-
-QDebug operator<<(QDebug dbg, const NetworkInfo &i) {
- dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
- << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding
- << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
- << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
- << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
- << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
- << " rejoinChannels = " << i.rejoinChannels << ")";
- return dbg.space();
-}
-
-QDataStream &operator<<(QDataStream &out, const Network::Server &server) {
- QVariantMap serverMap;
- serverMap["Host"] = server.host;
- serverMap["Port"] = server.port;
- serverMap["Password"] = server.password;
- serverMap["UseSSL"] = server.useSsl;
- serverMap["sslVersion"] = server.sslVersion;
- serverMap["UseProxy"] = server.useProxy;
- serverMap["ProxyType"] = server.proxyType;
- serverMap["ProxyHost"] = server.proxyHost;
- serverMap["ProxyPort"] = server.proxyPort;
- serverMap["ProxyUser"] = server.proxyUser;
- serverMap["ProxyPass"] = server.proxyPass;
- out << serverMap;
- return out;
-}
-
-QDataStream &operator>>(QDataStream &in, Network::Server &server) {
- QVariantMap serverMap;
- in >> serverMap;
- server.host = serverMap["Host"].toString();
- server.port = serverMap["Port"].toUInt();
- server.password = serverMap["Password"].toString();
- server.useSsl = serverMap["UseSSL"].toBool();
- server.sslVersion = serverMap["sslVersion"].toInt();
- server.useProxy = serverMap["UseProxy"].toBool();
- server.proxyType = serverMap["ProxyType"].toInt();
- server.proxyHost = serverMap["ProxyHost"].toString();
- server.proxyPort = serverMap["ProxyPort"].toUInt();
- server.proxyUser = serverMap["ProxyUser"].toString();
- server.proxyPass = serverMap["ProxyPass"].toString();
- return in;
-}
-
-
-bool Network::Server::operator==(const Server &other) const {
- if(host != other.host) return false;
- if(port != other.port) return false;
- if(password != other.password) return false;
- if(useSsl != other.useSsl) return false;
- if(sslVersion != other.sslVersion) return false;
- if(useProxy != other.useProxy) return false;
- if(proxyType != other.proxyType) return false;
- if(proxyHost != other.proxyHost) return false;
- if(proxyPort != other.proxyPort) return false;
- if(proxyUser != other.proxyUser) return false;
- if(proxyPass != other.proxyPass) return false;
- return true;
-}
-
-bool Network::Server::operator!=(const Server &other) const {
- return !(*this == other);
-}
-
-QDebug operator<<(QDebug dbg, const Network::Server &server) {
- dbg.nospace() << "Server(host = " << server.host << ":" << server.port << ", useSsl = " << server.useSsl << ")";
- return dbg.space();
+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);
+}
+
+bool NetworkInfo::operator==(const NetworkInfo& other) const
+{
+ return networkName == other.networkName
+ && serverList == other.serverList
+ && perform == other.perform
+ && skipCaps == other.skipCaps
+ && autoIdentifyService == other.autoIdentifyService
+ && autoIdentifyPassword == other.autoIdentifyPassword
+ && saslAccount == other.saslAccount
+ && saslPassword == other.saslPassword
+ && codecForServer == other.codecForServer
+ && codecForEncoding == other.codecForEncoding
+ && codecForDecoding == other.codecForDecoding
+ && networkId == other.networkId
+ && identity == other.identity
+ && messageRateBurstSize == other.messageRateBurstSize
+ && messageRateDelay == other.messageRateDelay
+ && autoReconnectInterval == other.autoReconnectInterval
+ && autoReconnectRetries == other.autoReconnectRetries
+ && rejoinChannels == other.rejoinChannels
+ && useRandomServer == other.useRandomServer
+ && useAutoIdentify == other.useAutoIdentify
+ && useSasl == other.useSasl
+ && useAutoReconnect == other.useAutoReconnect
+ && unlimitedReconnectRetries == other.unlimitedReconnectRetries
+ && useCustomMessageRate == other.useCustomMessageRate
+ && unlimitedMessageRate == other.unlimitedMessageRate
+ ;
+}
+
+bool NetworkInfo::operator!=(const NetworkInfo& other) const
+{
+ return !(*this == other);
+}
+
+QDataStream& operator<<(QDataStream& out, const NetworkInfo& info)
+{
+ QVariantMap i;
+ i["NetworkName"] = info.networkName;
+ i["ServerList"] = toVariantList(info.serverList);
+ i["Perform"] = info.perform;
+ i["SkipCaps"] = info.skipCaps;
+ i["AutoIdentifyService"] = info.autoIdentifyService;
+ i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
+ i["SaslAccount"] = info.saslAccount;
+ i["SaslPassword"] = info.saslPassword;
+ i["CodecForServer"] = info.codecForServer;
+ i["CodecForEncoding"] = info.codecForEncoding;
+ i["CodecForDecoding"] = info.codecForDecoding;
+ i["NetworkId"] = QVariant::fromValue(info.networkId);
+ i["Identity"] = QVariant::fromValue(info.identity);
+ i["MessageRateBurstSize"] = info.messageRateBurstSize;
+ i["MessageRateDelay"] = info.messageRateDelay;
+ i["AutoReconnectInterval"] = info.autoReconnectInterval;
+ i["AutoReconnectRetries"] = info.autoReconnectRetries;
+ i["RejoinChannels"] = info.rejoinChannels;
+ i["UseRandomServer"] = info.useRandomServer;
+ i["UseAutoIdentify"] = info.useAutoIdentify;
+ i["UseSasl"] = info.useSasl;
+ i["UseAutoReconnect"] = info.useAutoReconnect;
+ i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
+ i["UseCustomMessageRate"] = info.useCustomMessageRate;
+ i["UnlimitedMessageRate"] = info.unlimitedMessageRate;
+ out << i;
+ return out;
+}
+
+QDataStream& operator>>(QDataStream& in, NetworkInfo& info)
+{
+ QVariantMap i;
+ in >> i;
+ info.networkName = i["NetworkName"].toString();
+ info.serverList = fromVariantList<Network::Server>(i["ServerList"].toList());
+ info.perform = i["Perform"].toStringList();
+ info.skipCaps = i["SkipCaps"].toStringList();
+ info.autoIdentifyService = i["AutoIdentifyService"].toString();
+ info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
+ info.saslAccount = i["SaslAccount"].toString();
+ info.saslPassword = i["SaslPassword"].toString();
+ info.codecForServer = i["CodecForServer"].toByteArray();
+ info.codecForEncoding = i["CodecForEncoding"].toByteArray();
+ info.codecForDecoding = i["CodecForDecoding"].toByteArray();
+ info.networkId = i["NetworkId"].value<NetworkId>();
+ info.identity = i["Identity"].value<IdentityId>();
+ info.messageRateBurstSize = i["MessageRateBurstSize"].toUInt();
+ info.messageRateDelay = i["MessageRateDelay"].toUInt();
+ info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
+ info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
+ info.rejoinChannels = i["RejoinChannels"].toBool();
+ info.useRandomServer = i["UseRandomServer"].toBool();
+ info.useAutoIdentify = i["UseAutoIdentify"].toBool();
+ info.useSasl = i["UseSasl"].toBool();
+ info.useAutoReconnect = i["UseAutoReconnect"].toBool();
+ info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
+ info.useCustomMessageRate = i["UseCustomMessageRate"].toBool();
+ info.unlimitedMessageRate = i["UnlimitedMessageRate"].toBool();
+ return in;
+}
+
+QDebug operator<<(QDebug dbg, const NetworkInfo& i)
+{
+ dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
+ << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding
+ << " codecForDecoding = " << i.codecForDecoding << " serverList = " << i.serverList
+ << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
+ << " skipCaps = " << i.skipCaps << " useAutoIdentify = " << i.useAutoIdentify
+ << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
+ << " useSasl = " << i.useSasl << " saslAccount = " << i.saslAccount << " saslPassword = " << i.saslPassword
+ << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
+ << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
+ << " rejoinChannels = " << i.rejoinChannels << " useCustomMessageRate = " << i.useCustomMessageRate
+ << " messageRateBurstSize = " << i.messageRateBurstSize << " messageRateDelay = " << i.messageRateDelay
+ << " unlimitedMessageRate = " << i.unlimitedMessageRate << ")";
+ return dbg.space();
+}
+
+QDataStream& operator<<(QDataStream& out, const Network::Server& server)
+{
+ QVariantMap serverMap;
+ serverMap["Host"] = server.host;
+ serverMap["Port"] = server.port;
+ serverMap["Password"] = server.password;
+ serverMap["UseSSL"] = server.useSsl;
+ serverMap["sslVerify"] = server.sslVerify;
+ serverMap["sslVersion"] = server.sslVersion;
+ serverMap["UseProxy"] = server.useProxy;
+ serverMap["ProxyType"] = server.proxyType;
+ serverMap["ProxyHost"] = server.proxyHost;
+ serverMap["ProxyPort"] = server.proxyPort;
+ serverMap["ProxyUser"] = server.proxyUser;
+ serverMap["ProxyPass"] = server.proxyPass;
+ out << serverMap;
+ return out;
+}
+
+QDataStream& operator>>(QDataStream& in, Network::Server& server)
+{
+ QVariantMap serverMap;
+ in >> serverMap;
+ server.host = serverMap["Host"].toString();
+ server.port = serverMap["Port"].toUInt();
+ server.password = serverMap["Password"].toString();
+ server.useSsl = serverMap["UseSSL"].toBool();
+ server.sslVerify = serverMap["sslVerify"].toBool();
+ server.sslVersion = serverMap["sslVersion"].toInt();
+ server.useProxy = serverMap["UseProxy"].toBool();
+ server.proxyType = serverMap["ProxyType"].toInt();
+ server.proxyHost = serverMap["ProxyHost"].toString();
+ server.proxyPort = serverMap["ProxyPort"].toUInt();
+ server.proxyUser = serverMap["ProxyUser"].toString();
+ server.proxyPass = serverMap["ProxyPass"].toString();
+ return in;
+}
+
+bool Network::Server::operator==(const Server& other) const
+{
+ if (host != other.host)
+ return false;
+ if (port != other.port)
+ return false;
+ if (password != other.password)
+ return false;
+ if (useSsl != other.useSsl)
+ return false;
+ if (sslVerify != other.sslVerify)
+ return false;
+ if (sslVersion != other.sslVersion)
+ return false;
+ if (useProxy != other.useProxy)
+ return false;
+ if (proxyType != other.proxyType)
+ return false;
+ if (proxyHost != other.proxyHost)
+ return false;
+ if (proxyPort != other.proxyPort)
+ return false;
+ if (proxyUser != other.proxyUser)
+ return false;
+ if (proxyPass != other.proxyPass)
+ return false;
+ return true;
+}
+
+bool Network::Server::operator!=(const Server& other) const
+{
+ return !(*this == other);
+}
+
+QDebug operator<<(QDebug dbg, const Network::Server& server)
+{
+ dbg.nospace() << "Server(host = " << server.host << ":" << server.port << ", useSsl = " << server.useSsl
+ << ", sslVerify = " << server.sslVerify << ")";
+ return dbg.space();