summaryrefslogtreecommitdiffstats
path: root/src/mqtt/qmqttconnectionproperties.h
blob: 61ded91592b298bdcd7df5be8a5ff35dd2cb1e6c (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
/******************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtMqtt module.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
******************************************************************************/

#ifndef QMQTTCONNECTIONPROPERTIES_H
#define QMQTTCONNECTIONPROPERTIES_H

#include <QtMqtt/qmqttglobal.h>
#include <QtMqtt/qmqtttype.h>

#include <QtCore/QObject>
#include <QtCore/QSharedDataPointer>

QT_BEGIN_NAMESPACE

class QMqttConnectionPropertiesData;
class QMqttLastWillPropertiesData;
class QMqttServerConnectionPropertiesData;

class Q_MQTT_EXPORT QMqttLastWillProperties
{
    Q_GADGET
public:
    QMqttLastWillProperties();
    QMqttLastWillProperties(const QMqttLastWillProperties &);
    QMqttLastWillProperties &operator=(const QMqttLastWillProperties &);
    ~QMqttLastWillProperties();

    quint32 willDelayInterval() const;
    QMqtt::PayloadFormatIndicator payloadFormatIndicator() const;
    quint32 messageExpiryInterval() const;
    QString contentType() const;
    QString responseTopic() const;
    QByteArray correlationData() const;
    QMqttUserProperties userProperties() const;

    void setWillDelayInterval(quint32 delay);
    void setPayloadFormatIndicator(QMqtt::PayloadFormatIndicator p);
    void setMessageExpiryInterval(quint32 expiry);
    void setContentType(const QString &content);
    void setResponseTopic(const QString &response);
    void setCorrelationData(const QByteArray &correlation);
    void setUserProperties(const QMqttUserProperties &properties);

protected:
    QSharedDataPointer<QMqttLastWillPropertiesData> data;
};

class Q_MQTT_EXPORT QMqttConnectionProperties
{
    Q_GADGET
public:
    QMqttConnectionProperties();
    QMqttConnectionProperties(const QMqttConnectionProperties &);
    QMqttConnectionProperties &operator=(const QMqttConnectionProperties &);
    ~QMqttConnectionProperties();

    quint32 sessionExpiryInterval() const;
    quint16 maximumReceive() const;
    quint32 maximumPacketSize() const;
    quint16 maximumTopicAlias() const;
    bool requestResponseInformation() const;
    bool requestProblemInformation() const;
    QMqttUserProperties userProperties() const;
    QString authenticationMethod() const;
    QByteArray authenticationData() const;

    void setSessionExpiryInterval(quint32 expiry);
    void setMaximumReceive(quint16 qos);
    void setMaximumPacketSize(quint32 packetSize);
    void setMaximumTopicAlias(quint16 alias);
    void setRequestResponseInformation(bool response);
    void setRequestProblemInformation(bool problem);
    void setUserProperties(const QMqttUserProperties &properties);
    void setAuthenticationMethod(const QString &authMethod);
    void setAuthenticationData(const QByteArray &authData);

protected:
    QSharedDataPointer<QMqttConnectionPropertiesData> data;
};

class Q_MQTT_EXPORT QMqttServerConnectionProperties
        : public QMqttConnectionProperties
{
    Q_GADGET
public:
    enum ServerPropertyDetail : quint32 {
        None                            = 0x00000000,
        SessionExpiryInterval           = 0x00000001,
        MaximumReceive                  = 0x00000002,
        MaximumQoS                      = 0x00000004,
        RetainAvailable                 = 0x00000010,
        MaximumPacketSize               = 0x00000020,
        AssignedClientId                = 0x00000040,
        MaximumTopicAlias               = 0x00000080,
        ReasonString                    = 0x00000100,
        UserProperty                    = 0x00000200,
        WildCardSupported               = 0x00000400,
        SubscriptionIdentifierSupport   = 0x00000800,
        SharedSubscriptionSupport       = 0x00001000,
        ServerKeepAlive                 = 0x00002000,
        ResponseInformation             = 0x00004000,
        ServerReference                 = 0x00008000,
        AuthenticationMethod            = 0x00010000,
        AuthenticationData              = 0x00020000
    };
    Q_ENUM(ServerPropertyDetail)
    Q_DECLARE_FLAGS(ServerPropertyDetails, ServerPropertyDetail)

    QMqttServerConnectionProperties();
    QMqttServerConnectionProperties(const QMqttServerConnectionProperties &);
    QMqttServerConnectionProperties &operator=(const QMqttServerConnectionProperties &);
    ~QMqttServerConnectionProperties();

    ServerPropertyDetails availableProperties() const;

    bool isValid() const;

    quint8 maximumQoS() const;
    bool retainAvailable() const;
    bool clientIdAssigned() const;
    QString reason() const;
    bool wildcardSupported() const;
    bool subscriptionIdentifierSupported() const;
    bool sharedSubscriptionSupported() const;
    quint16 serverKeepAlive() const;
    QString responseInformation() const;
    QString serverReference() const;


private:
    friend class QMqttConnection;
    QSharedDataPointer<QMqttServerConnectionPropertiesData> serverData;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(QMqttServerConnectionProperties::ServerPropertyDetails)

QT_END_NAMESPACE

#endif // QMQTTCONNECTIONPROPERTIES_H