Loading...
Searching...
No Matches
QXmppMucManager.h
// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPMUCMANAGER_H
#define QXMPPMUCMANAGER_H
#include "QXmppClientExtension.h"
#include "QXmppMucIq.h"
#include "QXmppPresence.h"
class QXmppDataForm;
class QXmppDiscoveryIq;
class QXmppMessage;
class QXmppMucManagerPrivate;
class QXmppMucRoom;
class QXmppMucRoomPrivate;
class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension
{
Q_OBJECT
Q_PROPERTY(QList<QXmppMucRoom *> rooms READ rooms NOTIFY roomAdded)
public:
QXmppMucManager();
~QXmppMucManager() override;
QXmppMucRoom *addRoom(const QString &roomJid);
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QList<QXmppMucRoom *> rooms() const;
QStringList discoveryFeatures() const override;
bool handleStanza(const QDomElement &element) override;
Q_SIGNAL void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
Q_SIGNAL void roomAdded(QXmppMucRoom *room);
protected:
void onRegistered(QXmppClient *client) override;
void onUnregistered(QXmppClient *client) override;
private:
Q_SLOT void _q_messageReceived(const QXmppMessage &message);
Q_SLOT void _q_roomDestroyed(QObject *object);
const std::unique_ptr<QXmppMucManagerPrivate> d;
};
class QXMPP_EXPORT QXmppMucRoom : public QObject
{
Q_OBJECT
Q_FLAGS(Action Actions)
Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged)
Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged)
Q_PROPERTY(QString jid READ jid CONSTANT)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged)
Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged)
Q_PROPERTY(QString password READ password WRITE setPassword)
Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged)
public:
enum Action {
NoAction = 0,
SubjectAction = 1,
ConfigurationAction = 2,
PermissionsAction = 4,
KickAction = 8
};
Q_DECLARE_FLAGS(Actions, Action)
~QXmppMucRoom() override;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
Actions allowedActions() const;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
bool isJoined() const;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QString jid() const;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QString name() const;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QString nickName() const;
void setNickName(const QString &nickName);
Q_INVOKABLE QString participantFullJid(const QString &jid) const;
QXmppPresence participantPresence(const QString &jid) const;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QStringList participants() const;
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QString password() const;
void setPassword(const QString &password);
// documentation needs to be here, see https://stackoverflow.com/questions/49192523/
QString subject() const;
void setSubject(const QString &subject);
Q_SIGNAL void allowedActionsChanged(QXmppMucRoom::Actions actions);
Q_SIGNAL void configurationReceived(const QXmppDataForm &configuration);
Q_SIGNAL void error(const QXmppStanza::Error &error);
Q_SIGNAL void joined();
Q_SIGNAL void kicked(const QString &jid, const QString &reason);
Q_SIGNAL void isJoinedChanged();
Q_SIGNAL void left();
Q_SIGNAL void messageReceived(const QXmppMessage &message);
Q_SIGNAL void nameChanged(const QString &name);
Q_SIGNAL void nickNameChanged(const QString &nickName);
Q_SIGNAL void participantAdded(const QString &jid);
Q_SIGNAL void participantChanged(const QString &jid);
Q_SIGNAL void participantRemoved(const QString &jid);
Q_SIGNAL void participantsChanged();
Q_SIGNAL void permissionsReceived(const QList<QXmppMucItem> &permissions);
Q_SIGNAL void subjectChanged(const QString &subject);
Q_SLOT bool ban(const QString &jid, const QString &reason);
Q_SLOT bool join();
Q_SLOT bool kick(const QString &jid, const QString &reason);
Q_SLOT bool leave(const QString &message = QString());
Q_SLOT bool requestConfiguration();
Q_SLOT bool requestPermissions();
Q_SLOT bool setConfiguration(const QXmppDataForm &form);
Q_SLOT bool setPermissions(const QList<QXmppMucItem> &permissions);
Q_SLOT bool sendInvitation(const QString &jid, const QString &reason);
Q_SLOT bool sendMessage(const QString &text);
private:
QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
Q_SLOT void _q_disconnected();
Q_SLOT void _q_messageReceived(const QXmppMessage &message);
Q_SLOT void _q_presenceReceived(const QXmppPresence &presence);
const std::unique_ptr<QXmppMucRoomPrivate> d;
friend class QXmppMucManager;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
#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