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);
283 // mark IrcUser as already initialized to keep the SignalProxy from requesting initData
284 //if(isInitialized())
285 // ircuser->setInitialized();
287 proxy()->synchronize(ircuser);
289 qWarning() << "unable to synchronize new IrcUser" << hostmask << "forgot to call Network::setProxy(SignalProxy *)?";
291 connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString)));
292 connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone()));
293 _ircUsers[nick] = ircuser;
294 emit ircUserAdded(hostmask);
295 emit ircUserAdded(ircuser);
297 return _ircUsers[nick];
300 IrcUser *Network::newIrcUser(const QByteArray &hostmask) {
301 return newIrcUser(decodeServerString(hostmask));
304 void Network::removeIrcUser(IrcUser *ircuser) {
305 QString nick = _ircUsers.key(ircuser);
309 _ircUsers.remove(nick);
310 disconnect(ircuser, 0, this, 0);
311 emit ircUserRemoved(nick);
312 emit ircUserRemoved(ircuser);
313 ircuser->deleteLater();
316 void Network::removeChansAndUsers() {
317 QList<IrcUser *> users = ircUsers();
318 foreach(IrcUser *user, users) {
321 QList<IrcChannel *> channels = ircChannels();
322 foreach(IrcChannel *channel, channels) {
323 removeIrcChannel(channel);
327 void Network::removeIrcUser(const QString &nick) {
329 if((ircuser = ircUser(nick)) != 0)
330 removeIrcUser(ircuser);
333 IrcUser *Network::ircUser(QString nickname) const {
334 nickname = nickname.toLower();
335 if(_ircUsers.contains(nickname))
336 return _ircUsers[nickname];
341 IrcUser *Network::ircUser(const QByteArray &nickname) const {
342 return ircUser(decodeServerString(nickname));
345 QList<IrcUser *> Network::ircUsers() const {
346 return _ircUsers.values();
349 quint32 Network::ircUserCount() const {
350 return _ircUsers.count();
353 IrcChannel *Network::newIrcChannel(const QString &channelname) {
354 if(!_ircChannels.contains(channelname.toLower())) {
355 IrcChannel *channel = new IrcChannel(channelname, this);
356 // mark IrcUser as already initialized to keep the SignalProxy from requesting initData
357 //if(isInitialized())
358 // channel->setInitialized();
361 proxy()->synchronize(channel);
363 qWarning() << "unable to synchronize new IrcChannel" << channelname << "forgot to call Network::setProxy(SignalProxy *)?";
365 connect(channel, SIGNAL(initDone()), this, SLOT(ircChannelInitDone()));
366 connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
367 _ircChannels[channelname.toLower()] = channel;
368 emit ircChannelAdded(channelname);
369 emit ircChannelAdded(channel);
371 return _ircChannels[channelname.toLower()];
374 IrcChannel *Network::newIrcChannel(const QByteArray &channelname) {
375 return newIrcChannel(decodeServerString(channelname));
378 IrcChannel *Network::ircChannel(QString channelname) const {
379 channelname = channelname.toLower();
380 if(_ircChannels.contains(channelname))
381 return _ircChannels[channelname];
386 IrcChannel *Network::ircChannel(const QByteArray &channelname) const {
387 return ircChannel(decodeServerString(channelname));
391 QList<IrcChannel *> Network::ircChannels() const {
392 return _ircChannels.values();
395 quint32 Network::ircChannelCount() const {
396 return _ircChannels.count();
399 QByteArray Network::defaultCodecForServer() {
400 if(_defaultCodecForServer) return _defaultCodecForServer->name();
404 void Network::setDefaultCodecForServer(const QByteArray &name) {
405 _defaultCodecForServer = QTextCodec::codecForName(name);
408 QByteArray Network::defaultCodecForEncoding() {
409 if(_defaultCodecForEncoding) return _defaultCodecForEncoding->name();
413 void Network::setDefaultCodecForEncoding(const QByteArray &name) {
414 _defaultCodecForEncoding = QTextCodec::codecForName(name);
417 QByteArray Network::defaultCodecForDecoding() {
418 if(_defaultCodecForDecoding) return _defaultCodecForDecoding->name();
422 void Network::setDefaultCodecForDecoding(const QByteArray &name) {
423 _defaultCodecForDecoding = QTextCodec::codecForName(name);
426 QByteArray Network::codecForServer() const {
427 if(_codecForServer) return _codecForServer->name();
431 void Network::setCodecForServer(const QByteArray &name) {
432 setCodecForServer(QTextCodec::codecForName(name));
435 void Network::setCodecForServer(QTextCodec *codec) {
436 _codecForServer = codec;
437 emit codecForServerSet(codecForServer());
440 QByteArray Network::codecForEncoding() const {
441 if(_codecForEncoding) return _codecForEncoding->name();
445 void Network::setCodecForEncoding(const QByteArray &name) {
446 setCodecForEncoding(QTextCodec::codecForName(name));
449 void Network::setCodecForEncoding(QTextCodec *codec) {
450 _codecForEncoding = codec;
451 emit codecForEncodingSet(codecForEncoding());
454 QByteArray Network::codecForDecoding() const {
455 if(_codecForDecoding) return _codecForDecoding->name();
456 else return QByteArray();
459 void Network::setCodecForDecoding(const QByteArray &name) {
460 setCodecForDecoding(QTextCodec::codecForName(name));
463 void Network::setCodecForDecoding(QTextCodec *codec) {
464 _codecForDecoding = codec;
465 emit codecForDecodingSet(codecForDecoding());
468 // FIXME use server encoding if appropriate
469 QString Network::decodeString(const QByteArray &text) const {
470 if(_codecForDecoding) return ::decodeString(text, _codecForDecoding);
471 else return ::decodeString(text, _defaultCodecForDecoding);
474 QByteArray Network::encodeString(const QString &string) const {
475 if(_codecForEncoding) {
476 return _codecForEncoding->fromUnicode(string);
478 if(_defaultCodecForEncoding) {
479 return _defaultCodecForEncoding->fromUnicode(string);
481 return string.toAscii();
484 QString Network::decodeServerString(const QByteArray &text) const {
485 if(_codecForServer) return ::decodeString(text, _codecForServer);
486 else return ::decodeString(text, _defaultCodecForServer);
489 QByteArray Network::encodeServerString(const QString &string) const {
490 if(_codecForServer) {
491 return _codecForServer->fromUnicode(string);
493 if(_defaultCodecForServer) {
494 return _defaultCodecForServer->fromUnicode(string);
496 return string.toAscii();
499 // ====================
501 // ====================
502 void Network::setNetworkName(const QString &networkName) {
503 _networkName = networkName;
504 emit networkNameSet(networkName);
507 void Network::setCurrentServer(const QString ¤tServer) {
508 _currentServer = currentServer;
509 emit currentServerSet(currentServer);
512 void Network::setConnected(bool connected) {
513 _connected = connected;
515 removeChansAndUsers();
516 setCurrentServer(QString());
518 emit connectedSet(connected);
521 //void Network::setConnectionState(ConnectionState state) {
522 void Network::setConnectionState(int state) {
523 _connectionState = (ConnectionState)state;
524 //qDebug() << "netstate" << networkId() << networkName() << state;
525 emit connectionStateSet(state);
526 emit connectionStateSet(_connectionState);
529 void Network::setMyNick(const QString &nickname) {
531 emit myNickSet(nickname);
534 void Network::setIdentity(IdentityId id) {
536 emit identitySet(id);
539 void Network::setServerList(const QVariantList &serverList) {
540 _serverList = serverList;
541 emit serverListSet(serverList);
544 void Network::setUseRandomServer(bool use) {
545 _useRandomServer = use;
546 emit useRandomServerSet(use);
549 void Network::setPerform(const QStringList &perform) {
551 emit performSet(perform);
554 void Network::setUseAutoIdentify(bool use) {
555 _useAutoIdentify = use;
556 emit useAutoIdentifySet(use);
559 void Network::setAutoIdentifyService(const QString &service) {
560 _autoIdentifyService = service;
561 emit autoIdentifyServiceSet(service);
564 void Network::setAutoIdentifyPassword(const QString &password) {
565 _autoIdentifyPassword = password;
566 emit autoIdentifyPasswordSet(password);
569 void Network::setUseAutoReconnect(bool use) {
570 _useAutoReconnect = use;
571 emit useAutoReconnectSet(use);
574 void Network::setAutoReconnectInterval(quint32 interval) {
575 _autoReconnectInterval = interval;
576 emit autoReconnectIntervalSet(interval);
579 void Network::setAutoReconnectRetries(quint16 retries) {
580 _autoReconnectRetries = retries;
581 emit autoReconnectRetriesSet(retries);
584 void Network::setUnlimitedReconnectRetries(bool unlimited) {
585 _unlimitedReconnectRetries = unlimited;
586 emit unlimitedReconnectRetriesSet(unlimited);
589 void Network::setRejoinChannels(bool rejoin) {
590 _rejoinChannels = rejoin;
591 emit rejoinChannelsSet(rejoin);
594 void Network::addSupport(const QString ¶m, const QString &value) {
595 if(!_supports.contains(param)) {
596 _supports[param] = value;
597 emit supportAdded(param, value);
601 void Network::removeSupport(const QString ¶m) {
602 if(_supports.contains(param)) {
603 _supports.remove(param);
604 emit supportRemoved(param);
608 QVariantMap Network::initSupports() const {
609 QVariantMap supports;
610 QHashIterator<QString, QString> iter(_supports);
611 while(iter.hasNext()) {
613 supports[iter.key()] = iter.value();
618 QVariantList Network::initServerList() const {
622 QStringList Network::initIrcUsers() const {
623 QStringList hostmasks;
624 foreach(IrcUser *ircuser, ircUsers()) {
625 hostmasks << ircuser->hostmask();
630 QStringList Network::initIrcChannels() const {
631 return _ircChannels.keys();
634 void Network::initSetSupports(const QVariantMap &supports) {
635 QMapIterator<QString, QVariant> iter(supports);
636 while(iter.hasNext()) {
638 addSupport(iter.key(), iter.value().toString());
642 void Network::initSetServerList(const QVariantList & serverList) {
643 setServerList(serverList);
646 void Network::initSetIrcUsers(const QStringList &hostmasks) {
647 if(!_ircUsers.empty())
649 foreach(QString hostmask, hostmasks) {
650 newIrcUser(hostmask);
654 void Network::initSetChannels(const QStringList &channels) {
655 if(!_ircChannels.empty())
657 foreach(QString channel, channels)
658 newIrcChannel(channel);
661 IrcUser *Network::updateNickFromMask(const QString &mask) {
662 QString nick(nickFromMask(mask).toLower());
665 if(_ircUsers.contains(nick)) {
666 ircuser = _ircUsers[nick];
667 ircuser->updateHostmask(mask);
669 ircuser = newIrcUser(mask);
674 void Network::ircUserNickChanged(QString newnick) {
675 QString oldnick = _ircUsers.key(qobject_cast<IrcUser*>(sender()));
680 if(newnick.toLower() != oldnick) _ircUsers[newnick.toLower()] = _ircUsers.take(oldnick);
682 if(myNick().toLower() == oldnick)
686 void Network::ircUserInitDone() {
687 IrcUser *ircuser = static_cast<IrcUser *>(sender());
689 emit ircUserInitDone(ircuser);
692 void Network::ircChannelInitDone() {
693 IrcChannel *ircchannel = static_cast<IrcChannel *>(sender());
694 Q_ASSERT(ircchannel);
695 emit ircChannelInitDone(ircchannel);
698 void Network::removeIrcChannel(IrcChannel *channel) {
699 QString chanName = _ircChannels.key(channel);
700 if(chanName.isNull())
703 _ircChannels.remove(chanName);
704 disconnect(channel, 0, this, 0);
705 emit ircChannelRemoved(chanName);
706 emit ircChannelRemoved(channel);
707 channel->deleteLater();
710 void Network::removeIrcChannel(const QString &channel) {
712 if((chan = ircChannel(channel)) != 0)
713 removeIrcChannel(chan);
716 void Network::channelDestroyed() {
717 IrcChannel *channel = static_cast<IrcChannel *>(sender());
719 _ircChannels.remove(_ircChannels.key(channel));
720 emit ircChannelRemoved(channel);
723 void Network::requestConnect() const {
725 if(proxy()->proxyMode() == SignalProxy::Client) emit connectRequested(); // on the client this triggers calling this slot on the core
727 if(connectionState() != Disconnected) {
728 qWarning() << "Requesting connect while already being connected!";
731 emit connectRequested(networkId()); // and this is for CoreSession :)
735 void Network::requestDisconnect() const {
737 if(proxy()->proxyMode() == SignalProxy::Client) emit disconnectRequested(); // on the client this triggers calling this slot on the core
739 if(connectionState() == Disconnected) {
740 qWarning() << "Requesting disconnect while not being connected!";
743 emit disconnectRequested(networkId()); // and this is for CoreSession :)
747 void Network::emitConnectionError(const QString &errorMsg) {
748 emit connectionError(errorMsg);
751 // ====================
753 // ====================
754 void Network::determinePrefixes() {
755 // seems like we have to construct them first
756 QString PREFIX = support("PREFIX");
758 if(PREFIX.startsWith("(") && PREFIX.contains(")")) {
759 _prefixes = PREFIX.section(")", 1);
760 _prefixModes = PREFIX.mid(1).section(")", 0, 0);
762 QString defaultPrefixes("~&@%+");
763 QString defaultPrefixModes("qaohv");
765 // we just assume that in PREFIX are only prefix chars stored
766 for(int i = 0; i < defaultPrefixes.size(); i++) {
767 if(PREFIX.contains(defaultPrefixes[i])) {
768 _prefixes += defaultPrefixes[i];
769 _prefixModes += defaultPrefixModes[i];
773 if(!_prefixes.isNull())
776 // well... our assumption was obviously wrong...
777 // check if it's only prefix modes
778 for(int i = 0; i < defaultPrefixes.size(); i++) {
779 if(PREFIX.contains(defaultPrefixModes[i])) {
780 _prefixes += defaultPrefixes[i];
781 _prefixModes += defaultPrefixModes[i];
784 // now we've done all we've could...
788 /************************************************************************
790 ************************************************************************/
792 bool NetworkInfo::operator==(const NetworkInfo &other) const {
793 if(networkId != other.networkId) return false;
794 if(networkName != other.networkName) return false;
795 if(identity != other.identity) return false;
796 if(codecForServer != other.codecForServer) return false;
797 if(codecForEncoding != other.codecForEncoding) return false;
798 if(codecForDecoding != other.codecForDecoding) return false;
799 if(serverList != other.serverList) return false;
800 if(useRandomServer != other.useRandomServer) return false;
801 if(perform != other.perform) return false;
802 if(useAutoIdentify != other.useAutoIdentify) return false;
803 if(autoIdentifyService != other.autoIdentifyService) return false;
804 if(autoIdentifyPassword != other.autoIdentifyPassword) return false;
805 if(useAutoReconnect != other.useAutoReconnect) return false;
806 if(autoReconnectInterval != other.autoReconnectInterval) return false;
807 if(autoReconnectRetries != other.autoReconnectRetries) return false;
808 if(unlimitedReconnectRetries != other.unlimitedReconnectRetries) return false;
809 if(rejoinChannels != other.rejoinChannels) return false;
813 bool NetworkInfo::operator!=(const NetworkInfo &other) const {
814 return !(*this == other);
817 QDataStream &operator<<(QDataStream &out, const NetworkInfo &info) {
819 i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
820 i["NetworkName"] = info.networkName;
821 i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
822 i["CodecForServer"] = info.codecForServer;
823 i["CodecForEncoding"] = info.codecForEncoding;
824 i["CodecForDecoding"] = info.codecForDecoding;
825 i["ServerList"] = info.serverList;
826 i["UseRandomServer"] = info.useRandomServer;
827 i["Perform"] = info.perform;
828 i["UseAutoIdentify"] = info.useAutoIdentify;
829 i["AutoIdentifyService"] = info.autoIdentifyService;
830 i["AutoIdentifyPassword"] = info.autoIdentifyPassword;
831 i["UseAutoReconnect"] = info.useAutoReconnect;
832 i["AutoReconnectInterval"] = info.autoReconnectInterval;
833 i["AutoReconnectRetries"] = info.autoReconnectRetries;
834 i["UnlimitedReconnectRetries"] = info.unlimitedReconnectRetries;
835 i["RejoinChannels"] = info.rejoinChannels;
840 QDataStream &operator>>(QDataStream &in, NetworkInfo &info) {
843 info.networkId = i["NetworkId"].value<NetworkId>();
844 info.networkName = i["NetworkName"].toString();
845 info.identity = i["Identity"].value<IdentityId>();
846 info.codecForServer = i["CodecForServer"].toByteArray();
847 info.codecForEncoding = i["CodecForEncoding"].toByteArray();
848 info.codecForDecoding = i["CodecForDecoding"].toByteArray();
849 info.serverList = i["ServerList"].toList();
850 info.useRandomServer = i["UseRandomServer"].toBool();
851 info.perform = i["Perform"].toStringList();
852 info.useAutoIdentify = i["UseAutoIdentify"].toBool();
853 info.autoIdentifyService = i["AutoIdentifyService"].toString();
854 info.autoIdentifyPassword = i["AutoIdentifyPassword"].toString();
855 info.useAutoReconnect = i["UseAutoReconnect"].toBool();
856 info.autoReconnectInterval = i["AutoReconnectInterval"].toUInt();
857 info.autoReconnectRetries = i["AutoReconnectRetries"].toInt();
858 info.unlimitedReconnectRetries = i["UnlimitedReconnectRetries"].toBool();
859 info.rejoinChannels = i["RejoinChannels"].toBool();
863 QDebug operator<<(QDebug dbg, const NetworkInfo &i) {
864 dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity
865 << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding
866 << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform
867 << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword
868 << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval
869 << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries
870 << " rejoinChannels = " << i.rejoinChannels << ")";