QXmpp Version: 1.14.1
Loading...
Searching...
No Matches
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
12class QXmppDataForm;
14class QXmppMessage;
15class QXmppMucManagerPrivate;
16class QXmppMucRoom;
17class QXmppMucRoomPrivate;
18
43class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
44{
45 Q_OBJECT
47 Q_PROPERTY(QList<QXmppMucRoom *> rooms READ rooms NOTIFY roomAdded)
48
49public:
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
70protected:
72 void onRegistered(QXmppClient *client) override;
73 void onUnregistered(QXmppClient *client) override;
75
76private:
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
89class 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
111public:
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
231private:
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
242Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
243
244#endif
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:32
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
virtual void onUnregistered(QXmppClient *client)
Definition QXmppClientExtension.cpp:95
virtual void onRegistered(QXmppClient *client)
Definition QXmppClientExtension.cpp:85
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition client/compat/removed_api.cpp:44
Main class for starting and managing connections to XMPP servers.
Definition QXmppClient.h:62
Definition QXmppDataForm.h:28
Definition QXmppDiscoveryIq.h:200
Action
Definition QXmppExternalService.h:28
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition QXmppMucManager.h:44
Q_SIGNAL void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason)
This signal is emitted when an invitation to a chat room is received.
Q_SIGNAL void roomAdded(QXmppMucRoom *room)
This signal is emitted when a new room is managed.
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat.
Definition QXmppMucManager.h:90
Q_SIGNAL void kicked(const QString &jid, const QString &reason)
This signal is emitted if you get kicked from the room.
Q_SIGNAL void participantChanged(const QString &jid)
This signal is emitted when a participant changes.
Q_SIGNAL void configurationReceived(const QXmppDataForm &configuration)
This signal is emitted when the configuration form for the room is received.
Q_SIGNAL void permissionsReceived(const QList< QXmppMucItem > &permissions)
This signal is emitted when the room's permissions are received.
Q_SIGNAL void error(const QXmppStanza::Error &error)
This signal is emitted when an error is encountered.
Q_SIGNAL void nameChanged(const QString &name)
This signal is emitted when the room's human-readable name changes.
Q_SIGNAL void joined()
This signal is emitted once you have joined the room.
Q_SIGNAL void subjectChanged(const QString &subject)
This signal is emitted when the room's subject changes.
Q_SIGNAL void nickNameChanged(const QString &nickName)
This signal is emitted when your own nick name changes.
Q_SIGNAL void participantRemoved(const QString &jid)
This signal is emitted when a participant leaves the room.
Q_SIGNAL void messageReceived(const QXmppMessage &message)
This signal is emitted when a message is received.
Q_SIGNAL void allowedActionsChanged(QXmppMucRoom::Actions actions)
This signal is emitted when the allowed actions change.
Action
This enum is used to describe chat room actions.
Definition QXmppMucManager.h:113
Q_SIGNAL void participantAdded(const QString &jid)
This signal is emitted when a participant joins the room.
Q_SIGNAL void left()
This signal is emitted once you have left the room.
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:22
The Error class represents a stanza error.
Definition QXmppStanza.h:112