blob: 5609c1224670cd2b43c909d92efcfa2e3a2fdf78 (
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
// Main.qml — Demo app for testing BobinkClient connection flow.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Bobink
ApplicationWindow {
width: 600
height: 600
visible: true
title: "Bobink Demo"
Connections {
target: BobinkClient
function onServersChanged() {
console.log("Discovered server list updated")
}
function onConnectedChanged() {
console.log("Connected:", BobinkClient.connected)
}
function onConnectionError(message) {
console.log("Connection error:", message)
}
function onDiscoveringChanged() {
console.log("Discovering:", BobinkClient.discovering)
}
function onCertificateTrustRequested(certInfo) {
certTrustDialog.certInfo = certInfo
certTrustDialog.open()
}
}
Dialog {
id: certTrustDialog
property string certInfo
anchors.centerIn: parent
title: "Certificate Trust"
modal: true
standardButtons: Dialog.Yes | Dialog.No
Label { text: certTrustDialog.certInfo }
onAccepted: BobinkClient.acceptCertificate()
onRejected: BobinkClient.rejectCertificate()
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 20
spacing: 12
Label { text: "Discovery URL"; font.bold: true }
RowLayout {
TextField {
id: discoveryUrlField
Layout.fillWidth: true
text: "opc.tcp://localhost:4840"
}
Button {
text: BobinkClient.discovering ? "Stop" : "Discover"
onClicked: {
if (BobinkClient.discovering) {
BobinkClient.stopDiscovery()
} else {
BobinkClient.discoveryUrl = discoveryUrlField.text
BobinkClient.startDiscovery()
}
}
}
}
Label {
text: BobinkClient.discovering
? "Discovering... (" + BobinkClient.servers.length + " found)"
: BobinkClient.servers.length + " server(s)"
font.italic: true
}
ListView {
Layout.fillWidth: true
Layout.preferredHeight: 100
clip: true
model: BobinkClient.servers
delegate: ItemDelegate {
width: ListView.view.width
text: modelData.serverName + " — " + modelData.applicationUri
onClicked: {
if (modelData.discoveryUrls.length > 0)
serverUrlField.text = modelData.discoveryUrls[0]
}
}
ScrollBar.vertical: ScrollBar {}
}
Label { text: "PKI"; font.bold: true }
GridLayout {
columns: 2
Layout.fillWidth: true
Label { text: "PKI directory:" }
TextField {
id: pkiDirField
Layout.fillWidth: true
text: BobinkClient.pkiDir
onEditingFinished: BobinkClient.pkiDir = text
}
Label { text: "Certificate:" }
TextField {
id: certFileField
Layout.fillWidth: true
placeholderText: "/path/to/cert.der"
}
Label { text: "Private key:" }
TextField {
id: keyFileField
Layout.fillWidth: true
placeholderText: "/path/to/key.pem"
}
}
Button {
text: "Apply PKI"
Layout.fillWidth: true
onClicked: {
BobinkClient.pkiDir = pkiDirField.text
BobinkClient.certFile = certFileField.text
BobinkClient.keyFile = keyFileField.text
BobinkClient.applyPki()
console.log("PKI applied:", BobinkClient.pkiDir)
}
}
Label { text: "Server URL"; font.bold: true }
TextField {
id: serverUrlField
Layout.fillWidth: true
placeholderText: "opc.tcp://..."
}
Label { text: "Authentication"; font.bold: true }
BobinkAuth {
id: auth
mode: authModeCombo.currentValue
username: usernameField.text
password: passwordField.text
certPath: certPathField.text
keyPath: keyPathField.text
}
ComboBox {
id: authModeCombo
Layout.fillWidth: true
textRole: "text"
valueRole: "mode"
model: [
{ text: "Anonymous", mode: BobinkAuth.Anonymous },
{ text: "Username / Password", mode: BobinkAuth.UserPass },
{ text: "Certificate", mode: BobinkAuth.Certificate }
]
}
GridLayout {
columns: 2
visible: authModeCombo.currentValue === BobinkAuth.UserPass
Layout.fillWidth: true
Label { text: "Username:" }
TextField {
id: usernameField
Layout.fillWidth: true
}
Label { text: "Password:" }
TextField {
id: passwordField
Layout.fillWidth: true
echoMode: TextInput.Password
}
}
GridLayout {
columns: 2
visible: authModeCombo.currentValue === BobinkAuth.Certificate
Layout.fillWidth: true
Label { text: "Certificate:" }
TextField {
id: certPathField
Layout.fillWidth: true
placeholderText: "/path/to/cert.pem"
}
Label { text: "Private key:" }
TextField {
id: keyPathField
Layout.fillWidth: true
placeholderText: "/path/to/key.pem"
}
}
Button {
text: BobinkClient.connected ? "Disconnect" : "Connect"
Layout.fillWidth: true
onClicked: {
if (BobinkClient.connected) {
BobinkClient.disconnectFromServer()
} else {
BobinkClient.auth = auth
BobinkClient.serverUrl = serverUrlField.text
BobinkClient.connectToServer()
}
}
}
Label {
text: "Status: " + (BobinkClient.connected ? "Connected" : "Disconnected")
color: BobinkClient.connected ? "green" : "red"
}
Item { Layout.fillHeight: true }
}
}
|