QXmpp Version: 1.4.0
Loading...
Searching...
No Matches
QXmppMucManager.h
1/*
2 * Copyright (C) 2008-2021 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
31class QXmppDataForm;
33class QXmppMessage;
34class QXmppMucManagerPrivate;
35class QXmppMucRoom;
36class QXmppMucRoomPrivate;
37
58
59class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
60{
61 Q_OBJECT
62 Q_PROPERTY(QList<QXmppMucRoom *> rooms READ rooms NOTIFY roomAdded)
63
64public:
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
79Q_SIGNALS:
81 void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
82
85
86protected:
88 void setClient(QXmppClient *client) override;
90
91private Q_SLOTS:
92 void _q_messageReceived(const QXmppMessage &message);
93 void _q_roomDestroyed(QObject *object);
94
95private:
96 QXmppMucManagerPrivate *d;
97};
98
103
104class 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
126public:
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
185Q_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
236public 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
248private 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
254private:
255 QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
256 QXmppMucRoomPrivate *d;
257 friend class QXmppMucManager;
258};
259
260Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
261
262#endif
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:47
virtual void setClient(QXmppClient *client)
Definition QXmppClientExtension.cpp:79
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:54
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.
The QXmppClient class is the main class for using QXmpp.
Definition QXmppClient.h:94
The QXmppDataForm class represents a data form as defined by XEP-0004: Data Forms.
Definition QXmppDataForm.h:49
QXmppDiscoveryIq represents a discovery IQ request or result containing a list of features and other ...
Definition QXmppDiscoveryIq.h:44
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:46
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition QXmppMucManager.h:60
void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason)
This signal is emitted when an invitation to a chat room is received.
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:105
void error(const QXmppStanza::Error &error)
This signal is emitted when an error is encountered.
void participantChanged(const QString &jid)
This signal is emitted when a participant changes.
void messageReceived(const QXmppMessage &message)
This signal is emitted when a message is received.
void participantRemoved(const QString &jid)
This signal is emitted when a participant leaves the room.
void configurationReceived(const QXmppDataForm &configuration)
This signal is emitted when the configuration form for the room is received.
void nickNameChanged(const QString &nickName)
This signal is emitted when your own nick name changes.
void subjectChanged(const QString &subject)
This signal is emitted when the room's subject changes.
void nameChanged(const QString &name)
This signal is emitted when the room's human-readable name changes.
void participantAdded(const QString &jid)
This signal is emitted when a participant joins the room.
void left()
This signal is emitted once you have left the room.
void joined()
This signal is emitted once you have joined the room.
void allowedActionsChanged(QXmppMucRoom::Actions actions) const
This signal is emitted when the allowed actions change.
void permissionsReceived(const QList< QXmppMucItem > &permissions)
This signal is emitted when the room's permissions are received.
Action
This enum is used to describe chat room actions.
Definition QXmppMucManager.h:128
void kicked(const QString &jid, const QString &reason)
This signal is emitted if you get kicked from the room.
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:36
The Error class represents a stanza error.
Definition QXmppStanza.h:106