1 | // Copyright (C) 2018 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QMQTTCONNECTIONPROPERTIES_H |
5 | #define QMQTTCONNECTIONPROPERTIES_H |
6 | |
7 | #include <QtMqtt/qmqttglobal.h> |
8 | #include <QtMqtt/qmqtttype.h> |
9 | |
10 | #include <QtCore/QObject> |
11 | #include <QtCore/QSharedDataPointer> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QMqttConnectionPropertiesData; |
16 | class QMqttLastWillPropertiesData; |
17 | class QMqttServerConnectionPropertiesData; |
18 | |
19 | class Q_MQTT_EXPORT QMqttLastWillProperties |
20 | { |
21 | public: |
22 | QMqttLastWillProperties(); |
23 | QMqttLastWillProperties(const QMqttLastWillProperties &); |
24 | QMqttLastWillProperties &operator=(const QMqttLastWillProperties &); |
25 | ~QMqttLastWillProperties(); |
26 | |
27 | quint32 willDelayInterval() const; |
28 | QMqtt::PayloadFormatIndicator payloadFormatIndicator() const; |
29 | quint32 messageExpiryInterval() const; |
30 | QString contentType() const; |
31 | QString responseTopic() const; |
32 | QByteArray correlationData() const; |
33 | QMqttUserProperties userProperties() const; |
34 | |
35 | void setWillDelayInterval(quint32 delay); |
36 | void setPayloadFormatIndicator(QMqtt::PayloadFormatIndicator p); |
37 | void setMessageExpiryInterval(quint32 expiry); |
38 | void setContentType(const QString &content); |
39 | void setResponseTopic(const QString &response); |
40 | void setCorrelationData(const QByteArray &correlation); |
41 | void setUserProperties(const QMqttUserProperties &properties); |
42 | |
43 | private: |
44 | QSharedDataPointer<QMqttLastWillPropertiesData> data; |
45 | }; |
46 | |
47 | class Q_MQTT_EXPORT QMqttConnectionProperties |
48 | { |
49 | public: |
50 | QMqttConnectionProperties(); |
51 | QMqttConnectionProperties(const QMqttConnectionProperties &); |
52 | QMqttConnectionProperties &operator=(const QMqttConnectionProperties &); |
53 | ~QMqttConnectionProperties(); |
54 | |
55 | quint32 sessionExpiryInterval() const; |
56 | quint16 maximumReceive() const; |
57 | quint32 maximumPacketSize() const; |
58 | quint16 maximumTopicAlias() const; |
59 | bool requestResponseInformation() const; |
60 | bool requestProblemInformation() const; |
61 | QMqttUserProperties userProperties() const; |
62 | QString authenticationMethod() const; |
63 | QByteArray authenticationData() const; |
64 | |
65 | void setSessionExpiryInterval(quint32 expiry); |
66 | void setMaximumReceive(quint16 maximumReceive); |
67 | void setMaximumPacketSize(quint32 packetSize); |
68 | void setMaximumTopicAlias(quint16 alias); |
69 | void setRequestResponseInformation(bool response); |
70 | void setRequestProblemInformation(bool problem); |
71 | void setUserProperties(const QMqttUserProperties &properties); |
72 | void setAuthenticationMethod(const QString &authMethod); |
73 | void setAuthenticationData(const QByteArray &authData); |
74 | |
75 | private: |
76 | friend class QMqttConnection; |
77 | QSharedDataPointer<QMqttConnectionPropertiesData> data; |
78 | }; |
79 | |
80 | class Q_MQTT_EXPORT QMqttServerConnectionProperties |
81 | : public QMqttConnectionProperties |
82 | { |
83 | public: |
84 | enum ServerPropertyDetail : quint32 { |
85 | None = 0x00000000, |
86 | SessionExpiryInterval = 0x00000001, |
87 | MaximumReceive = 0x00000002, |
88 | MaximumQoS = 0x00000004, |
89 | RetainAvailable = 0x00000010, |
90 | MaximumPacketSize = 0x00000020, |
91 | AssignedClientId = 0x00000040, |
92 | MaximumTopicAlias = 0x00000080, |
93 | ReasonString = 0x00000100, |
94 | UserProperty = 0x00000200, |
95 | WildCardSupported = 0x00000400, |
96 | SubscriptionIdentifierSupport = 0x00000800, |
97 | SharedSubscriptionSupport = 0x00001000, |
98 | ServerKeepAlive = 0x00002000, |
99 | ResponseInformation = 0x00004000, |
100 | ServerReference = 0x00008000, |
101 | AuthenticationMethod = 0x00010000, |
102 | AuthenticationData = 0x00020000 |
103 | }; |
104 | Q_DECLARE_FLAGS(ServerPropertyDetails, ServerPropertyDetail) |
105 | |
106 | QMqttServerConnectionProperties(); |
107 | QMqttServerConnectionProperties(const QMqttServerConnectionProperties &); |
108 | QMqttServerConnectionProperties &operator=(const QMqttServerConnectionProperties &); |
109 | ~QMqttServerConnectionProperties(); |
110 | |
111 | ServerPropertyDetails availableProperties() const; |
112 | |
113 | bool isValid() const; |
114 | |
115 | quint8 maximumQoS() const; |
116 | bool retainAvailable() const; |
117 | bool clientIdAssigned() const; |
118 | QString reason() const; |
119 | QMqtt::ReasonCode reasonCode() const; |
120 | bool wildcardSupported() const; |
121 | bool subscriptionIdentifierSupported() const; |
122 | bool sharedSubscriptionSupported() const; |
123 | quint16 serverKeepAlive() const; |
124 | QString responseInformation() const; |
125 | QString serverReference() const; |
126 | |
127 | private: |
128 | friend class QMqttConnection; |
129 | QSharedDataPointer<QMqttServerConnectionPropertiesData> serverData; |
130 | }; |
131 | |
132 | Q_DECLARE_OPERATORS_FOR_FLAGS(QMqttServerConnectionProperties::ServerPropertyDetails) |
133 | |
134 | QT_END_NAMESPACE |
135 | |
136 | #endif // QMQTTCONNECTIONPROPERTIES_H |
137 | |