Loading...
Searching...
No Matches
QXmppMixManager.h
// SPDX-FileCopyrightText: 2023 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPMIXMANAGER_H
#define QXMPPMIXMANAGER_H
#include "QXmppClient.h"
#include "QXmppClientExtension.h"
#include "QXmppMixConfigItem.h"
#include "QXmppMixInfoItem.h"
#include "QXmppMixParticipantItem.h"
#include "QXmppPubSubEventHandler.h"
class QXmppMixIq;
class QXmppMixInvitation;
class QXmppMixManagerPrivate;
class QXMPP_EXPORT QXmppMixManager : public QXmppClientExtension, public QXmppPubSubEventHandler
{
Q_OBJECT
Q_PROPERTY(Support participantSupport READ participantSupport NOTIFY participantSupportChanged)
Q_PROPERTY(Support messageArchivingSupport READ messageArchivingSupport NOTIFY messageArchivingSupportChanged)
Q_PROPERTY(QList<Service> services READ services NOTIFY servicesChanged)
public:
enum class Support {
Unknown,
Unsupported,
Supported,
};
Q_ENUM(Support)
struct QXMPP_EXPORT Service {
QString jid;
bool channelsSearchable = false;
bool channelCreationAllowed = false;
bool operator==(const Service &other) const;
};
struct Subscription {
QXmppMixConfigItem::Nodes additions;
QXmppMixConfigItem::Nodes removals;
};
struct Participation {
QString participantId;
QString nickname;
QXmppMixConfigItem::Nodes subscriptions;
};
using Jid = QString;
using ChannelJid = QString;
using Nickname = QString;
using CreationResult = std::variant<ChannelJid, QXmppError>;
using ChannelJidResult = std::variant<QVector<ChannelJid>, QXmppError>;
using ChannelNodeResult = std::variant<QXmppMixConfigItem::Nodes, QXmppError>;
using ConfigurationResult = std::variant<QXmppMixConfigItem, QXmppError>;
using InformationResult = std::variant<QXmppMixInfoItem, QXmppError>;
using JoiningResult = std::variant<Participation, QXmppError>;
using NicknameResult = std::variant<Nickname, QXmppError>;
using InvitationResult = std::variant<QXmppMixInvitation, QXmppError>;
using SubscriptionResult = std::variant<Subscription, QXmppError>;
using JidResult = std::variant<QVector<Jid>, QXmppError>;
using ParticipantResult = std::variant<QVector<QXmppMixParticipantItem>, QXmppError>;
QXmppMixManager();
~QXmppMixManager() override;
QStringList discoveryFeatures() const override;
Support participantSupport() const;
Q_SIGNAL void participantSupportChanged();
Support messageArchivingSupport() const;
Q_SIGNAL void messageArchivingSupportChanged();
QList<Service> services() const;
Q_SIGNAL void servicesChanged();
QXmppTask<CreationResult> createChannel(const QString &serviceJid, const QString &channelId = {});
QXmppTask<ChannelJidResult> requestChannelJids(const QString &serviceJid);
QXmppTask<ChannelNodeResult> requestChannelNodes(const QString &channelJid);
QXmppTask<ConfigurationResult> requestChannelConfiguration(const QString &channelJid);
QXmppTask<QXmppClient::EmptyResult> updateChannelConfiguration(const QString &channelJid, QXmppMixConfigItem configuration);
Q_SIGNAL void channelConfigurationUpdated(const QString &channelJid, const QXmppMixConfigItem &configuration);
QXmppTask<InformationResult> requestChannelInformation(const QString &channelJid);
QXmppTask<QXmppClient::EmptyResult> updateChannelInformation(const QString &channelJid, QXmppMixInfoItem information);
Q_SIGNAL void channelInformationUpdated(const QString &channelJid, const QXmppMixInfoItem &information);
QXmppTask<JoiningResult> joinChannel(const QString &channelJid, const QString &nickname = {}, QXmppMixConfigItem::Nodes nodes = ~QXmppMixConfigItem::Nodes());
QXmppTask<JoiningResult> joinChannel(const QXmppMixInvitation &invitation, const QString &nickname = {}, QXmppMixConfigItem::Nodes nodes = ~QXmppMixConfigItem::Nodes());
QXmppTask<NicknameResult> updateNickname(const QString &channelJid, const QString &nickname);
QXmppTask<SubscriptionResult> updateSubscriptions(const QString &channelJid, QXmppMixConfigItem::Nodes subscriptionAdditions = ~QXmppMixConfigItem::Nodes(), QXmppMixConfigItem::Nodes subscriptionRemovals = {});
QXmppTask<InvitationResult> requestInvitation(const QString &channelJid, const QString &inviteeJid);
QXmppTask<JidResult> requestAllowedJids(const QString &channelJid);
QXmppTask<QXmppClient::EmptyResult> allowJid(const QString &channelJid, const QString &jid);
Q_SIGNAL void jidAllowed(const QString &channelJid, const QString &jid);
Q_SIGNAL void allJidsAllowed(const QString &channelJid);
QXmppTask<QXmppClient::EmptyResult> disallowJid(const QString &channelJid, const QString &jid);
Q_SIGNAL void jidDisallowed(const QString &channelJid, const QString &jid);
QXmppTask<QXmppClient::EmptyResult> disallowAllJids(const QString &channelJid);
Q_SIGNAL void allJidsDisallowed(const QString &channelJid);
QXmppTask<JidResult> requestBannedJids(const QString &channelJid);
QXmppTask<QXmppClient::EmptyResult> banJid(const QString &channelJid, const QString &jid);
Q_SIGNAL void jidBanned(const QString &channelJid, const QString &jid);
QXmppTask<QXmppClient::EmptyResult> unbanJid(const QString &channelJid, const QString &jid);
Q_SIGNAL void jidUnbanned(const QString &channelJid, const QString &jid);
QXmppTask<QXmppClient::EmptyResult> unbanAllJids(const QString &channelJid);
Q_SIGNAL void allJidsUnbanned(const QString &channelJid);
QXmppTask<ParticipantResult> requestParticipants(const QString &channelJid);
Q_SIGNAL void participantReceived(const QString &channelJid, const QXmppMixParticipantItem &participant);
Q_SIGNAL void participantLeft(const QString &channelJid, const QString &participantId);
QXmppTask<QXmppClient::EmptyResult> leaveChannel(const QString &channelJid);
QXmppTask<QXmppClient::EmptyResult> deleteChannel(const QString &channelJid);
Q_SIGNAL void channelDeleted(const QString &channelJid);
protected:
void onRegistered(QXmppClient *client) override;
void onUnregistered(QXmppClient *client) override;
bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName) override;
private:
QXmppMixIq prepareJoinIq(const QString &channelJid, const QString &nickname, QXmppMixConfigItem::Nodes nodes);
QXmppTask<JoiningResult> joinChannel(QXmppMixIq &&iq);
QXmppTask<JidResult> requestJids(const QString &channelJid, const QString &node);
QXmppTask<QXmppClient::EmptyResult> addJidToNode(const QString &channelJid, const QString &node, const QString &jid);
void updateCachedData();
void updateSupport();
void updateServices();
void updateService(const QString &jid);
void setParticipantSupport(Support participantSupport);
void setMessageArchivingSupport(Support messageArchivingSupport);
void addService(const Service &service);
void removeService(const QString &jid);
void removeServices();
void resetCachedData();
const std::unique_ptr<QXmppMixManagerPrivate> d;
friend class tst_QXmppMixManager;
};
#endif // QXMPPMIXMANAGER_H
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
QXmppMixConfigItem
The QXmppMixConfigItem class represents a PubSub item of a MIX channel containing its configuration a...
Definition QXmppMixConfigItem.h:14
QXmppMixInfoItem
The QXmppMixInfoItem class represents a PubSub item of a MIX channel containing channel information a...
Definition QXmppMixInfoItem.h:15
QXmppMixIq
Definition QXmppMixIq.h:18
QXmppMixManager::ChannelJidResult
std::variant< QVector< ChannelJid >, QXmppError > ChannelJidResult
Definition QXmppMixManager.h:60
QXmppMixManager::ChannelJid
QString ChannelJid
Definition QXmppMixManager.h:56
QXmppMixManager::participantLeft
Q_SIGNAL void participantLeft(const QString &channelJid, const QString &participantId)
QXmppMixManager::jidUnbanned
Q_SIGNAL void jidUnbanned(const QString &channelJid, const QString &jid)
QXmppMixManager::channelDeleted
Q_SIGNAL void channelDeleted(const QString &channelJid)
QXmppMixManager::requestParticipants
QXmppTask< ParticipantResult > requestParticipants(const QString &channelJid)
Definition QXmppMixManager.cpp:949
QXmppMixManager::jidBanned
Q_SIGNAL void jidBanned(const QString &channelJid, const QString &jid)
QXmppMixManager::participantSupport
Support participantSupport
Definition QXmppMixManager.h:22
QXmppMixManager::NicknameResult
std::variant< Nickname, QXmppError > NicknameResult
Definition QXmppMixManager.h:65
QXmppMixManager::ChannelNodeResult
std::variant< QXmppMixConfigItem::Nodes, QXmppError > ChannelNodeResult
Definition QXmppMixManager.h:61
QXmppMixManager::deleteChannel
QXmppTask< QXmppClient::EmptyResult > deleteChannel(const QString &channelJid)
Definition QXmppMixManager.cpp:999
QXmppMixManager::discoveryFeatures
QStringList discoveryFeatures() const override
Definition QXmppMixManager.cpp:420
QXmppMixManager::channelConfigurationUpdated
Q_SIGNAL void channelConfigurationUpdated(const QString &channelJid, const QXmppMixConfigItem &configuration)
QXmppMixManager::Jid
QString Jid
Definition QXmppMixManager.h:55
QXmppMixManager::jidDisallowed
Q_SIGNAL void jidDisallowed(const QString &channelJid, const QString &jid)
QXmppMixManager::allJidsUnbanned
Q_SIGNAL void allJidsUnbanned(const QString &channelJid)
QXmppMixManager::channelInformationUpdated
Q_SIGNAL void channelInformationUpdated(const QString &channelJid, const QXmppMixInfoItem &information)
QXmppMixManager::allJidsDisallowed
Q_SIGNAL void allJidsDisallowed(const QString &channelJid)
QXmppMixManager::allJidsAllowed
Q_SIGNAL void allJidsAllowed(const QString &channelJid)
QXmppMixManager::QXmppMixManager
QXmppMixManager()
Definition QXmppMixManager.cpp:412
QXmppMixManager::messageArchivingSupportChanged
Q_SIGNAL void messageArchivingSupportChanged()
QXmppMixManager::joinChannel
QXmppTask< JoiningResult > joinChannel(const QString &channelJid, const QString &nickname={}, QXmppMixConfigItem::Nodes nodes=~QXmppMixConfigItem::Nodes())
Definition QXmppMixManager.cpp:633
QXmppMixManager::CreationResult
std::variant< ChannelJid, QXmppError > CreationResult
Definition QXmppMixManager.h:59
QXmppMixManager::leaveChannel
QXmppTask< QXmppClient::EmptyResult > leaveChannel(const QString &channelJid)
Definition QXmppMixManager.cpp:981
QXmppMixManager::Support
Support
Definition QXmppMixManager.h:27
QXmppMixManager::requestBannedJids
QXmppTask< JidResult > requestBannedJids(const QString &channelJid)
Definition QXmppMixManager.cpp:856
QXmppMixManager::createChannel
QXmppTask< CreationResult > createChannel(const QString &serviceJid, const QString &channelId={})
Definition QXmppMixManager.cpp:500
QXmppMixManager::disallowAllJids
QXmppTask< QXmppClient::EmptyResult > disallowAllJids(const QString &channelJid)
Definition QXmppMixManager.cpp:834
QXmppMixManager::ParticipantResult
std::variant< QVector< QXmppMixParticipantItem >, QXmppError > ParticipantResult
Definition QXmppMixManager.h:69
QXmppMixManager::jidAllowed
Q_SIGNAL void jidAllowed(const QString &channelJid, const QString &jid)
QXmppMixManager::participantReceived
Q_SIGNAL void participantReceived(const QString &channelJid, const QXmppMixParticipantItem &participant)
QXmppMixManager::InvitationResult
std::variant< QXmppMixInvitation, QXmppError > InvitationResult
Definition QXmppMixManager.h:66
QXmppMixManager::JoiningResult
std::variant< Participation, QXmppError > JoiningResult
Definition QXmppMixManager.h:64
QXmppMixManager::servicesChanged
Q_SIGNAL void servicesChanged()
QXmppMixManager::requestChannelInformation
QXmppTask< InformationResult > requestChannelInformation(const QString &channelJid)
Definition QXmppMixManager.cpp:589
QXmppMixManager::messageArchivingSupport
Support messageArchivingSupport
Definition QXmppMixManager.h:23
QXmppMixManager::unbanJid
QXmppTask< QXmppClient::EmptyResult > unbanJid(const QString &channelJid, const QString &jid)
Definition QXmppMixManager.cpp:900
QXmppMixManager::updateChannelInformation
QXmppTask< QXmppClient::EmptyResult > updateChannelInformation(const QString &channelJid, QXmppMixInfoItem information)
Definition QXmppMixManager.cpp:607
QXmppMixManager::disallowJid
QXmppTask< QXmppClient::EmptyResult > disallowJid(const QString &channelJid, const QString &jid)
Definition QXmppMixManager.cpp:808
QXmppMixManager::SubscriptionResult
std::variant< Subscription, QXmppError > SubscriptionResult
Definition QXmppMixManager.h:67
QXmppMixManager::participantSupportChanged
Q_SIGNAL void participantSupportChanged()
QXmppMixManager::ConfigurationResult
std::variant< QXmppMixConfigItem, QXmppError > ConfigurationResult
Definition QXmppMixManager.h:62
QXmppMixManager::Nickname
QString Nickname
Definition QXmppMixManager.h:57
QXmppMixManager::JidResult
std::variant< QVector< Jid >, QXmppError > JidResult
Definition QXmppMixManager.h:68
QXmppMixManager::banJid
QXmppTask< QXmppClient::EmptyResult > banJid(const QString &channelJid, const QString &jid)
Definition QXmppMixManager.cpp:876
QXmppMixManager::InformationResult
std::variant< QXmppMixInfoItem, QXmppError > InformationResult
Definition QXmppMixManager.h:63
QXmppMixManager::unbanAllJids
QXmppTask< QXmppClient::EmptyResult > unbanAllJids(const QString &channelJid)
Definition QXmppMixManager.cpp:923
QXmppMixManager::services
QList< Service > services
Definition QXmppMixManager.h:24
QXmppMixParticipantItem
Definition QXmppMixParticipantItem.h:13
QXmppPubSubEventHandler
Definition QXmppPubSubEventHandler.h:15
QXmppPubSubEventHandler::handlePubSubEvent
virtual bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName)=0
QXmppTask
Definition QXmppTask.h:46
QXmppError
Definition QXmppError.h:17
QXmppMixManager::Participation
Definition QXmppMixManager.h:49
QXmppMixManager::Participation::participantId
QString participantId
Definition QXmppMixManager.h:50
QXmppMixManager::Participation::nickname
QString nickname
Definition QXmppMixManager.h:51
QXmppMixManager::Participation::subscriptions
QXmppMixConfigItem::Nodes subscriptions
Definition QXmppMixManager.h:52
QXmppMixManager::Service
Definition QXmppMixManager.h:34
QXmppMixManager::Service::jid
QString jid
Definition QXmppMixManager.h:35
QXmppMixManager::Service::channelCreationAllowed
bool channelCreationAllowed
Definition QXmppMixManager.h:37
QXmppMixManager::Service::channelsSearchable
bool channelsSearchable
Definition QXmppMixManager.h:36
QXmppMixManager::Subscription
Definition QXmppMixManager.h:44
QXmppMixManager::Subscription::additions
QXmppMixConfigItem::Nodes additions
Definition QXmppMixManager.h:45
QXmppMixManager::Subscription::removals
QXmppMixConfigItem::Nodes removals
Definition QXmppMixManager.h:46