return _connected;
}
-Network::ConnectionState Network::connectionState() const {
+//Network::ConnectionState Network::connectionState() const {
+int Network::connectionState() const {
return _connectionState;
}
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);
return;
_ircUsers.remove(nick);
+ disconnect(ircuser, 0, this, 0);
emit ircUserRemoved(nick);
emit ircUserRemoved(ircuser);
ircuser->deleteLater();
}
-void Network::removeIrcUser(QString nick) {
+void Network::removeChansAndUsers() {
+ QList<IrcUser *> users = ircUsers();
+ foreach(IrcUser *user, users) {
+ removeIrcUser(user);
+ }
+ QList<IrcChannel *> channels = ircChannels();
+ foreach(IrcChannel *channel, channels) {
+ removeIrcChannel(channel);
+ }
+}
+
+void Network::removeIrcUser(const QString &nick) {
IrcUser *ircuser;
if((ircuser = ircUser(nick)) != 0)
removeIrcUser(ircuser);
void Network::setConnected(bool connected) {
_connected = connected;
+ if(!connected)
+ removeChansAndUsers();
emit connectedSet(connected);
}
-void Network::setConnectionState(ConnectionState state) {
+//void Network::setConnectionState(ConnectionState state) {
+void Network::setConnectionState(int state) {
_connectionState = (ConnectionState)state;
+ //qDebug() << "netstate" << networkId() << networkName() << state;
+ emit connectionStateSet(state);
emit connectionStateSet(_connectionState);
}
emit ircChannelInitDone(ircchannel);
}
-void Network::ircUserDestroyed() {
- IrcUser *ircuser = static_cast<IrcUser *>(sender());
- Q_ASSERT(ircuser);
- removeIrcUser(ircuser);
+void Network::removeIrcChannel(IrcChannel *channel) {
+ QString chanName = _ircChannels.key(channel);
+ if(chanName.isNull())
+ return;
+
+ _ircChannels.remove(chanName);
+ disconnect(channel, 0, this, 0);
+ emit ircChannelRemoved(chanName);
+ emit ircChannelRemoved(channel);
+ channel->deleteLater();
+}
+
+void Network::removeIrcChannel(const QString &channel) {
+ IrcChannel *chan;
+ if((chan = ircChannel(channel)) != 0)
+ removeIrcChannel(chan);
}
void Network::channelDestroyed() {
IrcChannel *channel = static_cast<IrcChannel *>(sender());
Q_ASSERT(channel);
- emit ircChannelRemoved(sender());
_ircChannels.remove(_ircChannels.key(channel));
+ emit ircChannelRemoved(channel);
}
void Network::requestConnect() const {