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)
51 Q_PROPERTY(QStringList channels READ channels STORED false)
52 Q_PROPERTY(QString userModes READ userModes WRITE setUserModes)
55 IrcUser(const QString &hostmask, Network *network);
61 QString realName() const;
62 QString hostmask() const;
64 QString awayMessage() const;
66 QDateTime loginTime() const;
67 QString server() const;
68 QString ircOperator() const;
69 int lastAwayMessage() const;
70 Network *network() const;
72 QString userModes() const;
74 QStringList channels() const;
76 // user-specific encodings
77 QTextCodec *codecForEncoding() const;
78 QTextCodec *codecForDecoding() const;
79 void setCodecForEncoding(const QString &codecName);
80 void setCodecForEncoding(QTextCodec *codec);
81 void setCodecForDecoding(const QString &codecName);
82 void setCodecForDecoding(QTextCodec *codec);
84 QString decodeString(const QByteArray &text) const;
85 QByteArray encodeString(const QString &string) const;
88 void setUser(const QString &user);
89 void setHost(const QString &host);
90 void setNick(const QString &nick);
91 void setRealName(const QString &realName);
92 void setAway(const bool &away);
93 void setAwayMessage(const QString &awayMessage);
94 void setIdleTime(const QDateTime &idleTime);
95 void setLoginTime(const QDateTime &loginTime);
96 void setServer(const QString &server);
97 void setIrcOperator(const QString &ircOperator);
98 void setLastAwayMessage(const int &lastAwayMessage);
99 void updateHostmask(const QString &mask);
101 void setUserModes(const QString &modes);
103 void joinChannel(IrcChannel *channel);
104 void joinChannel(const QString &channelname);
105 void partChannel(IrcChannel *channel);
106 void partChannel(const QString &channelname);
108 void addUserModes(const QString &modes);
109 void removeUserModes(const QString &modes);
112 void userSet(QString user);
113 void hostSet(QString host);
114 void nickSet(QString newnick);
115 void realNameSet(QString realName);
116 void awaySet(bool away);
117 void awayMessageSet(QString awayMessage);
118 void idleTimeSet(QDateTime idleTime);
119 void loginTimeSet(QDateTime loginTime);
120 void serverSet(QString server);
121 void ircOperatorSet(QString ircOperator);
122 void lastAwayMessageSet(int lastAwayMessage);
123 void hostmaskUpdated(QString mask);
125 void userModesSet(QString modes);
127 // void channelJoined(QString channel);
128 void channelParted(QString channel);
130 void userModesAdded(QString modes);
131 void userModesRemoved(QString modes);
134 void updateObjectName();
135 void channelDestroyed();
138 inline bool operator==(const IrcUser &ircuser2) {
139 return (_nick.toLower() == ircuser2.nick().toLower());
142 inline bool operator==(const QString &nickname) {
143 return (_nick.toLower() == nickname.toLower());
152 QString _awayMessage;
156 QDateTime _idleTimeSet;
157 QDateTime _loginTime;
158 QString _ircOperator;
159 int _lastAwayMessage;
161 // QSet<QString> _channels;
162 QSet<IrcChannel *> _channels;
167 QTextCodec *_codecForEncoding;
168 QTextCodec *_codecForDecoding;