blob: 92965161ca0bd52e019d572878b1ec8364dc8d7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qmqttpublishproperties.h"
#include "qmqttpublishproperties_p.h"
#include "qmqtttype.h"
#include <QtCore/QLoggingCategory>
QT_BEGIN_NAMESPACE
/*!
\class QMqttPublishProperties
\inmodule QtMqtt
\since 5.12
\brief The QMqttPublishProperties class represents configuration
options for sending or receiving a message.
Invoking QMqttClient::publish() to send a message to a broker can
include QMqttPublishProperties to provide additional arguments on
how the message should be treated on the broker.
Furthermore receiving a message by an instantiated subscription
might contain publish properties which have been forwarded or
adapted by the server.
\note Publish properties are part of the MQTT 5.0 specification and
cannot be used when connecting with a lower protocol level. See
QMqttClient::ProtocolVersion for more information.
*/
/*!
\enum QMqttPublishProperties::PublishPropertyDetail
This enum type specifies the available properties set by the
server or the client when creating a message.
\value None
No property has been specified.
\value PayloadFormatIndicator
The type of content of the message.
\value MessageExpiryInterval
The duration a message is valid.
\value TopicAlias
The topic alias for this message.
\value ResponseTopic
The topic the receipient should respond to.
\value CorrelationData
An identifier of the response message.
\value UserProperty
Additional properties set by the user.
\value SubscriptionIdentifier
An identifier of subscriptions matching the publication.
\value ContentType
A description of the content of the message.
*/
QMqttPublishProperties::QMqttPublishProperties() : data(new QMqttPublishPropertiesData)
{
}
/*!
\internal
*/
QMqttPublishProperties::QMqttPublishProperties(const QMqttPublishProperties &) = default;
/*!
\internal
*/
QMqttPublishProperties &QMqttPublishProperties::operator=(const QMqttPublishProperties &rhs)
{
if (this != &rhs)
data.operator=(rhs.data);
return *this;
}
QMqttPublishProperties::~QMqttPublishProperties() = default;
/*!
Returns the available properties specified in this instance. When a message
is created, it does not need to include all properties. This function
serves as an indicator of those properties which have been explicitly
set.
*/
QMqttPublishProperties::PublishPropertyDetails QMqttPublishProperties::availableProperties() const
{
return data->details;
}
/*!
Returns the payload format indicator.
*/
QMqtt::PayloadFormatIndicator QMqttPublishProperties::payloadFormatIndicator() const
{
return data->payloadIndicator;
}
/*!
Sets the payload format indicator to \a indicator.
*/
void QMqttPublishProperties::setPayloadFormatIndicator(QMqtt::PayloadFormatIndicator indicator)
{
data->details |= QMqttPublishProperties::PayloadFormatIndicator;
data->payloadIndicator = indicator;
}
/*!
Returns the message expiry interval. This value specifies the number
of seconds a server is allowed to forward the message. If the interval
expires, the server must delete the message and abort publishing it.
*/
quint32 QMqttPublishProperties::messageExpiryInterval() const
{
return data->messageExpiry;
}
/*!
Sets the message expiry interval to \a interval.
*/
void QMqttPublishProperties::setMessageExpiryInterval(quint32 interval)
{
data->details |= QMqttPublishProperties::MessageExpiryInterval;
data->messageExpiry = interval;
}
/*!
Returns the topic alias used for publishing a message.
*/
quint16 QMqttPublishProperties::topicAlias() const
{
return data->topicAlias;
}
/*!
Sets the topic alias for publishing a message to \a alias. A topic alias
value must be greater than zero and less than the maximum topic alias
specified by the server.
\sa QMqttServerConnectionProperties::maximumTopicAlias()
*/
void QMqttPublishProperties::setTopicAlias(quint16 alias)
{
if (alias == 0) {
qCDebug(lcMqttClient) << "A topic alias with value 0 is not allowed.";
return;
}
data->details |= QMqttPublishProperties::TopicAlias;
data->topicAlias = alias;
}
/*!
Returns the response topic a user should use as a follow up to
a request.
*/
QString QMqttPublishProperties::responseTopic() const
{
return data->responseTopic;
}
/*!
Sets the response topic to \a topic.
*/
void QMqttPublishProperties::setResponseTopic(const QString &topic)
{
data->details |= QMqttPublishProperties::ResponseTopic;
data->responseTopic = topic;
}
/*!
Returns the correlation data.
*/
QByteArray QMqttPublishProperties::correlationData() const
{
return data->correlationData;
}
/*!
Sets the correlation data to \a correlation.
*/
void QMqttPublishProperties::setCorrelationData(const QByteArray &correlation)
{
data->details |= QMqttPublishProperties::CorrelationData;
data->correlationData = correlation;
}
/*!
Returns the user properties of a message.
*/
QMqttUserProperties QMqttPublishProperties::userProperties() const
{
return data->userProperties;
}
/*!
Sets the user properties of a message to \a properties.
*/
void QMqttPublishProperties::setUserProperties(const QMqttUserProperties &properties)
{
data->details |= QMqttPublishProperties::UserProperty;
data->userProperties = properties;
}
/*!
Returns the subscription identifiers of subscriptions matching
the topic filter of the message.
*/
QList<quint32> QMqttPublishProperties::subscriptionIdentifiers() const
{
return data->subscriptionIdentifier;
}
/*!
Sets the subscription identifiers to \a ids.
*/
void QMqttPublishProperties::setSubscriptionIdentifiers(const QList<quint32> &ids)
{
if (ids.contains(quint32(0))) {
qCDebug(lcMqttClient) << "A subscription identifier with value 0 is not allowed.";
return;
}
data->details |= QMqttPublishProperties::SubscriptionIdentifier;
data->subscriptionIdentifier = ids;
}
/*!
Returns the content type of the message.
*/
QString QMqttPublishProperties::contentType() const
{
return data->contentType;
}
/*!
Sets the content type of the message to \a type.
*/
void QMqttPublishProperties::setContentType(const QString &type)
{
data->details |= QMqttPublishProperties::ContentType;
data->contentType = type;
}
/*!
\class QMqttMessageStatusProperties
\inmodule QtMqtt
\since 5.12
\brief The QMqttMessageStatusProperties class represents additional
information provided by the server during message delivery.
Depending on the QoS level of a message being sent by QMqttClient::publish(),
a server reports the state of delivery. Additionally to the QMqtt::MessageStatus,
complementary information might be included by the server. These are exposed to
users via QMqttMessageStatusProperties.
\note Message status properties are part of the MQTT 5.0 specification and
cannot be used when connecting with a lower protocol level. See
QMqttClient::ProtocolVersion for more information.
*/
QMqttMessageStatusProperties::QMqttMessageStatusProperties() : data(new QMqttMessageStatusPropertiesData)
{
}
QMqttMessageStatusProperties &QMqttMessageStatusProperties::operator=(const QMqttMessageStatusProperties &rhs)
{
if (this != &rhs)
data.operator=(rhs.data);
return *this;
}
/*!
Returns the reason code of a failed message delivery.
*/
QMqtt::ReasonCode QMqttMessageStatusProperties::reasonCode() const
{
return data->reasonCode;
}
/*!
Returns the reason string of a failed message delivery.
*/
QString QMqttMessageStatusProperties::reason() const
{
return data->reasonString;
}
/*!
Returns properties specified in conjunction with a message.
*/
QMqttUserProperties QMqttMessageStatusProperties::userProperties() const
{
return data->userProperties;
}
QMqttMessageStatusProperties::~QMqttMessageStatusProperties() = default;
QMqttMessageStatusProperties::QMqttMessageStatusProperties(const QMqttMessageStatusProperties &) = default;
QT_END_NAMESPACE
|