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_SIGNALS:
void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
void roomAdded(QXmppMucRoom *room);
protected:
void setClient(QXmppClient *client) override;
private Q_SLOTS:
void _q_messageReceived(const QXmppMessage &message);
void _q_roomDestroyed(QObject *object);
private:
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_SIGNALS:
void allowedActionsChanged(QXmppMucRoom::Actions actions);
void configurationReceived(const QXmppDataForm &configuration);
void error(const QXmppStanza::Error &error);
void joined();
void kicked(const QString &jid, const QString &reason);
void isJoinedChanged();
void left();
void messageReceived(const QXmppMessage &message);
void nameChanged(const QString &name);
void nickNameChanged(const QString &nickName);
void participantAdded(const QString &jid);
void participantChanged(const QString &jid);
void participantRemoved(const QString &jid);
void participantsChanged();
void permissionsReceived(const QList<QXmppMucItem> &permissions);
void subjectChanged(const QString &subject);
public Q_SLOTS:
bool ban(const QString &jid, const QString &reason);
bool join();
bool kick(const QString &jid, const QString &reason);
bool leave(const QString &message = QString());
bool requestConfiguration();
bool requestPermissions();
bool setConfiguration(const QXmppDataForm &form);
bool setPermissions(const QList<QXmppMucItem> &permissions);
bool sendInvitation(const QString &jid, const QString &reason);
bool sendMessage(const QString &text);
private Q_SLOTS:
void _q_disconnected();
void _q_discoveryInfoReceived(const QXmppDiscoveryIq &iq);
void _q_messageReceived(const QXmppMessage &message);
void _q_presenceReceived(const QXmppPresence &presence);
private:
QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent);
const std::unique_ptr<QXmppMucRoomPrivate> d;
friend class QXmppMucManager;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
#endif
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:33
QXmppClientExtension::setClient
virtual void setClient(QXmppClient *client)
Definition QXmppClientExtension.cpp:88
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition QXmppClientExtension.cpp:51
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition QXmppClient.h:84
QXmppDataForm
Definition QXmppDataForm.h:27
QXmppDiscoveryIq
Definition QXmppDiscoveryIq.h:18
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:35
QXmppMucManager
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition QXmppMucManager.h:41
QXmppMucManager::invitationReceived
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::roomAdded
void roomAdded(QXmppMucRoom *room)
This signal is emitted when a new room is managed.
QXmppMucRoom
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat.
Definition QXmppMucManager.h:87
QXmppMucRoom::error
void error(const QXmppStanza::Error &error)
This signal is emitted when an error is encountered.
QXmppMucRoom::participantChanged
void participantChanged(const QString &jid)
This signal is emitted when a participant changes.
QXmppMucRoom::messageReceived
void messageReceived(const QXmppMessage &message)
This signal is emitted when a message is received.
QXmppMucRoom::participantRemoved
void participantRemoved(const QString &jid)
This signal is emitted when a participant leaves the room.
QXmppMucRoom::configurationReceived
void configurationReceived(const QXmppDataForm &configuration)
This signal is emitted when the configuration form for the room is received.
QXmppMucRoom::nickNameChanged
void nickNameChanged(const QString &nickName)
This signal is emitted when your own nick name changes.
QXmppMucRoom::subjectChanged
void subjectChanged(const QString &subject)
This signal is emitted when the room's subject changes.
QXmppMucRoom::nameChanged
void nameChanged(const QString &name)
This signal is emitted when the room's human-readable name changes.
QXmppMucRoom::participantAdded
void participantAdded(const QString &jid)
This signal is emitted when a participant joins the room.
QXmppMucRoom::left
void left()
This signal is emitted once you have left the room.
QXmppMucRoom::joined
void joined()
This signal is emitted once you have joined the room.
QXmppMucRoom::permissionsReceived
void permissionsReceived(const QList< QXmppMucItem > &permissions)
This signal is emitted when the room's permissions are received.
QXmppMucRoom::allowedActionsChanged
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:110
QXmppMucRoom::kicked
void kicked(const QString &jid, const QString &reason)
This signal is emitted if you get kicked from the room.
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:21
QXmppStanza::Error
The Error class represents a stanza error.
Definition QXmppStanza.h:94