QXmpp  Version: 1.15.1
QXmppMucManager.h
1 // SPDX-FileCopyrightText: 2010 Jeremy LainĂ© <jeremy.laine@m4x.org>
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 
5 #ifndef QXMPPMUCMANAGER_H
6 #define QXMPPMUCMANAGER_H
7 
8 #include "QXmppClientExtension.h"
9 #include "QXmppMucIq.h"
10 #include "QXmppPresence.h"
11 
12 class QXmppDataForm;
13 class QXmppDiscoveryIq;
14 class QXmppMessage;
15 class QXmppMucManagerPrivate;
16 class QXmppMucRoom;
17 class QXmppMucRoomPrivate;
18 
43 class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
44 {
45  Q_OBJECT
47  Q_PROPERTY(QList<QXmppMucRoom *> rooms READ rooms NOTIFY roomAdded)
48 
49 public:
51  ~QXmppMucManager() override;
52 
53  QXmppMucRoom *addRoom(const QString &roomJid);
54 
55  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
57  QList<QXmppMucRoom *> rooms() const;
58 
60  QStringList discoveryFeatures() const override;
61  bool handleStanza(const QDomElement &element) override;
63 
65  Q_SIGNAL void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
66 
68  Q_SIGNAL void roomAdded(QXmppMucRoom *room);
69 
70 protected:
72  void onRegistered(QXmppClient *client) override;
73  void onUnregistered(QXmppClient *client) override;
75 
76 private:
77  Q_SLOT void _q_messageReceived(const QXmppMessage &message);
78  Q_SLOT void _q_roomDestroyed(QObject *object);
79 
80  const std::unique_ptr<QXmppMucManagerPrivate> d;
81 };
82 
89 class QXMPP_EXPORT QXmppMucRoom : public QObject
90 {
91  Q_OBJECT
92  Q_FLAGS(Action Actions)
93 
94 
95  Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged)
97  Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged)
99  Q_PROPERTY(QString jid READ jid CONSTANT)
101  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
103  Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
105  Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged)
107  Q_PROPERTY(QString password READ password WRITE setPassword)
109  Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged)
110 
111 public:
113  enum Action {
114  NoAction = 0,
115  SubjectAction = 1,
116  ConfigurationAction = 2,
117  PermissionsAction = 4,
118  KickAction = 8
119  };
120  Q_DECLARE_FLAGS(Actions, Action)
121 
122  ~QXmppMucRoom() override;
123 
124  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
126  Actions allowedActions() const;
127 
128  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
130  bool isJoined() const;
131 
132  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
134  QString jid() const;
135 
136  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
142  QString name() const;
143 
144  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
146  QString nickName() const;
147  void setNickName(const QString &nickName);
148 
149  Q_INVOKABLE QString participantFullJid(const QString &jid) const;
150  QXmppPresence participantPresence(const QString &jid) const;
151 
152  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
158  QStringList participants() const;
159 
160  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
162  QString password() const;
163  void setPassword(const QString &password);
164 
165  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
167  QString subject() const;
168  void setSubject(const QString &subject);
169 
171  Q_SIGNAL void allowedActionsChanged(QXmppMucRoom::Actions actions);
172 
174  Q_SIGNAL void configurationReceived(const QXmppDataForm &configuration);
175 
177  Q_SIGNAL void error(const QXmppStanza::Error &error);
178 
180  Q_SIGNAL void joined();
181 
183  Q_SIGNAL void kicked(const QString &jid, const QString &reason);
184 
186  Q_SIGNAL void isJoinedChanged();
188 
190  Q_SIGNAL void left();
191 
193  Q_SIGNAL void messageReceived(const QXmppMessage &message);
194 
196  Q_SIGNAL void nameChanged(const QString &name);
197 
199  Q_SIGNAL void nickNameChanged(const QString &nickName);
200 
202  Q_SIGNAL void participantAdded(const QString &jid);
203 
205  Q_SIGNAL void participantChanged(const QString &jid);
206 
208  Q_SIGNAL void participantRemoved(const QString &jid);
209 
211  Q_SIGNAL void participantsChanged();
213 
215  Q_SIGNAL void permissionsReceived(const QList<QXmppMucItem> &permissions);
216 
218  Q_SIGNAL void subjectChanged(const QString &subject);
219 
220  Q_SLOT bool ban(const QString &jid, const QString &reason);
221  Q_SLOT bool join();
222  Q_SLOT bool kick(const QString &jid, const QString &reason);
223  Q_SLOT bool leave(const QString &message = QString());
224  Q_SLOT bool requestConfiguration();
225  Q_SLOT bool requestPermissions();
226  Q_SLOT bool setConfiguration(const QXmppDataForm &form);
227  Q_SLOT bool setPermissions(const QList<QXmppMucItem> &permissions);
228  Q_SLOT bool sendInvitation(const QString &jid, const QString &reason);
229  Q_SLOT bool sendMessage(const QString &text);
230 
231 private:
232  QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
233 
234  Q_SLOT void _q_disconnected();
235  Q_SLOT void _q_messageReceived(const QXmppMessage &message);
236  Q_SLOT void _q_presenceReceived(const QXmppPresence &presence);
237 
238  const std::unique_ptr<QXmppMucRoomPrivate> d;
239  friend class QXmppMucManager;
240 };
241 
242 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
243 
244 #endif
virtual void onRegistered(QXmppClient *client)
Definition: QXmppClientExtension.cpp:85
virtual void onUnregistered(QXmppClient *client)
Definition: QXmppClientExtension.cpp:95
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition: client/compat/removed_api.cpp:45
Action
This enum is used to describe chat room actions.
Definition: QXmppMucManager.h:113
Definition: QXmppDataForm.h:27
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat...
Definition: QXmppMucManager.h:89
Definition: QXmppDiscoveryIq.h:199
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:21
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:22
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:63
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition: QXmppMucManager.h:43
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:31
The Error class represents a stanza error.
Definition: QXmppStanza.h:111
Action
Definition: QXmppExternalService.h:28
Main class for starting and managing connections to XMPP servers.
Definition: QXmppClient.h:61