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(QString server READ server WRITE setServer STORED false)
47 Q_PROPERTY(QString ircOperator READ ircOperator WRITE setIrcOperator STORED false)
48 Q_PROPERTY(int lastAwayMessage READ lastAwayMessage WRITE setLastAwayMessage STORED false)
50 Q_PROPERTY(QStringList channels READ channels STORED false)
51 // Q_PROPERTY(QStringList usermodes READ usermodes WRITE setUsermodes)
54 IrcUser(const QString &hostmask, Network *network);
60 QString realName() const;
61 QString hostmask() const;
63 QString awayMessage() const;
64 QDateTime idleTime() const;
65 QString server() const;
66 QString ircOperator() const;
67 int lastAwayMessage() const;
68 Network *network() const;
70 QString userModes() const;
72 QStringList channels() const;
74 // user-specific encodings
75 QTextCodec *codecForEncoding() const;
76 QTextCodec *codecForDecoding() const;
77 void setCodecForEncoding(const QString &codecName);
78 void setCodecForEncoding(QTextCodec *codec);
79 void setCodecForDecoding(const QString &codecName);
80 void setCodecForDecoding(QTextCodec *codec);
82 QString decodeString(const QByteArray &text) const;
83 QByteArray encodeString(const QString &string) const;
86 void setUser(const QString &user);
87 void setHost(const QString &host);
88 void setNick(const QString &nick);
89 void setRealName(const QString &realName);
90 void setAway(const bool &away);
91 void setAwayMessage(const QString &awayMessage);
92 void setIdleTime(const QDateTime &idleTime);
93 void setServer(const QString &server);
94 void setIrcOperator(const QString &ircOperator);
95 void setLastAwayMessage(const int &lastAwayMessage);
96 void updateHostmask(const QString &mask);
98 void setUserModes(const QString &modes);
100 void joinChannel(IrcChannel *channel);
101 void joinChannel(const QString &channelname);
102 void partChannel(IrcChannel *channel);
103 void partChannel(const QString &channelname);
105 void addUserMode(const QString &mode);
106 void removeUserMode(const QString &mode);
109 void userSet(QString user);
110 void hostSet(QString host);
111 void nickSet(QString newnick);
112 void realNameSet(QString realName);
113 void awaySet(bool away);
114 void awayMessageSet(QString awayMessage);
115 void idleTimeSet(QDateTime idleTime);
116 void serverSet(QString server);
117 void ircOperatorSet(QString ircOperator);
118 void lastAwayMessageSet(int lastAwayMessage);
119 void hostmaskUpdated(QString mask);
121 void userModesSet(QString modes);
123 // void channelJoined(QString channel);
124 void channelParted(QString channel);
126 void userModeAdded(QString mode);
127 void userModeRemoved(QString mode);
129 // void setUsermodes(const QSet<QString> &usermodes);
130 // QSet<QString> usermodes() const;
133 void updateObjectName();
134 void channelDestroyed();
137 inline bool operator==(const IrcUser &ircuser2) {
138 return (_nick.toLower() == ircuser2.nick().toLower());
141 inline bool operator==(const QString &nickname) {
142 return (_nick.toLower() == nickname.toLower());
151 QString _awayMessage;
155 QString _ircOperator;
156 int _lastAwayMessage;
158 // QSet<QString> _channels;
159 QSet<IrcChannel *> _channels;
164 QTextCodec *_codecForEncoding;
165 QTextCodec *_codecForDecoding;