}
// I think this is unnecessary since IrcUsers have us as their daddy :)
-//Network::~Network() {
-// QHashIterator<QString, IrcUser *> ircuser(_ircUsers);
-// while (ircuser.hasNext()) {
-// ircuser.next();
-// delete ircuser.value();
-// }
-//}
+/*
+Network::~Network() {
+ QHashIterator<QString, IrcUser *> ircuser(_ircUsers);
+ while (ircuser.hasNext()) {
+ ircuser.next();
+ delete ircuser.value();
+ }
+}
+*/
NetworkId Network::networkId() const {
return _networkId;
return _connected;
}
+NetworkInfo Network::networkInfo() const {
+ NetworkInfo info;
+ info.networkName = networkName();
+ info.networkId = networkId();
+ info.identity = identity();
+ info.codecForEncoding = codecForEncoding();
+ info.codecForDecoding = codecForDecoding();
+ info.serverList = serverList();
+ return info;
+}
+
+void Network::setNetworkInfo(const NetworkInfo &info) {
+ // we don't set our ID!
+ if(!info.networkName.isEmpty()) setNetworkName(info.networkName);
+ if(info.identity > 0) setIdentity(info.identity);
+ if(!info.codecForEncoding.isEmpty()) setCodecForEncoding(QTextCodec::codecForName(info.codecForEncoding));
+ if(!info.codecForDecoding.isEmpty()) setCodecForDecoding(QTextCodec::codecForName(info.codecForDecoding));
+ if(info.serverList.count()) setServerList(info.serverList);
+}
+
QString Network::prefixToMode(const QString &prefix) {
if(prefixes().contains(prefix))
return QString(prefixModes()[prefixes().indexOf(prefix)]);
return newIrcChannel(decodeString(channelname));
}
-IrcChannel *Network::ircChannel(QString channelname) {
+IrcChannel *Network::ircChannel(QString channelname) const {
channelname = channelname.toLower();
if(_ircChannels.contains(channelname))
return _ircChannels[channelname];
return 0;
}
-IrcChannel *Network::ircChannel(const QByteArray &channelname) {
+IrcChannel *Network::ircChannel(const QByteArray &channelname) const {
return ircChannel(decodeString(channelname));
}
void Network::setCodecForEncoding(QTextCodec *codec) {
_codecForEncoding = codec;
+ emit codecForEncodingSet(codecForEncoding());
}
QByteArray Network::codecForDecoding() const {
void Network::setCodecForDecoding(QTextCodec *codec) {
_codecForDecoding = codec;
+ emit codecForDecodingSet(codecForDecoding());
}
QString Network::decodeString(const QByteArray &text) const {
else emit connectRequested(networkId()); // and this is for CoreSession :)
}
+void Network::requestDisconnect() {
+ if(!proxy()) return;
+ if(proxy()->proxyMode() == SignalProxy::Client) emit disconnectRequested(); // on the client this triggers calling this slot on the core
+ else emit disconnectRequested(networkId()); // and this is for CoreSession :)
+}
+
// ====================
// Private:
// ====================
}
}
+/************************************************************************
+ * NetworkInfo
+ ************************************************************************/
+
+bool NetworkInfo::operator==(const NetworkInfo &other) const {
+ if(networkId != other.networkId) return false;
+ if(networkName != other.networkName) return false;
+ if(identity != other.identity) return false;
+ if(codecForEncoding != other.codecForEncoding) return false;
+ if(codecForDecoding != other.codecForDecoding) return false;
+ if(serverList != other.serverList) return false;
+ return true;
+}
+
+bool NetworkInfo::operator!=(const NetworkInfo &other) const {
+ return !(*this == other);
+}