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 ***************************************************************************/
27 QTextCodec *Network::_defaultCodecForServer = 0;
28 QTextCodec *Network::_defaultCodecForEncoding = 0;
29 QTextCodec *Network::_defaultCodecForDecoding = 0;
30 // ====================
32 // ====================
33 Network::Network(const NetworkId &networkid, QObject *parent)
34 : SyncableObject(parent),
36 _networkId(networkid),
40 _networkName(QString("<not initialized>")),
41 _currentServer(QString()),
43 _connectionState(Disconnected),
45 _prefixModes(QString()),
46 _useRandomServer(false),
47 _useAutoIdentify(false),
48 _useAutoReconnect(false),
49 _autoReconnectInterval(60),
50 _autoReconnectRetries(10),
51 _unlimitedReconnectRetries(false),
55 _autoAwayActive(false)
57 setObjectName(QString::number(networkid.toInt()));
61 emit aboutToBeDestroyed();
64 bool Network::isChannelName(const QString &channelname) const {
65 if(channelname.isEmpty())
68 if(supports("CHANTYPES"))
69 return support("CHANTYPES").contains(channelname[0]);
71 return QString("#&!+").contains(channelname[0]);
74 NetworkInfo Network::networkInfo() const {
76 info.networkName = networkName();
77 info.networkId = networkId();
78 info.identity = identity();
79 info.codecForServer = codecForServer();
80 info.codecForEncoding = codecForEncoding();
81 info.codecForDecoding = codecForDecoding();
82 info.serverList = serverList();
83 info.useRandomServer = useRandomServer();
84 info.perform = perform();
85 info.useAutoIdentify = useAutoIdentify();
86 info.autoIdentifyService = autoIdentifyService();
87 info.autoIdentifyPassword = autoIdentifyPassword();
88 info.useAutoReconnect = useAutoReconnect();
89 info.autoReconnectInterval = autoReconnectInterval();
90 info.autoReconnectRetries = autoReconnectRetries();
91 info.unlimitedReconnectRetries = unlimitedReconnectRetries();
92 info.rejoinChannels = rejoinChannels();
96 void Network::setNetworkInfo(const NetworkInfo &info) {
97 // we don't set our ID!
98 if(!info.networkName.isEmpty() && info.networkName != networkName()) setNetworkName(info.networkName);
99 if(info.identity > 0 && info.identity != identity()) setIdentity(info.identity);
100 if(info.codecForServer != codecForServer()) setCodecForServer(QTextCodec::codecForName(info.codecForServer));
101 if(info.codecForEncoding != codecForEncoding()) setCodecForEncoding(QTextCodec::codecForName(info.codecForEncoding));
102 if(info.codecForDecoding != codecForDecoding()) setCodecForDecoding(QTextCodec::codecForName(info.codecForDecoding));
103 if(info.serverList.count()) setServerList(info.serverList); // FIXME compare components
104 if(info.useRandomServer != useRandomServer()) setUseRandomServer(info.useRandomServer);
105 if(info.perform != perform()) setPerform(info.perform);
106 if(info.useAutoIdentify != useAutoIdentify()) setUseAutoIdentify(info.useAutoIdentify);
107 if(info.autoIdentifyService != autoIdentifyService()) setAutoIdentifyService(info.autoIdentifyService);
108 if(info.autoIdentifyPassword != autoIdentifyPassword()) setAutoIdentifyPassword(info.autoIdentifyPassword);
109 if(info.useAutoReconnect != useAutoReconnect()) setUseAutoReconnect(info.useAutoReconnect);
110 if(info.autoReconnectInterval != autoReconnectInterval()) setAutoReconnectInterval(info.autoReconnectInterval);
111 if(info.autoReconnectRetries != autoReconnectRetries()) setAutoReconnectRetries(info.autoReconnectRetries);
112 if(info.unlimitedReconnectRetries != unlimitedReconnectRetries()) setUnlimitedReconnectRetries(info.unlimitedReconnectRetries);
113 if(info.rejoinChannels != rejoinChannels()) setRejoinChannels(info.rejoinChannels);
116 QString Network::prefixToMode(const QString &prefix) {
117 if(prefixes().contains(prefix))
118 return QString(prefixModes()[prefixes().indexOf(prefix)]);
123 QString Network::modeToPrefix(const QString &mode) {
124 if(prefixModes().contains(mode))
125 return QString(prefixes()[prefixModes().indexOf(mode)]);
130 QStringList Network::nicks() const {
131 // we don't use _ircUsers.keys() since the keys may be
132 // not up to date after a nick change
134 foreach(IrcUser *ircuser, _ircUsers.values()) {
135 nicks << ircuser->nick();
140 QString Network::prefixes() {
141 if(_prefixes.isNull())
147 QString Network::prefixModes() {
148 if(_prefixModes.isNull())
154 // example Unreal IRCD: CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG
155 Network::ChannelModeType Network::channelModeType(const QString &mode) {
157 return NOT_A_CHANMODE;
159 QString chanmodes = support("CHANMODES");
160 if(chanmodes.isEmpty())
161 return NOT_A_CHANMODE;
163 ChannelModeType modeType = A_CHANMODE;
164 for(int i = 0; i < chanmodes.count(); i++) {
165 if(chanmodes[i] == mode[0])
167 else if(chanmodes[i] == ',')
168 modeType = (ChannelModeType)(modeType << 1);
170 if(modeType > D_CHANMODE) {
171 qWarning() << "Network" << networkId() << "supplied invalid CHANMODES:" << chanmodes;
172 modeType = NOT_A_CHANMODE;
177 QString Network::support(const QString ¶m) const {
178 QString support_ = param.toUpper();
179 if(_supports.contains(support_))
180 return _supports[support_];
185 IrcUser *Network::newIrcUser(const QString &hostmask) {
186 QString nick(nickFromMask(hostmask).toLower());
187 if(!_ircUsers.contains(nick)) {
188 IrcUser *ircuser = new IrcUser(hostmask, this);
191 proxy()->synchronize(ircuser);
193 qWarning() << "unable to synchronize new IrcUser" << hostmask << "forgot to call Network::setProxy(SignalProxy *)?";
195 connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
196 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
197 connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
198 _ircUsers[nick] = ircuser;
199 emit ircUserAdded(hostmask);
200 emit ircUserAdded(ircuser);
202 return _ircUsers[nick];
205 void Network::ircUserDestroyed() {
206 IrcUser *ircUser = static_cast<IrcUser *>(sender());
210 QHash<QString, IrcUser *>::iterator ircUserIter = _ircUsers.begin();
211 while(ircUserIter != _ircUsers.end()) {
212 if(ircUser == *ircUserIter) {
213 ircUserIter = _ircUsers.erase(ircUserIter);
220 void Network::removeIrcUser(IrcUser *ircuser) {
221 QString nick = _ircUsers.key(ircuser);
225 _ircUsers.remove(nick);
226 disconnect(ircuser, 0, this, 0);
227 emit ircUserRemoved(nick);
228 emit ircUserRemoved(ircuser);
229 ircuser->deleteLater();
232 void Network::removeIrcUser(const QString &nick) {
234 if((ircuser = ircUser(nick)) != 0)
235 removeIrcUser(ircuser);
238 void Network::removeChansAndUsers() {
239 QList<IrcUser *> users = ircUsers();
240 foreach(IrcUser *user, users) {
243 QList<IrcChannel *> channels = ircChannels();
244 foreach(IrcChannel *channel, channels) {
245 removeIrcChannel(channel);
249 IrcUser *Network::ircUser(QString nickname) const {
250 nickname = nickname.toLower();
251 if(_ircUsers.contains(nickname))
252 return _ircUsers[nickname];
257 IrcChannel *Network::newIrcChannel(const QString &channelname) {
258 if(!_ircChannels.contains(channelname.toLower())) {
259 IrcChannel *channel = new IrcChannel(channelname, this);
262 proxy()->synchronize(channel);
264 qWarning() << "unable to synchronize new IrcChannel" << channelname << "forgot to call Network::setProxy(SignalProxy *)?";
266 connect(channel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
267 connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
268 _ircChannels[channelname.toLower()] = channel;
269 emit ircChannelAdded(channelname);
270 emit ircChannelAdded(channel);
272 return _ircChannels[channelname.toLower()];
275 IrcChannel *Network::ircChannel(QString channelname) const {
276 channelname = channelname.toLower();
277 if(_ircChannels.contains(channelname))
278 return _ircChannels[channelname];
283 QByteArray Network::defaultCodecForServer() {
284 if(_defaultCodecForServer)
285 return _defaultCodecForServer->name();
289 void Network::setDefaultCodecForServer(const QByteArray &name) {
290 _defaultCodecForServer = QTextCodec::codecForName(name);
293 QByteArray Network::defaultCodecForEncoding() {
294 if(_defaultCodecForEncoding)
295 return _defaultCodecForEncoding->name();
299 void Network::setDefaultCodecForEncoding(const QByteArray &name) {
300 _defaultCodecForEncoding = QTextCodec::codecForName(name);
303 QByteArray Network::defaultCodecForDecoding() {
304 if(_defaultCodecForDecoding)
305 return _defaultCodecForDecoding->name();
309 void Network::setDefaultCodecForDecoding(const QByteArray &name) {
310 _defaultCodecForDecoding = QTextCodec::codecForName(name);
313 QByteArray Network::codecForServer() const {
315 return _codecForServer->name();
319 void Network::setCodecForServer(const QByteArray &name) {
320 setCodecForServer(QTextCodec::codecForName(name));
323 void Network::setCodecForServer(QTextCodec *codec) {
324 _codecForServer = codec;
325 emit codecForServerSet(codecForServer());
328 QByteArray Network::codecForEncoding() const {
329 if(_codecForEncoding)
330 return _codecForEncoding->name();
334 void Network::setCodecForEncoding(const QByteArray &name) {
335 setCodecForEncoding(QTextCodec::codecForName(name));
338 void Network::setCodecForEncoding(QTextCodec *codec) {
339 _codecForEncoding = codec;
340 emit codecForEncodingSet(codecForEncoding());
343 QByteArray Network::codecForDecoding() const {
344 if(_codecForDecoding)
345 return _codecForDecoding->name();
346 else return QByteArray();
349 void Network::setCodecForDecoding(const QByteArray &name) {
350 setCodecForDecoding(QTextCodec::codecForName(name));
353 void Network::setCodecForDecoding(QTextCodec *codec) {
354 _codecForDecoding = codec;
355 emit codecForDecodingSet(codecForDecoding());
358 // FIXME use server encoding if appropriate
359 QString Network::decodeString(const QByteArray &text) const {
360 if(_codecForDecoding)
361 return ::decodeString(text, _codecForDecoding);
362 else return ::decodeString(text, _defaultCodecForDecoding);
365 QByteArray Network::encodeString(const QString &string) const {
366 if(_codecForEncoding) {
367 return _codecForEncoding->fromUnicode(string);
369 if(_defaultCodecForEncoding) {
370 return _defaultCodecForEncoding->fromUnicode(string);
372 return string.toAscii();
375 QString Network::decodeServerString(const QByteArray &text) const {
377 return ::decodeString(text, _codecForServer);
379 return ::decodeString(text, _defaultCodecForServer);
382 QByteArray Network::encodeServerString(const QString &string) const {
383 if(_codecForServer) {
384 return _codecForServer->fromUnicode(string);
386 if(_defaultCodecForServer) {
387 return _defaultCodecForServer->fromUnicode(string);
389 return string.toAscii();
392 // ====================
394 // ====================
395 void Network::setNetworkName(const QString &networkName) {
396 _networkName = networkName;
397 emit networkNameSet(networkName);
400 void Network::setCurrentServer(const QString ¤tServer) {
401 _currentServer = currentServer;
402 emit currentServerSet(currentServer);
405 void Network::setConnected(bool connected) {
406 if(_connected == connected)
409 _connected = connected;
411 setMyNick(QString());
412 setCurrentServer(QString());
413 removeChansAndUsers();
415 emit connectedSet(connected);
418 //void Network::setConnectionState(ConnectionState state) {
419 void Network::setConnectionState(int state) {
420 _connectionState = (ConnectionState)state;
421 //qDebug() << "netstate" << networkId() << networkName() << state;
422 emit connectionStateSet(state);
423 emit connectionStateSet(_connectionState);
426 void Network::setMyNick(const QString &nickname) {
428 if(!_myNick.isEmpty() && !ircUser(myNick())) {
429 newIrcUser(myNick());
431 emit myNickSet(nickname);
434 void Network::setLatency(int latency) {
435 if(_latency == latency)
438 emit latencySet(latency);
441 void Network::setIdentity(IdentityId id) {
443 emit identitySet(id);
446 void Network::setServerList(const QVariantList &serverList) {
447 _serverList = serverList;
448 emit serverListSet(serverList);
451 void Network::setUseRandomServer(bool use) {
452 _useRandomServer = use;
453 emit useRandomServerSet(use);
456 void Network::setPerform(const QStringList &perform) {
458 emit performSet(perform);
461 void Network::setUseAutoIdentify(bool use) {
462 _useAutoIdentify = use;
463 emit useAutoIdentifySet(use);
466 void Network::setAutoIdentifyService(const QString &service) {
467 _autoIdentifyService = service;
468 emit autoIdentifyServiceSet(service);
471 void Network::setAutoIdentifyPassword(const QString &password) {
472 _autoIdentifyPassword = password;
473 emit autoIdentifyPasswordSet(password);
476 void Network::setUseAutoReconnect(bool use) {
477 _useAutoReconnect = use;
478 emit useAutoReconnectSet(use);
481 void Network::setAutoReconnectInterval(quint32 interval) {
482 _autoReconnectInterval = interval;
483 emit autoReconnectIntervalSet(interval);
486 void Network::setAutoReconnectRetries(quint16 retries) {
487 _autoReconnectRetries = retries;
488 emit autoReconnectRetriesSet(retries);
491 void Network::setUnlimitedReconnectRetries(bool unlimited) {
492 _unlimitedReconnectRetries = unlimited;
493 emit unlimitedReconnectRetriesSet(unlimited);
496 void Network::setRejoinChannels(bool rejoin) {
497 _rejoinChannels = rejoin;
498 emit rejoinChannelsSet(rejoin);
501 void Network::addSupport(const QString ¶m, const QString &value) {
502 if(!_supports.contains(param)) {
503 _supports[param] = value;
504 emit supportAdded(param, value);
508 void Network::removeSupport(const QString ¶m) {
509 if(_supports.contains(param)) {
510 _supports.remove(param);
511 emit supportRemoved(param);
515 QVariantMap Network::initSupports() const {
516 QVariantMap supports;
517 QHashIterator<QString, QString> iter(_supports);
518 while(iter.hasNext()) {
520 supports[iter.key()] = iter.value();
525 QVariantMap Network::initIrcUsersAndChannels() const {
526 QVariantMap usersAndChannels;
528 QVariantMap channels;
530 QHash<QString, IrcUser *>::const_iterator userIter = _ircUsers.constBegin();
531 QHash<QString, IrcUser *>::const_iterator userIterEnd = _ircUsers.constEnd();
532 while(userIter != userIterEnd) {
533 users[userIter.value()->hostmask()] = userIter.value()->toVariantMap();
536 usersAndChannels["users"] = users;
538 QHash<QString, IrcChannel *>::const_iterator channelIter = _ircChannels.constBegin();
539 QHash<QString, IrcChannel *>::const_iterator channelIterEnd = _ircChannels.constEnd();
540 while(channelIter != channelIterEnd) {
541 channels[channelIter.value()->name()] = channelIter.value()->toVariantMap();
544 usersAndChannels["channels"] = channels;
546 return usersAndChannels;
549 void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) {
551 if(isInitialized()) {
552 qWarning() << "Network" << networkId() << "received init data for users and channels allthough there allready are known users or channels!";
556 QVariantMap users = usersAndChannels.value("users").toMap();
558 QVariantMap::const_iterator userIter = users.constBegin();
559 QVariantMap::const_iterator userIterEnd = users.constEnd();
560 IrcUser *ircUser = 0;
562 while(userIter != userIterEnd) {
563 hostmask = userIter.key();
564 ircUser = new IrcUser(hostmask, this);
565 ircUser->fromVariantMap(userIter.value().toMap());
566 ircUser->setInitialized();
567 proxy()->synchronize(ircUser);
569 connect(ircUser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
570 connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
572 _ircUsers[nickFromMask(hostmask).toLower()] = ircUser;
574 emit ircUserAdded(hostmask);
575 emit ircUserAdded(ircUser);
576 emit ircUserInitDone(ircUser);
582 QVariantMap channels = usersAndChannels.value("channels").toMap();
583 QVariantMap::const_iterator channelIter = channels.constBegin();
584 QVariantMap::const_iterator channelIterEnd = channels.constEnd();
585 IrcChannel *ircChannel = 0;
588 while(channelIter != channelIterEnd) {
589 channelName = channelIter.key();
590 ircChannel = new IrcChannel(channelName, this);
591 ircChannel->fromVariantMap(channelIter.value().toMap());
592 ircChannel->setInitialized();
593 proxy()->synchronize(ircChannel);
595 connect(ircChannel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
596 _ircChannels[channelName.toLower()] = ircChannel;
598 emit ircChannelAdded(channelName);
599 emit ircChannelAdded(ircChannel);
600 emit ircChannelInitDone(ircChannel);
607 void Network::initSetSupports(const QVariantMap &supports) {
608 QMapIterator<QString, QVariant> iter(supports);
609 while(iter.hasNext()) {
611 addSupport(iter.key(), iter.value().toString());
615 IrcUser *Network::updateNickFromMask(const QString &mask) {
616 QString nick(nickFromMask(mask).toLower());
619 if(_ircUsers.contains(nick)) {
620 ircuser = _ircUsers[nick];
621 ircuser->updateHostmask(mask);
623 ircuser = newIrcUser(mask);
628 void Network::ircUserNickChanged(QString newnick) {
629 QString oldnick = _ircUsers.key(qobject_cast<IrcUser*>(sender()));
634 if(newnick.toLower() != oldnick) _ircUsers[newnick.toLower()] = _ircUsers.take(oldnick);
636 if(myNick().toLower() == oldnick)
640 void Network::ircUserInitDone() {
641 IrcUser *ircuser = static_cast<IrcUser *>(sender());
643 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
644 emit ircUserInitDone(ircuser);
647 void Network::ircChannelInitDone() {
648 IrcChannel *ircChannel = static_cast<IrcChannel *>(sender());
649 Q_ASSERT(ircChannel);
650 disconnect(ircChannel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
651 emit ircChannelInitDone(ircChannel);
654 void Network::removeIrcChannel(IrcChannel *channel) {
655 QString chanName = _ircChannels.key(channel);
656 if(chanName.isNull())
659 _ircChannels.remove(chanName);
660 disconnect(channel, 0, this, 0);
661 emit ircChannelRemoved(chanName);
662 emit ircChannelRemoved(channel);
663 channel->deleteLater();
666 void Network::removeIrcChannel(const QString &channel) {
668 if((chan = ircChannel(channel)) != 0)
669 removeIrcChannel(chan);
672 void Network::channelDestroyed() {
673 IrcChannel *channel = static_cast<IrcChannel *>(sender());
675 _ircChannels.remove(_ircChannels.key(channel));
676 emit ircChannelRemoved(channel);
679 void Network::emitConnectionError(const QString &errorMsg) {
680 emit connectionError(errorMsg);
683 // ====================
685 // ====================
686 void Network::determinePrefixes() {
687 // seems like we have to construct them first
688 QString prefix = support("PREFIX");
690 if(prefix.startsWith("(") && prefix.contains(")")) {
691 _prefixes = prefix.section(")", 1);
692 _prefixModes = prefix.mid(1).section(")", 0, 0);
694 QString defaultPrefixes("~&@%+");
695 QString defaultPrefixModes("qaohv");
697 if(prefix.isEmpty()) {
698 _prefixes = defaultPrefixes;
699 _prefixModes = defaultPrefixModes;
703 // we just assume that in PREFIX are only prefix chars stored
704 for(int i = 0; i < defaultPrefixes.size(); i++) {
705 if(prefix.contains(defaultPrefixes[i])) {
706 _prefixes += defaultPrefixes[i];
707 _prefixModes += defaultPrefixModes[i];
711 if(!_prefixes.isNull())
714 // well... our assumption was obviously wrong...
715 // check if it's only prefix modes
716 for(int i = 0; i < defaultPrefixes.size(); i++) {
717 if(prefix.contains(defaultPrefixModes[i])) {
718 _prefixes += defaultPrefixes[i];
719 _prefixModes += defaultPrefixModes[i];
722 // now we've done all we've could...
726 /************************************************************************
728 ************************************************************************/
730 bool NetworkInfo::operator==(const NetworkInfo &other) const {
731 if(networkId != other.networkId) return false;
732 if(networkName != other.networkName) return false;
733 if(identity != other.identity) return false;
734 if(codecForServer != other.codecForServer) return false;
735 if(codecForEncoding != other.codecForEncoding) return false;
736 if(codecForDecoding != other.codecForDecoding) return false;
737 if(serverList != other.serverList) return false;
738 if(useRandomServer != other.useRandomServer) return false;
739 if(perform != other.perform) return false;
740 if(useAutoIdentify != other.useAutoIdentify) return false;
741 if(autoIdentifyService != other.autoIdentifyService) return false;
742 if(autoIdentifyPassword != other.autoIdentifyPassword) return false;
743 if(useAutoReconnect != other.useAutoReconnect) return false;
744 if(autoReconnectInterval != other.autoReconnectInterval) return false;
745 if(autoReconnectRetries != other.autoReconnectRetries) return false;
746 if(unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
747 if(rejoinChannels != other.rejoinChannels) return false;
751 bool NetworkInfo::operator!=(const NetworkInfo &other) const {
752 return !(*this == other);
755 QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) {
757 i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
758 i["NetworkName"] = info.networkName;
759 i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
760 i["CodecForServer"] = info.codecForServer;
761 i["CodecForEncoding"] = info.codecForEncoding;
762 i["CodecForDecoding"] = info.codecForDecoding;
763 i["ServerList"] = info.serverList;
764 i["UseRandomServer"] = info.useRandomServer;
765 i["Perform"] = info.perform;
766 i["UseAutoIdentify"] = info.useAutoIdentify;
767 i["AutoIdentifyService"] = info.autoIdentifyService;
768 i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
769 i["UseAutoReconnect"] = info.useAutoReconnect;
770 i["AutoReconnectInterval"] = info.autoReconnectInterval;
771 i["AutoReconnectRetries"] = info.autoReconnectRetries;
772 i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
773 i["RejoinChannels"] = info.rejoinChannels;
778 QDataStream &operator>>(QDataStream &in, NetworkInfo &info) {
781 info.networkId = i["NetworkId"].value<NetworkId>();
782 info.networkName = i["NetworkName"].toString();
783 info.identity = i["Identity"].value<IdentityId>();
784 info.codecForServer = i["CodecForServer"].toByteArray();
785 info.codecForEncoding = i["CodecForEncoding"].toByteArray();
786 info.codecForDecoding = i["CodecForDecoding"].toByteArray();
787 info.serverList = i["ServerList"].toList();
788 info.useRandomServer = i["UseRandomServer"].toBool();
789 info.perform = i["Perform"].toStringList();
790 info.useAutoIdentify = i["UseAutoIdentify"].toBool();
791 info.autoIdentifyService = i["AutoIdentifyService"].toString();
792 info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
793 info.useAutoReconnect = i["UseAutoReconnect"].toBool();
794 info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
795 info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
796 info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
797 info.rejoinChannels = i["RejoinChannels"].toBool();
801 QDebug operator<<(QDebug dbg, const NetworkInfo &i) {
802 dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
803 << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding
804 << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
805 << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
806 << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
807 << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
808 << " rejoinChannels = " << i.rejoinChannels << ")";