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