QXmpp  Version:1.3.1
QXmppMucManager.h
1 /*
2  * Copyright (C) 2008-2020 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() override;
67 
68  QXmppMucRoom *addRoom(const QString &roomJid);
69 
70  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
72  QList<QXmppMucRoom *> rooms() const;
73 
75  QStringList discoveryFeatures() const override;
76  bool handleStanza(const QDomElement &element) override;
78 
79 Q_SIGNALS:
81  void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
82 
84  void roomAdded(QXmppMucRoom *room);
85 
86 protected:
88  void setClient(QXmppClient *client) override;
90 
91 private Q_SLOTS:
92  void _q_messageReceived(const QXmppMessage &message);
93  void _q_roomDestroyed(QObject *object);
94 
95 private:
96  QXmppMucManagerPrivate *d;
97 };
98 
103 
104 class QXMPP_EXPORT QXmppMucRoom : public QObject
105 {
106  Q_OBJECT
107  Q_FLAGS(Action Actions)
108 
109 
110  Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged)
112  Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged)
114  Q_PROPERTY(QString jid READ jid CONSTANT)
116  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
118  Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
120  Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged)
122  Q_PROPERTY(QString password READ password WRITE setPassword)
124  Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged)
125 
126 public:
128  enum Action {
129  NoAction = 0,
130  SubjectAction = 1,
131  ConfigurationAction = 2,
132  PermissionsAction = 4,
133  KickAction = 8
134  };
135  Q_DECLARE_FLAGS(Actions, Action)
136 
137  ~QXmppMucRoom() override;
138 
139  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
141  Actions allowedActions() const;
142 
143  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
145  bool isJoined() const;
146 
147  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
149  QString jid() const;
150 
151  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
157  QString name() const;
158 
159  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
161  QString nickName() const;
162  void setNickName(const QString &nickName);
163 
164  Q_INVOKABLE QString participantFullJid(const QString &jid) const;
165  QXmppPresence participantPresence(const QString &jid) const;
166 
167  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
173  QStringList participants() const;
174 
175  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
177  QString password() const;
178  void setPassword(const QString &password);
179 
180  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
182  QString subject() const;
183  void setSubject(const QString &subject);
184 
185 Q_SIGNALS:
187  void allowedActionsChanged(QXmppMucRoom::Actions actions) const;
188 
190  void configurationReceived(const QXmppDataForm &configuration);
191 
193  void error(const QXmppStanza::Error &error);
194 
196  void joined();
197 
199  void kicked(const QString &jid, const QString &reason);
200 
202  void isJoinedChanged();
204 
206  void left();
207 
209  void messageReceived(const QXmppMessage &message);
210 
212  void nameChanged(const QString &name);
213 
215  void nickNameChanged(const QString &nickName);
216 
218  void participantAdded(const QString &jid);
219 
221  void participantChanged(const QString &jid);
222 
224  void participantRemoved(const QString &jid);
225 
227  void participantsChanged();
229 
231  void permissionsReceived(const QList<QXmppMucItem> &permissions);
232 
234  void subjectChanged(const QString &subject);
235 
236 public Q_SLOTS:
237  bool ban(const QString &jid, const QString &reason);
238  bool join();
239  bool kick(const QString &jid, const QString &reason);
240  bool leave(const QString &message = QString());
241  bool requestConfiguration();
242  bool requestPermissions();
243  bool setConfiguration(const QXmppDataForm &form);
244  bool setPermissions(const QList<QXmppMucItem> &permissions);
245  bool sendInvitation(const QString &jid, const QString &reason);
246  bool sendMessage(const QString &text);
247 
248 private Q_SLOTS:
249  void _q_disconnected();
250  void _q_discoveryInfoReceived(const QXmppDiscoveryIq &iq);
251  void _q_messageReceived(const QXmppMessage &message);
252  void _q_presenceReceived(const QXmppPresence &presence);
253 
254 private:
255  QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
256  QXmppMucRoomPrivate *d;
257  friend class QXmppMucManager;
258 };
259 
260 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
261 
262 #endif
QXmppMucManager
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition: QXmppMucManager.h:59
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:35
QXmppStanza::Error
The Error class represents a stanza error.
Definition: QXmppStanza.h:105
QXmppMucRoom
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat.
Definition: QXmppMucManager.h:104
QXmppDataForm
The QXmppDataForm class represents a data form as defined by XEP-0004: Data Forms.
Definition: QXmppDataForm.h:48
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
QXmppClientExtension::setClient
virtual void setClient(QXmppClient *client)
Definition: QXmppClientExtension.cpp:79
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:54
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:94
QXmppMucRoom::Action
Action
This enum is used to describe chat room actions.
Definition: QXmppMucManager.h:128
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.
QXmppDiscoveryIq
QXmppDiscoveryIq represents a discovery IQ request or result containing a list of features and other ...
Definition: QXmppDiscoveryIq.h:43
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:42