| 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 QOPCUAGDSCLIENT_H |
| 5 | #define QOPCUAGDSCLIENT_H |
| 6 | |
| 7 | #include <QtCore/QObject> |
| 8 | #include <QtOpcUa/qopcuaglobal.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | class QOpcUaApplicationIdentity; |
| 13 | class QOpcUaAuthenticationInformation; |
| 14 | class QOpcUaEndpointDescription; |
| 15 | class QOpcUaPkiConfiguration; |
| 16 | class QOpcUaGdsClientPrivate; |
| 17 | class QOpcUaApplicationRecordDataType; |
| 18 | class QOpcUaX509DistinguishedName; |
| 19 | |
| 20 | class Q_OPCUA_EXPORT QOpcUaGdsClient : public QObject |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | Q_DECLARE_PRIVATE(QOpcUaGdsClient) |
| 24 | |
| 25 | public: |
| 26 | enum class Error { |
| 27 | NoError, |
| 28 | InvalidBackend, |
| 29 | InvalidEndpoint, |
| 30 | ConnectionError, |
| 31 | DirectoryNodeNotFound, |
| 32 | FailedToRegisterApplication, |
| 33 | FailedToUnregisterApplication, |
| 34 | FailedToGetCertificateStatus, |
| 35 | FailedToGetCertificate, |
| 36 | }; |
| 37 | Q_ENUM(Error) |
| 38 | |
| 39 | enum class State { |
| 40 | Idle, |
| 41 | BackendInstantiated, |
| 42 | Connecting, |
| 43 | Connected, |
| 44 | RegisteringApplication, |
| 45 | ApplicationRegistered, |
| 46 | // |
| 47 | Error, |
| 48 | }; |
| 49 | Q_ENUM(State) |
| 50 | |
| 51 | QOpcUaGdsClient(QObject *parent = nullptr); |
| 52 | virtual ~QOpcUaGdsClient(); |
| 53 | |
| 54 | void setBackend(const QString &backend); |
| 55 | const QString &backend() const; |
| 56 | |
| 57 | void setEndpoint(const QOpcUaEndpointDescription &endpoint); |
| 58 | const QOpcUaEndpointDescription &endpoint() const; |
| 59 | |
| 60 | void setPkiConfiguration(const QOpcUaPkiConfiguration &pkiConfig); |
| 61 | const QOpcUaPkiConfiguration &pkiConfiguration() const; |
| 62 | |
| 63 | void setApplicationIdentity(const QOpcUaApplicationIdentity &appIdentity); |
| 64 | const QOpcUaApplicationIdentity &applicationIdentity() const; |
| 65 | |
| 66 | void setApplicationRecord(const QOpcUaApplicationRecordDataType &appRecord); |
| 67 | const QOpcUaApplicationRecordDataType &applicationRecord() const; |
| 68 | |
| 69 | QString applicationId() const; |
| 70 | |
| 71 | void setCertificateSigningRequestPresets(const QOpcUaX509DistinguishedName &dn, const QString &dns); |
| 72 | const QOpcUaX509DistinguishedName &distinguishedNameCertificateSigningRequestPreset() const; |
| 73 | const QString &dnsCertificateSigningRequestPreset() const; |
| 74 | |
| 75 | void setCertificateCheckInterval(int interval); |
| 76 | int certificateCheckInterval() const; |
| 77 | |
| 78 | void setTrustListUpdateInterval(int interval); |
| 79 | int trustListUpdateInterval() const; |
| 80 | |
| 81 | Error error() const; |
| 82 | State state() const; |
| 83 | |
| 84 | void start(); |
| 85 | void unregisterApplication(); |
| 86 | |
| 87 | Q_SIGNALS: |
| 88 | void stateChanged(State state); |
| 89 | void errorChanged(Error error); |
| 90 | void applicationRegistered(); |
| 91 | void certificateGroupsReceived(QStringList certificateGroups); |
| 92 | void certificateUpdateRequired(); |
| 93 | void certificateUpdated(); |
| 94 | void unregistered(); |
| 95 | void trustListUpdated(); |
| 96 | void authenticationRequired(QOpcUaAuthenticationInformation &authInfo); |
| 97 | |
| 98 | private: |
| 99 | Q_PRIVATE_SLOT(d_func(), void _q_certificateCheckTimeout()) |
| 100 | Q_PRIVATE_SLOT(d_func(), void _q_updateTrustList()) |
| 101 | }; |
| 102 | |
| 103 | QT_END_NAMESPACE |
| 104 | |
| 105 | #endif // QOPCUAGDSCLIENT_H |
| 106 | |
| 107 | |