QXmpp: QXmppMixManager.h Source File

QXmpp Version: 1.14.4

Loading...
Searching...
No Matches
QXmppMixManager.h
1// SPDX-FileCopyrightText: 2023 Melvin Keskin <melvo@olomono.de>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPMIXMANAGER_H
6#define QXMPPMIXMANAGER_H
7
8#include "QXmppClient.h"
9#include "QXmppClientExtension.h"
10#include "QXmppMixConfigItem.h"
11#include "QXmppMixInfoItem.h"
12#include "QXmppMixParticipantItem.h"
13#include "QXmppPubSubEventHandler.h"
14
15class QXmppMixIq;
16class QXmppMixInvitation;
17class QXmppMixManagerPrivate;
18
19 class QXMPP_EXPORT QXmppMixManager : public QXmppClientExtension, public QXmppPubSubEventHandler
20{
21 Q_OBJECT
22 Q_PROPERTY(Support participantSupport READ participantSupport NOTIFY participantSupportChanged)
23 Q_PROPERTY(Support messageArchivingSupport READ messageArchivingSupport NOTIFY messageArchivingSupportChanged)
24 Q_PROPERTY(QList<Service> services READ services NOTIFY servicesChanged)
25
26public:
27 enum class Support {
28 Unknown,
29 Unsupported,
30 Supported,
31 };
32 Q_ENUM(Support)
33
34 struct QXMPP_EXPORT Service {
35 QString jid;
36 bool channelsSearchable = false;
37 bool channelCreationAllowed = false;
38
40 bool operator==(const Service &other) const;
42 };
43
44 struct Subscription {
45 QXmppMixConfigItem::Nodes additions;
46 QXmppMixConfigItem::Nodes removals;
47 };
48
49 struct Participation {
50 QString participantId;
51 QString nickname;
52 QXmppMixConfigItem::Nodes subscriptions;
53 };
54
55 using Jid = QString;
56 using ChannelJid = QString;
57 using Nickname = QString;
58
59 using CreationResult = std::variant<ChannelJid, QXmppError>;
60 using ChannelJidResult = std::variant<QVector<ChannelJid>, QXmppError>;
61 using ChannelNodeResult = std::variant<QXmppMixConfigItem::Nodes, QXmppError>;
62 using ConfigurationResult = std::variant<QXmppMixConfigItem, QXmppError>;
63 using InformationResult = std::variant<QXmppMixInfoItem, QXmppError>;
64 using JoiningResult = std::variant<Participation, QXmppError>;
65 using NicknameResult = std::variant<Nickname, QXmppError>;
66 using InvitationResult = std::variant<QXmppMixInvitation, QXmppError>;
67 using SubscriptionResult = std::variant<Subscription, QXmppError>;
68 using JidResult = std::variant<QVector<Jid>, QXmppError>;
69 using ParticipantResult = std::variant<QVector<QXmppMixParticipantItem>, QXmppError>;
70
71 QXmppMixManager();
72 ~QXmppMixManager() override;
73
74 QStringList discoveryFeatures() const override;
75
76 Support participantSupport() const;
77 Q_SIGNAL void participantSupportChanged();
78
79 Support messageArchivingSupport() const;
80 Q_SIGNAL void messageArchivingSupportChanged();
81
82 QList<Service> services() const;
83 Q_SIGNAL void servicesChanged();
84
85 QXmppTask<CreationResult> createChannel(const QString &serviceJid, const QString &channelId = {});
86
87 QXmppTask<ChannelJidResult> requestChannelJids(const QString &serviceJid);
88 QXmppTask<ChannelNodeResult> requestChannelNodes(const QString &channelJid);
89
90 QXmppTask<ConfigurationResult> requestChannelConfiguration(const QString &channelJid);
91 QXmppTask<QXmppClient::EmptyResult> updateChannelConfiguration(const QString &channelJid, QXmppMixConfigItem configuration);
92 Q_SIGNAL void channelConfigurationUpdated(const QString &channelJid, const QXmppMixConfigItem &configuration);
93
94 QXmppTask<InformationResult> requestChannelInformation(const QString &channelJid);
95 QXmppTask<QXmppClient::EmptyResult> updateChannelInformation(const QString &channelJid, QXmppMixInfoItem information);
96 Q_SIGNAL void channelInformationUpdated(const QString &channelJid, const QXmppMixInfoItem &information);
97
98 QXmppTask<JoiningResult> joinChannel(const QString &channelJid, const QString &nickname = {}, QXmppMixConfigItem::Nodes nodes = ~QXmppMixConfigItem::Nodes());
99 QXmppTask<JoiningResult> joinChannel(const QXmppMixInvitation &invitation, const QString &nickname = {}, QXmppMixConfigItem::Nodes nodes = ~QXmppMixConfigItem::Nodes());
100
101 QXmppTask<NicknameResult> updateNickname(const QString &channelJid, const QString &nickname);
102 QXmppTask<SubscriptionResult> updateSubscriptions(const QString &channelJid, QXmppMixConfigItem::Nodes subscriptionAdditions = ~QXmppMixConfigItem::Nodes(), QXmppMixConfigItem::Nodes subscriptionRemovals = {});
103
104 QXmppTask<InvitationResult> requestInvitation(const QString &channelJid, const QString &inviteeJid);
105
106 QXmppTask<JidResult> requestAllowedJids(const QString &channelJid);
107 QXmppTask<QXmppClient::EmptyResult> allowJid(const QString &channelJid, const QString &jid);
108 Q_SIGNAL void jidAllowed(const QString &channelJid, const QString &jid);
109 Q_SIGNAL void allJidsAllowed(const QString &channelJid);
110
111 QXmppTask<QXmppClient::EmptyResult> disallowJid(const QString &channelJid, const QString &jid);
112 Q_SIGNAL void jidDisallowed(const QString &channelJid, const QString &jid);
113 QXmppTask<QXmppClient::EmptyResult> disallowAllJids(const QString &channelJid);
114 Q_SIGNAL void allJidsDisallowed(const QString &channelJid);
115
116 QXmppTask<JidResult> requestBannedJids(const QString &channelJid);
117 QXmppTask<QXmppClient::EmptyResult> banJid(const QString &channelJid, const QString &jid);
118 Q_SIGNAL void jidBanned(const QString &channelJid, const QString &jid);
119
120 QXmppTask<QXmppClient::EmptyResult> unbanJid(const QString &channelJid, const QString &jid);
121 Q_SIGNAL void jidUnbanned(const QString &channelJid, const QString &jid);
122 QXmppTask<QXmppClient::EmptyResult> unbanAllJids(const QString &channelJid);
123 Q_SIGNAL void allJidsUnbanned(const QString &channelJid);
124
125 QXmppTask<ParticipantResult> requestParticipants(const QString &channelJid);
126 Q_SIGNAL void participantReceived(const QString &channelJid, const QXmppMixParticipantItem &participant);
127 Q_SIGNAL void participantLeft(const QString &channelJid, const QString &participantId);
128
129 QXmppTask<QXmppClient::EmptyResult> leaveChannel(const QString &channelJid);
130
131 QXmppTask<QXmppClient::EmptyResult> deleteChannel(const QString &channelJid);
132 Q_SIGNAL void channelDeleted(const QString &channelJid);
133
134protected:
136 void onRegistered(QXmppClient *client) override;
137 void onUnregistered(QXmppClient *client) override;
138 bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName) override;
140
141private:
142 QXmppMixIq prepareJoinIq(const QString &channelJid, const QString &nickname, QXmppMixConfigItem::Nodes nodes);
143 QXmppTask<JoiningResult> joinChannel(QXmppMixIq &&iq);
144 QXmppTask<JidResult> requestJids(const QString &channelJid, const QString &node);
145 QXmppTask<QXmppClient::EmptyResult> addJidToNode(const QString &channelJid, const QString &node, const QString &jid);
146
147 void updateCachedData();
148 void updateSupport();
149 void updateServices();
150 void updateService(const QString &jid);
151
152 void setParticipantSupport(Support participantSupport);
153 void setMessageArchivingSupport(Support messageArchivingSupport);
154 void addService(const Service &service);
155 void removeService(const QString &jid);
156 void removeServices();
157
158 void resetCachedData();
159
160 const std::unique_ptr<QXmppMixManagerPrivate> d;
161
162 friend class tst_QXmppMixManager;
163};
164
165#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