1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef OPCUAENDPOINTDISCOVERY_P_H
5#define OPCUAENDPOINTDISCOVERY_P_H
6
7#include <private/opcuaconnection_p.h>
8#include <private/opcuastatus_p.h>
9
10#include <QtOpcUa/qopcuatype.h>
11#include <QOpcUaEndpointDescription>
12
13#include <QQmlParserStatus>
14#include <QObject>
15#include <QList>
16
17#include <QtQml/qqml.h>
18
19//
20// W A R N I N G
21// -------------
22//
23// This file is not part of the Qt API. It exists purely as an
24// implementation detail. This header file may change from version to
25// version without notice, or even be removed.
26//
27// We mean it.
28//
29
30QT_BEGIN_NAMESPACE
31
32class OpcUaEndpointDiscovery : public QObject, public QQmlParserStatus
33{
34 Q_OBJECT
35 Q_PROPERTY(QString serverUrl READ serverUrl WRITE setServerUrl NOTIFY serverUrlChanged)
36 Q_PROPERTY(int count READ count NOTIFY countChanged)
37 Q_PROPERTY(OpcUaStatus status READ status NOTIFY statusChanged)
38 Q_PROPERTY(OpcUaConnection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
39 Q_INTERFACES(QQmlParserStatus)
40
41 QML_NAMED_ELEMENT(EndpointDiscovery)
42 QML_ADDED_IN_VERSION(5, 13)
43
44public:
45 OpcUaEndpointDiscovery(QObject *parent = nullptr);
46 ~OpcUaEndpointDiscovery();
47
48 const QString &serverUrl() const;
49 void setServerUrl(const QString &serverUrl);
50 int count() const;
51 Q_INVOKABLE QOpcUaEndpointDescription at(int row) const;
52 const OpcUaStatus &status() const;
53 void setConnection(OpcUaConnection *);
54 OpcUaConnection *connection();
55
56signals:
57 void serverUrlChanged(const QString &serverUrl);
58 void endpointsChanged();
59 void countChanged();
60 void statusChanged();
61 void connectionChanged(OpcUaConnection *);
62
63private slots:
64 void connectSignals();
65 void handleEndpoints(const QList<QOpcUaEndpointDescription> &endpoints, QOpcUa::UaStatusCode statusCode, const QUrl &requestUrl);
66 void startRequestEndpoints();
67
68private:
69 // Callbacks from QQmlParserStatus
70 void classBegin() override;
71 void componentComplete() override;
72
73 QString m_serverUrl;
74 OpcUaConnection *m_connection = nullptr;
75 QList<QOpcUaEndpointDescription> m_endpoints;
76 OpcUaStatus m_status;
77 bool m_componentCompleted = false;
78};
79
80
81QT_END_NAMESPACE
82
83#endif // OPCUAENDPOINTDISCOVERY_P_H
84

source code of qtopcua/src/declarative_opcua/opcuaendpointdiscovery_p.h