1 /***************************************************************************
2 * Copyright (C) 2005-08 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"
36 class IrcUser : public SyncableObject {
39 Q_PROPERTY(QString user READ user WRITE setUser STORED false)
40 Q_PROPERTY(QString host READ host WRITE setHost STORED false)
41 Q_PROPERTY(QString nick READ nick WRITE setNick STORED false)
42 Q_PROPERTY(QString realName READ realName WRITE setRealName STORED false)
43 Q_PROPERTY(bool away READ isAway WRITE setAway STORED false)
44 Q_PROPERTY(QString awayMessage READ awayMessage WRITE setAwayMessage STORED false)
45 Q_PROPERTY(QDateTime idleTime READ idleTime WRITE setIdleTime STORED false)
46 Q_PROPERTY(QDateTime loginTime READ loginTime WRITE setLoginTime STORED false)
47 Q_PROPERTY(QString server READ server WRITE setServer STORED false)
48 Q_PROPERTY(QString ircOperator READ ircOperator WRITE setIrcOperator STORED false)
49 Q_PROPERTY(int lastAwayMessage READ lastAwayMessage WRITE setLastAwayMessage STORED false)
50 Q_PROPERTY(QString whoisServiceReply READ whoisServiceReply WRITE setWhoisServiceReply STORED false)
51 Q_PROPERTY(QString suserHost READ suserHost WRITE setSuserHost STORED false)
53 Q_PROPERTY(QStringList channels READ channels STORED false)
54 Q_PROPERTY(QString userModes READ userModes WRITE setUserModes)
57 IrcUser(const QString &hostmask, Network *network);
60 inline QString user() const { return _user; }
61 inline QString host() const { return _host; }
62 inline QString nick() const { return _nick; }
63 inline QString realName() const { return _realName; }
64 QString hostmask() const;
65 inline bool isAway() const { return _away; }
66 inline QString awayMessage() const { return _awayMessage; }
68 inline QDateTime loginTime() const { return _loginTime; }
69 inline QString server() const { return _server; }
70 inline QString ircOperator() const { return _ircOperator; }
71 inline int lastAwayMessage() const { return _lastAwayMessage; }
72 inline QString whoisServiceReply() const { return _whoisServiceReply; }
73 inline QString suserHost() const { return _suserHost; }
74 inline Network *network() const { return _network; }
76 inline QString userModes() const { return _userModes; }
78 QStringList channels() const;
80 // user-specific encodings
81 inline QTextCodec *codecForEncoding() const { return _codecForEncoding; }
82 inline QTextCodec *codecForDecoding() const { return _codecForDecoding; }
83 void setCodecForEncoding(const QString &codecName);
84 void setCodecForEncoding(QTextCodec *codec);
85 void setCodecForDecoding(const QString &codecName);
86 void setCodecForDecoding(QTextCodec *codec);
88 QString decodeString(const QByteArray &text) const;
89 QByteArray encodeString(const QString &string) const;
92 void setUser(const QString &user);
93 void setHost(const QString &host);
94 void setNick(const QString &nick);
95 void setRealName(const QString &realName);
96 void setAway(const bool &away);
97 void setAwayMessage(const QString &awayMessage);
98 void setIdleTime(const QDateTime &idleTime);
99 void setLoginTime(const QDateTime &loginTime);
100 void setServer(const QString &server);
101 void setIrcOperator(const QString &ircOperator);
102 void setLastAwayMessage(const int &lastAwayMessage);
103 void setWhoisServiceReply(const QString &whoisServiceReply);
104 void setSuserHost(const QString &suserHost);
105 void updateHostmask(const QString &mask);
107 void setUserModes(const QString &modes);
109 void joinChannel(IrcChannel *channel);
110 void joinChannel(const QString &channelname);
111 void partChannel(IrcChannel *channel);
112 void partChannel(const QString &channelname);
114 void addUserModes(const QString &modes);
115 void removeUserModes(const QString &modes);
118 void userSet(QString user);
119 void hostSet(QString host);
120 void nickSet(QString newnick);
121 void realNameSet(QString realName);
122 void awaySet(bool away);
123 void awayMessageSet(QString awayMessage);
124 void idleTimeSet(QDateTime idleTime);
125 void loginTimeSet(QDateTime loginTime);
126 void serverSet(QString server);
127 void ircOperatorSet(QString ircOperator);
128 void lastAwayMessageSet(int lastAwayMessage);
129 void whoisServiceReplySet(QString whoisServiceReply);
130 void suserHostSet(QString suserHost);
131 void hostmaskUpdated(QString mask);
133 void userModesSet(QString modes);
135 // void channelJoined(QString channel);
136 void channelParted(QString channel);
138 void userModesAdded(QString modes);
139 void userModesRemoved(QString modes);
142 void updateObjectName();
143 void channelDestroyed();
146 inline bool operator==(const IrcUser &ircuser2) {
147 return (_nick.toLower() == ircuser2.nick().toLower());
150 inline bool operator==(const QString &nickname) {
151 return (_nick.toLower() == nickname.toLower());
160 QString _awayMessage;
164 QDateTime _idleTimeSet;
165 QDateTime _loginTime;
166 QString _ircOperator;
167 int _lastAwayMessage;
168 QString _whoisServiceReply;
171 // QSet<QString> _channels;
172 QSet<IrcChannel *> _channels;
177 QTextCodec *_codecForEncoding;
178 QTextCodec *_codecForDecoding;