made the signalproxy compile with MSVC
[quassel.git] / src / common / ircuser.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #ifndef _IRCUSER_H_
22 #define _IRCUSER_H_
23
24 #include <QSet>
25 #include <QString>
26 #include <QStringList>
27 #include <QVariantMap>
28
29 #include "syncableobject.h"
30
31 class SignalProxy;
32 class Network;
33 class IrcChannel;
34
35 class IrcUser : public SyncableObject {
36   Q_OBJECT
37
38   Q_PROPERTY(QString user READ user WRITE setUser STORED false)
39   Q_PROPERTY(QString host READ host WRITE setHost STORED false)
40   Q_PROPERTY(QString nick READ nick WRITE setNick STORED false)
41
42   Q_PROPERTY(QStringList channels READ channels STORED false)
43   //  Q_PROPERTY(QStringList usermodes READ usermodes WRITE setUsermodes)
44
45 public:
46   IrcUser(const QString &hostmask, Network *network);
47   virtual ~IrcUser();
48
49   QString user() const;
50   QString host() const;
51   QString nick() const;
52   QString hostmask() const;
53   Network *network() const;
54
55   QString userModes() const;
56
57   QStringList channels() const;
58
59   // user-specific encodings
60   QTextCodec *codecForEncoding() const;
61   QTextCodec *codecForDecoding() const;
62   void setCodecForEncoding(const QString &codecName);
63   void setCodecForEncoding(QTextCodec *codec);
64   void setCodecForDecoding(const QString &codecName);
65   void setCodecForDecoding(QTextCodec *codec);
66
67   QString decodeString(const QByteArray &text) const;
68   QByteArray encodeString(const QString string) const;
69
70 public slots:
71   void setUser(const QString &user);
72   void setHost(const QString &host);
73   void setNick(const QString &nick);
74   void updateHostmask(const QString &mask);
75
76   void setUserModes(const QString &modes);
77
78   void joinChannel(IrcChannel *channel);
79   void joinChannel(const QString &channelname);
80   void partChannel(IrcChannel *channel);
81   void partChannel(const QString &channelname);
82
83   void addUserMode(const QString &mode);
84   void removeUserMode(const QString &mode);
85
86   // init seters
87   void initSetChannels(const QStringList channels);
88
89 signals:
90   void userSet(QString user);
91   void hostSet(QString host);
92   void nickSet(QString newnick);
93   void hostmaskUpdated(QString mask);
94
95   void userModesSet(QString modes);
96
97   void channelJoined(QString channel);
98   void channelParted(QString channel);
99
100   void userModeAdded(QString mode);
101   void userModeRemoved(QString mode);
102
103   void renameObject(QString oldname, QString newname);
104
105 //   void setUsermodes(const QSet<QString> &usermodes);
106 //   QSet<QString> usermodes() const;
107
108 private slots:
109   void updateObjectName();
110   void channelDestroyed();
111
112 private:
113   inline bool operator==(const IrcUser &ircuser2) {
114     return (_nick.toLower() == ircuser2.nick().toLower());
115   }
116
117   inline bool operator==(const QString &nickname) {
118     return (_nick.toLower() == nickname.toLower());
119   }
120
121   bool _initialized;
122
123   QString _nick;
124   QString _user;
125   QString _host;
126
127   // QSet<QString> _channels;
128   QSet<IrcChannel *> _channels;
129   QString _userModes;
130
131   Network *_network;
132
133   QTextCodec *_codecForEncoding;
134   QTextCodec *_codecForDecoding;
135 };
136
137 #endif