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),
39 _networkName(QString("<not initialized>")),
40 _currentServer(QString()),
42 _connectionState(Disconnected),
44 _prefixModes(QString()),
45 _useRandomServer(false),
46 _useAutoIdentify(false),
47 _useAutoReconnect(false),
48 _autoReconnectInterval(60),
49 _autoReconnectRetries(10),
50 _unlimitedReconnectRetries(false),
55 setObjectName(QString::number(networkid.toInt()));
59 emit aboutToBeDestroyed();
62 bool Network::isChannelName(const QString &channelname) const {
63 if(channelname.isEmpty())
66 if(supports("CHANTYPES"))
67 return support("CHANTYPES").contains(channelname[0]);
69 return QString("#&!+").contains(channelname[0]);
72 NetworkInfo Network::networkInfo() const {
74 info.networkName = networkName();
75 info.networkId = networkId();
76 info.identity = identity();
77 info.codecForServer = codecForServer();
78 info.codecForEncoding = codecForEncoding();
79 info.codecForDecoding = codecForDecoding();
80 info.serverList = serverList();
81 info.useRandomServer = useRandomServer();
82 info.perform = perform();
83 info.useAutoIdentify = useAutoIdentify();
84 info.autoIdentifyService = autoIdentifyService();
85 info.autoIdentifyPassword = autoIdentifyPassword();
86 info.useAutoReconnect = useAutoReconnect();
87 info.autoReconnectInterval = autoReconnectInterval();
88 info.autoReconnectRetries = autoReconnectRetries();
89 info.unlimitedReconnectRetries = unlimitedReconnectRetries();
90 info.rejoinChannels = rejoinChannels();
94 void Network::setNetworkInfo(const NetworkInfo &info) {
95 // we don't set our ID!
96 if(!info.networkName.isEmpty() && info.networkName != networkName()) setNetworkName(info.networkName);
97 if(info.identity > 0 && info.identity != identity()) setIdentity(info.identity);
98 if(info.codecForServer != codecForServer()) setCodecForServer(QTextCodec::codecForName(info.codecForServer));
99 if(info.codecForEncoding != codecForEncoding()) setCodecForEncoding(QTextCodec::codecForName(info.codecForEncoding));
100 if(info.codecForDecoding != codecForDecoding()) setCodecForDecoding(QTextCodec::codecForName(info.codecForDecoding));
101 if(info.serverList.count()) setServerList(info.serverList); // FIXME compare components
102 if(info.useRandomServer != useRandomServer()) setUseRandomServer(info.useRandomServer);
103 if(info.perform != perform()) setPerform(info.perform);
104 if(info.useAutoIdentify != useAutoIdentify()) setUseAutoIdentify(info.useAutoIdentify);
105 if(info.autoIdentifyService != autoIdentifyService()) setAutoIdentifyService(info.autoIdentifyService);
106 if(info.autoIdentifyPassword != autoIdentifyPassword()) setAutoIdentifyPassword(info.autoIdentifyPassword);
107 if(info.useAutoReconnect != useAutoReconnect()) setUseAutoReconnect(info.useAutoReconnect);
108 if(info.autoReconnectInterval != autoReconnectInterval()) setAutoReconnectInterval(info.autoReconnectInterval);
109 if(info.autoReconnectRetries != autoReconnectRetries()) setAutoReconnectRetries(info.autoReconnectRetries);
110 if(info.unlimitedReconnectRetries != unlimitedReconnectRetries()) setUnlimitedReconnectRetries(info.unlimitedReconnectRetries);
111 if(info.rejoinChannels != rejoinChannels()) setRejoinChannels(info.rejoinChannels);
114 QString Network::prefixToMode(const QString &prefix) {
115 if(prefixes().contains(prefix))
116 return QString(prefixModes()[prefixes().indexOf(prefix)]);
121 QString Network::modeToPrefix(const QString &mode) {
122 if(prefixModes().contains(mode))
123 return QString(prefixes()[prefixModes().indexOf(mode)]);
128 QStringList Network::nicks() const {
129 // we don't use _ircUsers.keys() since the keys may be
130 // not up to date after a nick change
132 foreach(IrcUser *ircuser, _ircUsers.values()) {
133 nicks << ircuser->nick();
138 QString Network::prefixes() {
139 if(_prefixes.isNull())
145 QString Network::prefixModes() {
146 if(_prefixModes.isNull())
152 // example Unreal IRCD: CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG
153 Network::ChannelModeType Network::channelModeType(const QString &mode) {
155 return NOT_A_CHANMODE;
157 QString chanmodes = support("CHANMODES");
158 if(chanmodes.isEmpty())
159 return NOT_A_CHANMODE;
161 ChannelModeType modeType = A_CHANMODE;
162 for(int i = 0; i < chanmodes.count(); i++) {
163 if(chanmodes[i] == mode[0])
165 else if(chanmodes[i] == ',')
166 modeType = (ChannelModeType)(modeType << 1);
168 if(modeType > D_CHANMODE) {
169 qWarning() << "Network" << networkId() << "supplied invalid CHANMODES:" << chanmodes;
170 modeType = NOT_A_CHANMODE;
175 QString Network::support(const QString ¶m) const {
176 QString support_ = param.toUpper();
177 if(_supports.contains(support_))
178 return _supports[support_];
183 IrcUser *Network::newIrcUser(const QString &hostmask) {
184 QString nick(nickFromMask(hostmask).toLower());
185 if(!_ircUsers.contains(nick)) {
186 IrcUser *ircuser = new IrcUser(hostmask, this);
189 proxy()->synchronize(ircuser);
191 qWarning() << "unable to synchronize new IrcUser" << hostmask << "forgot to call Network::setProxy(SignalProxy *)?";
193 connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
194 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
195 connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
196 _ircUsers[nick] = ircuser;
197 emit ircUserAdded(hostmask);
198 emit ircUserAdded(ircuser);
200 return _ircUsers[nick];
203 void Network::ircUserDestroyed() {
204 IrcUser *ircUser = static_cast<IrcUser *>(sender());
208 QHash<QString, IrcUser *>::iterator ircUserIter = _ircUsers.begin();
209 while(ircUserIter != _ircUsers.end()) {
210 if(ircUser == *ircUserIter) {
211 emit deletedIrcUserRemoved(ircUserIter.key());
212 ircUserIter = _ircUsers.erase(ircUserIter);
219 void Network::removeDeletedIrcUser(const QString &username) {
220 // DO NOT CALL THIS SLOT EVER!!!
222 // this slots purpose is only to remove deleted users that haven't been synced yet.
224 // as a user parting a channel results in it's deletion if it is no longer in any known channel
225 // this action can only be communicated if the slaves are allready in sync.
226 // so if such a deleted user isn't synced in slave mode, we kill and remove it.
230 if(!_ircUsers.contains(username))
233 IrcUser *ircUser = _ircUsers[username];
235 if(ircUser->isInitialized())
238 _ircUsers.remove(username);
239 emit ircUserRemoved(username);
240 emit ircUserRemoved(ircUser);
243 void Network::removeIrcUser(IrcUser *ircuser) {
244 QString nick = _ircUsers.key(ircuser);
248 _ircUsers.remove(nick);
249 disconnect(ircuser, 0, this, 0);
250 emit ircUserRemoved(nick);
251 emit ircUserRemoved(ircuser);
252 ircuser->deleteLater();
255 void Network::removeIrcUser(const QString &nick) {
257 if((ircuser = ircUser(nick)) != 0)
258 removeIrcUser(ircuser);
261 void Network::removeChansAndUsers() {
262 QList<IrcUser *> users = ircUsers();
263 foreach(IrcUser *user, users) {
266 QList<IrcChannel *> channels = ircChannels();
267 foreach(IrcChannel *channel, channels) {
268 removeIrcChannel(channel);
272 IrcUser *Network::ircUser(QString nickname) const {
273 nickname = nickname.toLower();
274 if(_ircUsers.contains(nickname))
275 return _ircUsers[nickname];
280 IrcChannel *Network::newIrcChannel(const QString &channelname) {
281 if(!_ircChannels.contains(channelname.toLower())) {
282 IrcChannel *channel = new IrcChannel(channelname, this);
285 proxy()->synchronize(channel);
287 qWarning() << "unable to synchronize new IrcChannel" << channelname << "forgot to call Network::setProxy(SignalProxy *)?";
289 connect(channel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
290 connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
291 _ircChannels[channelname.toLower()] = channel;
292 emit ircChannelAdded(channelname);
293 emit ircChannelAdded(channel);
295 return _ircChannels[channelname.toLower()];
298 IrcChannel *Network::ircChannel(QString channelname) const {
299 channelname = channelname.toLower();
300 if(_ircChannels.contains(channelname))
301 return _ircChannels[channelname];
306 QByteArray Network::defaultCodecForServer() {
307 if(_defaultCodecForServer)
308 return _defaultCodecForServer->name();
312 void Network::setDefaultCodecForServer(const QByteArray &name) {
313 _defaultCodecForServer = QTextCodec::codecForName(name);
316 QByteArray Network::defaultCodecForEncoding() {
317 if(_defaultCodecForEncoding)
318 return _defaultCodecForEncoding->name();
322 void Network::setDefaultCodecForEncoding(const QByteArray &name) {
323 _defaultCodecForEncoding = QTextCodec::codecForName(name);
326 QByteArray Network::defaultCodecForDecoding() {
327 if(_defaultCodecForDecoding)
328 return _defaultCodecForDecoding->name();
332 void Network::setDefaultCodecForDecoding(const QByteArray &name) {
333 _defaultCodecForDecoding = QTextCodec::codecForName(name);
336 QByteArray Network::codecForServer() const {
338 return _codecForServer->name();
342 void Network::setCodecForServer(const QByteArray &name) {
343 setCodecForServer(QTextCodec::codecForName(name));
346 void Network::setCodecForServer(QTextCodec *codec) {
347 _codecForServer = codec;
348 emit codecForServerSet(codecForServer());
351 QByteArray Network::codecForEncoding() const {
352 if(_codecForEncoding)
353 return _codecForEncoding->name();
357 void Network::setCodecForEncoding(const QByteArray &name) {
358 setCodecForEncoding(QTextCodec::codecForName(name));
361 void Network::setCodecForEncoding(QTextCodec *codec) {
362 _codecForEncoding = codec;
363 emit codecForEncodingSet(codecForEncoding());
366 QByteArray Network::codecForDecoding() const {
367 if(_codecForDecoding)
368 return _codecForDecoding->name();
369 else return QByteArray();
372 void Network::setCodecForDecoding(const QByteArray &name) {
373 setCodecForDecoding(QTextCodec::codecForName(name));
376 void Network::setCodecForDecoding(QTextCodec *codec) {
377 _codecForDecoding = codec;
378 emit codecForDecodingSet(codecForDecoding());
381 // FIXME use server encoding if appropriate
382 QString Network::decodeString(const QByteArray &text) const {
383 if(_codecForDecoding)
384 return ::decodeString(text, _codecForDecoding);
385 else return ::decodeString(text, _defaultCodecForDecoding);
388 QByteArray Network::encodeString(const QString &string) const {
389 if(_codecForEncoding) {
390 return _codecForEncoding->fromUnicode(string);
392 if(_defaultCodecForEncoding) {
393 return _defaultCodecForEncoding->fromUnicode(string);
395 return string.toAscii();
398 QString Network::decodeServerString(const QByteArray &text) const {
400 return ::decodeString(text, _codecForServer);
402 return ::decodeString(text, _defaultCodecForServer);
405 QByteArray Network::encodeServerString(const QString &string) const {
406 if(_codecForServer) {
407 return _codecForServer->fromUnicode(string);
409 if(_defaultCodecForServer) {
410 return _defaultCodecForServer->fromUnicode(string);
412 return string.toAscii();
415 // ====================
417 // ====================
418 void Network::setNetworkName(const QString &networkName) {
419 _networkName = networkName;
420 emit networkNameSet(networkName);
423 void Network::setCurrentServer(const QString ¤tServer) {
424 _currentServer = currentServer;
425 emit currentServerSet(currentServer);
428 void Network::setConnected(bool connected) {
429 if(_connected == connected)
432 _connected = connected;
434 setMyNick(QString());
435 setCurrentServer(QString());
436 removeChansAndUsers();
438 emit connectedSet(connected);
441 //void Network::setConnectionState(ConnectionState state) {
442 void Network::setConnectionState(int state) {
443 _connectionState = (ConnectionState)state;
444 //qDebug() << "netstate" << networkId() << networkName() << state;
445 emit connectionStateSet(state);
446 emit connectionStateSet(_connectionState);
449 void Network::setMyNick(const QString &nickname) {
451 if(!_myNick.isEmpty() && !ircUser(myNick())) {
452 newIrcUser(myNick());
454 emit myNickSet(nickname);
457 void Network::setIdentity(IdentityId id) {
459 emit identitySet(id);
462 void Network::setServerList(const QVariantList &serverList) {
463 _serverList = serverList;
464 emit serverListSet(serverList);
467 void Network::setUseRandomServer(bool use) {
468 _useRandomServer = use;
469 emit useRandomServerSet(use);
472 void Network::setPerform(const QStringList &perform) {
474 emit performSet(perform);
477 void Network::setUseAutoIdentify(bool use) {
478 _useAutoIdentify = use;
479 emit useAutoIdentifySet(use);
482 void Network::setAutoIdentifyService(const QString &service) {
483 _autoIdentifyService = service;
484 emit autoIdentifyServiceSet(service);
487 void Network::setAutoIdentifyPassword(const QString &password) {
488 _autoIdentifyPassword = password;
489 emit autoIdentifyPasswordSet(password);
492 void Network::setUseAutoReconnect(bool use) {
493 _useAutoReconnect = use;
494 emit useAutoReconnectSet(use);
497 void Network::setAutoReconnectInterval(quint32 interval) {
498 _autoReconnectInterval = interval;
499 emit autoReconnectIntervalSet(interval);
502 void Network::setAutoReconnectRetries(quint16 retries) {
503 _autoReconnectRetries = retries;
504 emit autoReconnectRetriesSet(retries);
507 void Network::setUnlimitedReconnectRetries(bool unlimited) {
508 _unlimitedReconnectRetries = unlimited;
509 emit unlimitedReconnectRetriesSet(unlimited);
512 void Network::setRejoinChannels(bool rejoin) {
513 _rejoinChannels = rejoin;
514 emit rejoinChannelsSet(rejoin);
517 void Network::addSupport(const QString ¶m, const QString &value) {
518 if(!_supports.contains(param)) {
519 _supports[param] = value;
520 emit supportAdded(param, value);
524 void Network::removeSupport(const QString ¶m) {
525 if(_supports.contains(param)) {
526 _supports.remove(param);
527 emit supportRemoved(param);
531 QVariantMap Network::initSupports() const {
532 QVariantMap supports;
533 QHashIterator<QString, QString> iter(_supports);
534 while(iter.hasNext()) {
536 supports[iter.key()] = iter.value();
541 QVariantMap Network::initIrcUsersAndChannels() const {
542 QVariantMap usersAndChannels;
544 QVariantMap channels;
546 QHash<QString, IrcUser *>::const_iterator userIter = _ircUsers.constBegin();
547 QHash<QString, IrcUser *>::const_iterator userIterEnd = _ircUsers.constEnd();
548 while(userIter != userIterEnd) {
549 users[userIter.value()->hostmask()] = userIter.value()->toVariantMap();
552 usersAndChannels["users"] = users;
554 QHash<QString, IrcChannel *>::const_iterator channelIter = _ircChannels.constBegin();
555 QHash<QString, IrcChannel *>::const_iterator channelIterEnd = _ircChannels.constEnd();
556 while(channelIter != channelIterEnd) {
557 channels[channelIter.key()] = channelIter.value()->toVariantMap();
560 usersAndChannels["channels"] = channels;
562 return usersAndChannels;
565 void Network::initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels) {
567 if(!_ircUsers.isEmpty() || !_ircChannels.isEmpty()) {
568 qWarning() << "Network" << networkId() << "received init data for users and channels allthough there allready are known users or channels!";
572 QVariantMap users = usersAndChannels.value("users").toMap();
574 QVariantMap::const_iterator userIter = users.constBegin();
575 QVariantMap::const_iterator userIterEnd = users.constEnd();
576 IrcUser *ircUser = 0;
578 while(userIter != userIterEnd) {
579 hostmask = userIter.key();
580 ircUser = new IrcUser(hostmask, this);
581 ircUser->fromVariantMap(userIter.value().toMap());
582 ircUser->setInitialized();
583 proxy()->synchronize(ircUser);
585 connect(ircUser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
586 connect(ircUser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
588 _ircUsers[nickFromMask(hostmask).toLower()] = ircUser;
590 emit ircUserAdded(hostmask);
591 emit ircUserAdded(ircUser);
592 emit ircUserInitDone(ircUser);
598 QVariantMap channels = usersAndChannels.value("channels").toMap();
599 QVariantMap::const_iterator channelIter = channels.constBegin();
600 QVariantMap::const_iterator channelIterEnd = channels.constEnd();
601 IrcChannel *ircChannel = 0;
604 while(channelIter != channelIterEnd) {
605 channelName = channelIter.key();
606 ircChannel = new IrcChannel(channelName, this);
607 ircChannel->fromVariantMap(channelIter.value().toMap());
608 ircChannel->setInitialized();
609 proxy()->synchronize(ircChannel);
611 connect(ircChannel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
612 _ircChannels[channelName.toLower()] = ircChannel;
614 emit ircChannelAdded(channelName);
615 emit ircChannelAdded(ircChannel);
616 emit ircChannelInitDone(ircChannel);
623 void Network::initSetSupports(const QVariantMap &supports) {
624 QMapIterator<QString, QVariant> iter(supports);
625 while(iter.hasNext()) {
627 addSupport(iter.key(), iter.value().toString());
631 IrcUser *Network::updateNickFromMask(const QString &mask) {
632 QString nick(nickFromMask(mask).toLower());
635 if(_ircUsers.contains(nick)) {
636 ircuser = _ircUsers[nick];
637 ircuser->updateHostmask(mask);
639 ircuser = newIrcUser(mask);
644 void Network::ircUserNickChanged(QString newnick) {
645 QString oldnick = _ircUsers.key(qobject_cast<IrcUser*>(sender()));
650 if(newnick.toLower() != oldnick) _ircUsers[newnick.toLower()] = _ircUsers.take(oldnick);
652 if(myNick().toLower() == oldnick)
656 void Network::ircUserInitDone() {
657 IrcUser *ircuser = static_cast<IrcUser *>(sender());
659 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
660 emit ircUserInitDone(ircuser);
663 void Network::ircChannelInitDone() {
664 IrcChannel *ircChannel = static_cast<IrcChannel *>(sender());
665 Q_ASSERT(ircChannel);
666 disconnect(ircChannel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
667 emit ircChannelInitDone(ircChannel);
670 void Network::removeIrcChannel(IrcChannel *channel) {
671 QString chanName = _ircChannels.key(channel);
672 if(chanName.isNull())
675 _ircChannels.remove(chanName);
676 disconnect(channel, 0, this, 0);
677 emit ircChannelRemoved(chanName);
678 emit ircChannelRemoved(channel);
679 channel->deleteLater();
682 void Network::removeIrcChannel(const QString &channel) {
684 if((chan = ircChannel(channel)) != 0)
685 removeIrcChannel(chan);
688 void Network::channelDestroyed() {
689 IrcChannel *channel = static_cast<IrcChannel *>(sender());
691 _ircChannels.remove(_ircChannels.key(channel));
692 emit ircChannelRemoved(channel);
695 void Network::emitConnectionError(const QString &errorMsg) {
696 emit connectionError(errorMsg);
699 // ====================
701 // ====================
702 void Network::determinePrefixes() {
703 // seems like we have to construct them first
704 QString PREFIX = support("PREFIX");
706 if(PREFIX.startsWith("(") && PREFIX.contains(")")) {
707 _prefixes = PREFIX.section(")", 1);
708 _prefixModes = PREFIX.mid(1).section(")", 0, 0);
710 QString defaultPrefixes("~&@%+");
711 QString defaultPrefixModes("qaohv");
713 // we just assume that in PREFIX are only prefix chars stored
714 for(int i = 0; i < defaultPrefixes.size(); i++) {
715 if(PREFIX.contains(defaultPrefixes[i])) {
716 _prefixes += defaultPrefixes[i];
717 _prefixModes += defaultPrefixModes[i];
721 if(!_prefixes.isNull())
724 // well... our assumption was obviously wrong...
725 // check if it's only prefix modes
726 for(int i = 0; i < defaultPrefixes.size(); i++) {
727 if(PREFIX.contains(defaultPrefixModes[i])) {
728 _prefixes += defaultPrefixes[i];
729 _prefixModes += defaultPrefixModes[i];
732 // now we've done all we've could...
736 /************************************************************************
738 ************************************************************************/
740 bool NetworkInfo::operator==(const NetworkInfo &other) const {
741 if(networkId != other.networkId) return false;
742 if(networkName != other.networkName) return false;
743 if(identity != other.identity) return false;
744 if(codecForServer != other.codecForServer) return false;
745 if(codecForEncoding != other.codecForEncoding) return false;
746 if(codecForDecoding != other.codecForDecoding) return false;
747 if(serverList != other.serverList) return false;
748 if(useRandomServer != other.useRandomServer) return false;
749 if(perform != other.perform) return false;
750 if(useAutoIdentify != other.useAutoIdentify) return false;
751 if(autoIdentifyService != other.autoIdentifyService) return false;
752 if(autoIdentifyPassword != other.autoIdentifyPassword) return false;
753 if(useAutoReconnect != other.useAutoReconnect) return false;
754 if(autoReconnectInterval != other.autoReconnectInterval) return false;
755 if(autoReconnectRetries != other.autoReconnectRetries) return false;
756 if(unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
757 if(rejoinChannels != other.rejoinChannels) return false;
761 bool NetworkInfo::operator!=(const NetworkInfo &other) const {
762 return !(*this == other);
765 QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) {
767 i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
768 i["NetworkName"] = info.networkName;
769 i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
770 i["CodecForServer"] = info.codecForServer;
771 i["CodecForEncoding"] = info.codecForEncoding;
772 i["CodecForDecoding"] = info.codecForDecoding;
773 i["ServerList"] = info.serverList;
774 i["UseRandomServer"] = info.useRandomServer;
775 i["Perform"] = info.perform;
776 i["UseAutoIdentify"] = info.useAutoIdentify;
777 i["AutoIdentifyService"] = info.autoIdentifyService;
778 i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
779 i["UseAutoReconnect"] = info.useAutoReconnect;
780 i["AutoReconnectInterval"] = info.autoReconnectInterval;
781 i["AutoReconnectRetries"] = info.autoReconnectRetries;
782 i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
783 i["RejoinChannels"] = info.rejoinChannels;
788 QDataStream &operator>>(QDataStream &in, NetworkInfo &info) {
791 info.networkId = i["NetworkId"].value<NetworkId>();
792 info.networkName = i["NetworkName"].toString();
793 info.identity = i["Identity"].value<IdentityId>();
794 info.codecForServer = i["CodecForServer"].toByteArray();
795 info.codecForEncoding = i["CodecForEncoding"].toByteArray();
796 info.codecForDecoding = i["CodecForDecoding"].toByteArray();
797 info.serverList = i["ServerList"].toList();
798 info.useRandomServer = i["UseRandomServer"].toBool();
799 info.perform = i["Perform"].toStringList();
800 info.useAutoIdentify = i["UseAutoIdentify"].toBool();
801 info.autoIdentifyService = i["AutoIdentifyService"].toString();
802 info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
803 info.useAutoReconnect = i["UseAutoReconnect"].toBool();
804 info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
805 info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
806 info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
807 info.rejoinChannels = i["RejoinChannels"].toBool();
811 QDebug operator<<(QDebug dbg, const NetworkInfo &i) {
812 dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
813 << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding
814 << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
815 << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
816 << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
817 << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
818 << " rejoinChannels = " << i.rejoinChannels << ")";