QXmppMucManager.h
/*
* Copyright (C) 2008-2014 The QXmpp developers
*
* Author:
* Jeremy Lainé
*
* Source:
* https://github.com/qxmpp-project/qxmpp
*
* This file is a part of QXmpp library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#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();
QXmppMucRoom *addRoom(const QString &roomJid);
QList<QXmppMucRoom*> rooms() const;
QStringList discoveryFeatures() const;
bool handleStanza(const QDomElement &element);
signals:
void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason);
void roomAdded(QXmppMucRoom *room);
protected:
void setClient(QXmppClient* client);
private slots:
void _q_messageReceived(const QXmppMessage &message);
void _q_roomDestroyed(QObject *object);
private:
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();
Actions allowedActions() const;
bool isJoined() const;
QString jid() const;
QString name() const;
QString nickName() const;
void setNickName(const QString &nickName);
Q_INVOKABLE QString participantFullJid(const QString &jid) const;
QXmppPresence participantPresence(const QString &jid) const;
QStringList participants() const;
QString password() const;
void setPassword(const QString &password);
QString subject() const;
void setSubject(const QString &subject);
signals:
void allowedActionsChanged(QXmppMucRoom::Actions actions) const;
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 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 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);
QXmppMucRoomPrivate *d;
friend class QXmppMucManager;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions)
#endif
QXmppMucRoom::Action
Action
This enum is used to describe chat room actions.
Definition: QXmppMucManager.h:117
QXmppDataForm
The QXmppDataForm class represents a data form as defined by XEP-0004: Data Forms.
Definition: QXmppDataForm.h:40
QXmppMucRoom
The QXmppMucRoom class represents a multi-user chat room as defined by XEP-0045: Multi-User Chat...
Definition: QXmppMucManager.h:101
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:36
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:54
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:38
QXmppMucManager
The QXmppMucManager class makes it possible to interact with multi-user chat rooms as defined by XEP-...
Definition: QXmppMucManager.h:59
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
QXmppClientExtension::setClient
virtual void setClient(QXmppClient *client)
Definition: QXmppClientExtension.cpp:79
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:80