X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fnetwork.cpp;h=db15d2538deec2915738a6074a35a653bf6bc3cd;hp=3162bd4c43ef6300f4e3012b451dea0aa540b8d5;hb=aa40491595ffec54ba340a9850d99dc14d920eb3;hpb=1f02b7201ab7b86238e705d2ce5b22f50bf6acfe diff --git a/src/common/network.cpp b/src/common/network.cpp index 3162bd4c..db15d253 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -280,9 +280,7 @@ IrcUser *Network::newIrcUser(const QString &hostmask) { QString nick(nickFromMask(hostmask).toLower()); if(!_ircUsers.contains(nick)) { IrcUser *ircuser = new IrcUser(hostmask, this); - // mark IrcUser as already initialized to keep the SignalProxy from requesting initData - //if(isInitialized()) - // ircuser->setInitialized(); + if(proxy()) proxy()->synchronize(ircuser); else @@ -290,6 +288,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 +300,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 +327,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 +344,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)) @@ -353,9 +367,6 @@ quint32 Network::ircUserCount() const { IrcChannel *Network::newIrcChannel(const QString &channelname) { if(!_ircChannels.contains(channelname.toLower())) { IrcChannel *channel = new IrcChannel(channelname, this); - // mark IrcUser as already initialized to keep the SignalProxy from requesting initData - //if(isInitialized()) - // channel->setInitialized(); if(proxy()) proxy()->synchronize(channel); @@ -628,7 +639,13 @@ QStringList Network::initIrcUsers() const { } QStringList Network::initIrcChannels() const { - return _ircChannels.keys(); + QStringList channels; + QHash::const_iterator iter = _ircChannels.constBegin(); + while(iter != _ircChannels.constEnd()) { + channels << iter.value()->name(); + iter++; + } + return channels; } void Network::initSetSupports(const QVariantMap &supports) { @@ -651,7 +668,7 @@ void Network::initSetIrcUsers(const QStringList &hostmasks) { } } -void Network::initSetChannels(const QStringList &channels) { +void Network::initSetIrcChannels(const QStringList &channels) { if(!_ircChannels.empty()) return; foreach(QString channel, channels) @@ -725,7 +742,7 @@ void Network::requestConnect() const { if(proxy()->proxyMode() == SignalProxy::Client) emit connectRequested(); // on the client this triggers calling this slot on the core else { if(connectionState() != Disconnected) { - qWarning() << "Requesting connect while not being disconnected!"; + qWarning() << "Requesting connect while already being connected!"; return; } emit connectRequested(networkId()); // and this is for CoreSession :) @@ -860,11 +877,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(); +}