QXmpp: QXmppPubSubNodeConfig.h Source File

QXmpp Version: 1.14.3

Loading...
Searching...
No Matches
QXmppPubSubNodeConfig.h
1// SPDX-FileCopyrightText: 2020 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPPUBSUBNODECONFIG_H
6#define QXMPPPUBSUBNODECONFIG_H
7
8#include "QXmppDataForm.h"
9#include "QXmppDataFormBase.h"
10
11#include <variant>
12
13class QXmppPubSubNodeConfigPrivate;
14
15class QXMPP_EXPORT QXmppPubSubNodeConfig : public QXmppExtensibleDataFormBase
16{
17public:
18 struct Unset { };
19 struct Max { };
20 using ItemLimit = std::variant<Unset, uint64_t, Max>;
21
22 enum AccessModel : uint8_t {
23 Open,
24 Presence,
25 Roster,
26 Authorize,
27 Allowlist
28 };
29
30 enum PublishModel : uint8_t {
31 Publishers,
32 Subscribers,
33 Anyone
34 };
35
36 enum class ChildAssociationPolicy : uint8_t {
37 All,
38 Owners,
39 Whitelist
40 };
41
42 enum ItemPublisher : uint8_t {
43 NodeOwner,
44 Publisher
45 };
46
47 enum NodeType : uint8_t {
48 Leaf,
49 Collection
50 };
51
52 enum NotificationType : uint8_t {
53 Normal,
54 Headline
55 };
56
57 enum SendLastItemType : uint8_t {
58 Never,
59 OnSubscription,
60 OnSubscriptionAndPresence
61 };
62
63 static std::optional<QXmppPubSubNodeConfig> fromDataForm(const QXmppDataForm &form);
64
65 QXmppPubSubNodeConfig();
66 QXmppPubSubNodeConfig(const QXmppPubSubNodeConfig &);
67 QXmppPubSubNodeConfig(QXmppPubSubNodeConfig &&);
68 ~QXmppPubSubNodeConfig() override;
69
70 QXmppPubSubNodeConfig &operator=(const QXmppPubSubNodeConfig &);
71 QXmppPubSubNodeConfig &operator=(QXmppPubSubNodeConfig &&);
72
73 std::optional<AccessModel> accessModel() const;
74 void setAccessModel(std::optional<AccessModel> accessModel);
75
76 QString bodyXslt() const;
77 void setBodyXslt(const QString &bodyXslt);
78
79 std::optional<ChildAssociationPolicy> childAssociationPolicy() const;
80 void setChildAssociationPolicy(std::optional<ChildAssociationPolicy> childAssociationPolicy);
81
82 QStringList childAssociationAllowlist() const;
83 void setChildAssociationAllowlist(const QStringList &childAssociationWhitelist);
84
85 QStringList childNodes() const;
86 void setChildNodes(const QStringList &childNodes);
87
88 std::optional<quint32> childNodesMax() const;
89 void setChildNodesMax(std::optional<quint32> childNodesMax);
90
91 QStringList collections() const;
92 void setCollections(const QStringList &collections);
93
94 QStringList contactJids() const;
95 void setContactJids(const QStringList &contactJids);
96
97 QString dataFormXslt() const;
98 void setDataFormXslt(const QString &dataFormXslt);
99
100 std::optional<bool> notificationsEnabled() const;
101 void setNotificationsEnabled(std::optional<bool> notificationsEnabled);
102
103 std::optional<bool> includePayloads() const;
104 void setIncludePayloads(std::optional<bool> includePayloads);
105
106 QString description() const;
107 void setDescription(const QString &description);
108
109 std::optional<quint32> itemExpiry() const;
110 void setItemExpiry(std::optional<quint32> itemExpiry);
111
112 std::optional<ItemPublisher> notificationItemPublisher() const;
113 void setNotificationItemPublisher(std::optional<ItemPublisher> notificationItemPublisher);
114
115 QString language() const;
116 void setLanguage(const QString &language);
117
118 ItemLimit maxItems() const;
119 void setMaxItems(ItemLimit maxItems);
120 inline void resetMaxItems() { setMaxItems(Unset()); }
121
122 std::optional<quint32> maxPayloadSize() const;
123 void setMaxPayloadSize(std::optional<quint32> maxPayloadSize);
124
125 std::optional<NodeType> nodeType() const;
126 void setNodeType(std::optional<NodeType> nodeType);
127
128 std::optional<QXmppPubSubNodeConfig::NotificationType> notificationType() const;
129 void setNotificationType(std::optional<QXmppPubSubNodeConfig::NotificationType> notificationType);
130
131 std::optional<bool> configNotificationsEnabled() const;
132 void setConfigNotificationsEnabled(std::optional<bool> configNotificationsEnabled);
133
134 std::optional<bool> deleteNotificationsEnabled() const;
135 void setDeleteNotificationsEnabled(std::optional<bool> nodeDeleteNotificationsEnabled);
136
137 std::optional<bool> retractNotificationsEnabled() const;
138 void setRetractNotificationsEnabled(std::optional<bool> retractNotificationsEnabled);
139
140 std::optional<bool> subNotificationsEnabled() const;
141 void setSubNotificationsEnabled(std::optional<bool> subNotificationsEnabled);
142
143 std::optional<bool> persistItems() const;
144 void setPersistItems(std::optional<bool> persistItems);
145
146 std::optional<bool> presenceBasedNotifications() const;
147 void setPresenceBasedNotifications(std::optional<bool> presenceBasedNotifications);
148
149 std::optional<PublishModel> publishModel() const;
150 void setPublishModel(std::optional<PublishModel> publishModel);
151
152 std::optional<bool> purgeWhenOffline() const;
153 void setPurgeWhenOffline(std::optional<bool> purgeWhenOffline);
154
155 QStringList allowedRosterGroups() const;
156 void setAllowedRosterGroups(const QStringList &allowedRosterGroups);
157
158 std::optional<SendLastItemType> sendLastItem() const;
159 void setSendLastItem(std::optional<SendLastItemType> sendLastItem);
160
161 std::optional<bool> temporarySubscriptions() const;
162 void setTemporarySubscriptions(std::optional<bool> temporarySubscriptions);
163
164 std::optional<bool> allowSubscriptions() const;
165 void setAllowSubscriptions(std::optional<bool> allowSubscriptions);
166
167 QString title() const;
168 void setTitle(const QString &title);
169
170 QString payloadType() const;
171 void setPayloadType(const QString &payloadType);
172
173protected:
174 QString formType() const override;
175 bool parseField(const QXmppDataForm::Field &) override;
176 void serializeForm(QXmppDataForm &) const override;
177
178private:
179 QSharedDataPointer<QXmppPubSubNodeConfigPrivate> d;
180};
181
182class QXMPP_EXPORT QXmppPubSubPublishOptions : public QXmppPubSubNodeConfig
183{
184public:
185 static std::optional<QXmppPubSubPublishOptions> fromDataForm(const QXmppDataForm &form);
186
187protected:
188 QString formType() const override;
189};
190
191Q_DECLARE_METATYPE(QXmppPubSubNodeConfig);
192Q_DECLARE_METATYPE(QXmppPubSubPublishOptions);
193
194#endif // QXMPPPUBSUBNODECONFIG_H
QXmppDataFormBase::fromDataForm
static bool fromDataForm(const QXmppDataForm &form, QXmppDataFormBase &parent)
Definition QXmppDataFormBase.cpp:55
QXmppDataFormBase::formType
virtual QString formType() const =0
QXmppExtensibleDataFormBase
Definition QXmppDataFormBase.h:112
QXmppExtensibleDataFormBase::serializeForm
void serializeForm(QXmppDataForm &) const override
Definition QXmppDataFormBase.cpp:204
QXmppExtensibleDataFormBase::parseField
virtual bool parseField(const QXmppDataForm::Field &)
Definition QXmppDataFormBase.cpp:215