/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
setObjectName(QString::number(network->networkId().toInt()) + "/" + channelname);
}
+IrcChannel::~IrcChannel() {
+}
+
// ====================
// PUBLIC:
// ====================
IrcUser *ircuser;
for(int i = 0; i < users.count(); i++) {
ircuser = users[i];
- if(!ircuser || _userModes.contains(ircuser))
+ if(!ircuser || _userModes.contains(ircuser)) {
+ addUserMode(ircuser, modes[i]);
continue;
+ }
_userModes[ircuser] = modes[i];
ircuser->joinChannel(this);
- //qDebug() << "JOIN" << name() << ircuser->nick() << ircUsers().count();
connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString)));
- connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
+ // connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
// if you wonder why there is no counterpart to ircUserJoined:
// the joines are propagted by the ircuser. the signal ircUserJoined is only for convenience
if(isKnownUser(ircuser)) {
_userModes.remove(ircuser);
ircuser->partChannel(this);
- //qDebug() << "PART" << name() << ircuser->nick() << ircUsers().count();
// if you wonder why there is no counterpart to ircUserParted:
// the joines are propagted by the ircuser. the signal ircUserParted is only for convenience
disconnect(ircuser, 0, this, 0);
emit ircUserParted(ircuser);
- if(network->isMe(ircuser))
- deleteLater();
+
+ if(network->isMe(ircuser) || _userModes.isEmpty()) {
+ // in either case we're no longer in the channel
+ // -> clean up the channel and destroy it
+ QList<IrcUser *> users = _userModes.keys();
+ _userModes.clear();
+ foreach(IrcUser *user, users) {
+ disconnect(user, 0, this, 0);
+ user->partChannel(this);
+ }
+ emit parted();
+ network->removeIrcChannel(this);
+ }
}
}
return;
case Network::A_CHANMODE:
if(_A_channelModes.contains(mode))
- _A_channelModes[mode].removeOne(value);
+ _A_channelModes[mode].removeAll(value);
break;
case Network::B_CHANMODE: