QXmpp  Version:0.9.1
QXmppMucManager.h
1 /*
2  * Copyright (C) 2008-2014 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * https://github.com/qxmpp-project/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 QXmppDiscoveryIq;
33 class QXmppMessage;
34 class QXmppMucManagerPrivate;
35 class QXmppMucRoom;
36 class QXmppMucRoomPrivate;
37 
58 
59 class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
60 {
61  Q_OBJECT
62  Q_PROPERTY(QList<QXmppMucRoom*> rooms READ rooms NOTIFY roomAdded)
63 
64 public:
66  ~QXmppMucManager();
67 
68  QXmppMucRoom *addRoom(const QString &roomJid);
69  QList<QXmppMucRoom*> rooms() const;
70 
72  QStringList discoveryFeatures() const;
73  bool handleStanza(const QDomElement &element);
75 
76 signals:
78  void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
79 
81  void roomAdded(QXmppMucRoom *room);
82 
83 protected:
85  void setClient(QXmppClient* client);
87 
88 private slots:
89  void _q_messageReceived(const QXmppMessage &message);
90  void _q_roomDestroyed(QObject *object);
91 
92 private:
93  QXmppMucManagerPrivate *d;
94 };
95 
100 
101 class QXMPP_EXPORT QXmppMucRoom : public QObject
102 {
103  Q_OBJECT
104  Q_FLAGS(Action Actions)
105  Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged)
106  Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged)
107  Q_PROPERTY(QString jid READ jid CONSTANT)
108  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
109  Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
110  Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged)
111  Q_PROPERTY(QString password READ password WRITE setPassword)
112  Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged)
113 
114 public:
115 
117  enum Action {
118  NoAction = 0,
119  SubjectAction = 1,
120  ConfigurationAction = 2,
121  PermissionsAction = 4,
122  KickAction = 8
123  };
124  Q_DECLARE_FLAGS(Actions, Action)
125 
126  ~QXmppMucRoom();
127 
128  Actions allowedActions() const;
129  bool isJoined() const;
130  QString jid() const;
131  QString name() const;
132 
133  QString nickName() const;
134  void setNickName(const QString &nickName);
135 
136  Q_INVOKABLE QString participantFullJid(const QString &jid) const;
137  QXmppPresence participantPresence(const QString &jid) const;
138  QStringList participants() const;
139 
140  QString password() const;
141  void setPassword(const QString &password);
142 
143  QString subject() const;
144  void setSubject(const QString &subject);
145 
146 signals:
148  void allowedActionsChanged(QXmppMucRoom::Actions actions) const;
149 
151  void configurationReceived(const QXmppDataForm &configuration);
152 
154  void error(const QXmppStanza::Error &error);
155 
157  void joined();
158 
160  void kicked(const QString &jid, const QString &reason);
161 
163  void isJoinedChanged();
165 
167  void left();
168 
170  void messageReceived(const QXmppMessage &message);
171 
173  void nameChanged(const QString &name);
174 
176  void nickNameChanged(const QString &nickName);
177 
179  void participantAdded(const QString &jid);
180 
182  void participantChanged(const QString &jid);
183 
185  void participantRemoved(const QString &jid);
186 
188  void participantsChanged();
190 
192  void permissionsReceived(const QList<QXmppMucItem> &permissions);
193 
195  void subjectChanged(const QString &subject);
196 
197 public slots:
198  bool ban(const QString &jid, const QString &reason);
199  bool join();
200  bool kick(const QString &jid, const QString &reason);
201  bool leave(const QString &message = QString());
202  bool requestConfiguration();
203  bool requestPermissions();
204  bool setConfiguration(const QXmppDataForm &form);
205  bool setPermissions(const QList<QXmppMucItem> &permissions);
206  bool sendInvitation(const QString &jid, const QString &reason);
207  bool sendMessage(const QString &text);
208 
209 private slots:
210  void _q_disconnected();
211  void _q_discoveryInfoReceived(const QXmppDiscoveryIq &iq);
212  void _q_messageReceived(const QXmppMessage &message);
213  void _q_presenceReceived(const QXmppPresence &presence);
214 
215 private:
216  QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
217  QXmppMucRoomPrivate *d;
218  friend class QXmppMucManager;
219 };
220 
221 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
222 
223 #endif
Action
This enum is used to describe chat room actions.
Definition: QXmppMucManager.h:117
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:54
The QXmppDataForm class represents a data form as defined by XEP-0004: Data Forms.
Definition: QXmppDataForm.h:40
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat...
Definition: QXmppMucManager.h:101
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:36
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:38
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition: QXmppMucManager.h:59
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
virtual void setClient(QXmppClient *client)
Definition: QXmppClientExtension.cpp:79
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:80