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 | |
6 | QT_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 | |
38 | class QMqttSubscriptionPropertiesData : public QSharedData |
39 | { |
40 | public: |
41 | quint32 subscriptionIdentifier{0}; |
42 | QMqttUserProperties userProperties; |
43 | bool noLocal{false}; |
44 | }; |
45 | |
46 | class QMqttUnsubscriptionPropertiesData : public QSharedData |
47 | { |
48 | public: |
49 | QMqttUserProperties userProperties; |
50 | }; |
51 | |
52 | /*! |
53 | \internal |
54 | */ |
55 | QMqttSubscriptionProperties::QMqttSubscriptionProperties() : data(new QMqttSubscriptionPropertiesData) |
56 | { |
57 | |
58 | } |
59 | |
60 | /*! |
61 | \internal |
62 | */ |
63 | QMqttSubscriptionProperties::QMqttSubscriptionProperties(const QMqttSubscriptionProperties &) = default; |
64 | |
65 | QMqttSubscriptionProperties &QMqttSubscriptionProperties::operator=(const QMqttSubscriptionProperties &rhs) |
66 | { |
67 | if (this != &rhs) |
68 | data.operator=(o: rhs.data); |
69 | return *this; |
70 | } |
71 | |
72 | QMqttSubscriptionProperties::~QMqttSubscriptionProperties() = default; |
73 | |
74 | /*! |
75 | Returns the user specified properties. |
76 | */ |
77 | QMqttUserProperties QMqttSubscriptionProperties::userProperties() const |
78 | { |
79 | return data->userProperties; |
80 | } |
81 | |
82 | /*! |
83 | Sets the user properties to \a user. |
84 | */ |
85 | void QMqttSubscriptionProperties::setUserProperties(const QMqttUserProperties &user) |
86 | { |
87 | data->userProperties = user; |
88 | } |
89 | |
90 | /*! |
91 | Returns the subscription identifier used to describe this subscription. |
92 | */ |
93 | quint32 QMqttSubscriptionProperties::subscriptionIdentifier() const |
94 | { |
95 | return data->subscriptionIdentifier; |
96 | } |
97 | |
98 | /*! |
99 | Sets the subscription identifier to \a id. |
100 | */ |
101 | void 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 | */ |
110 | bool 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 | */ |
122 | void QMqttSubscriptionProperties::setNoLocal(bool noloc) |
123 | { |
124 | data->noLocal = noloc; |
125 | } |
126 | |
127 | /*! |
128 | \internal |
129 | */ |
130 | QMqttUnsubscriptionProperties::QMqttUnsubscriptionProperties() : data(new QMqttUnsubscriptionPropertiesData) |
131 | { |
132 | } |
133 | |
134 | /*! |
135 | \internal |
136 | */ |
137 | QMqttUnsubscriptionProperties &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 | */ |
147 | QMqttUserProperties QMqttUnsubscriptionProperties::userProperties() const |
148 | { |
149 | return data->userProperties; |
150 | } |
151 | |
152 | /*! |
153 | Sets the user properties to \a user. |
154 | */ |
155 | void QMqttUnsubscriptionProperties::setUserProperties(const QMqttUserProperties &user) |
156 | { |
157 | data->userProperties = user; |
158 | } |
159 | |
160 | QMqttUnsubscriptionProperties::~QMqttUnsubscriptionProperties() = default; |
161 | |
162 | QMqttUnsubscriptionProperties::QMqttUnsubscriptionProperties(const QMqttUnsubscriptionProperties &) = default; |
163 | |
164 | QT_END_NAMESPACE |
165 |