QXmpp: QXmppMucManager.h Source File

QXmpp Version: 1.14.4

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;
13class QXmppDiscoveryIq;
14class QXmppMessage;
15class QXmppMucManagerPrivate;
16class QXmppMucRoom;
17class QXmppMucRoomPrivate;
18
43 class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
44{
45 Q_OBJECT
47 Q_PROPERTY(QList<QXmppMucRoom *> rooms READ rooms NOTIFY roomAdded)
48
49public:
50 QXmppMucManager();
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
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
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
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
QXmppClientExtension::onUnregistered
virtual void onUnregistered(QXmppClient *client)
Definition QXmppClientExtension.cpp:95
QXmppClientExtension::onRegistered
virtual void onRegistered(QXmppClient *client)
Definition QXmppClientExtension.cpp:85
QXmppClientExtension::client
QXmppClient * client() const
Definition QXmppClientExtension.cpp:57
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition client/compat/removed_api.cpp:44
QXmppClient
Main class for starting and managing connections to XMPP servers.
Definition QXmppClient.h:62
QXmppDataForm
Definition QXmppDataForm.h:28
QXmppDiscoveryIq
Definition QXmppDiscoveryIq.h:200
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
QXmppMucManager::invitationReceived
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.
QXmppMucManager::rooms
QList< QXmppMucRoom * > rooms
List of joined MUC rooms.
Definition QXmppMucManager.h:47
QXmppMucManager::QXmppMucManager
QXmppMucManager()
Definition QXmppMucManager.cpp:47
QXmppMucManager::roomAdded
Q_SIGNAL void roomAdded(QXmppMucRoom *room)
This signal is emitted when a new room is managed.
QXmppMucManager::addRoom
QXmppMucRoom * addRoom(const QString &roomJid)
Definition QXmppMucManager.cpp:58
QXmppMucRoom
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat.
Definition QXmppMucManager.h:90
QXmppMucRoom::kicked
Q_SIGNAL void kicked(const QString &jid, const QString &reason)
This signal is emitted if you get kicked from the room.
QXmppMucRoom::participantChanged
Q_SIGNAL void participantChanged(const QString &jid)
This signal is emitted when a participant changes.
QXmppMucRoom::setConfiguration
Q_SLOT bool setConfiguration(const QXmppDataForm &form)
Definition QXmppMucManager.cpp:449
QXmppMucRoom::ban
Q_SLOT bool ban(const QString &jid, const QString &reason)
Definition QXmppMucManager.cpp:199
QXmppMucRoom::allowedActions
QXmppMucRoom::Actions allowedActions
The actions you are allowed to perform on the room.
Definition QXmppMucManager.h:95
QXmppMucRoom::configurationReceived
Q_SIGNAL void configurationReceived(const QXmppDataForm &configuration)
This signal is emitted when the configuration form for the room is received.
QXmppMucRoom::nickName
QString nickName
Your own nickname.
Definition QXmppMucManager.h:103
QXmppMucRoom::kick
Q_SLOT bool kick(const QString &jid, const QString &reason)
Definition QXmppMucManager.cpp:256
QXmppMucRoom::permissionsReceived
Q_SIGNAL void permissionsReceived(const QList< QXmppMucItem > &permissions)
This signal is emitted when the room's permissions are received.
QXmppMucRoom::setNickName
void setNickName(const QString &nickName)
Definition QXmppMucManager.cpp:340
QXmppMucRoom::jid
QString jid
The chat room's bare JID.
Definition QXmppMucManager.h:99
QXmppMucRoom::error
Q_SIGNAL void error(const QXmppStanza::Error &error)
This signal is emitted when an error is encountered.
QXmppMucRoom::sendMessage
Q_SLOT bool sendMessage(const QString &text)
Definition QXmppMucManager.cpp:324
QXmppMucRoom::setPermissions
Q_SLOT bool setPermissions(const QList< QXmppMucItem > &permissions)
Definition QXmppMucManager.cpp:497
QXmppMucRoom::subject
QString subject
The room's subject.
Definition QXmppMucManager.h:109
QXmppMucRoom::nameChanged
Q_SIGNAL void nameChanged(const QString &name)
This signal is emitted when the room's human-readable name changes.
QXmppMucRoom::password
QString password
The chat room password.
Definition QXmppMucManager.h:107
QXmppMucRoom::joined
Q_SIGNAL void joined()
This signal is emitted once you have joined the room.
QXmppMucRoom::requestPermissions
Q_SLOT bool requestPermissions()
Definition QXmppMucManager.cpp:465
QXmppMucRoom::subjectChanged
Q_SIGNAL void subjectChanged(const QString &subject)
This signal is emitted when the room's subject changes.
QXmppMucRoom::name
QString name
The chat room's human-readable name.
Definition QXmppMucManager.h:101
QXmppMucRoom::participants
QStringList participants
The list of participant JIDs.
Definition QXmppMucManager.h:105
QXmppMucRoom::sendInvitation
Q_SLOT bool sendInvitation(const QString &jid, const QString &reason)
Definition QXmppMucManager.cpp:305
QXmppMucRoom::nickNameChanged
Q_SIGNAL void nickNameChanged(const QString &nickName)
This signal is emitted when your own nick name changes.
QXmppMucRoom::requestConfiguration
Q_SLOT bool requestConfiguration()
Definition QXmppMucManager.cpp:435
QXmppMucRoom::participantRemoved
Q_SIGNAL void participantRemoved(const QString &jid)
This signal is emitted when a participant leaves the room.
QXmppMucRoom::leave
Q_SLOT bool leave(const QString &message=QString())
Definition QXmppMucManager.cpp:278
QXmppMucRoom::messageReceived
Q_SIGNAL void messageReceived(const QXmppMessage &message)
This signal is emitted when a message is received.
QXmppMucRoom::allowedActionsChanged
Q_SIGNAL void allowedActionsChanged(QXmppMucRoom::Actions actions)
This signal is emitted when the allowed actions change.
QXmppMucRoom::Action
Action
This enum is used to describe chat room actions.
Definition QXmppMucManager.h:113
QXmppMucRoom::NoAction
@ NoAction
no action
Definition QXmppMucManager.h:114
QXmppMucRoom::SubjectAction
@ SubjectAction
change the room's subject
Definition QXmppMucManager.h:115
QXmppMucRoom::KickAction
@ KickAction
kick users from the room
Definition QXmppMucManager.h:118
QXmppMucRoom::PermissionsAction
@ PermissionsAction
change the room's permissions
Definition QXmppMucManager.h:117
QXmppMucRoom::ConfigurationAction
@ ConfigurationAction
change the room's configuration
Definition QXmppMucManager.h:116
QXmppMucRoom::participantAdded
Q_SIGNAL void participantAdded(const QString &jid)
This signal is emitted when a participant joins the room.
QXmppMucRoom::setSubject
void setSubject(const QString &subject)
Definition QXmppMucManager.cpp:419
QXmppMucRoom::setPassword
void setPassword(const QString &password)
Definition QXmppMucManager.cpp:404
QXmppMucRoom::isJoined
bool isJoined
Whether you are currently in the room.
Definition QXmppMucManager.h:97
QXmppMucRoom::left
Q_SIGNAL void left()
This signal is emitted once you have left the room.
QXmppMucRoom::join
Q_SLOT bool join()
Definition QXmppMucManager.cpp:234
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:22
QXmppStanza::Error
The Error class represents a stanza error.
Definition QXmppStanza.h:112