QXmpp: QXmppPubSubSubscribeOptions.h Source File

QXmpp Version: 1.14.2

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
34 enum SubscriptionType : uint8_t {
35 Items,
36 Nodes
37 };
38
39 enum SubscriptionDepth : uint8_t {
40 TopLevelOnly,
41 Recursive
42 };
43
44 static std::optional<QXmppPubSubSubscribeOptions> fromDataForm(const QXmppDataForm &form);
45
46 QXmppPubSubSubscribeOptions();
47 QXmppPubSubSubscribeOptions(const QXmppPubSubSubscribeOptions &);
48 QXmppPubSubSubscribeOptions(QXmppPubSubSubscribeOptions &&);
49 ~QXmppPubSubSubscribeOptions() override;
50
51 QXmppPubSubSubscribeOptions &operator=(const QXmppPubSubSubscribeOptions &);
52 QXmppPubSubSubscribeOptions &operator=(QXmppPubSubSubscribeOptions &&);
53
54 std::optional<bool> notificationsEnabled() const;
55 void setNotificationsEnabled(std::optional<bool> notifying);
56
57 std::optional<bool> digestsEnabled() const;
58 void setDigestsEnabled(std::optional<bool> digestsEnabled);
59
60 std::optional<quint32> digestFrequencyMs() const;
61 void setDigestFrequencyMs(std::optional<quint32> digestFrequencyMs);
62
63 QDateTime expire() const;
64 void setExpire(const QDateTime &expire);
65
66 std::optional<bool> bodyIncluded() const;
67 void setBodyIncluded(std::optional<bool> bodyIncluded);
68
69 PresenceStates notificationRules() const;
70 void setNotificationRules(PresenceStates notificationRules);
71
72 std::optional<SubscriptionType> subscriptionType() const;
73 void setSubscriptionType(std::optional<SubscriptionType> subscriptionType);
74
75 std::optional<SubscriptionDepth> subscriptionDepth() const;
76 void setSubscriptionDepth(std::optional<SubscriptionDepth> subscriptionDepth);
77
78protected:
79 QString formType() const override;
80 bool parseField(const QXmppDataForm::Field &) override;
81 void serializeForm(QXmppDataForm &) const override;
82
83private:
84 QSharedDataPointer<QXmppPubSubSubscribeOptionsPrivate> d;
85};
86
87Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppPubSubSubscribeOptions::PresenceStates)
88Q_DECLARE_METATYPE(QXmppPubSubSubscribeOptions)
89
90#endif // QXMPPPUBSUBSUBSCRIBEOPTIONS_H
QXmppDataFormBase::fromDataForm
static bool fromDataForm(const QXmppDataForm &form, QXmppDataFormBase &parent)
Definition QXmppDataFormBase.cpp:55
QXmppDataFormBase::formType
virtual QString formType() const =0
QXmppDataForm
Definition QXmppDataForm.h:28
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