QXmpp Version: 1.10.0
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
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
33 struct QXMPP_EXPORT Service {
34 QString jid;
35 bool channelsSearchable = false;
36 bool channelCreationAllowed = false;
37
39 bool operator==(const Service &other) const;
41 };
42
43 struct Subscription {
44 QXmppMixConfigItem::Nodes additions;
45 QXmppMixConfigItem::Nodes removals;
46 };
47
50 QString nickname;
51 QXmppMixConfigItem::Nodes subscriptions;
52 };
53
54 using Jid = QString;
55 using ChannelJid = QString;
56 using Nickname = QString;
57
58 using CreationResult = std::variant<ChannelJid, QXmppError>;
59 using ChannelJidResult = std::variant<QVector<ChannelJid>, QXmppError>;
60 using ChannelNodeResult = std::variant<QXmppMixConfigItem::Nodes, QXmppError>;
61 using ConfigurationResult = std::variant<QXmppMixConfigItem, QXmppError>;
62 using InformationResult = std::variant<QXmppMixInfoItem, QXmppError>;
63 using JoiningResult = std::variant<Participation, QXmppError>;
64 using NicknameResult = std::variant<Nickname, QXmppError>;
65 using InvitationResult = std::variant<QXmppMixInvitation, QXmppError>;
66 using SubscriptionResult = std::variant<Subscription, QXmppError>;
67 using JidResult = std::variant<QVector<Jid>, QXmppError>;
68 using ParticipantResult = std::variant<QVector<QXmppMixParticipantItem>, QXmppError>;
69
71 ~QXmppMixManager() override;
72
73 QStringList discoveryFeatures() const override;
74
75 Support participantSupport() const;
77
78 Support messageArchivingSupport() const;
80
81 QList<Service> services() const;
82 Q_SIGNAL void servicesChanged();
83
84 QXmppTask<CreationResult> createChannel(const QString &serviceJid, const QString &channelId = {});
85
86 QXmppTask<ChannelJidResult> requestChannelJids(const QString &serviceJid);
87 QXmppTask<ChannelNodeResult> requestChannelNodes(const QString &channelJid);
88
89 QXmppTask<ConfigurationResult> requestChannelConfiguration(const QString &channelJid);
90 QXmppTask<QXmppClient::EmptyResult> updateChannelConfiguration(const QString &channelJid, QXmppMixConfigItem configuration);
91 Q_SIGNAL void channelConfigurationUpdated(const QString &channelJid, const QXmppMixConfigItem &configuration);
92
93 QXmppTask<InformationResult> requestChannelInformation(const QString &channelJid);
94 QXmppTask<QXmppClient::EmptyResult> updateChannelInformation(const QString &channelJid, QXmppMixInfoItem information);
95 Q_SIGNAL void channelInformationUpdated(const QString &channelJid, const QXmppMixInfoItem &information);
96
97 QXmppTask<JoiningResult> joinChannel(const QString &channelJid, const QString &nickname = {}, QXmppMixConfigItem::Nodes nodes = ~QXmppMixConfigItem::Nodes());
98 QXmppTask<JoiningResult> joinChannel(const QXmppMixInvitation &invitation, const QString &nickname = {}, QXmppMixConfigItem::Nodes nodes = ~QXmppMixConfigItem::Nodes());
99
100 QXmppTask<NicknameResult> updateNickname(const QString &channelJid, const QString &nickname);
101 QXmppTask<SubscriptionResult> updateSubscriptions(const QString &channelJid, QXmppMixConfigItem::Nodes subscriptionAdditions = ~QXmppMixConfigItem::Nodes(), QXmppMixConfigItem::Nodes subscriptionRemovals = ~QXmppMixConfigItem::Nodes());
102
103 QXmppTask<InvitationResult> requestInvitation(const QString &channelJid, const QString &inviteeJid);
104
105 QXmppTask<JidResult> requestAllowedJids(const QString &channelJid);
106 QXmppTask<QXmppClient::EmptyResult> allowJid(const QString &channelJid, const QString &jid);
107 Q_SIGNAL void jidAllowed(const QString &channelJid, const QString &jid);
108 Q_SIGNAL void allJidsAllowed(const QString &channelJid);
109
110 QXmppTask<QXmppClient::EmptyResult> disallowJid(const QString &channelJid, const QString &jid);
111 Q_SIGNAL void jidDisallowed(const QString &channelJid, const QString &jid);
112 QXmppTask<QXmppClient::EmptyResult> disallowAllJids(const QString &channelJid);
113 Q_SIGNAL void allJidsDisallowed(const QString &channelJid);
114
115 QXmppTask<JidResult> requestBannedJids(const QString &channelJid);
116 QXmppTask<QXmppClient::EmptyResult> banJid(const QString &channelJid, const QString &jid);
117 Q_SIGNAL void jidBanned(const QString &channelJid, const QString &jid);
118
119 QXmppTask<QXmppClient::EmptyResult> unbanJid(const QString &channelJid, const QString &jid);
120 Q_SIGNAL void jidUnbanned(const QString &channelJid, const QString &jid);
121 QXmppTask<QXmppClient::EmptyResult> unbanAllJids(const QString &channelJid);
122 Q_SIGNAL void allJidsUnbanned(const QString &channelJid);
123
124 QXmppTask<ParticipantResult> requestParticipants(const QString &channelJid);
125 Q_SIGNAL void participantReceived(const QString &channelJid, const QXmppMixParticipantItem &participant);
126 Q_SIGNAL void participantLeft(const QString &channelJid, const QString &participantId);
127
128 QXmppTask<QXmppClient::EmptyResult> leaveChannel(const QString &channelJid);
129
130 QXmppTask<QXmppClient::EmptyResult> deleteChannel(const QString &channelJid);
131 Q_SIGNAL void channelDeleted(const QString &channelJid);
132
133protected:
135 void onRegistered(QXmppClient *client) override;
136 void onUnregistered(QXmppClient *client) override;
137 bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName) override;
139
140private:
141 QXmppMixIq prepareJoinIq(const QString &channelJid, const QString &nickname, QXmppMixConfigItem::Nodes nodes);
142 QXmppTask<JoiningResult> joinChannel(QXmppMixIq &&iq);
143 QXmppTask<JidResult> requestJids(const QString &channelJid, const QString &node);
144 QXmppTask<QXmppClient::EmptyResult> addJidToNode(const QString &channelJid, const QString &node, const QString &jid);
145
146 void handleDiscoInfo(const QXmppDiscoveryIq &iq);
147
148 void setParticipantSupport(Support participantSupport);
149 void setMessageArchivingSupport(Support messageArchivingSupport);
150 void addService(const Service &service);
151 void removeService(const QString &jid);
152 void removeServices();
153 void resetCachedData();
154
155 const std::unique_ptr<QXmppMixManagerPrivate> d;
156
157 friend class tst_QXmppMixManager;
158};
159
160#endif // QXMPPMIXMANAGER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:22
virtual void onUnregistered(QXmppClient *client)
Definition: QXmppClientExtension.cpp:95
virtual void onRegistered(QXmppClient *client)
Definition: QXmppClientExtension.cpp:85
Main class for starting and managing connections to XMPP servers.
Definition: QXmppClient.h:62
Definition: QXmppDiscoveryIq.h:18
The QXmppMixConfigItem class represents a PubSub item of a MIX channel containing its configuration a...
Definition: QXmppMixConfigItem.h:14
The QXmppMixInfoItem class represents a PubSub item of a MIX channel containing channel information a...
Definition: QXmppMixInfoItem.h:15
Definition: QXmppMixIq.h:18
Definition: QXmppMixManager.h:20
std::variant< Subscription, QXmppError > SubscriptionResult
Definition: QXmppMixManager.h:66
Q_SIGNAL void allJidsDisallowed(const QString &channelJid)
Q_SIGNAL void allJidsUnbanned(const QString &channelJid)
std::variant< QXmppMixInvitation, QXmppError > InvitationResult
Definition: QXmppMixManager.h:65
Q_SIGNAL void jidBanned(const QString &channelJid, const QString &jid)
Q_SIGNAL void participantSupportChanged()
std::variant< Participation, QXmppError > JoiningResult
Definition: QXmppMixManager.h:63
QString Nickname
Definition: QXmppMixManager.h:56
Q_SIGNAL void participantLeft(const QString &channelJid, const QString &participantId)
std::variant< QXmppMixConfigItem, QXmppError > ConfigurationResult
Definition: QXmppMixManager.h:61
std::variant< Nickname, QXmppError > NicknameResult
Definition: QXmppMixManager.h:64
Q_SIGNAL void servicesChanged()
Q_SIGNAL void channelDeleted(const QString &channelJid)
Q_SIGNAL void jidUnbanned(const QString &channelJid, const QString &jid)
Q_SIGNAL void jidAllowed(const QString &channelJid, const QString &jid)
std::variant< QXmppMixConfigItem::Nodes, QXmppError > ChannelNodeResult
Definition: QXmppMixManager.h:60
std::variant< QXmppMixInfoItem, QXmppError > InformationResult
Definition: QXmppMixManager.h:62
std::variant< QVector< ChannelJid >, QXmppError > ChannelJidResult
Definition: QXmppMixManager.h:59
Support
Definition: QXmppMixManager.h:27
QString Jid
Definition: QXmppMixManager.h:54
Q_SIGNAL void channelConfigurationUpdated(const QString &channelJid, const QXmppMixConfigItem &configuration)
std::variant< QVector< QXmppMixParticipantItem >, QXmppError > ParticipantResult
Definition: QXmppMixManager.h:68
Q_SIGNAL void allJidsAllowed(const QString &channelJid)
Q_SIGNAL void messageArchivingSupportChanged()
Q_SIGNAL void channelInformationUpdated(const QString &channelJid, const QXmppMixInfoItem &information)
QString ChannelJid
Definition: QXmppMixManager.h:55
Q_SIGNAL void participantReceived(const QString &channelJid, const QXmppMixParticipantItem &participant)
std::variant< ChannelJid, QXmppError > CreationResult
Definition: QXmppMixManager.h:58
std::variant< QVector< Jid >, QXmppError > JidResult
Definition: QXmppMixManager.h:67
Q_SIGNAL void jidDisallowed(const QString &channelJid, const QString &jid)
Definition: QXmppMixParticipantItem.h:13
Definition: QXmppPubSubEventHandler.h:15
virtual bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName)=0
Definition: QXmppTask.h:62
Definition: QXmppError.h:17
Definition: QXmppMixManager.h:48
QString participantId
Definition: QXmppMixManager.h:49
QXmppMixConfigItem::Nodes subscriptions
Definition: QXmppMixManager.h:51
QString nickname
Definition: QXmppMixManager.h:50
Definition: QXmppMixManager.h:33
QString jid
Definition: QXmppMixManager.h:34
Definition: QXmppMixManager.h:43
QXmppMixConfigItem::Nodes additions
Definition: QXmppMixManager.h:44
QXmppMixConfigItem::Nodes removals
Definition: QXmppMixManager.h:45