1 /***************************************************************************
2 * Copyright (C) 2005-08 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
22 #include "signalproxy.h"
24 #include "ircchannel.h"
31 QTextCodec *Network::_defaultCodecForServer = 0;
32 QTextCodec *Network::_defaultCodecForEncoding = 0;
33 QTextCodec *Network::_defaultCodecForDecoding = 0;
35 // ====================
37 // ====================
38 Network::Network(const NetworkId &networkid, QObject *parent) : SyncableObject(parent),
40 _networkId(networkid),
43 _networkName(QString("<not initialized>")),
44 _currentServer(QString()),
46 _connectionState(Disconnected),
48 _prefixModes(QString()),
49 _useRandomServer(false),
50 _useAutoIdentify(false),
51 _useAutoReconnect(false),
52 _autoReconnectInterval(60),
53 _autoReconnectRetries(10),
54 _unlimitedReconnectRetries(false),
59 setObjectName(QString::number(networkid.toInt()));
62 // I think this is unnecessary since IrcUsers have us as their daddy :)
65 emit aboutToBeDestroyed();
66 // QHashIterator<QString, IrcUser *> ircuser(_ircUsers);
67 // while (ircuser.hasNext()) {
69 // delete ircuser.value();
71 // qDebug() << "Destroying net" << networkName() << networkId();
75 NetworkId Network::networkId() const {
79 SignalProxy *Network::proxy() const {
83 void Network::setProxy(SignalProxy *proxy) {
85 //proxy->synchronize(this); // we should to this explicitly from the outside!
88 bool Network::isMyNick(const QString &nick) const {
89 return (myNick().toLower() == nick.toLower());
92 bool Network::isMe(IrcUser *ircuser) const {
93 return (ircuser->nick().toLower() == myNick().toLower());
96 bool Network::isChannelName(const QString &channelname) const {
97 if(channelname.isEmpty())
100 if(supports("CHANTYPES"))
101 return support("CHANTYPES").contains(channelname[0]);
103 return QString("#&!+").contains(channelname[0]);
106 bool Network::isConnected() const {
110 //Network::ConnectionState Network::connectionState() const {
111 int Network::connectionState() const {
112 return _connectionState;
115 NetworkInfo Network::networkInfo() const {
117 info.networkName = networkName();
118 info.networkId = networkId();
119 info.identity = identity();
120 info.codecForServer = codecForServer();
121 info.codecForEncoding = codecForEncoding();
122 info.codecForDecoding = codecForDecoding();
123 info.serverList = serverList();
124 info.useRandomServer = useRandomServer();
125 info.perform = perform();
126 info.useAutoIdentify = useAutoIdentify();
127 info.autoIdentifyService = autoIdentifyService();
128 info.autoIdentifyPassword = autoIdentifyPassword();
129 info.useAutoReconnect = useAutoReconnect();
130 info.autoReconnectInterval = autoReconnectInterval();
131 info.autoReconnectRetries = autoReconnectRetries();
132 info.unlimitedReconnectRetries = unlimitedReconnectRetries();
133 info.rejoinChannels = rejoinChannels();
137 void Network::setNetworkInfo(const NetworkInfo &info) {
138 // we don't set our ID!
139 if(!info.networkName.isEmpty() && info.networkName != networkName()) setNetworkName(info.networkName);
140 if(info.identity > 0 && info.identity != identity()) setIdentity(info.identity);
141 if(info.codecForServer != codecForServer()) setCodecForServer(QTextCodec::codecForName(info.codecForServer));
142 if(info.codecForEncoding != codecForEncoding()) setCodecForEncoding(QTextCodec::codecForName(info.codecForEncoding));
143 if(info.codecForDecoding != codecForDecoding()) setCodecForDecoding(QTextCodec::codecForName(info.codecForDecoding));
144 if(info.serverList.count()) setServerList(info.serverList); // FIXME compare components
145 if(info.useRandomServer != useRandomServer()) setUseRandomServer(info.useRandomServer);
146 if(info.perform != perform()) setPerform(info.perform);
147 if(info.useAutoIdentify != useAutoIdentify()) setUseAutoIdentify(info.useAutoIdentify);
148 if(info.autoIdentifyService != autoIdentifyService()) setAutoIdentifyService(info.autoIdentifyService);
149 if(info.autoIdentifyPassword != autoIdentifyPassword()) setAutoIdentifyPassword(info.autoIdentifyPassword);
150 if(info.useAutoReconnect != useAutoReconnect()) setUseAutoReconnect(info.useAutoReconnect);
151 if(info.autoReconnectInterval != autoReconnectInterval()) setAutoReconnectInterval(info.autoReconnectInterval);
152 if(info.autoReconnectRetries != autoReconnectRetries()) setAutoReconnectRetries(info.autoReconnectRetries);
153 if(info.unlimitedReconnectRetries != unlimitedReconnectRetries()) setUnlimitedReconnectRetries(info.unlimitedReconnectRetries);
154 if(info.rejoinChannels != rejoinChannels()) setRejoinChannels(info.rejoinChannels);
157 QString Network::prefixToMode(const QString &prefix) {
158 if(prefixes().contains(prefix))
159 return QString(prefixModes()[prefixes().indexOf(prefix)]);
164 QString Network::prefixToMode(const QCharRef &prefix) {
165 return prefixToMode(QString(prefix));
168 QString Network::modeToPrefix(const QString &mode) {
169 if(prefixModes().contains(mode))
170 return QString(prefixes()[prefixModes().indexOf(mode)]);
175 QString Network::modeToPrefix(const QCharRef &mode) {
176 return modeToPrefix(QString(mode));
179 QString Network::networkName() const {
183 QString Network::currentServer() const {
184 return _currentServer;
187 QString Network::myNick() const {
191 IdentityId Network::identity() const {
195 QStringList Network::nicks() const {
196 // we don't use _ircUsers.keys() since the keys may be
197 // not up to date after a nick change
199 foreach(IrcUser *ircuser, _ircUsers.values()) {
200 nicks << ircuser->nick();
205 QStringList Network::channels() const {
206 return _ircChannels.keys();
209 QVariantList Network::serverList() const {
213 bool Network::useRandomServer() const {
214 return _useRandomServer;
217 QStringList Network::perform() const {
221 bool Network::useAutoIdentify() const {
222 return _useAutoIdentify;
225 QString Network::autoIdentifyService() const {
226 return _autoIdentifyService;
229 QString Network::autoIdentifyPassword() const {
230 return _autoIdentifyPassword;
233 bool Network::useAutoReconnect() const {
234 return _useAutoReconnect;
237 quint32 Network::autoReconnectInterval() const {
238 return _autoReconnectInterval;
241 quint16 Network::autoReconnectRetries() const {
242 return _autoReconnectRetries;
245 bool Network::unlimitedReconnectRetries() const {
246 return _unlimitedReconnectRetries;
249 bool Network::rejoinChannels() const {
250 return _rejoinChannels;
253 QString Network::prefixes() {
254 if(_prefixes.isNull())
260 QString Network::prefixModes() {
261 if(_prefixModes.isNull())
267 bool Network::supports(const QString ¶m) const {
268 return _supports.contains(param);
271 QString Network::support(const QString ¶m) const {
272 QString support_ = param.toUpper();
273 if(_supports.contains(support_))
274 return _supports[support_];
279 IrcUser *Network::newIrcUser(const QString &hostmask) {
280 QString nick(nickFromMask(hostmask).toLower());
281 if(!_ircUsers.contains(nick)) {
282 IrcUser *ircuser = new IrcUser(hostmask, this);
285 proxy()->synchronize(ircuser);
287 qWarning() << "unable to synchronize new IrcUser" << hostmask << "forgot to call Network::setProxy(SignalProxy *)?";
289 connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
290 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
291 connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
292 _ircUsers[nick] = ircuser;
293 emit ircUserAdded(hostmask);
294 emit ircUserAdded(ircuser);
296 return _ircUsers[nick];
299 IrcUser *Network::newIrcUser(const QByteArray &hostmask) {
300 return newIrcUser(decodeServerString(hostmask));
303 void Network::ircUserDestroyed() {
304 IrcUser *ircUser = static_cast<IrcUser *>(sender());
308 QHash<QString, IrcUser *>::iterator ircUserIter = _ircUsers.begin();
309 while(ircUserIter != _ircUsers.end()) {
310 if(ircUser == *ircUserIter) {
311 ircUserIter = _ircUsers.erase(ircUserIter);
318 void Network::removeIrcUser(IrcUser *ircuser) {
319 QString nick = _ircUsers.key(ircuser);
323 _ircUsers.remove(nick);
324 disconnect(ircuser, 0, this, 0);
325 emit ircUserRemoved(nick);
326 emit ircUserRemoved(ircuser);
327 ircuser->deleteLater();
330 void Network::removeIrcUser(const QString &nick) {
332 if((ircuser = ircUser(nick)) != 0)
333 removeIrcUser(ircuser);
336 void Network::removeChansAndUsers() {
337 QList<IrcUser *> users = ircUsers();
338 foreach(IrcUser *user, users) {
341 QList<IrcChannel *> channels = ircChannels();
342 foreach(IrcChannel *channel, channels) {
343 removeIrcChannel(channel);
347 IrcUser *Network::ircUser(QString nickname) const {
348 nickname = nickname.toLower();
349 if(_ircUsers.contains(nickname))
350 return _ircUsers[nickname];
355 IrcUser *Network::ircUser(const QByteArray &nickname) const {
356 return ircUser(decodeServerString(nickname));
359 QList<IrcUser *> Network::ircUsers() const {
360 return _ircUsers.values();
363 quint32 Network::ircUserCount() const {
364 return _ircUsers.count();
367 IrcChannel *Network::newIrcChannel(const QString &channelname) {
368 if(!_ircChannels.contains(channelname.toLower())) {
369 IrcChannel *channel = new IrcChannel(channelname, this);
372 proxy()->synchronize(channel);
374 qWarning() << "unable to synchronize new IrcChannel" << channelname << "forgot to call Network::setProxy(SignalProxy *)?";
376 connect(channel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
377 connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
378 _ircChannels[channelname.toLower()] = channel;
379 emit ircChannelAdded(channelname);
380 emit ircChannelAdded(channel);
382 return _ircChannels[channelname.toLower()];
385 IrcChannel *Network::newIrcChannel(const QByteArray &channelname) {
386 return newIrcChannel(decodeServerString(channelname));
389 IrcChannel *Network::ircChannel(QString channelname) const {
390 channelname = channelname.toLower();
391 if(_ircChannels.contains(channelname))
392 return _ircChannels[channelname];
397 IrcChannel *Network::ircChannel(const QByteArray &channelname) const {
398 return ircChannel(decodeServerString(channelname));
402 QList<IrcChannel *> Network::ircChannels() const {
403 return _ircChannels.values();
406 quint32 Network::ircChannelCount() const {
407 return _ircChannels.count();
410 QByteArray Network::defaultCodecForServer() {
411 if(_defaultCodecForServer) return _defaultCodecForServer->name();
415 void Network::setDefaultCodecForServer(const QByteArray &name) {
416 _defaultCodecForServer = QTextCodec::codecForName(name);
419 QByteArray Network::defaultCodecForEncoding() {
420 if(_defaultCodecForEncoding) return _defaultCodecForEncoding->name();
424 void Network::setDefaultCodecForEncoding(const QByteArray &name) {
425 _defaultCodecForEncoding = QTextCodec::codecForName(name);
428 QByteArray Network::defaultCodecForDecoding() {
429 if(_defaultCodecForDecoding) return _defaultCodecForDecoding->name();
433 void Network::setDefaultCodecForDecoding(const QByteArray &name) {
434 _defaultCodecForDecoding = QTextCodec::codecForName(name);
437 QByteArray Network::codecForServer() const {
438 if(_codecForServer) return _codecForServer->name();
442 void Network::setCodecForServer(const QByteArray &name) {
443 setCodecForServer(QTextCodec::codecForName(name));
446 void Network::setCodecForServer(QTextCodec *codec) {
447 _codecForServer = codec;
448 emit codecForServerSet(codecForServer());
451 QByteArray Network::codecForEncoding() const {
452 if(_codecForEncoding) return _codecForEncoding->name();
456 void Network::setCodecForEncoding(const QByteArray &name) {
457 setCodecForEncoding(QTextCodec::codecForName(name));
460 void Network::setCodecForEncoding(QTextCodec *codec) {
461 _codecForEncoding = codec;
462 emit codecForEncodingSet(codecForEncoding());
465 QByteArray Network::codecForDecoding() const {
466 if(_codecForDecoding) return _codecForDecoding->name();
467 else return QByteArray();
470 void Network::setCodecForDecoding(const QByteArray &name) {
471 setCodecForDecoding(QTextCodec::codecForName(name));
474 void Network::setCodecForDecoding(QTextCodec *codec) {
475 _codecForDecoding = codec;
476 emit codecForDecodingSet(codecForDecoding());
479 // FIXME use server encoding if appropriate
480 QString Network::decodeString(const QByteArray &text) const {
481 if(_codecForDecoding) return ::decodeString(text, _codecForDecoding);
482 else return ::decodeString(text, _defaultCodecForDecoding);
485 QByteArray Network::encodeString(const QString &string) const {
486 if(_codecForEncoding) {
487 return _codecForEncoding->fromUnicode(string);
489 if(_defaultCodecForEncoding) {
490 return _defaultCodecForEncoding->fromUnicode(string);
492 return string.toAscii();
495 QString Network::decodeServerString(const QByteArray &text) const {
496 if(_codecForServer) return ::decodeString(text, _codecForServer);
497 else return ::decodeString(text, _defaultCodecForServer);
500 QByteArray Network::encodeServerString(const QString &string) const {
501 if(_codecForServer) {
502 return _codecForServer->fromUnicode(string);
504 if(_defaultCodecForServer) {
505 return _defaultCodecForServer->fromUnicode(string);
507 return string.toAscii();
510 // ====================
512 // ====================
513 void Network::setNetworkName(const QString &networkName) {
514 _networkName = networkName;
515 emit networkNameSet(networkName);
518 void Network::setCurrentServer(const QString ¤tServer) {
519 _currentServer = currentServer;
520 emit currentServerSet(currentServer);
523 void Network::setConnected(bool connected) {
524 _connected = connected;
526 removeChansAndUsers();
527 setCurrentServer(QString());
529 emit connectedSet(connected);
532 //void Network::setConnectionState(ConnectionState state) {
533 void Network::setConnectionState(int state) {
534 _connectionState = (ConnectionState)state;
535 //qDebug() << "netstate" << networkId() << networkName() << state;
536 emit connectionStateSet(state);
537 emit connectionStateSet(_connectionState);
540 void Network::setMyNick(const QString &nickname) {
542 emit myNickSet(nickname);
545 void Network::setIdentity(IdentityId id) {
547 emit identitySet(id);
550 void Network::setServerList(const QVariantList &serverList) {
551 _serverList = serverList;
552 emit serverListSet(serverList);
555 void Network::setUseRandomServer(bool use) {
556 _useRandomServer = use;
557 emit useRandomServerSet(use);
560 void Network::setPerform(const QStringList &perform) {
562 emit performSet(perform);
565 void Network::setUseAutoIdentify(bool use) {
566 _useAutoIdentify = use;
567 emit useAutoIdentifySet(use);
570 void Network::setAutoIdentifyService(const QString &service) {
571 _autoIdentifyService = service;
572 emit autoIdentifyServiceSet(service);
575 void Network::setAutoIdentifyPassword(const QString &password) {
576 _autoIdentifyPassword = password;
577 emit autoIdentifyPasswordSet(password);
580 void Network::setUseAutoReconnect(bool use) {
581 _useAutoReconnect = use;
582 emit useAutoReconnectSet(use);
585 void Network::setAutoReconnectInterval(quint32 interval) {
586 _autoReconnectInterval = interval;
587 emit autoReconnectIntervalSet(interval);
590 void Network::setAutoReconnectRetries(quint16 retries) {
591 _autoReconnectRetries = retries;
592 emit autoReconnectRetriesSet(retries);
595 void Network::setUnlimitedReconnectRetries(bool unlimited) {
596 _unlimitedReconnectRetries = unlimited;
597 emit unlimitedReconnectRetriesSet(unlimited);
600 void Network::setRejoinChannels(bool rejoin) {
601 _rejoinChannels = rejoin;
602 emit rejoinChannelsSet(rejoin);
605 void Network::addSupport(const QString ¶m, const QString &value) {
606 if(!_supports.contains(param)) {
607 _supports[param] = value;
608 emit supportAdded(param, value);
612 void Network::removeSupport(const QString ¶m) {
613 if(_supports.contains(param)) {
614 _supports.remove(param);
615 emit supportRemoved(param);
619 QVariantMap Network::initSupports() const {
620 QVariantMap supports;
621 QHashIterator<QString, QString> iter(_supports);
622 while(iter.hasNext()) {
624 supports[iter.key()] = iter.value();
629 QVariantList Network::initServerList() const {
633 QStringList Network::initIrcUsers() const {
634 QStringList hostmasks;
635 foreach(IrcUser *ircuser, ircUsers()) {
636 hostmasks << ircuser->hostmask();
641 QStringList Network::initIrcChannels() const {
642 QStringList channels;
643 QHash<QString, IrcChannel *>::const_iterator iter = _ircChannels.constBegin();
644 while(iter != _ircChannels.constEnd()) {
645 channels << iter.value()->name();
651 void Network::initSetSupports(const QVariantMap &supports) {
652 QMapIterator<QString, QVariant> iter(supports);
653 while(iter.hasNext()) {
655 addSupport(iter.key(), iter.value().toString());
659 void Network::initSetServerList(const QVariantList & serverList) {
660 setServerList(serverList);
663 void Network::initSetIrcUsers(const QStringList &hostmasks) {
664 if(!_ircUsers.empty())
666 foreach(QString hostmask, hostmasks) {
667 newIrcUser(hostmask);
671 void Network::initSetIrcChannels(const QStringList &channels) {
672 if(!_ircChannels.empty())
674 foreach(QString channel, channels)
675 newIrcChannel(channel);
678 IrcUser *Network::updateNickFromMask(const QString &mask) {
679 QString nick(nickFromMask(mask).toLower());
682 if(_ircUsers.contains(nick)) {
683 ircuser = _ircUsers[nick];
684 ircuser->updateHostmask(mask);
686 ircuser = newIrcUser(mask);
691 void Network::ircUserNickChanged(QString newnick) {
692 QString oldnick = _ircUsers.key(qobject_cast<IrcUser*>(sender()));
697 if(newnick.toLower() != oldnick) _ircUsers[newnick.toLower()] = _ircUsers.take(oldnick);
699 if(myNick().toLower() == oldnick)
703 void Network::ircUserInitDone() {
704 IrcUser *ircuser = static_cast<IrcUser *>(sender());
706 emit ircUserInitDone(ircuser);
709 void Network::ircChannelInitDone() {
710 IrcChannel *ircchannel = static_cast<IrcChannel *>(sender());
711 Q_ASSERT(ircchannel);
712 emit ircChannelInitDone(ircchannel);
715 void Network::removeIrcChannel(IrcChannel *channel) {
716 QString chanName = _ircChannels.key(channel);
717 if(chanName.isNull())
720 _ircChannels.remove(chanName);
721 disconnect(channel, 0, this, 0);
722 emit ircChannelRemoved(chanName);
723 emit ircChannelRemoved(channel);
724 channel->deleteLater();
727 void Network::removeIrcChannel(const QString &channel) {
729 if((chan = ircChannel(channel)) != 0)
730 removeIrcChannel(chan);
733 void Network::channelDestroyed() {
734 IrcChannel *channel = static_cast<IrcChannel *>(sender());
736 _ircChannels.remove(_ircChannels.key(channel));
737 emit ircChannelRemoved(channel);
740 void Network::requestConnect() const {
742 if(proxy()->proxyMode() == SignalProxy::Client) emit connectRequested(); // on the client this triggers calling this slot on the core
744 if(connectionState() != Disconnected) {
745 qWarning() << "Requesting connect while already being connected!";
748 emit connectRequested(networkId()); // and this is for CoreSession :)
752 void Network::requestDisconnect() const {
754 if(proxy()->proxyMode() == SignalProxy::Client) emit disconnectRequested(); // on the client this triggers calling this slot on the core
756 if(connectionState() == Disconnected) {
757 qWarning() << "Requesting disconnect while not being connected!";
760 emit disconnectRequested(networkId()); // and this is for CoreSession :)
764 void Network::emitConnectionError(const QString &errorMsg) {
765 emit connectionError(errorMsg);
768 // ====================
770 // ====================
771 void Network::determinePrefixes() {
772 // seems like we have to construct them first
773 QString PREFIX = support("PREFIX");
775 if(PREFIX.startsWith("(") && PREFIX.contains(")")) {
776 _prefixes = PREFIX.section(")", 1);
777 _prefixModes = PREFIX.mid(1).section(")", 0, 0);
779 QString defaultPrefixes("~&@%+");
780 QString defaultPrefixModes("qaohv");
782 // we just assume that in PREFIX are only prefix chars stored
783 for(int i = 0; i < defaultPrefixes.size(); i++) {
784 if(PREFIX.contains(defaultPrefixes[i])) {
785 _prefixes += defaultPrefixes[i];
786 _prefixModes += defaultPrefixModes[i];
790 if(!_prefixes.isNull())
793 // well... our assumption was obviously wrong...
794 // check if it's only prefix modes
795 for(int i = 0; i < defaultPrefixes.size(); i++) {
796 if(PREFIX.contains(defaultPrefixModes[i])) {
797 _prefixes += defaultPrefixes[i];
798 _prefixModes += defaultPrefixModes[i];
801 // now we've done all we've could...
805 /************************************************************************
807 ************************************************************************/
809 bool NetworkInfo::operator==(const NetworkInfo &other) const {
810 if(networkId != other.networkId) return false;
811 if(networkName != other.networkName) return false;
812 if(identity != other.identity) return false;
813 if(codecForServer != other.codecForServer) return false;
814 if(codecForEncoding != other.codecForEncoding) return false;
815 if(codecForDecoding != other.codecForDecoding) return false;
816 if(serverList != other.serverList) return false;
817 if(useRandomServer != other.useRandomServer) return false;
818 if(perform != other.perform) return false;
819 if(useAutoIdentify != other.useAutoIdentify) return false;
820 if(autoIdentifyService != other.autoIdentifyService) return false;
821 if(autoIdentifyPassword != other.autoIdentifyPassword) return false;
822 if(useAutoReconnect != other.useAutoReconnect) return false;
823 if(autoReconnectInterval != other.autoReconnectInterval) return false;
824 if(autoReconnectRetries != other.autoReconnectRetries) return false;
825 if(unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
826 if(rejoinChannels != other.rejoinChannels) return false;
830 bool NetworkInfo::operator!=(const NetworkInfo &other) const {
831 return !(*this == other);
834 QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) {
836 i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
837 i["NetworkName"] = info.networkName;
838 i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
839 i["CodecForServer"] = info.codecForServer;
840 i["CodecForEncoding"] = info.codecForEncoding;
841 i["CodecForDecoding"] = info.codecForDecoding;
842 i["ServerList"] = info.serverList;
843 i["UseRandomServer"] = info.useRandomServer;
844 i["Perform"] = info.perform;
845 i["UseAutoIdentify"] = info.useAutoIdentify;
846 i["AutoIdentifyService"] = info.autoIdentifyService;
847 i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
848 i["UseAutoReconnect"] = info.useAutoReconnect;
849 i["AutoReconnectInterval"] = info.autoReconnectInterval;
850 i["AutoReconnectRetries"] = info.autoReconnectRetries;
851 i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
852 i["RejoinChannels"] = info.rejoinChannels;
857 QDataStream &operator>>(QDataStream &in, NetworkInfo &info) {
860 info.networkId = i["NetworkId"].value<NetworkId>();
861 info.networkName = i["NetworkName"].toString();
862 info.identity = i["Identity"].value<IdentityId>();
863 info.codecForServer = i["CodecForServer"].toByteArray();
864 info.codecForEncoding = i["CodecForEncoding"].toByteArray();
865 info.codecForDecoding = i["CodecForDecoding"].toByteArray();
866 info.serverList = i["ServerList"].toList();
867 info.useRandomServer = i["UseRandomServer"].toBool();
868 info.perform = i["Perform"].toStringList();
869 info.useAutoIdentify = i["UseAutoIdentify"].toBool();
870 info.autoIdentifyService = i["AutoIdentifyService"].toString();
871 info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
872 info.useAutoReconnect = i["UseAutoReconnect"].toBool();
873 info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
874 info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
875 info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
876 info.rejoinChannels = i["RejoinChannels"].toBool();
880 QDebug operator<<(QDebug dbg, const NetworkInfo &i) {
881 dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
882 << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding
883 << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
884 << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
885 << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
886 << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
887 << " rejoinChannels = " << i.rejoinChannels << ")";