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),
56 setObjectName(QString::number(networkid.toInt()));
60 emit aboutToBeDestroyed();
63 bool Network::isChannelName(const QString &channelname) const {
64 if(channelname.isEmpty())
67 if(supports("CHANTYPES"))
68 return support("CHANTYPES").contains(channelname[0]);
70 return QString("#&!+").contains(channelname[0]);
73 NetworkInfo Network::networkInfo() const {
75 info.networkName = networkName();
76 info.networkId = networkId();
77 info.identity = identity();
78 info.codecForServer = codecForServer();
79 info.codecForEncoding = codecForEncoding();
80 info.codecForDecoding = codecForDecoding();
81 info.serverList = serverList();
82 info.useRandomServer = useRandomServer();
83 info.perform = perform();
84 info.useAutoIdentify = useAutoIdentify();
85 info.autoIdentifyService = autoIdentifyService();
86 info.autoIdentifyPassword = autoIdentifyPassword();
87 info.useAutoReconnect = useAutoReconnect();
88 info.autoReconnectInterval = autoReconnectInterval();
89 info.autoReconnectRetries = autoReconnectRetries();
90 info.unlimitedReconnectRetries = unlimitedReconnectRetries();
91 info.rejoinChannels = rejoinChannels();
95 void Network::setNetworkInfo(const NetworkInfo &info) {
96 // we don't set our ID!
97 if(!info.networkName.isEmpty() && info.networkName != networkName()) setNetworkName(info.networkName);
98 if(info.identity > 0 && info.identity != identity()) setIdentity(info.identity);
99 if(info.codecForServer != codecForServer()) setCodecForServer(QTextCodec::codecForName(info.codecForServer));
100 if(info.codecForEncoding != codecForEncoding()) setCodecForEncoding(QTextCodec::codecForName(info.codecForEncoding));
101 if(info.codecForDecoding != codecForDecoding()) setCodecForDecoding(QTextCodec::codecForName(info.codecForDecoding));
102 if(info.serverList.count()) setServerList(info.serverList); // FIXME compare components
103 if(info.useRandomServer != useRandomServer()) setUseRandomServer(info.useRandomServer);
104 if(info.perform != perform()) setPerform(info.perform);
105 if(info.useAutoIdentify != useAutoIdentify()) setUseAutoIdentify(info.useAutoIdentify);
106 if(info.autoIdentifyService != autoIdentifyService()) setAutoIdentifyService(info.autoIdentifyService);
107 if(info.autoIdentifyPassword != autoIdentifyPassword()) setAutoIdentifyPassword(info.autoIdentifyPassword);
108 if(info.useAutoReconnect != useAutoReconnect()) setUseAutoReconnect(info.useAutoReconnect);
109 if(info.autoReconnectInterval != autoReconnectInterval()) setAutoReconnectInterval(info.autoReconnectInterval);
110 if(info.autoReconnectRetries != autoReconnectRetries()) setAutoReconnectRetries(info.autoReconnectRetries);
111 if(info.unlimitedReconnectRetries != unlimitedReconnectRetries()) setUnlimitedReconnectRetries(info.unlimitedReconnectRetries);
112 if(info.rejoinChannels != rejoinChannels()) setRejoinChannels(info.rejoinChannels);
115 QString Network::prefixToMode(const QString &prefix) {
116 if(prefixes().contains(prefix))
117 return QString(prefixModes()[prefixes().indexOf(prefix)]);
122 QString Network::modeToPrefix(const QString &mode) {
123 if(prefixModes().contains(mode))
124 return QString(prefixes()[prefixModes().indexOf(mode)]);
129 QStringList Network::nicks() const {
130 // we don't use _ircUsers.keys() since the keys may be
131 // not up to date after a nick change
133 foreach(IrcUser *ircuser, _ircUsers.values()) {
134 nicks << ircuser->nick();
139 QString Network::prefixes() {
140 if(_prefixes.isNull())
146 QString Network::prefixModes() {
147 if(_prefixModes.isNull())
153 // example Unreal IRCD: CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG
154 Network::ChannelModeType Network::channelModeType(const QString &mode) {
156 return NOT_A_CHANMODE;
158 QString chanmodes = support("CHANMODES");
159 if(chanmodes.isEmpty())
160 return NOT_A_CHANMODE;
162 ChannelModeType modeType = A_CHANMODE;
163 for(int i = 0; i < chanmodes.count(); i++) {
164 if(chanmodes[i] == mode[0])
166 else if(chanmodes[i] == ',')
167 modeType = (ChannelModeType)(modeType << 1);
169 if(modeType > D_CHANMODE) {
170 qWarning() << "Network" << networkId() << "supplied invalid CHANMODES:" << chanmodes;
171 modeType = NOT_A_CHANMODE;
176 QString Network::support(const QString ¶m) const {
177 QString support_ = param.toUpper();
178 if(_supports.contains(support_))
179 return _supports[support_];
184 IrcUser *Network::newIrcUser(const QString &hostmask) {
185 QString nick(nickFromMask(hostmask).toLower());
186 if(!_ircUsers.contains(nick)) {
187 IrcUser *ircuser = new IrcUser(hostmask, this);
190 proxy()->synchronize(ircuser);
192 qWarning() << "unable to synchronize new IrcUser" << hostmask << "forgot to call Network::setProxy(SignalProxy *)?";
194 connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
195 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
196 connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
197 _ircUsers[nick] = ircuser;
198 emit ircUserAdded(hostmask);
199 emit ircUserAdded(ircuser);
201 return _ircUsers[nick];
204 void Network::ircUserDestroyed() {
205 IrcUser *ircUser = static_cast<IrcUser *>(sender());
209 QHash<QString, IrcUser *>::iterator ircUserIter = _ircUsers.begin();
210 while(ircUserIter != _ircUsers.end()) {
211 if(ircUser == *ircUserIter) {
212 ircUserIter = _ircUsers.erase(ircUserIter);
219 void Network::removeIrcUser(IrcUser *ircuser) {
220 QString nick = _ircUsers.key(ircuser);
224 _ircUsers.remove(nick);
225 disconnect(ircuser, 0, this, 0);
226 emit ircUserRemoved(nick);
227 emit ircUserRemoved(ircuser);
228 ircuser->deleteLater();
231 void Network::removeIrcUser(const QString &nick) {
233 if((ircuser = ircUser(nick)) != 0)
234 removeIrcUser(ircuser);
237 void Network::removeChansAndUsers() {
238 QList<IrcUser *> users = ircUsers();
239 foreach(IrcUser *user, users) {
242 QList<IrcChannel *> channels = ircChannels();
243 foreach(IrcChannel *channel, channels) {
244 removeIrcChannel(channel);
248 IrcUser *Network::ircUser(QString nickname) const {
249 nickname = nickname.toLower();
250 if(_ircUsers.contains(nickname))
251 return _ircUsers[nickname];
256 IrcChannel *Network::newIrcChannel(const QString &channelname) {
257 if(!_ircChannels.contains(channelname.toLower())) {
258 IrcChannel *channel = new IrcChannel(channelname, this);
261 proxy()->synchronize(channel);
263 qWarning() << "unable to synchronize new IrcChannel" << channelname << "forgot to call Network::setProxy(SignalProxy *)?";
265 connect(channel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
266 connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
267 _ircChannels[channelname.toLower()] = channel;
268 emit ircChannelAdded(channelname);
269 emit ircChannelAdded(channel);
271 return _ircChannels[channelname.toLower()];
274 IrcChannel *Network::ircChannel(QString channelname) const {
275 channelname = channelname.toLower();
276 if(_ircChannels.contains(channelname))
277 return _ircChannels[channelname];
282 QByteArray Network::defaultCodecForServer() {
283 if(_defaultCodecForServer)
284 return _defaultCodecForServer->name();
288 void Network::setDefaultCodecForServer(const QByteArray &name) {
289 _defaultCodecForServer = QTextCodec::codecForName(name);
292 QByteArray Network::defaultCodecForEncoding() {
293 if(_defaultCodecForEncoding)
294 return _defaultCodecForEncoding->name();
298 void Network::setDefaultCodecForEncoding(const QByteArray &name) {
299 _defaultCodecForEncoding = QTextCodec::codecForName(name);
302 QByteArray Network::defaultCodecForDecoding() {
303 if(_defaultCodecForDecoding)
304 return _defaultCodecForDecoding->name();
308 void Network::setDefaultCodecForDecoding(const QByteArray &name) {
309 _defaultCodecForDecoding = QTextCodec::codecForName(name);
312 QByteArray Network::codecForServer() const {
314 return _codecForServer->name();
318 void Network::setCodecForServer(const QByteArray &name) {
319 setCodecForServer(QTextCodec::codecForName(name));
322 void Network::setCodecForServer(QTextCodec *codec) {
323 _codecForServer = codec;
324 emit codecForServerSet(codecForServer());
327 QByteArray Network::codecForEncoding() const {
328 if(_codecForEncoding)
329 return _codecForEncoding->name();
333 void Network::setCodecForEncoding(const QByteArray &name) {
334 setCodecForEncoding(QTextCodec::codecForName(name));
337 void Network::setCodecForEncoding(QTextCodec *codec) {
338 _codecForEncoding = codec;
339 emit codecForEncodingSet(codecForEncoding());
342 QByteArray Network::codecForDecoding() const {
343 if(_codecForDecoding)
344 return _codecForDecoding->name();
345 else return QByteArray();
348 void Network::setCodecForDecoding(const QByteArray &name) {
349 setCodecForDecoding(QTextCodec::codecForName(name));
352 void Network::setCodecForDecoding(QTextCodec *codec) {
353 _codecForDecoding = codec;
354 emit codecForDecodingSet(codecForDecoding());
357 // FIXME use server encoding if appropriate
358 QString Network::decodeString(const QByteArray &text) const {
359 if(_codecForDecoding)
360 return ::decodeString(text, _codecForDecoding);
361 else return ::decodeString(text, _defaultCodecForDecoding);
364 QByteArray Network::encodeString(const QString &string) const {
365 if(_codecForEncoding) {
366 return _codecForEncoding->fromUnicode(string);
368 if(_defaultCodecForEncoding) {
369 return _defaultCodecForEncoding->fromUnicode(string);
371 return string.toAscii();
374 QString Network::decodeServerString(const QByteArray &text) const {
376 return ::decodeString(text, _codecForServer);
378 return ::decodeString(text, _defaultCodecForServer);
381 QByteArray Network::encodeServerString(const QString &string) const {
382 if(_codecForServer) {
383 return _codecForServer->fromUnicode(string);
385 if(_defaultCodecForServer) {
386 return _defaultCodecForServer->fromUnicode(string);
388 return string.toAscii();
391 // ====================
393 // ====================
394 void Network::setNetworkName(const QString &networkName) {
395 _networkName = networkName;
396 emit networkNameSet(networkName);
399 void Network::setCurrentServer(const QString ¤tServer) {
400 _currentServer = currentServer;
401 emit currentServerSet(currentServer);
404 void Network::setConnected(bool connected) {
405 if(_connected == connected)
408 _connected = connected;
410 setMyNick(QString());
411 setCurrentServer(QString());
412 removeChansAndUsers();
414 emit connectedSet(connected);
417 //void Network::setConnectionState(ConnectionState state) {
418 void Network::setConnectionState(int state) {
419 _connectionState = (ConnectionState)state;
420 //qDebug() << "netstate" << networkId() << networkName() << state;
421 emit connectionStateSet(state);
422 emit connectionStateSet(_connectionState);
425 void Network::setMyNick(const QString &nickname) {
427 if(!_myNick.isEmpty() && !ircUser(myNick())) {
428 newIrcUser(myNick());
430 emit myNickSet(nickname);
433 void Network::setLatency(int latency) {
434 if(_latency == latency)
437 emit latencySet(latency);
440 void Network::setIdentity(IdentityId id) {
442 emit identitySet(id);
445 void Network::setServerList(const QVariantList &serverList) {
446 _serverList = serverList;
447 emit serverListSet(serverList);
450 void Network::setUseRandomServer(bool use) {
451 _useRandomServer = use;
452 emit useRandomServerSet(use);
455 void Network::setPerform(const QStringList &perform) {
457 emit performSet(perform);
460 void Network::setUseAutoIdentify(bool use) {
461 _useAutoIdentify = use;
462 emit useAutoIdentifySet(use);
465 void Network::setAutoIdentifyService(const QString &service) {
466 _autoIdentifyService = service;
467 emit autoIdentifyServiceSet(service);
470 void Network::setAutoIdentifyPassword(const QString &password) {
471 _autoIdentifyPassword = password;
472 emit autoIdentifyPasswordSet(password);
475 void Network::setUseAutoReconnect(bool use) {
476 _useAutoReconnect = use;
477 emit useAutoReconnectSet(use);
480 void Network::setAutoReconnectInterval(quint32 interval) {
481 _autoReconnectInterval = interval;
482 emit autoReconnectIntervalSet(interval);
485 void Network::setAutoReconnectRetries(quint16 retries) {
486 _autoReconnectRetries = retries;
487 emit autoReconnectRetriesSet(retries);
490 void Network::setUnlimitedReconnectRetries(bool unlimited) {
491 _unlimitedReconnectRetries = unlimited;
492 emit unlimitedReconnectRetriesSet(unlimited);
495 void Network::setRejoinChannels(bool rejoin) {
496 _rejoinChannels = rejoin;
497 emit rejoinChannelsSet(rejoin);
500 void Network::addSupport(const QString ¶m, const QString &value) {
501 if(!_supports.contains(param)) {
502 _supports[param] = value;
503 emit supportAdded(param, value);
507 void Network::removeSupport(const QString ¶m) {
508 if(_supports.contains(param)) {
509 _supports.remove(param);
510 emit supportRemoved(param);
514 QVariantMap Network::initSupports() const {
515 QVariantMap supports;
516 QHashIterator<QString, QString> iter(_supports);
517 while(iter.hasNext()) {
519 supports[iter.key()] = iter.value();
524 QVariantMap Network::initIrcUsersAndChannels() const {
525 QVariantMap usersAndChannels;
527 QVariantMap channels;
529 QHash<QString, IrcUser *>::const_iterator userIter = _ircUsers.constBegin();
530 QHash<QString, IrcUser *>::const_iterator userIterEnd = _ircUsers.constEnd();
531 while(userIter != userIterEnd) {
532 users[userIter.value()->hostmask()] = userIter.value()->toVariantMap();
535 usersAndChannels["users"] = users;
537 QHash<QString, IrcChannel *>::const_iterator channelIter = _ircChannels.constBegin();
538 QHash<QString, IrcChannel *>::const_iterator channelIterEnd = _ircChannels.constEnd();
539 while(channelIter != channelIterEnd) {
540 channels[channelIter.value()->name()] = channelIter.value()->toVariantMap();
543 usersAndChannels["channels"] = channels;
545 return usersAndChannels;
548 void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) {
550 if(!_ircUsers.isEmpty() || !_ircChannels.isEmpty()) {
551 qWarning() << "Network" << networkId() << "received init data for users and channels allthough there allready are known users or channels!";
555 QVariantMap users = usersAndChannels.value("users").toMap();
557 QVariantMap::const_iterator userIter = users.constBegin();
558 QVariantMap::const_iterator userIterEnd = users.constEnd();
559 IrcUser *ircUser = 0;
561 while(userIter != userIterEnd) {
562 hostmask = userIter.key();
563 ircUser = new IrcUser(hostmask, this);
564 ircUser->fromVariantMap(userIter.value().toMap());
565 ircUser->setInitialized();
566 proxy()->synchronize(ircUser);
568 connect(ircUser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
569 connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
571 _ircUsers[nickFromMask(hostmask).toLower()] = ircUser;
573 emit ircUserAdded(hostmask);
574 emit ircUserAdded(ircUser);
575 emit ircUserInitDone(ircUser);
581 QVariantMap channels = usersAndChannels.value("channels").toMap();
582 QVariantMap::const_iterator channelIter = channels.constBegin();
583 QVariantMap::const_iterator channelIterEnd = channels.constEnd();
584 IrcChannel *ircChannel = 0;
587 while(channelIter != channelIterEnd) {
588 channelName = channelIter.key();
589 ircChannel = new IrcChannel(channelName, this);
590 ircChannel->fromVariantMap(channelIter.value().toMap());
591 ircChannel->setInitialized();
592 proxy()->synchronize(ircChannel);
594 connect(ircChannel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
595 _ircChannels[channelName.toLower()] = ircChannel;
597 emit ircChannelAdded(channelName);
598 emit ircChannelAdded(ircChannel);
599 emit ircChannelInitDone(ircChannel);
606 void Network::initSetSupports(const QVariantMap &supports) {
607 QMapIterator<QString, QVariant> iter(supports);
608 while(iter.hasNext()) {
610 addSupport(iter.key(), iter.value().toString());
614 IrcUser *Network::updateNickFromMask(const QString &mask) {
615 QString nick(nickFromMask(mask).toLower());
618 if(_ircUsers.contains(nick)) {
619 ircuser = _ircUsers[nick];
620 ircuser->updateHostmask(mask);
622 ircuser = newIrcUser(mask);
627 void Network::ircUserNickChanged(QString newnick) {
628 QString oldnick = _ircUsers.key(qobject_cast<IrcUser*>(sender()));
633 if(newnick.toLower() != oldnick) _ircUsers[newnick.toLower()] = _ircUsers.take(oldnick);
635 if(myNick().toLower() == oldnick)
639 void Network::ircUserInitDone() {
640 IrcUser *ircuser = static_cast<IrcUser *>(sender());
642 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
643 emit ircUserInitDone(ircuser);
646 void Network::ircChannelInitDone() {
647 IrcChannel *ircChannel = static_cast<IrcChannel *>(sender());
648 Q_ASSERT(ircChannel);
649 disconnect(ircChannel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
650 emit ircChannelInitDone(ircChannel);
653 void Network::removeIrcChannel(IrcChannel *channel) {
654 QString chanName = _ircChannels.key(channel);
655 if(chanName.isNull())
658 _ircChannels.remove(chanName);
659 disconnect(channel, 0, this, 0);
660 emit ircChannelRemoved(chanName);
661 emit ircChannelRemoved(channel);
662 channel->deleteLater();
665 void Network::removeIrcChannel(const QString &channel) {
667 if((chan = ircChannel(channel)) != 0)
668 removeIrcChannel(chan);
671 void Network::channelDestroyed() {
672 IrcChannel *channel = static_cast<IrcChannel *>(sender());
674 _ircChannels.remove(_ircChannels.key(channel));
675 emit ircChannelRemoved(channel);
678 void Network::emitConnectionError(const QString &errorMsg) {
679 emit connectionError(errorMsg);
682 // ====================
684 // ====================
685 void Network::determinePrefixes() {
686 // seems like we have to construct them first
687 QString PREFIX = support("PREFIX");
689 if(PREFIX.startsWith("(") && PREFIX.contains(")")) {
690 _prefixes = PREFIX.section(")", 1);
691 _prefixModes = PREFIX.mid(1).section(")", 0, 0);
693 QString defaultPrefixes("~&@%+");
694 QString defaultPrefixModes("qaohv");
696 if(PREFIX.isEmpty()) {
697 _prefixes = defaultPrefixes;
698 _prefixModes = defaultPrefixModes;
702 // we just assume that in PREFIX are only prefix chars stored
703 for(int i = 0; i < defaultPrefixes.size(); i++) {
704 if(PREFIX.contains(defaultPrefixes[i])) {
705 _prefixes += defaultPrefixes[i];
706 _prefixModes += defaultPrefixModes[i];
710 if(!_prefixes.isNull())
713 // well... our assumption was obviously wrong...
714 // check if it's only prefix modes
715 for(int i = 0; i < defaultPrefixes.size(); i++) {
716 if(PREFIX.contains(defaultPrefixModes[i])) {
717 _prefixes += defaultPrefixes[i];
718 _prefixModes += defaultPrefixModes[i];
721 // now we've done all we've could...
725 /************************************************************************
727 ************************************************************************/
729 bool NetworkInfo::operator==(const NetworkInfo &other) const {
730 if(networkId != other.networkId) return false;
731 if(networkName != other.networkName) return false;
732 if(identity != other.identity) return false;
733 if(codecForServer != other.codecForServer) return false;
734 if(codecForEncoding != other.codecForEncoding) return false;
735 if(codecForDecoding != other.codecForDecoding) return false;
736 if(serverList != other.serverList) return false;
737 if(useRandomServer != other.useRandomServer) return false;
738 if(perform != other.perform) return false;
739 if(useAutoIdentify != other.useAutoIdentify) return false;
740 if(autoIdentifyService != other.autoIdentifyService) return false;
741 if(autoIdentifyPassword != other.autoIdentifyPassword) return false;
742 if(useAutoReconnect != other.useAutoReconnect) return false;
743 if(autoReconnectInterval != other.autoReconnectInterval) return false;
744 if(autoReconnectRetries != other.autoReconnectRetries) return false;
745 if(unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
746 if(rejoinChannels != other.rejoinChannels) return false;
750 bool NetworkInfo::operator!=(const NetworkInfo &other) const {
751 return !(*this == other);
754 QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) {
756 i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
757 i["NetworkName"] = info.networkName;
758 i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
759 i["CodecForServer"] = info.codecForServer;
760 i["CodecForEncoding"] = info.codecForEncoding;
761 i["CodecForDecoding"] = info.codecForDecoding;
762 i["ServerList"] = info.serverList;
763 i["UseRandomServer"] = info.useRandomServer;
764 i["Perform"] = info.perform;
765 i["UseAutoIdentify"] = info.useAutoIdentify;
766 i["AutoIdentifyService"] = info.autoIdentifyService;
767 i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
768 i["UseAutoReconnect"] = info.useAutoReconnect;
769 i["AutoReconnectInterval"] = info.autoReconnectInterval;
770 i["AutoReconnectRetries"] = info.autoReconnectRetries;
771 i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
772 i["RejoinChannels"] = info.rejoinChannels;
777 QDataStream &operator>>(QDataStream &in, NetworkInfo &info) {
780 info.networkId = i["NetworkId"].value<NetworkId>();
781 info.networkName = i["NetworkName"].toString();
782 info.identity = i["Identity"].value<IdentityId>();
783 info.codecForServer = i["CodecForServer"].toByteArray();
784 info.codecForEncoding = i["CodecForEncoding"].toByteArray();
785 info.codecForDecoding = i["CodecForDecoding"].toByteArray();
786 info.serverList = i["ServerList"].toList();
787 info.useRandomServer = i["UseRandomServer"].toBool();
788 info.perform = i["Perform"].toStringList();
789 info.useAutoIdentify = i["UseAutoIdentify"].toBool();
790 info.autoIdentifyService = i["AutoIdentifyService"].toString();
791 info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
792 info.useAutoReconnect = i["UseAutoReconnect"].toBool();
793 info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
794 info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
795 info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
796 info.rejoinChannels = i["RejoinChannels"].toBool();
800 QDebug operator<<(QDebug dbg, const NetworkInfo &i) {
801 dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
802 << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding
803 << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
804 << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
805 << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
806 << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
807 << " rejoinChannels = " << i.rejoinChannels << ")";