/***************************************************************************
- * Copyright (C) 2005-07 by The Quassel Team *
+ * Copyright (C) 2005-07 by the Quassel IRC Team *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
+ * (at your option) version 3. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
}
// I think this is unnecessary since IrcUsers have us as their daddy :)
-// NetworkInfo::~NetworkInfo() {
+//NetworkInfo::~NetworkInfo() {
// QHashIterator<QString, IrcUser *> ircuser(_ircUsers);
// while (ircuser.hasNext()) {
// ircuser.next();
// delete ircuser.value();
// }
-// }
+//}
uint NetworkInfo::networkId() const {
return _networkId;
}
IrcUser *NetworkInfo::newIrcUser(const QString &hostmask) {
- QString nick(nickFromMask(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(initialized())
ircuser->setInitialized();
- _proxy->synchronize(ircuser);
+ 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()));
_ircUsers[nick] = ircuser;
emit ircUserAdded(hostmask);
}
- return _ircUsers[nick];
+ return _ircUsers[nick];
}
-IrcUser *NetworkInfo::ircUser(const QString &nickname) const {
+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(QString nickname) const {
+ nickname = nickname.toLower();
if(_ircUsers.contains(nickname))
return _ircUsers[nickname];
else
}
IrcChannel *NetworkInfo::newIrcChannel(const QString &channelname) {
- if(!_ircChannels.contains(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(initialized())
channel->setInitialized();
- _proxy->synchronize(channel);
+
+ 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;
+ _ircChannels[channelname.toLower()] = channel;
emit ircChannelAdded(channelname);
}
- return _ircChannels[channelname];
+ return _ircChannels[channelname.toLower()];
}
-IrcChannel *NetworkInfo::ircChannel(const QString &channelname) {
+IrcChannel *NetworkInfo::ircChannel(QString channelname) {
+ channelname = channelname.toLower();
if(_ircChannels.contains(channelname))
return _ircChannels[channelname];
else
void NetworkInfo::ircUserDestroyed() {
IrcUser *ircuser = static_cast<IrcUser *>(sender());
Q_ASSERT(ircuser);
- _ircUsers.remove(_ircUsers.key(ircuser));
+ removeIrcUser(ircuser);
}
void NetworkInfo::channelDestroyed() {
_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++) {