6dab1e20cbcea86769253530e2f6aef89d2977e6
[quassel.git] / src / common / ircchannel.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 by The Quassel 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) any later version.                                   *
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 _IRCCHANNEL_H_
22 #define _IRCCHANNEL_H_
23
24 #include <QHash>
25 #include <QString>
26 #include <QStringList>
27 #include <QVariantMap>
28
29 class IrcUser;
30 class NetworkInfo;
31 class SignalProxy;
32
33 class IrcChannel : public QObject {
34   Q_OBJECT
35
36   Q_PROPERTY(QString name READ name STORED false)
37   Q_PROPERTY(QString topic READ topic WRITE setTopic STORED false)
38
39 public:
40   IrcChannel(const QString &channelname, NetworkInfo *networkInfo);
41   ~IrcChannel();
42
43   bool isKnownUser(IrcUser *ircuser) const;
44   bool isValidChannelUserMode(const QString &mode) const;
45
46   bool initialized() const;
47
48   QString name() const;
49   QString topic() const;
50
51   QList<IrcUser *> ircUsers() const;
52
53   QString userModes(IrcUser *ircuser) const;
54   QString userModes(const QString &nick) const;
55
56 public slots:
57   void setTopic(const QString &topic);
58
59   void join(IrcUser *ircuser);
60   void join(const QString &nick);
61
62   void part(IrcUser *ircuser);
63   void part(const QString &nick);
64
65   void setUserModes(IrcUser *ircuser, const QString &modes);
66   void setUserModes(const QString &nick, const QString &modes);
67
68   void addUserMode(IrcUser *ircuser, const QString &mode);
69   void addUserMode(const QString &nick, const QString &mode);
70
71   void removeUserMode(IrcUser *ircuser, const QString &mode);
72   void removeUserMode(const QString &nick, const QString &mode);
73
74   // init geters
75   QVariantMap initUserModes() const;
76
77   // init seters
78   void initSetUserModes(const QVariantMap &usermodes);
79
80   void setInitialized();
81
82 signals:
83   void topicSet(QString topic);
84   void userModesSet(QString nick, QString modes);
85   //void userModesSet(IrcUser *ircuser, QString modes);
86   void userModeAdded(QString nick, QString mode);
87   //void userModeAdded(IrcUser *ircuser, QString mode);
88   void userModeRemoved(QString nick, QString mode);
89   //void userModeRemoved(IrcUser *ircuser, QString mode);
90
91   void ircUserJoined(IrcUser *ircuser);
92   void ircUserParted(IrcUser *ircuser);
93   void ircUserDestroyed(IrcUser *ircuser);
94   void ircUserNickSet(IrcUser *ircuser, QString nick);
95   void ircUserModeAdded(IrcUser *ircuser, QString mode);
96   void ircUserModeRemoved(IrcUser *ircuser, QString mode);
97   void ircUserModesSet(IrcUser *ircuser, QString modes);
98
99   void initDone();
100
101 private slots:
102    void ircUserDestroyed();
103    void ircUserNickSet(QString nick);
104
105 private:
106   bool _initialized;
107   QString _name;
108   QString _topic;
109
110   QHash<IrcUser *, QString> _userModes;
111
112   NetworkInfo *networkInfo;
113 };
114
115 #endif