1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
26 #include <QStringList>
27 #include <QVariantMap>
30 #include "syncableobject.h"
37 class IrcUser : public SyncableObject {
41 Q_PROPERTY(QString user READ user WRITE setUser STORED false)
42 Q_PROPERTY(QString host READ host WRITE setHost STORED false)
43 Q_PROPERTY(QString nick READ nick WRITE setNick STORED false)
44 Q_PROPERTY(QString realName READ realName WRITE setRealName STORED false)
45 Q_PROPERTY(bool away READ isAway WRITE setAway STORED false)
46 Q_PROPERTY(QString awayMessage READ awayMessage WRITE setAwayMessage STORED false)
47 Q_PROPERTY(QDateTime idleTime READ idleTime WRITE setIdleTime STORED false)
48 Q_PROPERTY(QDateTime loginTime READ loginTime WRITE setLoginTime STORED false)
49 Q_PROPERTY(QString server READ server WRITE setServer STORED false)
50 Q_PROPERTY(QString ircOperator READ ircOperator WRITE setIrcOperator STORED false)
51 Q_PROPERTY(int lastAwayMessage READ lastAwayMessage WRITE setLastAwayMessage STORED false)
52 Q_PROPERTY(QString whoisServiceReply READ whoisServiceReply WRITE setWhoisServiceReply STORED false)
53 Q_PROPERTY(QString suserHost READ suserHost WRITE setSuserHost STORED false)
55 Q_PROPERTY(QStringList channels READ channels STORED false)
56 Q_PROPERTY(QString userModes READ userModes WRITE setUserModes)
59 IrcUser(const QString &hostmask, Network *network);
62 inline QString user() const { return _user; }
63 inline QString host() const { return _host; }
64 inline QString nick() const { return _nick; }
65 inline QString realName() const { return _realName; }
66 QString hostmask() const;
67 inline bool isAway() const { return _away; }
68 inline QString awayMessage() const { return _awayMessage; }
70 inline QDateTime loginTime() const { return _loginTime; }
71 inline QString server() const { return _server; }
72 inline QString ircOperator() const { return _ircOperator; }
73 inline int lastAwayMessage() const { return _lastAwayMessage; }
74 inline QString whoisServiceReply() const { return _whoisServiceReply; }
75 inline QString suserHost() const { return _suserHost; }
76 inline Network *network() const { return _network; }
78 inline QString userModes() const { return _userModes; }
80 QStringList channels() const;
82 // user-specific encodings
83 inline QTextCodec *codecForEncoding() const { return _codecForEncoding; }
84 inline QTextCodec *codecForDecoding() const { return _codecForDecoding; }
85 void setCodecForEncoding(const QString &codecName);
86 void setCodecForEncoding(QTextCodec *codec);
87 void setCodecForDecoding(const QString &codecName);
88 void setCodecForDecoding(QTextCodec *codec);
90 QString decodeString(const QByteArray &text) const;
91 QByteArray encodeString(const QString &string) const;
93 // only valid on client side, these are not synced!
94 inline QDateTime lastChannelActivity(BufferId id) const { return _lastActivity.value(id); }
95 void setLastChannelActivity(BufferId id, const QDateTime &time);
96 inline QDateTime lastSpokenTo(BufferId id) const { return _lastSpokenTo.value(id); }
97 void setLastSpokenTo(BufferId id, const QDateTime &time);
100 void setUser(const QString &user);
101 void setHost(const QString &host);
102 void setNick(const QString &nick);
103 void setRealName(const QString &realName);
104 void setAway(const bool &away);
105 void setAwayMessage(const QString &awayMessage);
106 void setIdleTime(const QDateTime &idleTime);
107 void setLoginTime(const QDateTime &loginTime);
108 void setServer(const QString &server);
109 void setIrcOperator(const QString &ircOperator);
110 void setLastAwayMessage(const int &lastAwayMessage);
111 void setWhoisServiceReply(const QString &whoisServiceReply);
112 void setSuserHost(const QString &suserHost);
113 void updateHostmask(const QString &mask);
115 void setUserModes(const QString &modes);
117 void joinChannel(IrcChannel *channel);
118 void joinChannel(const QString &channelname);
119 void partChannel(IrcChannel *channel);
120 void partChannel(const QString &channelname);
123 void addUserModes(const QString &modes);
124 void removeUserModes(const QString &modes);
127 // void userSet(QString user);
128 // void hostSet(QString host);
129 void nickSet(QString newnick); // needed in NetworkModel
130 // void realNameSet(QString realName);
131 void awaySet(bool away); // needed in NetworkModel
132 // void awayMessageSet(QString awayMessage);
133 // void idleTimeSet(QDateTime idleTime);
134 // void loginTimeSet(QDateTime loginTime);
135 // void serverSet(QString server);
136 // void ircOperatorSet(QString ircOperator);
137 // void lastAwayMessageSet(int lastAwayMessage);
138 // void whoisServiceReplySet(QString whoisServiceReply);
139 // void suserHostSet(QString suserHost);
141 void userModesSet(QString modes);
142 void userModesAdded(QString modes);
143 void userModesRemoved(QString modes);
145 // void channelJoined(QString channel);
146 void channelParted(QString channel);
149 void lastChannelActivityUpdated(BufferId id, const QDateTime &newTime);
150 void lastSpokenToUpdated(BufferId id, const QDateTime &newTime);
153 void updateObjectName();
154 void channelDestroyed();
157 inline bool operator==(const IrcUser &ircuser2) {
158 return (_nick.toLower() == ircuser2.nick().toLower());
161 inline bool operator==(const QString &nickname) {
162 return (_nick.toLower() == nickname.toLower());
171 QString _awayMessage;
175 QDateTime _idleTimeSet;
176 QDateTime _loginTime;
177 QString _ircOperator;
178 int _lastAwayMessage;
179 QString _whoisServiceReply;
182 // QSet<QString> _channels;
183 QSet<IrcChannel *> _channels;
188 QTextCodec *_codecForEncoding;
189 QTextCodec *_codecForDecoding;
191 QHash<BufferId, QDateTime> _lastActivity;
192 QHash<BufferId, QDateTime> _lastSpokenTo;