/***************************************************************************
- * 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 *
_awayMessage(),
_away(false),
_server(),
- _idleTime(QDateTime::currentDateTime()),
+ // _idleTime(QDateTime::currentDateTime()),
_ircOperator(),
_lastAwayMessage(0),
+ _whoisServiceReply(),
_network(network),
_codecForEncoding(0),
_codecForDecoding(0)
// PUBLIC:
// ====================
-QString IrcUser::user() const {
- return _user;
-}
-
-QString IrcUser::host() const {
- return _host;
-}
-
-QString IrcUser::nick() const {
- return _nick;
-}
-
-QString IrcUser::realName() const {
- return _realName;
-}
-
QString IrcUser::hostmask() const {
return QString("%1!%2@%3").arg(nick()).arg(user()).arg(host());
}
-bool IrcUser::isAway() const {
- return _away;
-}
-
-QString IrcUser::awayMessage() const {
- return _awayMessage;
-}
-
-QString IrcUser::server() const {
- return _server;
-}
-
-QDateTime IrcUser::idleTime() const {
+QDateTime IrcUser::idleTime() {
+ if(QDateTime::currentDateTime().toTime_t() - _idleTimeSet.toTime_t() > 1200)
+ _idleTime = QDateTime();
return _idleTime;
}
-QString IrcUser::ircOperator() const {
- return _ircOperator;
-}
-
-int IrcUser::lastAwayMessage() const {
- return _lastAwayMessage;
-}
-
-QString IrcUser::userModes() const {
- return _userModes;
-}
-
QStringList IrcUser::channels() const {
QStringList chanList;
IrcChannel *channel;
return chanList;
}
-Network* IrcUser::network() const {
- return _network;
-}
-
-QTextCodec *IrcUser::codecForEncoding() const {
- return _codecForEncoding;
-}
void IrcUser::setCodecForEncoding(const QString &name) {
setCodecForEncoding(QTextCodec::codecForName(name.toAscii()));
_codecForEncoding = codec;
}
-QTextCodec *IrcUser::codecForDecoding() const {
- return _codecForDecoding;
-}
-
void IrcUser::setCodecForDecoding(const QString &name) {
setCodecForDecoding(QTextCodec::codecForName(name.toAscii()));
}
void IrcUser::setIdleTime(const QDateTime &idleTime) {
if(idleTime.isValid() && _idleTime != idleTime) {
_idleTime = idleTime;
+ _idleTimeSet = QDateTime::currentDateTime();
emit idleTimeSet(idleTime);
}
}
+void IrcUser::setLoginTime(const QDateTime &loginTime) {
+ if(loginTime.isValid() && _loginTime != loginTime) {
+ _loginTime = loginTime;
+ emit loginTimeSet(loginTime);
+ }
+}
+
void IrcUser::setServer(const QString &server) {
if(!server.isEmpty() && _server != server) {
_server = server;
}
}
+void IrcUser::setWhoisServiceReply(const QString &whoisServiceReply) {
+ if(!whoisServiceReply.isEmpty() && whoisServiceReply != _whoisServiceReply) {
+ _whoisServiceReply = whoisServiceReply;
+ emit whoisServiceReplySet(whoisServiceReply);
+ }
+}
+
+void IrcUser::setSuserHost(const QString &suserHost) {
+ if(!suserHost.isEmpty() && suserHost != _suserHost) {
+ _suserHost = suserHost;
+ emit suserHostSet(suserHost);
+ }
+}
+
void IrcUser::updateObjectName() {
renameObject(QString::number(network()->networkId().toInt()) + "/" + _nick);
}
if(!_channels.contains(channel)) {
_channels.insert(channel);
channel->joinIrcUsers(this);
- connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
}
}
disconnect(channel, 0, this, 0);
channel->part(this);
emit channelParted(channel->name());
- if(_channels.isEmpty() && network()->isMe(this))
- deleteLater();
+ if(_channels.isEmpty() && !network()->isMe(this))
+ quit();
}
}
}
}
+void IrcUser::quit() {
+ QList<IrcChannel *> channels = _channels.toList();
+ _channels.clear();
+ foreach(IrcChannel *channel, channels) {
+ disconnect(channel, 0, this, 0);
+ channel->part(this);
+ }
+ network()->removeIrcUser(this);
+ emit quited();
+}
+
void IrcUser::channelDestroyed() {
// private slot!
IrcChannel *channel = static_cast<IrcChannel*>(sender());
if(_channels.contains(channel)) {
_channels.remove(channel);
- if(_channels.isEmpty())
- deleteLater();
+ if(_channels.isEmpty() && !network()->isMe(this))
+ quit();
}
}