From 5cc736dd4004e06f65c3f16f2db322d722c1b564 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Mon, 7 Sep 2020 16:52:59 +0200 Subject: Add PubSubNodeConfig form --- src/base/QXmppPubSubNodeConfig.h | 208 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 src/base/QXmppPubSubNodeConfig.h (limited to 'src/base/QXmppPubSubNodeConfig.h') diff --git a/src/base/QXmppPubSubNodeConfig.h b/src/base/QXmppPubSubNodeConfig.h new file mode 100644 index 00000000..4b9de9c7 --- /dev/null +++ b/src/base/QXmppPubSubNodeConfig.h @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2008-2021 The QXmpp developers + * + * Author: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef QXMPPPUBSUBNODECONFIG_H +#define QXMPPPUBSUBNODECONFIG_H + +#include "QXmppDataForm.h" +#include "QXmppDataFormBase.h" + +class QXmppPubSubNodeConfigPrivate; + +class QXMPP_EXPORT QXmppPubSubNodeConfig : public QXmppExtensibleDataFormBase +{ +public: + enum AccessModel : uint8_t { + Open, + Presence, + Roster, + Authorize, + Allowlist + }; + static std::optional accessModelFromString(const QString &); + static QString accessModelToString(AccessModel); + + enum PublishModel : uint8_t { + Publishers, + Subscribers, + Anyone + }; + static std::optional publishModelFromString(const QString &); + static QString publishModelToString(PublishModel); + + enum class ChildAssociationPolicy : uint8_t { + All, + Owners, + Whitelist + }; + static std::optional childAssociatationPolicyFromString(const QString &); + static QString childAssociationPolicyToString(ChildAssociationPolicy); + + enum ItemPublisher : uint8_t { + NodeOwner, + Publisher + }; + static std::optional itemPublisherFromString(const QString &); + static QString itemPublisherToString(ItemPublisher); + + enum NodeType : uint8_t { + Leaf, + Collection + }; + static std::optional nodeTypeFromString(const QString &); + static QString nodeTypeToString(NodeType); + + enum NotificationType : uint8_t { + Normal, + Headline + }; + static std::optional notificationTypeFromString(const QString &); + static QString notificationTypeToString(NotificationType); + + enum SendLastItemType : uint8_t { + Never, + OnSubscription, + OnSubscriptionAndPresence + }; + static std::optional sendLastItemTypeFromString(const QString &); + static QString sendLastItemTypeToString(SendLastItemType); + + static std::optional fromDataForm(const QXmppDataForm &form); + + QXmppPubSubNodeConfig(); + QXmppPubSubNodeConfig(const QXmppPubSubNodeConfig &); + ~QXmppPubSubNodeConfig(); + + QXmppPubSubNodeConfig &operator=(const QXmppPubSubNodeConfig &); + + std::optional accessModel() const; + void setAccessModel(std::optional accessModel); + + QString bodyXslt() const; + void setBodyXslt(const QString &bodyXslt); + + std::optional childAssociationPolicy() const; + void setChildAssociationPolicy(std::optional childAssociationPolicy); + + QStringList childAssociationAllowlist() const; + void setChildAssociationAllowlist(const QStringList &childAssociationWhitelist); + + QStringList childNodes() const; + void setChildNodes(const QStringList &childNodes); + + std::optional childNodesMax() const; + void setChildNodesMax(std::optional childNodesMax); + + QStringList collections() const; + void setCollections(const QStringList &collections); + + QStringList contactJids() const; + void setContactJids(const QStringList &contactJids); + + QString dataFormXslt() const; + void setDataFormXslt(const QString &dataFormXslt); + + std::optional notificationsEnabled() const; + void setNotificationsEnabled(std::optional notificationsEnabled); + + std::optional includePayloads() const; + void setIncludePayloads(std::optional includePayloads); + + QString description() const; + void setDescription(const QString &description); + + std::optional itemExpiry() const; + void setItemExpiry(std::optional itemExpiry); + + std::optional notificationItemPublisher() const; + void setNotificationItemPublisher(std::optional notificationItemPublisher); + + QString language() const; + void setLanguage(const QString &language); + + std::optional maxItems() const; + void setMaxItems(std::optional maxItems); + + std::optional maxPayloadSize() const; + void setMaxPayloadSize(std::optional maxPayloadSize); + + std::optional nodeType() const; + void setNodeType(std::optional nodeType); + + std::optional notificationType() const; + void setNotificationType(std::optional notificationType); + + std::optional configNotificationsEnabled() const; + void setConfigNotificationsEnabled(std::optional configNotificationsEnabled); + + std::optional nodeDeleteNotificationsEnabled() const; + void setNodeDeleteNotificationsEnabled(std::optional nodeDeleteNotificationsEnabled); + + std::optional retractNotificationsEnabled() const; + void setRetractNotificationsEnabled(std::optional retractNotificationsEnabled); + + std::optional subNotificationsEnabled() const; + void setSubNotificationsEnabled(std::optional subNotificationsEnabled); + + std::optional persistItems() const; + void setPersistItems(std::optional persistItems); + + std::optional presenceBasedNotifications() const; + void setPresenceBasedNotifications(std::optional presenceBasedNotifications); + + std::optional publishModel() const; + void setPublishModel(std::optional publishModel); + + std::optional purgeWhenOffline() const; + void setPurgeWhenOffline(std::optional purgeWhenOffline); + + QStringList allowedRosterGroups() const; + void setAllowedRosterGroups(const QStringList &allowedRosterGroups); + + std::optional sendLastItem() const; + void setSendLastItem(std::optional sendLastItem); + + std::optional temporarySubscriptions() const; + void setTemporarySubscriptions(std::optional temporarySubscriptions); + + std::optional allowSubscriptions() const; + void setAllowSubscriptions(std::optional allowSubscriptions); + + QString title() const; + void setTitle(const QString &title); + + QString payloadType() const; + void setPayloadType(const QString &payloadType); + +protected: + QString formType() const override; + bool parseField(const QXmppDataForm::Field &) override; + void serializeForm(QXmppDataForm &) const override; + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(QXmppPubSubNodeConfig); + +#endif // QXMPPPUBSUBNODECONFIG_H -- cgit v1.2.3