QXmpp  Version:0.4.91
 All Classes Functions Enumerations Enumerator Properties Groups
QXmppMucManager.h
1 /*
2  * Copyright (C) 2008-2011 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * http://code.google.com/p/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPMUCMANAGER_H
25 #define QXMPPMUCMANAGER_H
26 
27 #include "QXmppClientExtension.h"
28 #include "QXmppMucIq.h"
29 #include "QXmppPresence.h"
30 
31 class QXmppDataForm;
32 class QXmppMessage;
33 class QXmppMucManagerPrivate;
34 class QXmppMucRoom;
35 class QXmppMucRoomPrivate;
36 
57 
58 class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
59 {
60  Q_OBJECT
61  Q_PROPERTY(QList<QXmppMucRoom*> rooms READ rooms NOTIFY roomAdded)
62 
63 public:
65  ~QXmppMucManager();
66 
67  QXmppMucRoom *addRoom(const QString &roomJid);
68  QList<QXmppMucRoom*> rooms() const;
69 
71  QStringList discoveryFeatures() const;
72  bool handleStanza(const QDomElement &element);
74 
75 signals:
77  void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
78 
80  void roomAdded(QXmppMucRoom *room);
81 
82 protected:
84  void setClient(QXmppClient* client);
86 
87 private slots:
88  void _q_messageReceived(const QXmppMessage &message);
89  void _q_roomDestroyed(QObject *object);
90 
91 private:
92  QXmppMucManagerPrivate *d;
93 };
94 
99 
100 class QXMPP_EXPORT QXmppMucRoom : public QObject
101 {
102  Q_OBJECT
103  Q_FLAGS(Action Actions)
104  Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged)
105  Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged)
106  Q_PROPERTY(QString jid READ jid CONSTANT)
107  Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
108  Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged)
109  Q_PROPERTY(QString password READ password WRITE setPassword)
110  Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged)
111 
112 public:
113 
115  enum Action {
116  NoAction = 0,
117  SubjectAction = 1,
118  ConfigurationAction = 2,
119  PermissionsAction = 4,
120  KickAction = 8,
121  };
122  Q_DECLARE_FLAGS(Actions, Action)
123 
124  ~QXmppMucRoom();
125 
126  Actions allowedActions() const;
127  bool isJoined() const;
128  QString jid() const;
129 
130  QString nickName() const;
131  void setNickName(const QString &nickName);
132 
133  QXmppPresence participantPresence(const QString &jid) const;
134  QStringList participants() const;
135 
136  QString password() const;
137  void setPassword(const QString &password);
138 
139  QString subject() const;
140  void setSubject(const QString &subject);
141 
142 signals:
144  void allowedActionsChanged(QXmppMucRoom::Actions actions) const;
145 
147  void configurationReceived(const QXmppDataForm &configuration);
148 
150  void error(const QXmppStanza::Error &error);
151 
153  void joined();
154 
156  void kicked(const QString &jid, const QString &reason);
157 
159  void isJoinedChanged();
161 
163  void left();
164 
166  void messageReceived(const QXmppMessage &message);
167 
169  void nickNameChanged(const QString &nickName);
170 
172  void participantAdded(const QString &jid);
173 
175  void participantChanged(const QString &jid);
176 
178  void participantRemoved(const QString &jid);
179 
181  void participantsChanged();
183 
185  void permissionsReceived(const QList<QXmppMucItem> &permissions);
186 
188  void subjectChanged(const QString &subject);
189 
190 public slots:
191  bool join();
192  bool kick(const QString &jid, const QString &reason);
193  bool leave(const QString &message = QString());
194  bool requestConfiguration();
195  bool requestPermissions();
196  bool setConfiguration(const QXmppDataForm &form);
197  bool setPermissions(const QList<QXmppMucItem> &permissions);
198  bool sendInvitation(const QString &jid, const QString &reason);
199  bool sendMessage(const QString &text);
200 
201 private slots:
202  void _q_disconnected();
203  void _q_messageReceived(const QXmppMessage &message);
204  void _q_presenceReceived(const QXmppPresence &presence);
205 
206 private:
207  QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
208  QXmppMucRoomPrivate *d;
209  friend class QXmppMucManager;
210 };
211 
212 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
213 
214 #endif