X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fnetworkinfo.cpp;h=74cb8b9a0abcea0cada826d557a201fcc35c098b;hp=24ed8d7f52600b9830a092101e2053ca84e7827c;hb=836534302ea576791dc5cc01918dd4c5abd61878;hpb=cd122ca8e0d2c0ffc5397e0a813c75d791a7e6e3 diff --git a/src/common/networkinfo.cpp b/src/common/networkinfo.cpp index 24ed8d7f..74cb8b9a 100644 --- a/src/common/networkinfo.cpp +++ b/src/common/networkinfo.cpp @@ -20,7 +20,6 @@ #include "networkinfo.h" #include "signalproxy.h" -#include "synchronizer.h" #include "ircuser.h" #include "ircchannel.h" @@ -31,7 +30,7 @@ // ==================== // Public: // ==================== -NetworkInfo::NetworkInfo(const uint &networkid, SignalProxy *proxy, QObject *parent) +NetworkInfo::NetworkInfo(const uint &networkid, QObject *parent) : QObject(parent), _networkId(networkid), _initialized(false), @@ -39,20 +38,20 @@ NetworkInfo::NetworkInfo(const uint &networkid, SignalProxy *proxy, QObject *par _networkName(QString()), _currentServer(QString()), _prefixes(QString()), - _prefixModes(QString()) + _prefixModes(QString()), + _proxy(NULL) { setObjectName(QString::number(networkid)); - _synchronizer = new Synchronizer(this, proxy); } // I think this is unnecessary since IrcUsers have us as their daddy :) -// NetworkInfo::~NetworkInfo() { +//NetworkInfo::~NetworkInfo() { // QHashIterator ircuser(_ircUsers); // while (ircuser.hasNext()) { // ircuser.next(); // delete ircuser.value(); // } -// } +//} uint NetworkInfo::networkId() const { return _networkId; @@ -62,8 +61,13 @@ bool NetworkInfo::initialized() const { return _initialized; } -Synchronizer *NetworkInfo::synchronizer() { - return _synchronizer; +SignalProxy *NetworkInfo::proxy() const { + return _proxy; +} + +void NetworkInfo::setProxy(SignalProxy *proxy) { + _proxy = proxy; + proxy->synchronize(this); } bool NetworkInfo::isMyNick(const QString &nick) const { @@ -162,7 +166,14 @@ IrcUser *NetworkInfo::newIrcUser(const QString &hostmask) { QString nick(nickFromMask(hostmask)); if(!_ircUsers.contains(nick)) { IrcUser *ircuser = new IrcUser(hostmask, this); - new Synchronizer(ircuser, synchronizer()->proxy()); + // mark IrcUser as already initialized to keep the SignalProxy from requesting initData + if(initialized()) + ircuser->setInitialized(); + if(proxy()) + proxy()->synchronize(ircuser); + else + qWarning() << "unable to synchronize new IrcUser" << hostmask << "forgot to call NetworkInfo::setProxy(SignalProxy *)?"; + connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString))); connect(ircuser, SIGNAL(initDone()), this, SIGNAL(ircUserInitDone())); connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); @@ -172,6 +183,22 @@ IrcUser *NetworkInfo::newIrcUser(const QString &hostmask) { return _ircUsers[nick]; } +void NetworkInfo::removeIrcUser(IrcUser *ircuser) { + QString nick = _ircUsers.key(ircuser); + if(nick.isNull()) + return; + + _ircUsers.remove(nick); + ircuser->deleteLater(); + emit ircUserRemoved(nick); +} + +void NetworkInfo::removeIrcUser(QString nick) { + IrcUser *ircuser; + if((ircuser = ircUser(nick)) != 0) + removeIrcUser(ircuser); +} + IrcUser *NetworkInfo::ircUser(const QString &nickname) const { if(_ircUsers.contains(nickname)) return _ircUsers[nickname]; @@ -186,7 +213,15 @@ QList NetworkInfo::ircUsers() const { IrcChannel *NetworkInfo::newIrcChannel(const QString &channelname) { if(!_ircChannels.contains(channelname)) { IrcChannel *channel = new IrcChannel(channelname, this); - new Synchronizer(channel, synchronizer()->proxy()); + // mark IrcUser as already initialized to keep the SignalProxy from requesting initData + if(initialized()) + channel->setInitialized(); + + if(proxy()) + proxy()->synchronize(channel); + else + qWarning() << "unable to synchronize new IrcChannel" << channelname << "forgot to call NetworkInfo::setProxy(SignalProxy *)?"; + connect(channel, SIGNAL(initDone()), this, SIGNAL(ircChannelInitDone())); connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed())); _ircChannels[channelname] = channel; @@ -312,7 +347,7 @@ void NetworkInfo::ircUserNickChanged(QString newnick) { void NetworkInfo::ircUserDestroyed() { IrcUser *ircuser = static_cast(sender()); Q_ASSERT(ircuser); - _ircUsers.remove(_ircUsers.key(ircuser)); + removeIrcUser(ircuser); } void NetworkInfo::channelDestroyed() { @@ -337,8 +372,8 @@ void NetworkInfo::determinePrefixes() { _prefixes = PREFIX.section(")", 1); _prefixModes = PREFIX.mid(1).section(")", 0, 0); } else { - QString defaultPrefixes("@%+"); - QString defaultPrefixModes("ohv"); + QString defaultPrefixes("~&@%+"); + QString defaultPrefixModes("qaohv"); // we just assume that in PREFIX are only prefix chars stored for(int i = 0; i < defaultPrefixes.size(); i++) {