X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fnetwork.cpp;h=2fbde1e39b395dd0764011db1ce1867f85849529;hp=b565a78e104e8757d46d69c493355fb6767a44eb;hb=56607f81246f04db3a0e71c9a8757d7f75d6cfcf;hpb=8010224cf5bfe5685dc2cf535e8dc1ec19c4c364 diff --git a/src/common/network.cpp b/src/common/network.cpp index b565a78e..2fbde1e3 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -290,6 +290,7 @@ IrcUser *Network::newIrcUser(const QString &hostmask) { connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString))); connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone())); + connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); _ircUsers[nick] = ircuser; emit ircUserAdded(hostmask); emit ircUserAdded(ircuser); @@ -301,6 +302,21 @@ IrcUser *Network::newIrcUser(const QByteArray &hostmask) { return newIrcUser(decodeServerString(hostmask)); } +void Network::ircUserDestroyed() { + IrcUser *ircUser = static_cast(sender()); + if(!ircUser) + return; + + QHash::iterator ircUserIter = _ircUsers.begin(); + while(ircUserIter != _ircUsers.end()) { + if(ircUser == *ircUserIter) { + ircUserIter = _ircUsers.erase(ircUserIter); + break; + } + ircUserIter++; + } +} + void Network::removeIrcUser(IrcUser *ircuser) { QString nick = _ircUsers.key(ircuser); if(nick.isNull()) @@ -313,6 +329,12 @@ void Network::removeIrcUser(IrcUser *ircuser) { ircuser->deleteLater(); } +void Network::removeIrcUser(const QString &nick) { + IrcUser *ircuser; + if((ircuser = ircUser(nick)) != 0) + removeIrcUser(ircuser); +} + void Network::removeChansAndUsers() { QList users = ircUsers(); foreach(IrcUser *user, users) { @@ -324,12 +346,6 @@ void Network::removeChansAndUsers() { } } -void Network::removeIrcUser(const QString &nick) { - IrcUser *ircuser; - if((ircuser = ircUser(nick)) != 0) - removeIrcUser(ircuser); -} - IrcUser *Network::ircUser(QString nickname) const { nickname = nickname.toLower(); if(_ircUsers.contains(nickname)) @@ -651,7 +667,11 @@ void Network::initSetIrcUsers(const QStringList &hostmasks) { } } -void Network::initSetChannels(const QStringList &channels) { +void Network::initSetIrcChannels(const QStringList &channels) { + // FIXME This does not work correctly, "received data for unknown User" triggers + // So we disable this for now + return; + if(!_ircChannels.empty()) return; foreach(QString channel, channels) @@ -860,11 +880,16 @@ QDataStream &operator>>(QDataStream &in, NetworkInfo &info) { return in; } - - - - - +QDebug operator<<(QDebug dbg, const NetworkInfo &i) { + dbg.nospace() << "(id = " << i.networkId << " name = " << i.networkName << " identity = " << i.identity + << " codecForServer = " << i.codecForServer << " codecForEncoding = " << i.codecForEncoding << " codecForDecoding = " << i.codecForDecoding + << " serverList = " << i.serverList << " useRandomServer = " << i.useRandomServer << " perform = " << i.perform + << " useAutoIdentify = " << i.useAutoIdentify << " autoIdentifyService = " << i.autoIdentifyService << " autoIdentifyPassword = " << i.autoIdentifyPassword + << " useAutoReconnect = " << i.useAutoReconnect << " autoReconnectInterval = " << i.autoReconnectInterval + << " autoReconnectRetries = " << i.autoReconnectRetries << " unlimitedReconnectRetries = " << i.unlimitedReconnectRetries + << " rejoinChannels = " << i.rejoinChannels << ")"; + return dbg.space(); +}