1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
25 #include <QStringList>
27 #include <QNetworkProxy>
29 #include <QVariantMap>
36 #include "syncableobject.h"
38 #include "signalproxy.h"
40 #include "ircchannel.h"
48 // TODO: ConnectionInfo to propagate and sync the current state of NetworkConnection, encodings etcpp
50 class Network : public SyncableObject
54 Q_ENUMS(ConnectionState)
56 Q_PROPERTY(QString networkName READ networkName WRITE setNetworkName)
57 Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer)
58 Q_PROPERTY(QString myNick READ myNick WRITE setMyNick)
59 Q_PROPERTY(int latency READ latency WRITE setLatency)
60 Q_PROPERTY(QByteArray codecForServer READ codecForServer WRITE setCodecForServer)
61 Q_PROPERTY(QByteArray codecForEncoding READ codecForEncoding WRITE setCodecForEncoding)
62 Q_PROPERTY(QByteArray codecForDecoding READ codecForDecoding WRITE setCodecForDecoding)
63 Q_PROPERTY(IdentityId identityId READ identity WRITE setIdentity)
64 Q_PROPERTY(bool isConnected READ isConnected WRITE setConnected)
65 //Q_PROPERTY(Network::ConnectionState connectionState READ connectionState WRITE setConnectionState)
66 Q_PROPERTY(int connectionState READ connectionState WRITE setConnectionState)
67 Q_PROPERTY(bool useRandomServer READ useRandomServer WRITE setUseRandomServer)
68 Q_PROPERTY(QStringList perform READ perform WRITE setPerform)
69 Q_PROPERTY(bool useAutoIdentify READ useAutoIdentify WRITE setUseAutoIdentify)
70 Q_PROPERTY(QString autoIdentifyService READ autoIdentifyService WRITE setAutoIdentifyService)
71 Q_PROPERTY(QString autoIdentifyPassword READ autoIdentifyPassword WRITE setAutoIdentifyPassword)
72 Q_PROPERTY(bool useSasl READ useSasl WRITE setUseSasl)
73 Q_PROPERTY(QString saslAccount READ saslAccount WRITE setSaslAccount)
74 Q_PROPERTY(QString saslPassword READ saslPassword WRITE setSaslPassword)
75 Q_PROPERTY(bool useAutoReconnect READ useAutoReconnect WRITE setUseAutoReconnect)
76 Q_PROPERTY(quint32 autoReconnectInterval READ autoReconnectInterval WRITE setAutoReconnectInterval)
77 Q_PROPERTY(quint16 autoReconnectRetries READ autoReconnectRetries WRITE setAutoReconnectRetries)
78 Q_PROPERTY(bool unlimitedReconnectRetries READ unlimitedReconnectRetries WRITE setUnlimitedReconnectRetries)
79 Q_PROPERTY(bool rejoinChannels READ rejoinChannels WRITE setRejoinChannels)
80 // Custom rate limiting
81 Q_PROPERTY(bool useCustomMessageRate READ useCustomMessageRate WRITE setUseCustomMessageRate)
82 Q_PROPERTY(quint32 msgRateBurstSize READ messageRateBurstSize WRITE setMessageRateBurstSize)
83 Q_PROPERTY(quint32 msgRateMessageDelay READ messageRateDelay WRITE setMessageRateDelay)
84 Q_PROPERTY(bool unlimitedMessageRate READ unlimitedMessageRate WRITE setUnlimitedMessageRate)
87 enum ConnectionState {
97 // http://www.irc.org/tech_docs/005.html
98 // http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
99 enum ChannelModeType {
100 NOT_A_CHANMODE = 0x00,
107 // Default port assignments according to what many IRC networks have settled on.
108 // Technically not a standard, but it's fairly widespread.
109 // See https://freenode.net/news/port-6697-irc-via-tlsssl
111 PORT_PLAINTEXT = 6667, /// Default port for unencrypted connections
112 PORT_SSL = 6697 /// Default port for encrypted connections
120 bool sslVerify; /// If true, validate SSL certificates
130 // sslVerify only applies when useSsl is true. sslVerify should be enabled by default,
131 // so enabling useSsl offers a more secure default.
132 Server() : port(6667), useSsl(false), sslVerify(true), sslVersion(0), useProxy(false),
133 proxyType(QNetworkProxy::Socks5Proxy), proxyHost("localhost"), proxyPort(8080) {}
135 Server(const QString &host, uint port, const QString &password, bool useSsl,
137 : host(host), port(port), password(password), useSsl(useSsl), sslVerify(sslVerify),
138 sslVersion(0), useProxy(false), proxyType(QNetworkProxy::Socks5Proxy),
139 proxyHost("localhost"), proxyPort(8080) {}
141 bool operator==(const Server &other) const;
142 bool operator!=(const Server &other) const;
144 typedef QList<Server> ServerList;
146 Network(const NetworkId &networkid, QObject *parent = 0);
149 inline NetworkId networkId() const { return _networkId; }
151 inline SignalProxy *proxy() const { return _proxy; }
152 inline void setProxy(SignalProxy *proxy) { _proxy = proxy; }
154 inline bool isMyNick(const QString &nick) const { return (myNick().toLower() == nick.toLower()); }
155 inline bool isMe(IrcUser *ircuser) const { return (ircuser->nick().toLower() == myNick().toLower()); }
157 bool isChannelName(const QString &channelname) const;
160 * Checks if the target counts as a STATUSMSG
162 * Status messages are prefixed with one or more characters from the server-provided STATUSMSG
163 * if available, otherwise "@" and "+" are assumed. Generally, status messages sent to a
164 * channel are only visible to those with the same or higher permissions, e.g. voiced.
166 * @param[in] target Name of destination, e.g. a channel or query
167 * @returns True if a STATUSMSG, otherwise false
169 bool isStatusMsg(const QString &target) const;
171 inline bool isConnected() const { return _connected; }
172 //Network::ConnectionState connectionState() const;
173 inline int connectionState() const { return _connectionState; }
177 * Translates a user’s prefix to the channelmode associated with it.
178 * @param prefix Prefix to be translated.
180 QString prefixToMode(const QString &prefix) const;
181 inline QString prefixToMode(const QCharRef &prefix) const { return prefixToMode(QString(prefix)); }
182 inline QString prefixesToModes(const QString &prefix) const {
184 for (QChar c : prefix) {
185 modes += prefixToMode(c);
193 * Translates a user’s prefix to the channelmode associated with it.
194 * @param prefix Prefix to be translated.
196 QString modeToPrefix(const QString &mode) const;
197 inline QString modeToPrefix(const QCharRef &mode) const { return modeToPrefix(QString(mode)); }
198 inline QString modesToPrefixes(const QString &mode) const {
200 for (QChar c : mode) {
201 prefixes += modeToPrefix(c);
208 * Sorts the user channelmodes according to priority set by PREFIX
210 * Given a list of channel modes, sorts according to the order of PREFIX, putting the highest
211 * modes first. Any unknown modes are moved to the end in no given order.
213 * If prefix modes cannot be determined from the network, no changes will be made.
215 * @param modes User channelmodes
216 * @return Priority-sorted user channelmodes
218 QString sortPrefixModes(const QString &modes) const;
222 * Sorts the list of users' channelmodes according to priority set by PREFIX
224 * Maintains order of the modes list.
226 * @seealso Network::sortPrefixModes()
228 * @param modesList List of users' channel modes
229 * @return Priority-sorted list of users' channel modes
231 inline QStringList sortPrefixModes(const QStringList &modesList) const {
232 QStringList sortedModesList;
233 // Sort each individual mode string, appending back
234 // Must maintain the order received!
235 for (QString modes : modesList) {
236 sortedModesList << sortPrefixModes(modes);
238 return sortedModesList;
242 ChannelModeType channelModeType(const QString &mode);
243 inline ChannelModeType channelModeType(const QCharRef &mode) { return channelModeType(QString(mode)); }
245 inline const QString &networkName() const { return _networkName; }
246 inline const QString ¤tServer() const { return _currentServer; }
247 inline const QString &myNick() const { return _myNick; }
248 inline int latency() const { return _latency; }
249 inline IrcUser *me() const { return ircUser(myNick()); }
250 inline IdentityId identity() const { return _identity; }
251 QStringList nicks() const;
252 inline QStringList channels() const { return _ircChannels.keys(); }
254 * Gets the list of available capabilities.
256 * @returns QStringList of available capabilities
258 inline const QStringList caps() const { return QStringList(_caps.keys()); }
260 * Gets the list of enabled (acknowledged) capabilities.
262 * @returns QStringList of enabled (acknowledged) capabilities
264 inline const QStringList capsEnabled() const { return _capsEnabled; }
265 inline const ServerList &serverList() const { return _serverList; }
266 inline bool useRandomServer() const { return _useRandomServer; }
267 inline const QStringList &perform() const { return _perform; }
268 inline bool useAutoIdentify() const { return _useAutoIdentify; }
269 inline const QString &autoIdentifyService() const { return _autoIdentifyService; }
270 inline const QString &autoIdentifyPassword() const { return _autoIdentifyPassword; }
271 inline bool useSasl() const { return _useSasl; }
272 inline const QString &saslAccount() const { return _saslAccount; }
273 inline const QString &saslPassword() const { return _saslPassword; }
274 inline bool useAutoReconnect() const { return _useAutoReconnect; }
275 inline quint32 autoReconnectInterval() const { return _autoReconnectInterval; }
276 inline quint16 autoReconnectRetries() const { return _autoReconnectRetries; }
277 inline bool unlimitedReconnectRetries() const { return _unlimitedReconnectRetries; }
278 inline bool rejoinChannels() const { return _rejoinChannels; }
280 // Custom rate limiting
283 * Gets whether or not custom rate limiting is used
285 * @return True if custom rate limiting is enabled, otherwise false.
287 inline bool useCustomMessageRate() const { return _useCustomMessageRate; }
290 * Gets maximum number of messages to send without any delays
294 * Maximum number of messages to send without any delays. A value of 1 disables message
298 inline quint32 messageRateBurstSize() const { return _messageRateBurstSize; }
301 * Gets the delay between messages after the maximum number of undelayed messages have been sent
305 * Delay in milliseconds between messages after the maximum number of undelayed messages have
309 inline quint32 messageRateDelay() const { return _messageRateDelay; }
312 * Gets whether or not all rate limiting is disabled, e.g. for IRC bridges
314 * @return If true, disable rate limiting, otherwise apply configured limits.
316 inline bool unlimitedMessageRate() const { return _unlimitedMessageRate; }
318 NetworkInfo networkInfo() const;
319 void setNetworkInfo(const NetworkInfo &);
321 QString prefixes() const;
322 QString prefixModes() const;
323 void determinePrefixes() const;
325 bool supports(const QString ¶m) const { return _supports.contains(param); }
326 QString support(const QString ¶m) const;
329 * Checks if a given capability is advertised by the server.
331 * These results aren't valid if the network is disconnected or capability negotiation hasn't
332 * happened, and some servers might not correctly advertise capabilities. Don't treat this as
335 * @param[in] capability Name of capability
336 * @returns True if connected and advertised by the server, otherwise false
338 inline bool capAvailable(const QString &capability) const { return _caps.contains(capability.toLower()); }
339 // IRCv3 specs all use lowercase capability names
342 * Checks if a given capability is acknowledged and active.
344 * @param[in] capability Name of capability
345 * @returns True if acknowledged (active), otherwise false
347 inline bool capEnabled(const QString &capability) const { return _capsEnabled.contains(capability.toLower()); }
348 // IRCv3 specs all use lowercase capability names
351 * Gets the value of an available capability, e.g. for SASL, "EXTERNAL,PLAIN".
353 * @param[in] capability Name of capability
354 * @returns Value of capability if one was specified, otherwise empty string
356 QString capValue(const QString &capability) const { return _caps.value(capability.toLower()); }
357 // IRCv3 specs all use lowercase capability names
358 // QHash returns the default constructed value if not found, in this case, empty string
359 // See: https://doc.qt.io/qt-4.8/qhash.html#value
362 * Check if the given authentication mechanism is likely to be supported.
364 * This depends on the server advertising SASL support and either declaring available mechanisms
365 * (SASL 3.2), or just indicating something is supported (SASL 3.1).
367 * @param[in] saslMechanism Desired SASL mechanism
368 * @return True if mechanism supported or unknown, otherwise false
370 bool saslMaybeSupports(const QString &saslMechanism) const;
372 IrcUser *newIrcUser(const QString &hostmask, const QVariantMap &initData = QVariantMap());
373 inline IrcUser *newIrcUser(const QByteArray &hostmask) { return newIrcUser(decodeServerString(hostmask)); }
374 IrcUser *ircUser(QString nickname) const;
375 inline IrcUser *ircUser(const QByteArray &nickname) const { return ircUser(decodeServerString(nickname)); }
376 inline QList<IrcUser *> ircUsers() const { return _ircUsers.values(); }
377 inline quint32 ircUserCount() const { return _ircUsers.count(); }
379 IrcChannel *newIrcChannel(const QString &channelname, const QVariantMap &initData = QVariantMap());
380 inline IrcChannel *newIrcChannel(const QByteArray &channelname) { return newIrcChannel(decodeServerString(channelname)); }
381 IrcChannel *ircChannel(QString channelname) const;
382 inline IrcChannel *ircChannel(const QByteArray &channelname) const { return ircChannel(decodeServerString(channelname)); }
383 inline QList<IrcChannel *> ircChannels() const { return _ircChannels.values(); }
384 inline quint32 ircChannelCount() const { return _ircChannels.count(); }
386 QByteArray codecForServer() const;
387 QByteArray codecForEncoding() const;
388 QByteArray codecForDecoding() const;
389 void setCodecForServer(QTextCodec *codec);
390 void setCodecForEncoding(QTextCodec *codec);
391 void setCodecForDecoding(QTextCodec *codec);
393 QString decodeString(const QByteArray &text) const;
394 QByteArray encodeString(const QString &string) const;
395 QString decodeServerString(const QByteArray &text) const;
396 QByteArray encodeServerString(const QString &string) const;
398 static QByteArray defaultCodecForServer();
399 static QByteArray defaultCodecForEncoding();
400 static QByteArray defaultCodecForDecoding();
401 static void setDefaultCodecForServer(const QByteArray &name);
402 static void setDefaultCodecForEncoding(const QByteArray &name);
403 static void setDefaultCodecForDecoding(const QByteArray &name);
405 inline bool autoAwayActive() const { return _autoAwayActive; }
406 inline void setAutoAwayActive(bool active) { _autoAwayActive = active; }
409 void setNetworkName(const QString &networkName);
410 void setCurrentServer(const QString ¤tServer);
411 void setConnected(bool isConnected);
412 void setConnectionState(int state);
413 virtual void setMyNick(const QString &mynick);
414 void setLatency(int latency);
415 void setIdentity(IdentityId);
417 void setServerList(const QVariantList &serverList);
418 void setUseRandomServer(bool);
419 void setPerform(const QStringList &);
420 void setUseAutoIdentify(bool);
421 void setAutoIdentifyService(const QString &);
422 void setAutoIdentifyPassword(const QString &);
423 void setUseSasl(bool);
424 void setSaslAccount(const QString &);
425 void setSaslPassword(const QString &);
426 virtual void setUseAutoReconnect(bool);
427 virtual void setAutoReconnectInterval(quint32);
428 virtual void setAutoReconnectRetries(quint16);
429 void setUnlimitedReconnectRetries(bool);
430 void setRejoinChannels(bool);
432 // Custom rate limiting
435 * Sets whether or not custom rate limiting is used.
437 * Setting limits too low may get you disconnected from the server!
439 * @param[in] useCustomRate If true, use custom rate limits, otherwise use Quassel defaults.
441 void setUseCustomMessageRate(bool useCustomRate);
444 * Sets maximum number of messages to send without any delays
446 * @param[in] burstSize
448 * Maximum number of messages to send without any delays. A value of 1 disables message
449 * bursting. Cannot be less than 1 as sending 0 messages at a time accomplishes nothing.
452 void setMessageRateBurstSize(quint32 burstSize);
455 * Sets the delay between messages after the maximum number of undelayed messages have been sent
457 * @param[in] messageDelay
459 * Delay in milliseconds between messages after the maximum number of undelayed messages have
463 void setMessageRateDelay(quint32 messageDelay);
466 * Sets whether or not all rate limiting is disabled, e.g. for IRC bridges
468 * Don't use with most normal networks.
470 * @param[in] unlimitedRate If true, disable rate limiting, otherwise apply configured limits.
472 void setUnlimitedMessageRate(bool unlimitedRate);
474 void setCodecForServer(const QByteArray &codecName);
475 void setCodecForEncoding(const QByteArray &codecName);
476 void setCodecForDecoding(const QByteArray &codecName);
478 void addSupport(const QString ¶m, const QString &value = QString());
479 void removeSupport(const QString ¶m);
481 // IRCv3 capability negotiation (can be connected to signals)
484 * Add an available capability, optionally providing a value.
486 * This may happen during first connect, or at any time later if a new capability becomes
487 * available (e.g. SASL service starting).
489 * @param[in] capability Name of the capability
492 * Optional value of the capability, e.g. sasl=plain.
495 void addCap(const QString &capability, const QString &value = QString());
498 * Marks a capability as acknowledged (enabled by the IRC server).
500 * @param[in] capability Name of the capability
502 void acknowledgeCap(const QString &capability);
505 * Removes a capability from the list of available capabilities.
507 * This may happen during first connect, or at any time later if an existing capability becomes
508 * unavailable (e.g. SASL service stopping). This also removes the capability from the list
509 * of acknowledged capabilities.
511 * @param[in] capability Name of the capability
513 void removeCap(const QString &capability);
516 * Clears all capabilities from the list of available capabilities.
518 * This also removes the capability from the list of acknowledged capabilities.
522 inline void addIrcUser(const QString &hostmask) { newIrcUser(hostmask); }
523 inline void addIrcChannel(const QString &channel) { newIrcChannel(channel); }
526 QVariantMap initSupports() const;
528 * Get the initial list of available capabilities.
530 * @return QVariantMap of <QString, QString> indicating available capabilities and values
532 QVariantMap initCaps() const;
534 * Get the initial list of enabled (acknowledged) capabilities.
536 * @return QVariantList of QString indicating enabled (acknowledged) capabilities and values
538 QVariantList initCapsEnabled() const { return toVariantList(capsEnabled()); }
539 inline QVariantList initServerList() const { return toVariantList(serverList()); }
540 virtual QVariantMap initIrcUsersAndChannels() const;
543 void initSetSupports(const QVariantMap &supports);
545 * Initialize the list of available capabilities.
547 * @param[in] caps QVariantMap of <QString, QString> indicating available capabilities and values
549 void initSetCaps(const QVariantMap &caps);
551 * Initialize the list of enabled (acknowledged) capabilities.
553 * @param[in] caps QVariantList of QString indicating enabled (acknowledged) capabilities and values
555 inline void initSetCapsEnabled(const QVariantList &capsEnabled) { _capsEnabled = fromVariantList<QString>(capsEnabled); }
556 inline void initSetServerList(const QVariantList &serverList) { _serverList = fromVariantList<Server>(serverList); }
557 virtual void initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels);
560 * Update IrcUser hostmask and username from mask, creating an IrcUser if one does not exist.
562 * @param[in] mask Full nick!user@hostmask string
563 * @return IrcUser of the matching nick if exists, otherwise a new IrcUser
565 IrcUser *updateNickFromMask(const QString &mask);
567 // these slots are to keep the hashlists of all users and the
568 // channel lists up to date
569 void ircUserNickChanged(QString newnick);
571 virtual inline void requestConnect() const { REQUEST(NO_ARG) }
572 virtual inline void requestDisconnect() const { REQUEST(NO_ARG) }
573 virtual inline void requestSetNetworkInfo(const NetworkInfo &info) { REQUEST(ARG(info)) }
575 void emitConnectionError(const QString &);
578 virtual void removeIrcUser(IrcUser *ircuser);
579 virtual void removeIrcChannel(IrcChannel *ircChannel);
580 virtual void removeChansAndUsers();
583 void aboutToBeDestroyed();
584 void networkNameSet(const QString &networkName);
585 void currentServerSet(const QString ¤tServer);
586 void connectedSet(bool isConnected);
587 void connectionStateSet(Network::ConnectionState);
588 // void connectionStateSet(int);
589 void connectionError(const QString &errorMsg);
590 void myNickSet(const QString &mynick);
591 // void latencySet(int latency);
592 void identitySet(IdentityId);
594 void configChanged();
596 // void serverListSet(QVariantList serverList);
597 // void useRandomServerSet(bool);
598 // void performSet(const QStringList &);
599 // void useAutoIdentifySet(bool);
600 // void autoIdentifyServiceSet(const QString &);
601 // void autoIdentifyPasswordSet(const QString &);
602 // void useAutoReconnectSet(bool);
603 // void autoReconnectIntervalSet(quint32);
604 // void autoReconnectRetriesSet(quint16);
605 // void unlimitedReconnectRetriesSet(bool);
606 // void rejoinChannelsSet(bool);
608 // Custom rate limiting (can drive other slots)
611 * Signals enabling or disabling custom rate limiting
613 * @see Network::useCustomMessageRate()
615 * @param[out] useCustomRate
617 void useCustomMessageRateSet(const bool useCustomRate);
620 * Signals a change in maximum number of messages to send without any delays
622 * @see Network::messageRateBurstSize()
624 * @param[out] burstSize
626 void messageRateBurstSizeSet(const quint32 burstSize);
629 * Signals a change in delay between messages after the max. undelayed messages have been sent
631 * @see Network::messageRateDelay()
633 * @param[out] messageDelay
635 void messageRateDelaySet(const quint32 messageDelay);
638 * Signals enabling or disabling all rate limiting
640 * @see Network::unlimitedMessageRate()
642 * @param[out] unlimitedRate
644 void unlimitedMessageRateSet(const bool unlimitedRate);
646 // void codecForServerSet(const QByteArray &codecName);
647 // void codecForEncodingSet(const QByteArray &codecName);
648 // void codecForDecodingSet(const QByteArray &codecName);
650 // void supportAdded(const QString ¶m, const QString &value);
651 // void supportRemoved(const QString ¶m);
653 // IRCv3 capability negotiation (can drive other slots)
655 * Indicates a capability is now available, with optional value in Network::capValue().
657 * @see Network::addCap()
659 * @param[in] capability Name of the capability
661 void capAdded (const QString &capability);
664 * Indicates a capability was acknowledged (enabled by the IRC server).
666 * @see Network::acknowledgeCap()
668 * @param[in] capability Name of the capability
670 void capAcknowledged(const QString &capability);
673 * Indicates a capability was removed from the list of available capabilities.
675 * @see Network::removeCap()
677 * @param[in] capability Name of the capability
679 void capRemoved(const QString &capability);
681 // void ircUserAdded(const QString &hostmask);
682 void ircUserAdded(IrcUser *);
683 // void ircChannelAdded(const QString &channelname);
684 void ircChannelAdded(IrcChannel *);
686 // void connectRequested() const;
687 // void disconnectRequested() const;
688 // void setNetworkInfoRequested(const NetworkInfo &) const;
691 inline virtual IrcChannel *ircChannelFactory(const QString &channelname) { return new IrcChannel(channelname, this); }
692 inline virtual IrcUser *ircUserFactory(const QString &hostmask) { return new IrcUser(hostmask, this); }
695 QPointer<SignalProxy> _proxy;
697 NetworkId _networkId;
698 IdentityId _identity;
702 QString _networkName;
703 QString _currentServer;
705 ConnectionState _connectionState;
707 mutable QString _prefixes;
708 mutable QString _prefixModes;
710 QHash<QString, IrcUser *> _ircUsers; // stores all known nicks for the server
711 QHash<QString, IrcChannel *> _ircChannels; // stores all known channels
712 QHash<QString, QString> _supports; // stores results from RPL_ISUPPORT
714 QHash<QString, QString> _caps; /// Capabilities supported by the IRC server
715 // By synchronizing the supported capabilities, the client could suggest certain behaviors, e.g.
716 // in the Network settings dialog, recommending SASL instead of using NickServ, or warning if
717 // SASL EXTERNAL isn't available.
718 QStringList _capsEnabled; /// Enabled capabilities that received 'CAP ACK'
719 // _capsEnabled uses the same values from the <name>=<value> pairs stored in _caps
721 ServerList _serverList;
722 bool _useRandomServer;
723 QStringList _perform;
725 bool _useAutoIdentify;
726 QString _autoIdentifyService;
727 QString _autoIdentifyPassword;
730 QString _saslAccount;
731 QString _saslPassword;
733 bool _useAutoReconnect;
734 quint32 _autoReconnectInterval;
735 quint16 _autoReconnectRetries;
736 bool _unlimitedReconnectRetries;
737 bool _rejoinChannels;
739 // Custom rate limiting
740 bool _useCustomMessageRate; /// If true, use custom rate limits, otherwise use defaults
741 quint32 _messageRateBurstSize; /// Maximum number of messages to send without any delays
742 quint32 _messageRateDelay; /// Delay in ms. for messages when max. burst messages sent
743 bool _unlimitedMessageRate; /// If true, disable rate limiting, otherwise apply limits
745 QTextCodec *_codecForServer;
746 QTextCodec *_codecForEncoding;
747 QTextCodec *_codecForDecoding;
749 static QTextCodec *_defaultCodecForServer;
750 static QTextCodec *_defaultCodecForEncoding;
751 static QTextCodec *_defaultCodecForDecoding;
753 bool _autoAwayActive; // when this is active handle305 and handle306 don't trigger any output
755 friend class IrcUser;
756 friend class IrcChannel;
760 //! Stores all editable information about a network (as opposed to runtime state).
765 Network::ServerList serverList;
768 QString autoIdentifyService{"NickServ"};
769 QString autoIdentifyPassword;
772 QString saslPassword;
774 QByteArray codecForServer;
775 QByteArray codecForEncoding;
776 QByteArray codecForDecoding;
778 NetworkId networkId {0};
779 IdentityId identity {1};
781 quint32 messageRateBurstSize {5}; ///< Maximum number of messages to send without any delays
782 quint32 messageRateDelay {2200}; ///< Delay in ms. for messages when max. burst messages sent
784 quint32 autoReconnectInterval {60};
785 quint16 autoReconnectRetries {20};
787 bool rejoinChannels {true};
788 bool useRandomServer {false};
789 bool useAutoIdentify {false};
790 bool useSasl {false};
791 bool useAutoReconnect {true};
792 bool unlimitedReconnectRetries {false};
793 bool useCustomMessageRate {false}; ///< If true, use custom rate limits, otherwise use defaults
794 bool unlimitedMessageRate {false}; ///< If true, disable rate limiting, otherwise apply limits
797 bool operator==(const NetworkInfo &other) const;
798 bool operator!=(const NetworkInfo &other) const;
801 QDataStream &operator<<(QDataStream &out, const NetworkInfo &info);
802 QDataStream &operator>>(QDataStream &in, NetworkInfo &info);
803 QDebug operator<<(QDebug dbg, const NetworkInfo &i);
804 Q_DECLARE_METATYPE(NetworkInfo)
806 QDataStream &operator<<(QDataStream &out, const Network::Server &server);
807 QDataStream &operator>>(QDataStream &in, Network::Server &server);
808 QDebug operator<<(QDebug dbg, const Network::Server &server);
809 Q_DECLARE_METATYPE(Network::Server)