This Update is like 90% bugfixes.
[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 SignalProxy;
30 class NetworkInfo;
31 class IrcUser;
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
42   bool isKnownUser(IrcUser *ircuser) const;
43   bool isValidChannelUserMode(const QString &mode) const;
44
45   bool initialized() const;
46
47   QString name() const;
48   QString topic() const;
49   
50   QList<IrcUser *> ircUsers() const;
51   
52   QString userMode(IrcUser *ircuser) const;
53   QString userMode(const QString &nick) const;
54
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 userModeAdded(QString nick, QString mode);
86   void userModeRemoved(QString nick, QString mode);
87
88   void initDone();
89
90 private slots:
91    void ircUserDestroyed();
92
93 private:
94   bool _initialized;
95   QString _name;
96   QString _topic;
97
98   QHash<IrcUser *, QString> _userModes; 
99   
100   NetworkInfo *networkInfo;
101 };
102
103 #endif