| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qmqttauthenticationproperties.h" |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | /*! |
| 9 | \class QMqttAuthenticationProperties |
| 10 | |
| 11 | \inmodule QtMqtt |
| 12 | \since 5.12 |
| 13 | |
| 14 | \brief The QMqttAuthenticationProperties class represents configuration |
| 15 | options during the authentication process. |
| 16 | |
| 17 | \note Authentication properties are part of the MQTT 5.0 specification and |
| 18 | cannot be used when connecting with a lower protocol level. See |
| 19 | QMqttClient::ProtocolVersion for more information. |
| 20 | */ |
| 21 | |
| 22 | class QMqttAuthenticationPropertiesData : public QSharedData |
| 23 | { |
| 24 | public: |
| 25 | QString authenticationMethod; |
| 26 | QByteArray authenticationData; |
| 27 | QString reason; |
| 28 | QMqttUserProperties userProperties; |
| 29 | }; |
| 30 | |
| 31 | /*! |
| 32 | \internal |
| 33 | */ |
| 34 | QMqttAuthenticationProperties::QMqttAuthenticationProperties() : data(new QMqttAuthenticationPropertiesData) |
| 35 | { |
| 36 | |
| 37 | } |
| 38 | |
| 39 | /*! |
| 40 | \internal |
| 41 | */ |
| 42 | QMqttAuthenticationProperties::QMqttAuthenticationProperties(const QMqttAuthenticationProperties &) = default; |
| 43 | |
| 44 | QMqttAuthenticationProperties &QMqttAuthenticationProperties::operator=(const QMqttAuthenticationProperties &rhs) |
| 45 | { |
| 46 | if (this != &rhs) |
| 47 | data.operator=(o: rhs.data); |
| 48 | return *this; |
| 49 | } |
| 50 | |
| 51 | QMqttAuthenticationProperties::~QMqttAuthenticationProperties() = default; |
| 52 | |
| 53 | /*! |
| 54 | Returns the authentication method. |
| 55 | */ |
| 56 | QString QMqttAuthenticationProperties::authenticationMethod() const |
| 57 | { |
| 58 | return data->authenticationMethod; |
| 59 | } |
| 60 | |
| 61 | /*! |
| 62 | Sets the authentication method to \a method. |
| 63 | */ |
| 64 | void QMqttAuthenticationProperties::setAuthenticationMethod(const QString &method) |
| 65 | { |
| 66 | data->authenticationMethod = method; |
| 67 | } |
| 68 | |
| 69 | /*! |
| 70 | Returns the authentication data |
| 71 | */ |
| 72 | QByteArray QMqttAuthenticationProperties::authenticationData() const |
| 73 | { |
| 74 | return data->authenticationData; |
| 75 | } |
| 76 | |
| 77 | /*! |
| 78 | Sets the authentication data to \a adata. |
| 79 | |
| 80 | Authentication data can only be used if an authentication method has |
| 81 | been specified. |
| 82 | |
| 83 | \sa authenticationMethod() |
| 84 | */ |
| 85 | void QMqttAuthenticationProperties::setAuthenticationData(const QByteArray &adata) |
| 86 | { |
| 87 | data->authenticationData = adata; |
| 88 | } |
| 89 | |
| 90 | /*! |
| 91 | Returns the reason string. The reason string specifies the reason for |
| 92 | a disconnect. |
| 93 | */ |
| 94 | QString QMqttAuthenticationProperties::reason() const |
| 95 | { |
| 96 | return data->reason; |
| 97 | } |
| 98 | |
| 99 | /*! |
| 100 | Sets the reason string to \a r. |
| 101 | */ |
| 102 | void QMqttAuthenticationProperties::setReason(const QString &r) |
| 103 | { |
| 104 | data->reason = r; |
| 105 | } |
| 106 | |
| 107 | /*! |
| 108 | Returns the user properties. |
| 109 | */ |
| 110 | QMqttUserProperties QMqttAuthenticationProperties::userProperties() const |
| 111 | { |
| 112 | return data->userProperties; |
| 113 | } |
| 114 | |
| 115 | /*! |
| 116 | Sets the user properties to \a user. |
| 117 | */ |
| 118 | void QMqttAuthenticationProperties::setUserProperties(const QMqttUserProperties &user) |
| 119 | { |
| 120 | data->userProperties = user; |
| 121 | } |
| 122 | |
| 123 | QT_END_NAMESPACE |
| 124 |
