QXmpp Version: 1.15.0
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:
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
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
QXmppClient * client() const
Definition QXmppClientExtension.cpp:57
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition client/compat/removed_api.cpp:45
Main class for starting and managing connections to XMPP servers.
Definition QXmppClient.h:62
Definition QXmppDataForm.h:28
Definition QXmppDiscoveryIq.h:200
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
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.
QList< QXmppMucRoom * > rooms
List of joined MUC rooms.
Definition QXmppMucManager.h:47
QXmppMucManager()
Definition QXmppMucManager.cpp:47
Q_SIGNAL void roomAdded(QXmppMucRoom *room)
This signal is emitted when a new room is managed.
QXmppMucRoom * addRoom(const QString &roomJid)
Definition QXmppMucManager.cpp:58
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_SLOT bool setConfiguration(const QXmppDataForm &form)
Definition QXmppMucManager.cpp:449
Q_SLOT bool ban(const QString &jid, const QString &reason)
Definition QXmppMucManager.cpp:199
QXmppMucRoom::Actions allowedActions
The actions you are allowed to perform on the room.
Definition QXmppMucManager.h:95
Q_SIGNAL void configurationReceived(const QXmppDataForm &configuration)
This signal is emitted when the configuration form for the room is received.
QString nickName
Your own nickname.
Definition QXmppMucManager.h:103
Q_SLOT bool kick(const QString &jid, const QString &reason)
Definition QXmppMucManager.cpp:256
Q_SIGNAL void permissionsReceived(const QList< QXmppMucItem > &permissions)
This signal is emitted when the room's permissions are received.
void setNickName(const QString &nickName)
Definition QXmppMucManager.cpp:340
QString jid
The chat room's bare JID.
Definition QXmppMucManager.h:99
Q_SIGNAL void error(const QXmppStanza::Error &error)
This signal is emitted when an error is encountered.
Q_SLOT bool sendMessage(const QString &text)
Definition QXmppMucManager.cpp:324
Q_SLOT bool setPermissions(const QList< QXmppMucItem > &permissions)
Definition QXmppMucManager.cpp:497
QString subject
The room's subject.
Definition QXmppMucManager.h:109
Q_SIGNAL void nameChanged(const QString &name)
This signal is emitted when the room's human-readable name changes.
QString password
The chat room password.
Definition QXmppMucManager.h:107
Q_SIGNAL void joined()
This signal is emitted once you have joined the room.
Q_SLOT bool requestPermissions()
Definition QXmppMucManager.cpp:465
Q_SIGNAL void subjectChanged(const QString &subject)
This signal is emitted when the room's subject changes.
QString name
The chat room's human-readable name.
Definition QXmppMucManager.h:101
QStringList participants
The list of participant JIDs.
Definition QXmppMucManager.h:105
Q_SLOT bool sendInvitation(const QString &jid, const QString &reason)
Definition QXmppMucManager.cpp:305
Q_SIGNAL void nickNameChanged(const QString &nickName)
This signal is emitted when your own nick name changes.
Q_SLOT bool requestConfiguration()
Definition QXmppMucManager.cpp:435
Q_SIGNAL void participantRemoved(const QString &jid)
This signal is emitted when a participant leaves the room.
Q_SLOT bool leave(const QString &message=QString())
Definition QXmppMucManager.cpp:278
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
@ NoAction
no action
Definition QXmppMucManager.h:114
@ SubjectAction
change the room's subject
Definition QXmppMucManager.h:115
@ KickAction
kick users from the room
Definition QXmppMucManager.h:118
@ PermissionsAction
change the room's permissions
Definition QXmppMucManager.h:117
@ ConfigurationAction
change the room's configuration
Definition QXmppMucManager.h:116
Q_SIGNAL void participantAdded(const QString &jid)
This signal is emitted when a participant joins the room.
void setSubject(const QString &subject)
Definition QXmppMucManager.cpp:419
void setPassword(const QString &password)
Definition QXmppMucManager.cpp:404
bool isJoined
Whether you are currently in the room.
Definition QXmppMucManager.h:97
Q_SIGNAL void left()
This signal is emitted once you have left the room.
Q_SLOT bool join()
Definition QXmppMucManager.cpp:234
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:22
The Error class represents a stanza error.
Definition QXmppStanza.h:112