/***************************************************************************
- * 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 *
#include <QTextCodec>
#include <QDebug>
+INIT_SYNCABLE_OBJECT(IrcUser)
IrcUser::IrcUser(const QString &hostmask, Network *network) : SyncableObject(network),
_initialized(false),
_nick(nickFromMask(hostmask)),
_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::setUser(const QString &user) {
if(!user.isEmpty() && _user != user) {
_user = user;
- emit userSet(user);
+ SYNC(ARG(user));
}
}
void IrcUser::setRealName(const QString &realName) {
if (!realName.isEmpty() && _realName != realName) {
_realName = realName;
- emit realNameSet(realName);
+ SYNC(ARG(realName))
}
}
void IrcUser::setAway(const bool &away) {
if(away != _away) {
_away = away;
+ SYNC(ARG(away))
emit awaySet(away);
}
}
void IrcUser::setAwayMessage(const QString &awayMessage) {
if(!awayMessage.isEmpty() && _awayMessage != awayMessage) {
_awayMessage = awayMessage;
- emit awayMessageSet(awayMessage);
+ SYNC(ARG(awayMessage))
}
}
void IrcUser::setIdleTime(const QDateTime &idleTime) {
if(idleTime.isValid() && _idleTime != idleTime) {
_idleTime = idleTime;
- emit idleTimeSet(idleTime);
+ _idleTimeSet = QDateTime::currentDateTime();
+ SYNC(ARG(idleTime))
+ }
+}
+
+void IrcUser::setLoginTime(const QDateTime &loginTime) {
+ if(loginTime.isValid() && _loginTime != loginTime) {
+ _loginTime = loginTime;
+ SYNC(ARG(loginTime))
}
}
void IrcUser::setServer(const QString &server) {
if(!server.isEmpty() && _server != server) {
_server = server;
- emit serverSet(server);
+ SYNC(ARG(server))
}
}
void IrcUser::setIrcOperator(const QString &ircOperator) {
if(!ircOperator.isEmpty() && _ircOperator != ircOperator) {
_ircOperator = ircOperator;
- emit ircOperatorSet(ircOperator);
+ SYNC(ARG(ircOperator))
}
}
void IrcUser::setLastAwayMessage(const int &lastAwayMessage) {
if(lastAwayMessage > _lastAwayMessage) {
_lastAwayMessage = lastAwayMessage;
- emit lastAwayMessageSet(lastAwayMessage);
+ SYNC(ARG(lastAwayMessage))
}
}
void IrcUser::setHost(const QString &host) {
if(!host.isEmpty() && _host != host) {
_host = host;
- emit hostSet(host);
+ SYNC(ARG(host))
}
}
void IrcUser::setNick(const QString &nick) {
if(!nick.isEmpty() && nick != _nick) {
+ qDebug() << "setNick" << this << _nick << nick;
_nick = nick;
updateObjectName();
+ SYNC(ARG(nick))
emit nickSet(nick);
}
}
+void IrcUser::setWhoisServiceReply(const QString &whoisServiceReply) {
+ if(!whoisServiceReply.isEmpty() && whoisServiceReply != _whoisServiceReply) {
+ _whoisServiceReply = whoisServiceReply;
+ SYNC(ARG(whoisServiceReply))
+ }
+}
+
+void IrcUser::setSuserHost(const QString &suserHost) {
+ if(!suserHost.isEmpty() && suserHost != _suserHost) {
+ _suserHost = suserHost;
+ SYNC(ARG(suserHost))
+ }
+}
+
void IrcUser::updateObjectName() {
renameObject(QString::number(network()->networkId().toInt()) + "/" + _nick);
}
Q_ASSERT(channel);
if(!_channels.contains(channel)) {
_channels.insert(channel);
- channel->joinIrcUsers(this);
- connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed()));
+ channel->joinIrcUser(this);
}
}
_channels.remove(channel);
disconnect(channel, 0, this, 0);
channel->part(this);
- emit channelParted(channel->name());
- if(_channels.isEmpty() && network()->isMe(this))
- deleteLater();
+ QString channelName = channel->name();
+ SYNC_OTHER(partChannel, ARG(channelName))
+ 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);
+ SYNC(NO_ARG)
+ 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();
}
}
void IrcUser::setUserModes(const QString &modes) {
_userModes = modes;
+ SYNC(ARG(modes))
emit userModesSet(modes);
}
_userModes += modes[i];
}
+ SYNC(ARG(modes))
emit userModesAdded(modes);
}
for(int i = 0; i < modes.count(); i++) {
_userModes.remove(modes[i]);
}
+ SYNC(ARG(modes))
emit userModesRemoved(modes);
}
+
+void IrcUser::setLastChannelActivity(BufferId buffer, const QDateTime &time) {
+ _lastActivity[buffer] = time;
+ emit lastChannelActivityUpdated(buffer, time);
+}
+
+void IrcUser::setLastSpokenTo(BufferId buffer, const QDateTime &time) {
+ _lastSpokenTo[buffer] = time;
+ emit lastSpokenToUpdated(buffer, time);
+}