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