summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2018-08-07 10:55:50 +0200
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2018-08-09 11:55:24 +0000
commite6baf4b075b682a963f367ce8f196a6798b5ca28 (patch)
tree173ae49f59f770cf5c4d23eecdb205ded822c455
parente8bdfe7b4c0406622c3b74e74bc33c373667ab58 (diff)
Add documentation for MQTT 5.0 related features
MQTT 5.0 has been added in the Qt 5.12 release. Change-Id: I614ad162e836c82f86f21fa3e6fca6f0c3805b01 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/mqtt/doc/src/index.qdoc4
-rw-r--r--src/mqtt/qmqttauthenticationproperties.cpp50
-rw-r--r--src/mqtt/qmqttclient.cpp151
-rw-r--r--src/mqtt/qmqttconnectionproperties.cpp317
-rw-r--r--src/mqtt/qmqttmessage.cpp13
-rw-r--r--src/mqtt/qmqttpublishproperties.cpp116
-rw-r--r--src/mqtt/qmqttsubscription.cpp31
-rw-r--r--src/mqtt/qmqttsubscriptionproperties.cpp60
-rw-r--r--src/mqtt/qmqtttopicfilter.cpp7
-rw-r--r--src/mqtt/qmqtttype.cpp76
10 files changed, 822 insertions, 3 deletions
diff --git a/src/mqtt/doc/src/index.qdoc b/src/mqtt/doc/src/index.qdoc
index fd50391..92aacbb 100644
--- a/src/mqtt/doc/src/index.qdoc
+++ b/src/mqtt/doc/src/index.qdoc
@@ -41,8 +41,8 @@
The Qt MQTT module provides a standard compliant implementation of the MQTT
protocol specification. It enables applications to act as telemetry displays
- and devices to publish telemetry data. The supported versions are MQTT 3.1
- and MQTT 3.1.1.
+ and devices to publish telemetry data. The supported versions are MQTT 3.1,
+ MQTT 3.1.1, and MQTT 5.0.
\note Qt MQTT is part of the Qt for Automation offering and not Qt. For further
details please see \l {Qt for Automation}.
diff --git a/src/mqtt/qmqttauthenticationproperties.cpp b/src/mqtt/qmqttauthenticationproperties.cpp
index 778aa6b..0425939 100644
--- a/src/mqtt/qmqttauthenticationproperties.cpp
+++ b/src/mqtt/qmqttauthenticationproperties.cpp
@@ -31,6 +31,20 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QMqttAuthenticationProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttAuthenticationProperties class represents configuration
+ options during the authentication process.
+
+ \note Authentication 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.
+*/
+
class QMqttAuthenticationPropertiesData : public QSharedData
{
public:
@@ -40,11 +54,17 @@ public:
QMqttUserProperties userProperties;
};
+/*!
+ \internal
+*/
QMqttAuthenticationProperties::QMqttAuthenticationProperties() : data(new QMqttAuthenticationPropertiesData)
{
}
+/*!
+ \internal
+*/
QMqttAuthenticationProperties::QMqttAuthenticationProperties(const QMqttAuthenticationProperties &) = default;
QMqttAuthenticationProperties &QMqttAuthenticationProperties::operator=(const QMqttAuthenticationProperties &rhs)
@@ -56,41 +76,71 @@ QMqttAuthenticationProperties &QMqttAuthenticationProperties::operator=(const QM
QMqttAuthenticationProperties::~QMqttAuthenticationProperties() = default;
+/*!
+ Returns the authentication method.
+*/
QString QMqttAuthenticationProperties::authenticationMethod() const
{
return data->authenticationMethod;
}
+/*!
+ Sets the authentication method to \a method.
+*/
void QMqttAuthenticationProperties::setAuthenticationMethod(const QString &method)
{
data->authenticationMethod = method;
}
+/*!
+ Returns the authentication data
+*/
QByteArray QMqttAuthenticationProperties::authenticationData() const
{
return data->authenticationData;
}
+/*!
+ Sets the authentication data to \a adata.
+
+ Authentication data can only be used if an authentication method has
+ been specified.
+
+ \sa authenticationMethod()
+*/
void QMqttAuthenticationProperties::setAuthenticationData(const QByteArray &adata)
{
data->authenticationData = adata;
}
+/*!
+ Returns the reason string. The reason string specifies the reason for
+ a disconnect.
+*/
QString QMqttAuthenticationProperties::reason() const
{
return data->reason;
}
+/*!
+ Sets the reason string to \a r.
+*/
void QMqttAuthenticationProperties::setReason(const QString &r)
{
data->reason = r;
}
+/*!
+ Returns the user properties.
+*/
QMqttUserProperties QMqttAuthenticationProperties::userProperties() const
{
return data->userProperties;
}
+/*!
+ Sets the user properties to \a user.
+*/
void QMqttAuthenticationProperties::setUserProperties(const QMqttUserProperties &user)
{
data->userProperties = user;
diff --git a/src/mqtt/qmqttclient.cpp b/src/mqtt/qmqttclient.cpp
index 948ea9a..d4ea1ea 100644
--- a/src/mqtt/qmqttclient.cpp
+++ b/src/mqtt/qmqttclient.cpp
@@ -222,6 +222,8 @@ Q_LOGGING_CATEGORY(lcMqttClient, "qt.mqtt.client")
MQTT Standard 3.1
\value MQTT_3_1_1
MQTT Standard 3.1.1, publicly referred to as version 4
+ \value MQTT_5_0
+ MQTT Standard 5.0
*/
/*!
@@ -272,6 +274,37 @@ Q_LOGGING_CATEGORY(lcMqttClient, "qt.mqtt.client")
*/
/*!
+ \since 5.12
+ \fn QMqttClient::authenticationRequested(const QMqttAuthenticationProperties &p)
+
+ This signal is emitted after a client invoked QMqttClient::connectToHost or
+ QMqttClient::connectToHostEncrypted and before the connection is
+ established. In extended authentication, a broker might request additional
+ details which need to be provided by invoking QMqttClient::authenticate.
+ \a p specifies properties provided by the broker.
+
+ \note Extended authentication is part of the MQTT 5.0 standard and can
+ only be used when the client specifies MQTT_5_0 as ProtocolVersion.
+
+ \sa authenticationFinished(), authenticate()
+*/
+
+/*!
+ \since 5.12
+ \fn QMqttClient::authenticationFinished(const QMqttAuthenticationProperties &p)
+
+ This signal is emitted after extended authentication has finished. \a p
+ specifies available details on the authentication process.
+
+ After successful authentication QMqttClient::connected is emitted.
+
+ \note Extended authentication is part of the MQTT 5.0 standard and can
+ only be used when the client specifies MQTT_5_0 as ProtocolVersion.
+
+ \sa authenticationRequested(), authenticate()
+*/
+
+/*
Creates a new MQTT client instance with the specified \a parent.
*/
QMqttClient::QMqttClient(QObject *parent) : QObject(*(new QMqttClientPrivate(this)), parent)
@@ -321,6 +354,22 @@ QMqttSubscription *QMqttClient::subscribe(const QMqttTopicFilter &topic, quint8
return subscribe(topic, QMqttSubscriptionProperties(), qos);
}
+/*!
+ \since 5.12
+
+ Adds a new subscription to receive notifications on \a topic. The parameter
+ \a properties specifies additional subscription properties to be validated
+ by the broker. The parameter \a qos specifies the level at which security
+ messages are received. For more information about the available QoS levels,
+ see \l {Quality of Service}.
+
+ This function returns a pointer to a \l QMqttSubscription. If the same topic
+ is subscribed twice, the return value points to the same subscription
+ instance. The MQTT client is the owner of the subscription.
+
+ \note \a properties will only be passed to the broker when the client
+ specifies MQTT_5_0 as ProtocolVersion.
+*/
QMqttSubscription *QMqttClient::subscribe(const QMqttTopicFilter &topic, const QMqttSubscriptionProperties &properties, quint8 qos)
{
Q_D(QMqttClient);
@@ -343,6 +392,19 @@ void QMqttClient::unsubscribe(const QMqttTopicFilter &topic)
unsubscribe(topic, QMqttUnsubscriptionProperties());
}
+/*!
+ \since 5.12
+
+ Unsubscribes from \a topic. No notifications will be sent to any of the
+ subscriptions made by calling subscribe(). \a properties specifies
+ additional user properties to be passed to the broker.
+
+ \note If a client disconnects from a broker without unsubscribing, the
+ broker will store all messages and publish them on the next reconnect.
+
+ \note \a properties will only be passed to the broker when the client
+ specifies MQTT_5_0 as ProtocolVersion.
+*/
void QMqttClient::unsubscribe(const QMqttTopicFilter &topic, const QMqttUnsubscriptionProperties &properties)
{
Q_D(QMqttClient);
@@ -357,12 +419,27 @@ void QMqttClient::unsubscribe(const QMqttTopicFilter &topic, const QMqttUnsubscr
other clients to connect and receive the message.
Returns an ID that is used internally to identify the message.
- */
+*/
qint32 QMqttClient::publish(const QMqttTopicName &topic, const QByteArray &message, quint8 qos, bool retain)
{
return publish(topic, QMqttPublishProperties(), message, qos, retain);
}
+/*!
+ \since 5.12
+
+ Publishes a \a message to the broker with the specified \a properties and
+ \a topic. \a qos specifies the level of security required for transferring
+ the message.
+
+ If \a retain is set to \c true, the message will stay on the broker for
+ other clients to connect and receive the message.
+
+ Returns an ID that is used internally to identify the message.
+
+ \note \a properties will only be passed to the broker when the client
+ specifies MQTT_5_0 as ProtocolVersion.
+*/
qint32 QMqttClient::publish(const QMqttTopicName &topic, const QMqttPublishProperties &properties,
const QByteArray &message, quint8 qos, bool retain)
{
@@ -523,36 +600,108 @@ bool QMqttClient::willRetain() const
return d->m_willRetain;
}
+/*!
+ \since 5.12
+
+ Sets the connection properties to \a prop. \l QMqttConnectionProperties
+ can be used to ask the server to use a specific feature set. After a
+ connection request the server response can be obtained by calling
+ \l QMqttClient::serverConnectionProperties.
+
+ \note The connection properties can only be set if the MQTT client is in the
+ \l Disconnected state.
+
+ \note QMqttConnectionProperties can only be used when the client specifies
+ MQTT_5_0 as ProtocolVersion.
+*/
void QMqttClient::setConnectionProperties(const QMqttConnectionProperties &prop)
{
Q_D(QMqttClient);
d->m_connectionProperties = prop;
}
+/*!
+ \since 5.12
+
+ Returns the connection properties the client requests to the broker.
+
+ \note QMqttConnectionProperties can only be used when the client specifies
+ MQTT_5_0 as ProtocolVersion.
+*/
QMqttConnectionProperties QMqttClient::connectionProperties() const
{
Q_D(const QMqttClient);
return d->m_connectionProperties;
}
+/*!
+ \since 5.12
+
+ Sets the last will properties to \a prop. QMqttLastWillProperties allows
+ to set additional features for the last will message stored at the broker.
+
+ \note The connection properties can only be set if the MQTT client is in the
+ \l Disconnected state.
+
+ \note QMqttLastWillProperties can only be used when the client specifies
+ MQTT_5_0 as ProtocolVersion.
+*/
void QMqttClient::setLastWillProperties(const QMqttLastWillProperties &prop)
{
Q_D(QMqttClient);
d->m_lastWillProperties = prop;
}
+/*!
+ \since 5.12
+
+ Returns the last will properties.
+
+ \note QMqttLastWillProperties can only be used when the client specifies
+ MQTT_5_0 as ProtocolVersion.
+*/
QMqttLastWillProperties QMqttClient::lastWillProperties() const
{
Q_D(const QMqttClient);
return d->m_lastWillProperties;
}
+/*!
+ \since 5.12
+
+ Returns the QMqttServerConnectionProperties the broker returned after a
+ connection attempt.
+
+ This can be used to verify that client side connection properties set by
+ QMqttClient::setConnectionProperties have been accepted by the broker. Also,
+ in case of a failed connection attempt, it can be used for connection
+ diagnostics.
+
+ \note QMqttServerConnectionProperties can only be used when the client
+ specifies MQTT_5_0 as ProtocolVersion.
+
+ \sa connectionProperties()
+*/
QMqttServerConnectionProperties QMqttClient::serverConnectionProperties() const
{
Q_D(const QMqttClient);
return d->m_serverConnectionProperties;
}
+/*!
+ \since 5.12
+
+ Sends an authentication request to the broker. \a prop specifies
+ the required information to fulfill the authentication request.
+
+ This function should only be called after a
+ QMqttClient::authenticationRequested signal has been emitted.
+
+ \note Extended authentication is part of the MQTT 5.0 standard and can
+ only be used when the client specifies MQTT_5_0 as ProtocolVersion.
+
+ \sa authenticationRequested(), authenticationFinished()
+*/
void QMqttClient::authenticate(const QMqttAuthenticationProperties &prop)
{
Q_D(QMqttClient);
diff --git a/src/mqtt/qmqttconnectionproperties.cpp b/src/mqtt/qmqttconnectionproperties.cpp
index 68d0374..68647ec 100644
--- a/src/mqtt/qmqttconnectionproperties.cpp
+++ b/src/mqtt/qmqttconnectionproperties.cpp
@@ -39,10 +39,115 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcMqttConnection)
+/*!
+ \class QMqttConnectionProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttConnectionProperties class represents configuration
+ options a QMqttClient can pass to the server when invoking
+ QMqttClient::connectToHost().
+
+ \note Connection 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.
+*/
+
+/*!
+ \class QMqttServerConnectionProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttServerConnectionProperties class represents configuration
+ options of a server a QMqttClient is connected to.
+
+ When a connection has been established the server might send additional
+ details about the connection properties. Use availableProperties() to
+ identify properties set by the server. If a property is not set by the
+ server, default values are assumed and can be obtained by invoking access
+ functions of this instance.
+
+ \note Connection 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.
+*/
+
+/*!
+ \class QMqttLastWillProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttLastWillProperties class represents configuration
+ options a QMqttClient can pass to the server when specifying the last will
+ during connecting to a server.
+
+ \note Last Will 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 QMqttServerConnectionProperties::ServerPropertyDetail
+
+ This enum type specifies the available properties set by the
+ server or the client after establishing a connection.
+
+ \value None
+ No property has been specified.
+ \value SessionExpiryInterval
+ The number of seconds the server keeps the session after
+ a disconnect.
+ \value MaximumReceive
+ The maximum number of QoS 1 and 2 message the server is
+ capable of managing concurrently.
+ \value MaximumQoS
+ The maximum QoS level the server can understand.
+ \value RetainAvailable
+ Specifies whether retained messages are supported.
+ \value MaximumPacketSize
+ Specifies the maximum packet size including the message header
+ and properties.
+ \value AssignedClientId
+ Specifies whether the server assigned a client identifier.
+ \value MaximumTopicAlias
+ Specifies the maximum amount of topic aliases.
+ \value ReasonString
+ Specifies a string providing more details on connection state.
+ \value UserProperty
+ Specifies additional user properties.
+ \value WildCardSupported
+ Specifies whether the server supports wildcard subscriptions.
+ \value SubscriptionIdentifierSupport
+ Specifies whether the server supports subscription identifiers.
+ \value SharedSubscriptionSupport
+ Specifies whether the server supports shared subscriptions.
+ \value ServerKeepAlive
+ Specifies the number of seconds the server expects a keep alive
+ packet from the client.
+ \value ResponseInformation
+ Specifies the response information.
+ \value ServerReference
+ Specifies an alternative server address for the client to
+ connect to.
+ \value AuthenticationMethod
+ Specifies the authentication method.
+ \value AuthenticationData
+ Specifies the authentication data.
+*/
+
+/*!
+ \internal
+*/
QMqttLastWillProperties::QMqttLastWillProperties() : data(new QMqttLastWillPropertiesData)
{
}
+/*!
+ \internal
+*/
QMqttLastWillProperties::QMqttLastWillProperties(const QMqttLastWillProperties &) = default;
QMqttLastWillProperties &QMqttLastWillProperties::operator=(const QMqttLastWillProperties &rhs)
@@ -54,81 +159,132 @@ QMqttLastWillProperties &QMqttLastWillProperties::operator=(const QMqttLastWillP
QMqttLastWillProperties::~QMqttLastWillProperties() = default;
+/*!
+ Returns the delay in seconds a last will message will be sent after
+ disconnecting from the server.
+*/
quint32 QMqttLastWillProperties::willDelayInterval() const
{
return data->willDelayInterval;
}
+/*!
+ Returns the payload format indicator.
+*/
QMqtt::PayloadFormatIndicator QMqttLastWillProperties::payloadFormatIndicator() const
{
return data->formatIndicator;
}
+/*!
+ Returns the lifetime of the last will message in seconds, starting from
+ the will delay interval.
+*/
quint32 QMqttLastWillProperties::messageExpiryInterval() const
{
return data->messageExpiryInterval;
}
+/*!
+ Returns the content type of the last will message.
+*/
QString QMqttLastWillProperties::contentType() const
{
return data->contentType;
}
+/*!
+ Returns the topic that subscribers to the last will message should respond
+ to.
+*/
QString QMqttLastWillProperties::responseTopic() const
{
return data->responseTopic;
}
+/*!
+ Returns the correlation data to identify the request.
+*/
QByteArray QMqttLastWillProperties::correlationData() const
{
return data->correlationData;
}
+/*!
+ Returns the user properties.
+*/
QMqttUserProperties QMqttLastWillProperties::userProperties() const
{
return data->userProperties;
}
+/*!
+ Sets the will delay interval to \a delay.
+*/
void QMqttLastWillProperties::setWillDelayInterval(quint32 delay)
{
data->willDelayInterval = delay;
}
+/*!
+ Sets the payload format indicator to \a p.
+*/
void QMqttLastWillProperties::setPayloadFormatIndicator(QMqtt::PayloadFormatIndicator p)
{
data->formatIndicator = p;
}
+/*!
+ Sets the message expiry interval to \a expiry.
+*/
void QMqttLastWillProperties::setMessageExpiryInterval(quint32 expiry)
{
data->messageExpiryInterval = expiry;
}
+/*!
+ Sets the content type to \a content.
+*/
void QMqttLastWillProperties::setContentType(const QString &content)
{
data->contentType = content;
}
+/*!
+ Sets the response topic to \a response.
+*/
void QMqttLastWillProperties::setResponseTopic(const QString &response)
{
data->responseTopic = response;
}
+/*!
+ Sets the correlation data to \a correlation.
+*/
void QMqttLastWillProperties::setCorrelationData(const QByteArray &correlation)
{
data->correlationData = correlation;
}
+/*!
+ Sets the user properties to \a properties.
+*/
void QMqttLastWillProperties::setUserProperties(const QMqttUserProperties &properties)
{
data->userProperties = properties;
}
+/*!
+ \internal
+*/
QMqttConnectionProperties::QMqttConnectionProperties() : data(new QMqttConnectionPropertiesData)
{
}
+/*!
+ \internal
+*/
QMqttConnectionProperties::QMqttConnectionProperties(const QMqttConnectionProperties &) = default;
QMqttConnectionProperties &QMqttConnectionProperties::operator=(const QMqttConnectionProperties &rhs)
@@ -140,11 +296,25 @@ QMqttConnectionProperties &QMqttConnectionProperties::operator=(const QMqttConne
QMqttConnectionProperties::~QMqttConnectionProperties() = default;
+/*!
+ Sets the session expiry interval to \a expiry. The session expiry interval
+ specifies the number of seconds a server holds information on the client
+ state after a connection has been closed.
+
+ The default value is 0, which specifies that the session is closed when
+ the network connection ends. If the value is specified as maximum of
+ quint32, then the session does not expire.
+*/
void QMqttConnectionProperties::setSessionExpiryInterval(quint32 expiry)
{
data->sessionExpiryInterval = expiry;
}
+/*!
+ Sets the maximum QoS level the client is allowed to receive to \a qos.
+
+ A maximum receive value of 0 is not allowed.
+*/
void QMqttConnectionProperties::setMaximumReceive(quint16 qos)
{
if (qos == 0) {
@@ -154,6 +324,14 @@ void QMqttConnectionProperties::setMaximumReceive(quint16 qos)
data->maximumReceive = qos;
}
+/*!
+ Sets the maximum packet size to \a packetSize. The maximum packet size
+ specifies the maximum size one packet can contain. This includes the
+ packet header and its properties.
+
+ If no maximum packet size is specified, no limit is imposed beyond the
+ limitations of the protocol itself.
+*/
void QMqttConnectionProperties::setMaximumPacketSize(quint32 packetSize)
{
if (packetSize == 0) {
@@ -163,81 +341,161 @@ void QMqttConnectionProperties::setMaximumPacketSize(quint32 packetSize)
data->maximumPacketSize = packetSize;
}
+/*!
+ Sets the maximum topic alias to \a alias. The maximum topic alias specifies
+ the highest value that the client will accept from the server. The client
+ uses this value to limit the number of topic aliases it is willing to hold
+ for the connection.
+
+ The default value is 0. 0 indicates that the client does not accept any
+ topic aliases on this connection.
+*/
void QMqttConnectionProperties::setMaximumTopicAlias(quint16 alias)
{
data->maximumTopicAlias = alias;
}
+/*!
+ Sets the request response information to \a response. A client uses this
+ to request the server to return response information after the connection
+ request has been handled.
+
+ The default value is \c false, which indicates that the client must not
+ return any response information. If the value is \c true, the server
+ may return response information, but is not enforced to do so.
+*/
void QMqttConnectionProperties::setRequestResponseInformation(bool response)
{
data->requestResponseInformation = response;
}
+/*!
+ Sets the request problem information to \a problem. A client uses this
+ to request the server to return additional information in case of failure.
+ Types of failure include connection and message management on the server
+ side.
+
+ The default value is \c false, which indicates that the client must not
+ receive any problem information for anything but connection management.
+ The server still may send problem information for connection handling.
+ If the value is \c true, the server may return problem information.
+
+ Problem information is available in user properties or reason strings
+ of the property classes.
+*/
void QMqttConnectionProperties::setRequestProblemInformation(bool problem)
{
data->requestProblemInformation = problem;
}
+/*!
+ Sets the user properties of the connection to \a properties.
+
+ The default value is to not send any user information.
+*/
void QMqttConnectionProperties::setUserProperties(const QMqttUserProperties &properties)
{
data->userProperties = properties;
}
+/*!
+ Sets the authentication method to \a authMethod.
+
+ \sa authenticationData()
+*/
void QMqttConnectionProperties::setAuthenticationMethod(const QString &authMethod)
{
data->authenticationMethod = authMethod;
}
+/*!
+ Sets the authentication data to \a authData.
+
+ Authentication data can only be used if an authentication method has
+ been specified.
+
+ \sa authenticationMethod()
+*/
void QMqttConnectionProperties::setAuthenticationData(const QByteArray &authData)
{
data->authenticationData = authData;
}
+/*!
+ Returns the session expiry interval.
+*/
quint32 QMqttConnectionProperties::sessionExpiryInterval() const
{
return data->sessionExpiryInterval;
}
+/*!
+ Returns the maximum QoS level the client can receive.
+*/
quint16 QMqttConnectionProperties::maximumReceive() const
{
return data->maximumReceive;
}
+/*!
+ Returns the maximum packet size the client can receive.
+*/
quint32 QMqttConnectionProperties::maximumPacketSize() const
{
return data->maximumPacketSize;
}
+/*!
+ Returns the maximum topic alias ID the client can use.
+*/
quint16 QMqttConnectionProperties::maximumTopicAlias() const
{
return data->maximumTopicAlias;
}
+/*!
+ Returns whether the client should receive response information.
+*/
bool QMqttConnectionProperties::requestResponseInformation() const
{
return data->requestResponseInformation;
}
+/*!
+ Returns whether the client should receive problem information.
+*/
bool QMqttConnectionProperties::requestProblemInformation() const
{
return data->requestProblemInformation;
}
+/*!
+ Returns the user properties for the connection.
+*/
QMqttUserProperties QMqttConnectionProperties::userProperties() const
{
return data->userProperties;
}
+/*!
+ Returns the authentication method.
+*/
QString QMqttConnectionProperties::authenticationMethod() const
{
return data->authenticationMethod;
}
+/*!
+ Returns the authentication data.
+*/
QByteArray QMqttConnectionProperties::authenticationData() const
{
return data->authenticationData;
}
+/*!
+ \internal
+*/
QMqttServerConnectionProperties::QMqttServerConnectionProperties()
: QMqttConnectionProperties()
, serverData(new QMqttServerConnectionPropertiesData)
@@ -245,6 +503,9 @@ QMqttServerConnectionProperties::QMqttServerConnectionProperties()
}
+/*!
+ \internal
+*/
QMqttServerConnectionProperties::QMqttServerConnectionProperties(const QMqttServerConnectionProperties &rhs)
: QMqttConnectionProperties(rhs)
, serverData(rhs.serverData)
@@ -263,61 +524,117 @@ QMqttServerConnectionProperties &QMqttServerConnectionProperties::operator=(cons
QMqttServerConnectionProperties::~QMqttServerConnectionProperties() = default;
+/*!
+ Returns the available properties specified by the server.
+*/
QMqttServerConnectionProperties::ServerPropertyDetails QMqttServerConnectionProperties::availableProperties() const
{
return serverData->details;
}
+/*!
+ Returns \c true if the server provided properties as part of the connection
+ aknowledgment. Returns \c false if no properties have been provided.
+*/
bool QMqttServerConnectionProperties::isValid() const
{
return serverData->valid;
}
+/*!
+ Returns the maximum QoS level the server is able to understand.
+ The default value is 2.
+*/
quint8 QMqttServerConnectionProperties::maximumQoS() const
{
return serverData->maximumQoS;
}
+/*!
+ Returns \c true if the server accepts retained messages.
+ The default value is \c true.
+*/
bool QMqttServerConnectionProperties::retainAvailable() const
{
return serverData->retainAvailable;
}
+/*!
+ Returns \c true if the server assigned a new client identifier to
+ the client.
+
+ \sa QMqttClient::clientId()
+*/
bool QMqttServerConnectionProperties::clientIdAssigned() const
{
return serverData->details & QMqttServerConnectionProperties::AssignedClientId;
}
+/*!
+ Returns the reason string associated with this response.
+*/
QString QMqttServerConnectionProperties::reason() const
{
return serverData->reasonString;
}
+/*!
+ Returns \c true if the server accepts subscriptions including wildcards.
+ The default value is \c true.
+*/
bool QMqttServerConnectionProperties::wildcardSupported() const
{
return serverData->wildcardSupported;
}
+/*!
+ Returns \c true if the server accepts subscription identifiers.
+ Subscription identifiers can be passed to the server when creating
+ a new subscription.
+
+ The default value is \c true.
+
+ \sa QMqttSubscriptionProperties::setSubscriptionIdentifier()
+*/
bool QMqttServerConnectionProperties::subscriptionIdentifierSupported() const
{
return serverData->subscriptionIdentifierSupported;
}
+/*!
+ Returns \c true if the server accepts shared subscriptions.
+ The default value is \c true.
+*/
bool QMqttServerConnectionProperties::sharedSubscriptionSupported() const
{
return serverData->sharedSubscriptionSupported;
}
+
+/*!
+ Returns the number of seconds the server requested as keep alive. This
+ overwrites the keep alive being set from the client side.
+
+ \sa QMqttClient::setKeepAlive()
+*/
quint16 QMqttServerConnectionProperties::serverKeepAlive() const
{
return serverData->serverKeepAlive;
}
+/*!
+ Returns the response information.
+*/
QString QMqttServerConnectionProperties::responseInformation() const
{
return serverData->responseInformation;
}
+/*!
+ Returns a server address which can be used by the client alternatively
+ to connect to. Typically, this is used together with the reason
+ code \c 0x9c (Use another server) or \c 0x9c (Server moved).
+*/
QString QMqttServerConnectionProperties::serverReference() const
{
return serverData->serverReference;
diff --git a/src/mqtt/qmqttmessage.cpp b/src/mqtt/qmqttmessage.cpp
index c04f9bf..1f3b49e 100644
--- a/src/mqtt/qmqttmessage.cpp
+++ b/src/mqtt/qmqttmessage.cpp
@@ -162,6 +162,19 @@ bool QMqttMessage::retain() const
return d->m_retain;
}
+/*!
+ \since 5.12
+
+ Returns the publish properties received as part of the message.
+
+ \note This function only specifies the properties when a
+ publish message is received. Messages with a QoS value of
+ 1 or 2 can contain additional properties when a message is released.
+ Those can be obtained by the QMqttClient::messageStatusChanged signal.
+
+ \note This function will only provide valid data when the client
+ specifies QMqttClient::MQTT_5_0 as QMqttClient::ProtocolVersion.
+*/
QMqttPublishProperties QMqttMessage::publishProperties() const
{
return d->m_publishProperties;
diff --git a/src/mqtt/qmqttpublishproperties.cpp b/src/mqtt/qmqttpublishproperties.cpp
index 66cc9e8..e358d61 100644
--- a/src/mqtt/qmqttpublishproperties.cpp
+++ b/src/mqtt/qmqttpublishproperties.cpp
@@ -36,6 +36,54 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcMqttClient)
+/*!
+ \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.
+*/
+
class QMqttPublishPropertiesData : public QSharedData
{
public:
@@ -55,8 +103,14 @@ QMqttPublishProperties::QMqttPublishProperties() : data(new QMqttPublishProperti
}
+/*!
+ \internal
+*/
QMqttPublishProperties::QMqttPublishProperties(const QMqttPublishProperties &) = default;
+/*!
+ \internal
+*/
QMqttPublishProperties &QMqttPublishProperties::operator=(const QMqttPublishProperties &rhs)
{
if (this != &rhs)
@@ -66,38 +120,68 @@ QMqttPublishProperties &QMqttPublishProperties::operator=(const QMqttPublishProp
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) {
@@ -108,44 +192,70 @@ void QMqttPublishProperties::setTopicAlias(quint16 alias)
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 id.
+*/
void QMqttPublishProperties::setSubscriptionIdentifiers(const QList<quint32> &id)
{
if (id.indexOf(0) != -1) {
@@ -156,11 +266,17 @@ void QMqttPublishProperties::setSubscriptionIdentifiers(const QList<quint32> &id
data->subscriptionIdentifier = id;
}
+/*!
+ 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;
diff --git a/src/mqtt/qmqttsubscription.cpp b/src/mqtt/qmqttsubscription.cpp
index 3d9362a..74e9d21 100644
--- a/src/mqtt/qmqttsubscription.cpp
+++ b/src/mqtt/qmqttsubscription.cpp
@@ -86,6 +86,28 @@ QT_BEGIN_NAMESPACE
This signal is emitted when the new message \a msg has been received.
*/
+/*!
+ \property QMqttSubscription::reason
+ \since 5.12
+ \brief This property holds the reason string after subscription has
+ been established.
+
+ A reason string is used by the server to provide additional information
+ about the subscription. It is optional for the server to send it.
+*/
+
+/*!
+ \property QMqttSubscription::shared
+ \since 5.12
+ \brief This property holds whether the subscription is shared.
+*/
+
+/*!
+ \property QMqttSubscription::shareName
+ \since 5.12
+ \brief This property holds the name of the shared subscription.
+*/
+
QMqttSubscription::QMqttSubscription(QObject *parent) : QObject(*(new QMqttSubscriptionPrivate), parent)
{
@@ -126,6 +148,15 @@ QString QMqttSubscription::reason() const
return d->m_reasonString;
}
+/*!
+ \since 5.12
+
+ Returns the user properties received from the broker when the subscription
+ has been accepted.
+
+ \note This function will only provide valid data when the client
+ specifies QMqttClient::MQTT_5_0 as QMqttClient::ProtocolVersion.
+*/
QMqttUserProperties QMqttSubscription::userProperties() const
{
Q_D(const QMqttSubscription);
diff --git a/src/mqtt/qmqttsubscriptionproperties.cpp b/src/mqtt/qmqttsubscriptionproperties.cpp
index 78e7c87..08977a9 100644
--- a/src/mqtt/qmqttsubscriptionproperties.cpp
+++ b/src/mqtt/qmqttsubscriptionproperties.cpp
@@ -31,6 +31,36 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QMqttSubscriptionProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttSubscriptionProperties class represents configuration
+ options a QMqttClient can pass to the server when subscribing to a
+ topic filter.
+
+ \note Subscription 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.
+*/
+
+/*!
+ \class QMqttUnsubscriptionProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttUnsubscriptionProperties class represents configuration
+ options a QMqttClient can pass to the server when unsubscribing from a
+ topic filter.
+
+ \note Unsubscription 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.
+*/
+
class QMqttSubscriptionPropertiesData : public QSharedData
{
public:
@@ -44,11 +74,17 @@ public:
QMqttUserProperties userProperties;
};
+/*!
+ \internal
+*/
QMqttSubscriptionProperties::QMqttSubscriptionProperties() : data(new QMqttSubscriptionPropertiesData)
{
}
+/*!
+ \internal
+*/
QMqttSubscriptionProperties::QMqttSubscriptionProperties(const QMqttSubscriptionProperties &) = default;
QMqttSubscriptionProperties &QMqttSubscriptionProperties::operator=(const QMqttSubscriptionProperties &rhs)
@@ -60,30 +96,48 @@ QMqttSubscriptionProperties &QMqttSubscriptionProperties::operator=(const QMqttS
QMqttSubscriptionProperties::~QMqttSubscriptionProperties() = default;
+/*!
+ Returns the user specified properties.
+*/
QMqttUserProperties QMqttSubscriptionProperties::userProperties() const
{
return data->userProperties;
}
+/*!
+ Sets the user properties to \a user.
+*/
void QMqttSubscriptionProperties::setUserProperties(const QMqttUserProperties &user)
{
data->userProperties = user;
}
+/*!
+ Returns the subscription identifier used to describe this subscription.
+*/
quint32 QMqttSubscriptionProperties::subscriptionIdentifier() const
{
return data->subscriptionIdentifier;
}
+/*!
+ Sets the subscription identifier to \a id.
+*/
void QMqttSubscriptionProperties::setSubscriptionIdentifier(quint32 id)
{
data->subscriptionIdentifier = id;
}
+/*!
+ \internal
+*/
QMqttUnsubscriptionProperties::QMqttUnsubscriptionProperties() : data(new QMqttUnsubscriptionPropertiesData)
{
}
+/*!
+ \internal
+*/
QMqttUnsubscriptionProperties &QMqttUnsubscriptionProperties::operator=(const QMqttUnsubscriptionProperties &rhs)
{
if (this != &rhs)
@@ -91,11 +145,17 @@ QMqttUnsubscriptionProperties &QMqttUnsubscriptionProperties::operator=(const QM
return *this;
}
+/*!
+ Returns the user specified properties.
+*/
QMqttUserProperties QMqttUnsubscriptionProperties::userProperties() const
{
return data->userProperties;
}
+/*!
+ Sets the user properties to \a user.
+*/
void QMqttUnsubscriptionProperties::setUserProperties(const QMqttUserProperties &user)
{
data->userProperties = user;
diff --git a/src/mqtt/qmqtttopicfilter.cpp b/src/mqtt/qmqtttopicfilter.cpp
index 671b0d6..1e6bd9c 100644
--- a/src/mqtt/qmqtttopicfilter.cpp
+++ b/src/mqtt/qmqtttopicfilter.cpp
@@ -153,6 +153,13 @@ void QMqttTopicFilter::setFilter(const QString &filter)
d->filter = filter;
}
+/*!
+ \since 5.12
+
+ Returns the name of a share if the topic filter has been specified as
+ a shared subscription. The format of shared subscriptions is defined
+ as \c $share/sharename/topicfilter.
+*/
QString QMqttTopicFilter::shareName() const
{
QString result;
diff --git a/src/mqtt/qmqtttype.cpp b/src/mqtt/qmqtttype.cpp
index 4cbfffa..29a9160 100644
--- a/src/mqtt/qmqtttype.cpp
+++ b/src/mqtt/qmqtttype.cpp
@@ -31,6 +31,67 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QMqttStringPair
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttStringPair class represents the string pair data type
+ of the MQTT 5.0 standard.
+
+ This data type is used to hold a name-value pair.
+*/
+
+/*!
+ \class QMqttUserProperties
+
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief The QMqttUserProperties class represents a list of QMqttStringPair
+ values which can be passed to the server.
+
+ User properties allow a client to pass additional data to the server or
+ other subscribers, which do not belong to the message payload.
+
+ On the other hand it also provides a server the flexibility to provide
+ further information to connected clients.
+
+ The server might add additional user properties to the ones provided.
+ However, the order of the provided properties is not changed during transfer.
+
+ \note User properties are part of the MQTT 5.0 specification and
+ cannot be used when using QtMqtt with an older protocol level. See
+ QMqttClient::ProtocolVersion for more information.
+
+ \sa QMqttAuthenticationProperties, QMqttConnectionProperties,
+ QMqttLastWillProperties, QMqttPublishProperties, QMqttSubscriptionProperties,
+ QMqttUnsubscriptionProperties, QMqttSubscription
+*/
+
+/*!
+ \namespace QMqtt
+ \inmodule QtMqtt
+ \since 5.12
+
+ \brief Contains miscellaneous identifiers used throughout the Qt MQTT module.
+*/
+
+/*!
+ \enum QMqtt::PayloadFormatIndicator
+ \since 5.12
+
+ The payload format provides information on the content of a message.
+ This can help other clients to handle the message faster.
+
+ \value Unspecified
+ The format is not specified.
+ \value UTF8Encoded
+ The payload of the message is formatted as UTF-8 Encoded
+ Character Data.
+*/
+
class QMqttStringPairData : public QSharedData
{
public:
@@ -68,26 +129,41 @@ QMqttStringPair::QMqttStringPair(const QMqttStringPair &) = default;
QMqttStringPair::~QMqttStringPair() = default;
+/*!
+ Returns the name of the string pair.
+*/
QString QMqttStringPair::name() const
{
return data->m_name;
}
+/*!
+ Sets the name to \a n.
+*/
void QMqttStringPair::setName(const QString &n)
{
data->m_name = n;
}
+/*!
+ Returns the value of the string pair.
+*/
QString QMqttStringPair::value() const
{
return data->m_value;
}
+/*!
+ Sets the value to \a v.
+*/
void QMqttStringPair::setValue(const QString &v)
{
data->m_value = v;
}
+/*!
+ Returns \c true if this instance matches \a other.
+*/
bool QMqttStringPair::operator==(const QMqttStringPair &other) const
{
return *data.constData() == *other.data.constData();