1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qmqttsubscriptionproperties.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QMqttSubscriptionProperties
10
11 \inmodule QtMqtt
12 \since 5.12
13
14 \brief The QMqttSubscriptionProperties class represents configuration
15 options a QMqttClient can pass to the server when subscribing to a
16 topic filter.
17
18 \note Subscription properties are part of the MQTT 5.0 specification and
19 cannot be used when connecting with a lower protocol level. See
20 QMqttClient::ProtocolVersion for more information.
21*/
22
23/*!
24 \class QMqttUnsubscriptionProperties
25
26 \inmodule QtMqtt
27 \since 5.12
28
29 \brief The QMqttUnsubscriptionProperties class represents configuration
30 options a QMqttClient can pass to the server when unsubscribing from a
31 topic filter.
32
33 \note Unsubscription properties are part of the MQTT 5.0 specification and
34 cannot be used when connecting with a lower protocol level. See
35 QMqttClient::ProtocolVersion for more information.
36*/
37
38class QMqttSubscriptionPropertiesData : public QSharedData
39{
40public:
41 quint32 subscriptionIdentifier{0};
42 QMqttUserProperties userProperties;
43 bool noLocal{false};
44};
45
46class QMqttUnsubscriptionPropertiesData : public QSharedData
47{
48public:
49 QMqttUserProperties userProperties;
50};
51
52/*!
53 \internal
54*/
55QMqttSubscriptionProperties::QMqttSubscriptionProperties() : data(new QMqttSubscriptionPropertiesData)
56{
57
58}
59
60/*!
61 \internal
62*/
63QMqttSubscriptionProperties::QMqttSubscriptionProperties(const QMqttSubscriptionProperties &) = default;
64
65QMqttSubscriptionProperties &QMqttSubscriptionProperties::operator=(const QMqttSubscriptionProperties &rhs)
66{
67 if (this != &rhs)
68 data.operator=(o: rhs.data);
69 return *this;
70}
71
72QMqttSubscriptionProperties::~QMqttSubscriptionProperties() = default;
73
74/*!
75 Returns the user specified properties.
76*/
77QMqttUserProperties QMqttSubscriptionProperties::userProperties() const
78{
79 return data->userProperties;
80}
81
82/*!
83 Sets the user properties to \a user.
84*/
85void QMqttSubscriptionProperties::setUserProperties(const QMqttUserProperties &user)
86{
87 data->userProperties = user;
88}
89
90/*!
91 Returns the subscription identifier used to describe this subscription.
92*/
93quint32 QMqttSubscriptionProperties::subscriptionIdentifier() const
94{
95 return data->subscriptionIdentifier;
96}
97
98/*!
99 Sets the subscription identifier to \a id.
100*/
101void QMqttSubscriptionProperties::setSubscriptionIdentifier(quint32 id)
102{
103 data->subscriptionIdentifier = id;
104}
105
106/*!
107 * \since 6.4
108 * Returns true if the subscription shall not receive local messages on the same topic.
109 */
110bool QMqttSubscriptionProperties::noLocal() const
111{
112 return data->noLocal;
113}
114
115/*!
116 * \since 6.4
117 * Sets the subscription option to not receive local message.
118 * When a client publishes a message with the same topic as an existing local subscription
119 * the server by default sends the message back to the client. If \a noloc is set to true
120 * the broker will not send any message the same client has published.
121 */
122void QMqttSubscriptionProperties::setNoLocal(bool noloc)
123{
124 data->noLocal = noloc;
125}
126
127/*!
128 \internal
129*/
130QMqttUnsubscriptionProperties::QMqttUnsubscriptionProperties() : data(new QMqttUnsubscriptionPropertiesData)
131{
132}
133
134/*!
135 \internal
136*/
137QMqttUnsubscriptionProperties &QMqttUnsubscriptionProperties::operator=(const QMqttUnsubscriptionProperties &rhs)
138{
139 if (this != &rhs)
140 data.operator=(o: rhs.data);
141 return *this;
142}
143
144/*!
145 Returns the user specified properties.
146*/
147QMqttUserProperties QMqttUnsubscriptionProperties::userProperties() const
148{
149 return data->userProperties;
150}
151
152/*!
153 Sets the user properties to \a user.
154*/
155void QMqttUnsubscriptionProperties::setUserProperties(const QMqttUserProperties &user)
156{
157 data->userProperties = user;
158}
159
160QMqttUnsubscriptionProperties::~QMqttUnsubscriptionProperties() = default;
161
162QMqttUnsubscriptionProperties::QMqttUnsubscriptionProperties(const QMqttUnsubscriptionProperties &) = default;
163
164QT_END_NAMESPACE
165

source code of qtmqtt/src/mqtt/qmqttsubscriptionproperties.cpp