QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
QXmppPubSubSubscribeOptions.h
1// SPDX-FileCopyrightText: 2020 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPPUBSUBSUBSCRIBEOPTIONS_H
6#define QXMPPPUBSUBSUBSCRIBEOPTIONS_H
7
8#include "QXmppDataForm.h"
9#include "QXmppDataFormBase.h"
10#include "QXmppGlobal.h"
11
12#include <QFlags>
13#include <QSharedDataPointer>
14
15class QDateTime;
16class QDomElement;
17class QXmlStreamWriter;
18class QXmppDataForm;
19class QXmppPubSubSubscribeOptionsPrivate;
20
21class QXMPP_EXPORT QXmppPubSubSubscribeOptions : public QXmppExtensibleDataFormBase
22{
23public:
24 enum PresenceState : uint8_t {
25 Unset = 0x00,
26 Online = 0x01,
27 Away = 0x02,
28 Chat = 0x04,
29 DoNotDisturb = 0x08,
30 ExtendedAway = 0x10
31 };
32 Q_DECLARE_FLAGS(PresenceStates, PresenceState)
33 static PresenceStates presenceStatesFromStringList(const QStringList &);
34 static QStringList presenceStatesToStringList(PresenceStates);
35
36 enum SubscriptionType : uint8_t {
37 Items,
38 Nodes
39 };
40
41 enum SubscriptionDepth : uint8_t {
42 TopLevelOnly,
43 Recursive
44 };
45
46 static std::optional<QXmppPubSubSubscribeOptions> fromDataForm(const QXmppDataForm &form);
47
48 QXmppPubSubSubscribeOptions();
49 QXmppPubSubSubscribeOptions(const QXmppPubSubSubscribeOptions &);
50 QXmppPubSubSubscribeOptions(QXmppPubSubSubscribeOptions &&);
51 virtual ~QXmppPubSubSubscribeOptions();
52
53 QXmppPubSubSubscribeOptions &operator=(const QXmppPubSubSubscribeOptions &);
54 QXmppPubSubSubscribeOptions &operator=(QXmppPubSubSubscribeOptions &&);
55
56 std::optional<bool> notificationsEnabled() const;
57 void setNotificationsEnabled(std::optional<bool> notifying);
58
59 std::optional<bool> digestsEnabled() const;
60 void setDigestsEnabled(std::optional<bool> digestsEnabled);
61
62 std::optional<quint32> digestFrequencyMs() const;
63 void setDigestFrequencyMs(std::optional<quint32> digestFrequencyMs);
64
65 QDateTime expire() const;
66 void setExpire(const QDateTime &expire);
67
68 std::optional<bool> bodyIncluded() const;
69 void setBodyIncluded(std::optional<bool> bodyIncluded);
70
71 PresenceStates notificationRules() const;
72 void setNotificationRules(PresenceStates notificationRules);
73
74 std::optional<SubscriptionType> subscriptionType() const;
75 void setSubscriptionType(std::optional<SubscriptionType> subscriptionType);
76
77 std::optional<SubscriptionDepth> subscriptionDepth() const;
78 void setSubscriptionDepth(std::optional<SubscriptionDepth> subscriptionDepth);
79
80protected:
81 QString formType() const override;
82 bool parseField(const QXmppDataForm::Field &) override;
83 void serializeForm(QXmppDataForm &) const override;
84
85private:
86 QSharedDataPointer<QXmppPubSubSubscribeOptionsPrivate> d;
87};
88
89Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppPubSubSubscribeOptions::PresenceStates)
90Q_DECLARE_METATYPE(QXmppPubSubSubscribeOptions)
91
92#endif // QXMPPPUBSUBSUBSCRIBEOPTIONS_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