Making Quassel slowly ready for its first release...
[quassel.git] / src / common / ircuser.h
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by the Quassel IRC Team                         *
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 class SignalProxy;
30 class NetworkInfo;
31 class IrcChannel;
32
33 class IrcUser : public QObject {
34   Q_OBJECT
35
36   Q_PROPERTY(QString user READ user WRITE setUser STORED false)
37   Q_PROPERTY(QString host READ host WRITE setHost STORED false)
38   Q_PROPERTY(QString nick READ nick WRITE setNick STORED false)
39
40   Q_PROPERTY(QStringList channels READ channels STORED false)
41   //  Q_PROPERTY(QStringList usermodes READ usermodes WRITE setUsermodes)
42
43
44 public:
45   IrcUser(const QString &hostmask, NetworkInfo *networkInfo);
46   virtual ~IrcUser();
47
48   bool initialized() const;
49
50   QString user() const;
51   QString host() const;
52   QString nick() const;
53   QString hostmask() const;
54
55   QString userModes() const;
56
57   QStringList channels() const;
58
59 public slots:
60   void setUser(const QString &user);
61   void setHost(const QString &host);
62   void setNick(const QString &nick);
63   void updateHostmask(const QString &mask);
64
65   void setUserModes(const QString &modes);
66
67   void joinChannel(const QString &channel);
68   void partChannel(const QString &channel);
69
70   void addUserMode(const QString &mode);
71   void removeUserMode(const QString &mode);
72
73   // init seters
74   void initSetChannels(const QStringList channels);
75
76   void setInitialized();
77
78 signals:
79   void userSet(QString user);
80   void hostSet(QString host);
81   void nickSet(QString newnick);
82   void hostmaskUpdated(QString mask);
83   
84   void channelsSet(QStringList channels);
85   void userModesSet(QString modes);
86   
87   void channelJoined(QString channel);
88   void channelParted(QString channel);
89
90   void userModeAdded(QString mode);
91   void userModeRemoved(QString mode);
92
93   void renameObject(QString oldname, QString newname);
94   
95 //   void setUsermodes(const QSet<QString> &usermodes);
96 //   QSet<QString> usermodes() const;
97
98   void initDone();
99
100 private slots:
101   void updateObjectName();
102   
103 private:
104   inline bool operator==(const IrcUser &ircuser2) {
105     return (_nick.toLower() == ircuser2.nick().toLower());
106   }
107
108   inline bool operator==(const QString &nickname) {
109     return (_nick.toLower() == nickname.toLower());
110   }
111
112   bool _initialized;
113
114   QString _nick;
115   QString _user;
116   QString _host;
117
118   QSet<QString> _channels;
119   QString _userModes;
120   
121   NetworkInfo *networkInfo;
122 };
123
124 #endif