1 /***************************************************************************
2 * Copyright (C) 2005-2020 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 ***************************************************************************/
23 #include "common-export.h"
31 #include <QNetworkProxy>
34 #include <QStringList>
35 #include <QVariantMap>
37 #include "ircchannel.h"
39 #include "signalproxy.h"
40 #include "syncableobject.h"
50 // TODO: ConnectionInfo to propagate and sync the current state of NetworkConnection, encodings etcpp
52 class COMMON_EXPORT Network : public SyncableObject
57 Q_ENUMS(ConnectionState)
59 Q_PROPERTY(QString networkName READ networkName WRITE setNetworkName)
60 Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer)
61 Q_PROPERTY(QString myNick READ myNick WRITE setMyNick)
62 Q_PROPERTY(int latency READ latency WRITE setLatency)
63 Q_PROPERTY(QByteArray codecForServer READ codecForServer WRITE setCodecForServer)
64 Q_PROPERTY(QByteArray codecForEncoding READ codecForEncoding WRITE setCodecForEncoding)
65 Q_PROPERTY(QByteArray codecForDecoding READ codecForDecoding WRITE setCodecForDecoding)
66 Q_PROPERTY(IdentityId identityId READ identity WRITE setIdentity)
67 Q_PROPERTY(bool isConnected READ isConnected WRITE setConnected)
68 // Q_PROPERTY(Network::ConnectionState connectionState READ connectionState WRITE setConnectionState)
69 Q_PROPERTY(int connectionState READ connectionState WRITE setConnectionState)
70 Q_PROPERTY(bool useRandomServer READ useRandomServer WRITE setUseRandomServer)
71 Q_PROPERTY(QStringList perform READ perform WRITE setPerform)
72 Q_PROPERTY(bool useAutoIdentify READ useAutoIdentify WRITE setUseAutoIdentify)
73 Q_PROPERTY(QString autoIdentifyService READ autoIdentifyService WRITE setAutoIdentifyService)
74 Q_PROPERTY(QString autoIdentifyPassword READ autoIdentifyPassword WRITE setAutoIdentifyPassword)
75 Q_PROPERTY(bool useSasl READ useSasl WRITE setUseSasl)
76 Q_PROPERTY(QString saslAccount READ saslAccount WRITE setSaslAccount)
77 Q_PROPERTY(QString saslPassword READ saslPassword WRITE setSaslPassword)
78 Q_PROPERTY(bool useAutoReconnect READ useAutoReconnect WRITE setUseAutoReconnect)
79 Q_PROPERTY(quint32 autoReconnectInterval READ autoReconnectInterval WRITE setAutoReconnectInterval)
80 Q_PROPERTY(quint16 autoReconnectRetries READ autoReconnectRetries WRITE setAutoReconnectRetries)
81 Q_PROPERTY(bool unlimitedReconnectRetries READ unlimitedReconnectRetries WRITE setUnlimitedReconnectRetries)
82 Q_PROPERTY(bool rejoinChannels READ rejoinChannels WRITE setRejoinChannels)
83 // Custom rate limiting
84 Q_PROPERTY(bool useCustomMessageRate READ useCustomMessageRate WRITE setUseCustomMessageRate)
85 Q_PROPERTY(quint32 msgRateBurstSize READ messageRateBurstSize WRITE setMessageRateBurstSize)
86 Q_PROPERTY(quint32 msgRateMessageDelay READ messageRateDelay WRITE setMessageRateDelay)
87 Q_PROPERTY(bool unlimitedMessageRate READ unlimitedMessageRate WRITE setUnlimitedMessageRate)
101 // http://www.irc.org/tech_docs/005.html
102 // http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
105 NOT_A_CHANMODE = 0x00,
112 // Default port assignments according to what many IRC networks have settled on.
113 // Technically not a standard, but it's fairly widespread.
114 // See https://freenode.net/news/port-6697-irc-via-tlsssl
117 PORT_PLAINTEXT = 6667, /// Default port for unencrypted connections
118 PORT_SSL = 6697 /// Default port for encrypted connections
127 bool sslVerify{true}; /// If true, validate SSL certificates
130 bool useProxy{false};
131 int proxyType{QNetworkProxy::Socks5Proxy};
133 uint proxyPort{8080};
137 // sslVerify only applies when useSsl is true. sslVerify should be enabled by default,
138 // so enabling useSsl offers a more secure default.
140 : proxyHost("localhost")
143 Server(QString host, uint port, QString password, bool useSsl, bool sslVerify)
144 : host(std::move(host))
146 , password(std::move(password))
148 , sslVerify(sslVerify)
149 , proxyType(QNetworkProxy::Socks5Proxy)
150 , proxyHost("localhost")
154 bool operator==(const Server& other) const;
155 bool operator!=(const Server& other) const;
157 using ServerList = QList<Server>;
159 Network(const NetworkId& networkid, QObject* parent = nullptr);
162 inline NetworkId networkId() const { return _networkId; }
164 inline SignalProxy* proxy() const { return _proxy; }
165 inline void setProxy(SignalProxy* proxy) { _proxy = proxy; }
167 inline bool isMyNick(const QString& nick) const { return (myNick().toLower() == nick.toLower()); }
168 inline bool isMe(IrcUser* ircuser) const { return (ircuser->nick().toLower() == myNick().toLower()); }
170 bool isChannelName(const QString& channelname) const;
173 * Checks if the target counts as a STATUSMSG
175 * Status messages are prefixed with one or more characters from the server-provided STATUSMSG
176 * if available, otherwise "@" and "+" are assumed. Generally, status messages sent to a
177 * channel are only visible to those with the same or higher permissions, e.g. voiced.
179 * @param[in] target Name of destination, e.g. a channel or query
180 * @returns True if a STATUSMSG, otherwise false
182 bool isStatusMsg(const QString& target) const;
184 inline bool isConnected() const { return _connected; }
185 // Network::ConnectionState connectionState() const;
186 inline int connectionState() const { return _connectionState; }
190 * Translates a user’s prefix to the channelmode associated with it.
191 * @param prefix Prefix to be translated.
193 QString prefixToMode(const QString& prefix) const;
194 inline QString prefixToMode(const QCharRef& prefix) const { return prefixToMode(QString(prefix)); }
195 inline QString prefixesToModes(const QString& prefix) const
198 for (QChar c : prefix) {
199 modes += prefixToMode(c);
207 * Translates a user’s prefix to the channelmode associated with it.
208 * @param prefix Prefix to be translated.
210 QString modeToPrefix(const QString& mode) const;
211 inline QString modeToPrefix(const QCharRef& mode) const { return modeToPrefix(QString(mode)); }
212 inline QString modesToPrefixes(const QString& mode) const
215 for (QChar c : mode) {
216 prefixes += modeToPrefix(c);
223 * Sorts the user channelmodes according to priority set by PREFIX
225 * Given a list of channel modes, sorts according to the order of PREFIX, putting the highest
226 * modes first. Any unknown modes are moved to the end in no given order.
228 * If prefix modes cannot be determined from the network, no changes will be made.
230 * @param modes User channelmodes
231 * @return Priority-sorted user channelmodes
233 QString sortPrefixModes(const QString& modes) const;
237 * Sorts the list of users' channelmodes according to priority set by PREFIX
239 * Maintains order of the modes list.
241 * @seealso Network::sortPrefixModes()
243 * @param modesList List of users' channel modes
244 * @return Priority-sorted list of users' channel modes
246 inline QStringList sortPrefixModes(const QStringList& modesList) const
248 QStringList sortedModesList;
249 // Sort each individual mode string, appending back
250 // Must maintain the order received!
251 for (QString modes : modesList) {
252 sortedModesList << sortPrefixModes(modes);
254 return sortedModesList;
258 ChannelModeType channelModeType(const QString& mode);
259 inline ChannelModeType channelModeType(const QCharRef& mode) { return channelModeType(QString(mode)); }
261 inline const QString& networkName() const { return _networkName; }
262 inline const QString& currentServer() const { return _currentServer; }
263 inline const QString& myNick() const { return _myNick; }
264 inline int latency() const { return _latency; }
265 inline IrcUser* me() const { return ircUser(myNick()); }
266 inline IdentityId identity() const { return _identity; }
267 QStringList nicks() const;
268 inline QStringList channels() const { return _ircChannels.keys(); }
270 * Gets the list of available capabilities.
272 * @returns QStringList of available capabilities
274 inline const QStringList caps() const { return QStringList(_caps.keys()); }
276 * Gets the list of enabled (acknowledged) capabilities.
278 * @returns QStringList of enabled (acknowledged) capabilities
280 inline const QStringList capsEnabled() const { return _capsEnabled; }
281 inline const ServerList& serverList() const { return _serverList; }
282 inline bool useRandomServer() const { return _useRandomServer; }
283 inline const QStringList& perform() const { return _perform; }
284 inline bool useAutoIdentify() const { return _useAutoIdentify; }
285 inline const QString& autoIdentifyService() const { return _autoIdentifyService; }
286 inline const QString& autoIdentifyPassword() const { return _autoIdentifyPassword; }
287 inline bool useSasl() const { return _useSasl; }
288 inline const QString& saslAccount() const { return _saslAccount; }
289 inline const QString& saslPassword() const { return _saslPassword; }
290 inline bool useAutoReconnect() const { return _useAutoReconnect; }
291 inline quint32 autoReconnectInterval() const { return _autoReconnectInterval; }
292 inline quint16 autoReconnectRetries() const { return _autoReconnectRetries; }
293 inline bool unlimitedReconnectRetries() const { return _unlimitedReconnectRetries; }
294 inline bool rejoinChannels() const { return _rejoinChannels; }
296 // Custom rate limiting
299 * Gets whether or not custom rate limiting is used
301 * @return True if custom rate limiting is enabled, otherwise false.
303 inline bool useCustomMessageRate() const { return _useCustomMessageRate; }
306 * Gets maximum number of messages to send without any delays
310 * Maximum number of messages to send without any delays. A value of 1 disables message
314 inline quint32 messageRateBurstSize() const { return _messageRateBurstSize; }
317 * Gets the delay between messages after the maximum number of undelayed messages have been sent
321 * Delay in milliseconds between messages after the maximum number of undelayed messages have
325 inline quint32 messageRateDelay() const { return _messageRateDelay; }
328 * Gets whether or not all rate limiting is disabled, e.g. for IRC bridges
330 * @return If true, disable rate limiting, otherwise apply configured limits.
332 inline bool unlimitedMessageRate() const { return _unlimitedMessageRate; }
334 NetworkInfo networkInfo() const;
335 void setNetworkInfo(const NetworkInfo&);
337 QString prefixes() const;
338 QString prefixModes() const;
339 void determinePrefixes() const;
341 bool supports(const QString& param) const { return _supports.contains(param); }
342 QString support(const QString& param) const;
345 * Checks if a given capability is advertised by the server.
347 * These results aren't valid if the network is disconnected or capability negotiation hasn't
348 * happened, and some servers might not correctly advertise capabilities. Don't treat this as
351 * @param[in] capability Name of capability
352 * @returns True if connected and advertised by the server, otherwise false
354 inline bool capAvailable(const QString& capability) const { return _caps.contains(capability.toLower()); }
355 // IRCv3 specs all use lowercase capability names
358 * Checks if a given capability is acknowledged and active.
360 * @param[in] capability Name of capability
361 * @returns True if acknowledged (active), otherwise false
363 inline bool capEnabled(const QString& capability) const { return _capsEnabled.contains(capability.toLower()); }
364 // IRCv3 specs all use lowercase capability names
367 * Gets the value of an available capability, e.g. for SASL, "EXTERNAL,PLAIN".
369 * @param[in] capability Name of capability
370 * @returns Value of capability if one was specified, otherwise empty string
372 QString capValue(const QString& capability) const { return _caps.value(capability.toLower()); }
373 // IRCv3 specs all use lowercase capability names
374 // QHash returns the default constructed value if not found, in this case, empty string
375 // See: https://doc.qt.io/qt-4.8/qhash.html#value
378 * Check if the given authentication mechanism is likely to be supported.
380 * This depends on the server advertising SASL support and either declaring available mechanisms
381 * (SASL 3.2), or just indicating something is supported (SASL 3.1).
383 * @param[in] saslMechanism Desired SASL mechanism
384 * @return True if mechanism supported or unknown, otherwise false
386 bool saslMaybeSupports(const QString& saslMechanism) const;
388 IrcUser* newIrcUser(const QString& hostmask, const QVariantMap& initData = QVariantMap());
389 inline IrcUser* newIrcUser(const QByteArray& hostmask) { return newIrcUser(decodeServerString(hostmask)); }
390 IrcUser* ircUser(QString nickname) const;
391 inline IrcUser* ircUser(const QByteArray& nickname) const { return ircUser(decodeServerString(nickname)); }
392 inline QList<IrcUser*> ircUsers() const { return _ircUsers.values(); }
393 inline quint32 ircUserCount() const { return _ircUsers.count(); }
395 IrcChannel* newIrcChannel(const QString& channelname, const QVariantMap& initData = QVariantMap());
396 inline IrcChannel* newIrcChannel(const QByteArray& channelname) { return newIrcChannel(decodeServerString(channelname)); }
397 IrcChannel* ircChannel(QString channelname) const;
398 inline IrcChannel* ircChannel(const QByteArray& channelname) const { return ircChannel(decodeServerString(channelname)); }
399 inline QList<IrcChannel*> ircChannels() const { return _ircChannels.values(); }
400 inline quint32 ircChannelCount() const { return _ircChannels.count(); }
402 QByteArray codecForServer() const;
403 QByteArray codecForEncoding() const;
404 QByteArray codecForDecoding() const;
405 void setCodecForServer(QTextCodec* codec);
406 void setCodecForEncoding(QTextCodec* codec);
407 void setCodecForDecoding(QTextCodec* codec);
409 QString decodeString(const QByteArray& text) const;
410 QByteArray encodeString(const QString& string) const;
411 QString decodeServerString(const QByteArray& text) const;
412 QByteArray encodeServerString(const QString& string) const;
414 static QByteArray defaultCodecForServer();
415 static QByteArray defaultCodecForEncoding();
416 static QByteArray defaultCodecForDecoding();
417 static void setDefaultCodecForServer(const QByteArray& name);
418 static void setDefaultCodecForEncoding(const QByteArray& name);
419 static void setDefaultCodecForDecoding(const QByteArray& name);
421 inline bool autoAwayActive() const { return _autoAwayActive; }
422 inline void setAutoAwayActive(bool active) { _autoAwayActive = active; }
425 void setNetworkName(const QString& networkName);
426 void setCurrentServer(const QString& currentServer);
427 void setConnected(bool isConnected);
428 void setConnectionState(int state);
429 virtual void setMyNick(const QString& mynick);
430 void setLatency(int latency);
431 void setIdentity(IdentityId);
433 void setServerList(const QVariantList& serverList);
434 void setUseRandomServer(bool);
435 void setPerform(const QStringList&);
436 void setUseAutoIdentify(bool);
437 void setAutoIdentifyService(const QString&);
438 void setAutoIdentifyPassword(const QString&);
439 void setUseSasl(bool);
440 void setSaslAccount(const QString&);
441 void setSaslPassword(const QString&);
442 virtual void setUseAutoReconnect(bool);
443 virtual void setAutoReconnectInterval(quint32);
444 virtual void setAutoReconnectRetries(quint16);
445 void setUnlimitedReconnectRetries(bool);
446 void setRejoinChannels(bool);
448 // Custom rate limiting
451 * Sets whether or not custom rate limiting is used.
453 * Setting limits too low may get you disconnected from the server!
455 * @param[in] useCustomRate If true, use custom rate limits, otherwise use Quassel defaults.
457 void setUseCustomMessageRate(bool useCustomRate);
460 * Sets maximum number of messages to send without any delays
462 * @param[in] burstSize
464 * Maximum number of messages to send without any delays. A value of 1 disables message
465 * bursting. Cannot be less than 1 as sending 0 messages at a time accomplishes nothing.
468 void setMessageRateBurstSize(quint32 burstSize);
471 * Sets the delay between messages after the maximum number of undelayed messages have been sent
473 * @param[in] messageDelay
475 * Delay in milliseconds between messages after the maximum number of undelayed messages have
479 void setMessageRateDelay(quint32 messageDelay);
482 * Sets whether or not all rate limiting is disabled, e.g. for IRC bridges
484 * Don't use with most normal networks.
486 * @param[in] unlimitedRate If true, disable rate limiting, otherwise apply configured limits.
488 void setUnlimitedMessageRate(bool unlimitedRate);
490 void setCodecForServer(const QByteArray& codecName);
491 void setCodecForEncoding(const QByteArray& codecName);
492 void setCodecForDecoding(const QByteArray& codecName);
494 void addSupport(const QString& param, const QString& value = QString());
495 void removeSupport(const QString& param);
497 // IRCv3 capability negotiation (can be connected to signals)
500 * Add an available capability, optionally providing a value.
502 * This may happen during first connect, or at any time later if a new capability becomes
503 * available (e.g. SASL service starting).
505 * @param[in] capability Name of the capability
508 * Optional value of the capability, e.g. sasl=plain.
511 void addCap(const QString& capability, const QString& value = QString());
514 * Marks a capability as acknowledged (enabled by the IRC server).
516 * @param[in] capability Name of the capability
518 void acknowledgeCap(const QString& capability);
521 * Removes a capability from the list of available capabilities.
523 * This may happen during first connect, or at any time later if an existing capability becomes
524 * unavailable (e.g. SASL service stopping). This also removes the capability from the list
525 * of acknowledged capabilities.
527 * @param[in] capability Name of the capability
529 void removeCap(const QString& capability);
532 * Clears all capabilities from the list of available capabilities.
534 * This also removes the capability from the list of acknowledged capabilities.
538 inline void addIrcUser(const QString& hostmask) { newIrcUser(hostmask); }
539 inline void addIrcChannel(const QString& channel) { newIrcChannel(channel); }
542 QVariantMap initSupports() const;
544 * Get the initial list of available capabilities.
546 * @return QVariantMap of <QString, QString> indicating available capabilities and values
548 QVariantMap initCaps() const;
550 * Get the initial list of enabled (acknowledged) capabilities.
552 * @return QVariantList of QString indicating enabled (acknowledged) capabilities and values
554 QVariantList initCapsEnabled() const { return toVariantList(capsEnabled()); }
555 inline QVariantList initServerList() const { return toVariantList(serverList()); }
556 virtual QVariantMap initIrcUsersAndChannels() const;
559 void initSetSupports(const QVariantMap& supports);
561 * Initialize the list of available capabilities.
563 * @param[in] caps QVariantMap of <QString, QString> indicating available capabilities and values
565 void initSetCaps(const QVariantMap& caps);
567 * Initialize the list of enabled (acknowledged) capabilities.
569 * @param[in] caps QVariantList of QString indicating enabled (acknowledged) capabilities and values
571 inline void initSetCapsEnabled(const QVariantList& capsEnabled) { _capsEnabled = fromVariantList<QString>(capsEnabled); }
572 inline void initSetServerList(const QVariantList& serverList) { _serverList = fromVariantList<Server>(serverList); }
573 virtual void initSetIrcUsersAndChannels(const QVariantMap& usersAndChannels);
576 * Update IrcUser hostmask and username from mask, creating an IrcUser if one does not exist.
578 * @param[in] mask Full nick!user@hostmask string
579 * @return IrcUser of the matching nick if exists, otherwise a new IrcUser
581 IrcUser* updateNickFromMask(const QString& mask);
583 // these slots are to keep the hashlists of all users and the
584 // channel lists up to date
585 void ircUserNickChanged(QString newnick);
587 virtual inline void requestConnect() const { REQUEST(NO_ARG) }
588 virtual inline void requestDisconnect() const { REQUEST(NO_ARG) }
589 virtual inline void requestSetNetworkInfo(const NetworkInfo& info) { REQUEST(ARG(info)) }
591 void emitConnectionError(const QString&);
594 virtual void removeIrcUser(IrcUser* ircuser);
595 virtual void removeIrcChannel(IrcChannel* ircChannel);
596 virtual void removeChansAndUsers();
599 void aboutToBeDestroyed();
600 void networkNameSet(const QString& networkName);
601 void currentServerSet(const QString& currentServer);
602 void connectedSet(bool isConnected);
603 void connectionStateSet(Network::ConnectionState);
604 // void connectionStateSet(int);
605 void connectionError(const QString& errorMsg);
606 void myNickSet(const QString& mynick);
607 // void latencySet(int latency);
608 void identitySet(IdentityId);
610 void configChanged();
612 // void serverListSet(QVariantList serverList);
613 // void useRandomServerSet(bool);
614 // void performSet(const QStringList &);
615 // void useAutoIdentifySet(bool);
616 // void autoIdentifyServiceSet(const QString &);
617 // void autoIdentifyPasswordSet(const QString &);
618 // void useAutoReconnectSet(bool);
619 // void autoReconnectIntervalSet(quint32);
620 // void autoReconnectRetriesSet(quint16);
621 // void unlimitedReconnectRetriesSet(bool);
622 // void rejoinChannelsSet(bool);
624 // Custom rate limiting (can drive other slots)
627 * Signals enabling or disabling custom rate limiting
629 * @see Network::useCustomMessageRate()
631 * @param[out] useCustomRate
633 void useCustomMessageRateSet(const bool useCustomRate);
636 * Signals a change in maximum number of messages to send without any delays
638 * @see Network::messageRateBurstSize()
640 * @param[out] burstSize
642 void messageRateBurstSizeSet(const quint32 burstSize);
645 * Signals a change in delay between messages after the max. undelayed messages have been sent
647 * @see Network::messageRateDelay()
649 * @param[out] messageDelay
651 void messageRateDelaySet(const quint32 messageDelay);
654 * Signals enabling or disabling all rate limiting
656 * @see Network::unlimitedMessageRate()
658 * @param[out] unlimitedRate
660 void unlimitedMessageRateSet(const bool unlimitedRate);
662 // void codecForServerSet(const QByteArray &codecName);
663 // void codecForEncodingSet(const QByteArray &codecName);
664 // void codecForDecodingSet(const QByteArray &codecName);
666 // void supportAdded(const QString ¶m, const QString &value);
667 // void supportRemoved(const QString ¶m);
669 // IRCv3 capability negotiation (can drive other slots)
671 * Indicates a capability is now available, with optional value in Network::capValue().
673 * @see Network::addCap()
675 * @param[in] capability Name of the capability
677 void capAdded(const QString& capability);
680 * Indicates a capability was acknowledged (enabled by the IRC server).
682 * @see Network::acknowledgeCap()
684 * @param[in] capability Name of the capability
686 void capAcknowledged(const QString& capability);
689 * Indicates a capability was removed from the list of available capabilities.
691 * @see Network::removeCap()
693 * @param[in] capability Name of the capability
695 void capRemoved(const QString& capability);
697 // void ircUserAdded(const QString &hostmask);
698 void ircUserAdded(IrcUser*);
699 // void ircChannelAdded(const QString &channelname);
700 void ircChannelAdded(IrcChannel*);
702 // void connectRequested() const;
703 // void disconnectRequested() const;
704 // void setNetworkInfoRequested(const NetworkInfo &) const;
707 inline virtual IrcChannel* ircChannelFactory(const QString& channelname) { return new IrcChannel(channelname, this); }
708 inline virtual IrcUser* ircUserFactory(const QString& hostmask) { return new IrcUser(hostmask, this); }
711 QPointer<SignalProxy> _proxy;
713 NetworkId _networkId;
714 IdentityId _identity;
718 QString _networkName;
719 QString _currentServer;
721 ConnectionState _connectionState;
723 mutable QString _prefixes;
724 mutable QString _prefixModes;
726 QHash<QString, IrcUser*> _ircUsers; // stores all known nicks for the server
727 QHash<QString, IrcChannel*> _ircChannels; // stores all known channels
728 QHash<QString, QString> _supports; // stores results from RPL_ISUPPORT
730 QHash<QString, QString> _caps; /// Capabilities supported by the IRC server
731 // By synchronizing the supported capabilities, the client could suggest certain behaviors, e.g.
732 // in the Network settings dialog, recommending SASL instead of using NickServ, or warning if
733 // SASL EXTERNAL isn't available.
734 QStringList _capsEnabled; /// Enabled capabilities that received 'CAP ACK'
735 // _capsEnabled uses the same values from the <name>=<value> pairs stored in _caps
737 ServerList _serverList;
738 bool _useRandomServer;
739 QStringList _perform;
741 bool _useAutoIdentify;
742 QString _autoIdentifyService;
743 QString _autoIdentifyPassword;
746 QString _saslAccount;
747 QString _saslPassword;
749 bool _useAutoReconnect;
750 quint32 _autoReconnectInterval;
751 quint16 _autoReconnectRetries;
752 bool _unlimitedReconnectRetries;
753 bool _rejoinChannels;
755 // Custom rate limiting
756 bool _useCustomMessageRate; /// If true, use custom rate limits, otherwise use defaults
757 quint32 _messageRateBurstSize; /// Maximum number of messages to send without any delays
758 quint32 _messageRateDelay; /// Delay in ms. for messages when max. burst messages sent
759 bool _unlimitedMessageRate; /// If true, disable rate limiting, otherwise apply limits
761 QTextCodec* _codecForServer;
762 QTextCodec* _codecForEncoding;
763 QTextCodec* _codecForDecoding;
765 static QTextCodec* _defaultCodecForServer;
766 static QTextCodec* _defaultCodecForEncoding;
767 static QTextCodec* _defaultCodecForDecoding;
769 bool _autoAwayActive; // when this is active handle305 and handle306 don't trigger any output
771 friend class IrcUser;
772 friend class IrcChannel;
775 //! Stores all editable information about a network (as opposed to runtime state).
776 struct COMMON_EXPORT NetworkInfo
780 Network::ServerList serverList;
783 QString autoIdentifyService{"NickServ"};
784 QString autoIdentifyPassword;
787 QString saslPassword;
789 QByteArray codecForServer;
790 QByteArray codecForEncoding;
791 QByteArray codecForDecoding;
793 NetworkId networkId{0};
794 IdentityId identity{1};
796 quint32 messageRateBurstSize{5}; ///< Maximum number of messages to send without any delays
797 quint32 messageRateDelay{2200}; ///< Delay in ms. for messages when max. burst messages sent
799 quint32 autoReconnectInterval{60};
800 quint16 autoReconnectRetries{20};
802 bool rejoinChannels{true};
803 bool useRandomServer{false};
804 bool useAutoIdentify{false};
806 bool useAutoReconnect{true};
807 bool unlimitedReconnectRetries{false};
808 bool useCustomMessageRate{false}; ///< If true, use custom rate limits, otherwise use defaults
809 bool unlimitedMessageRate{false}; ///< If true, disable rate limiting, otherwise apply limits
812 bool operator==(const NetworkInfo& other) const;
813 bool operator!=(const NetworkInfo& other) const;
816 COMMON_EXPORT QDataStream& operator<<(QDataStream& out, const NetworkInfo& info);
817 COMMON_EXPORT QDataStream& operator>>(QDataStream& in, NetworkInfo& info);
818 COMMON_EXPORT QDebug operator<<(QDebug dbg, const NetworkInfo& i);
819 Q_DECLARE_METATYPE(NetworkInfo)
821 COMMON_EXPORT QDataStream& operator<<(QDataStream& out, const Network::Server& server);
822 COMMON_EXPORT QDataStream& operator>>(QDataStream& in, Network::Server& server);
823 COMMON_EXPORT QDebug operator<<(QDebug dbg, const Network::Server& server);
824 Q_DECLARE_METATYPE(Network::Server)