~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-yakkety-1987

« back to all changes in this revision

Viewing changes to plugins/Ubuntu/Settings/Vpn/Openvpn/Editor.qml

  • Committer: CI Train Bot
  • Author(s): jonas-drange
  • Date: 2016-04-27 12:32:13 UTC
  • mfrom: (122.1.7 lp1567389)
  • Revision ID: ci-train-bot@canonical.com-20160427123213-tc58m4bes3wryrb0
* Make Cancel/Ok buttons visible always
* Add support for TLS, Password, Password+TLS and Static auth types. Fixes: #1558531, #1567389

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
            PropertyChanges { target: routesField; enabled: false }
44
44
            PropertyChanges { target: tcpToggle; enabled: false }
45
45
            PropertyChanges { target: udpToggle; enabled: false }
 
46
            PropertyChanges { target: authTypeField; enabled: false }
46
47
            PropertyChanges { target: certField; enabled: false }
47
48
            PropertyChanges { target: caField; enabled: false }
48
49
            PropertyChanges { target: keyField; enabled: false }
74
75
    // the field value.
75
76
    function getChanges () {
76
77
        var fields = [
77
 
            ["remote",           serverField.text],
78
 
            ["portSet",          customPortToggle.checked],
79
 
            ["port",             parseInt(portField.text, 10) || 0],
80
 
            ["neverDefault",     routesField.neverDefault],
81
 
            ["protoTcp",         tcpToggle.checked],
82
 
            ["cert",             certField.path],
83
 
            ["ca",               caField.path],
84
 
            ["key",              keyField.path],
85
 
            ["certPass",         certPassField.text],
86
 
            ["ta",               taField.path],
87
 
            ["taSet",            taSetToggle.checked],
88
 
            ["taDir",            parseInt(taDirSelector.selectedIndex, 10) || 0],
89
 
            ["remoteCertTlsSet", remoteCertSetToggle.checked],
90
 
            ["remoteCertTls",    parseInt(remoteCertTlsSelector.selectedIndex, 10) || 0],
91
 
            ["cipher",           parseInt(cipherSelector.selectedIndex, 10) || 0],
92
 
            ["compLzo",          compressionToggle.checked]
 
78
            ["remote",             serverField.text],
 
79
            ["portSet",            customPortToggle.checked],
 
80
            ["port",               parseInt(portField.text, 10) || 0],
 
81
            ["neverDefault",       routesField.neverDefault],
 
82
            ["protoTcp",           tcpToggle.checked],
 
83
            ["connectionType",     authTypeField.type],
 
84
 
 
85
            ["username",           usernameField.text],
 
86
            ["password",           passwordField.text],
 
87
 
 
88
            ["cert",               certField.path],
 
89
            ["ca",                 caField.path],
 
90
            ["key",                keyField.path],
 
91
            ["certPass",           certPassField.text],
 
92
 
 
93
            ["staticKey",          staticKeyField.path],
 
94
            ["staticKeyDirection", parseInt(staticKeyDirectionSelector.selectedIndex, 10) || 0],
 
95
            ["remoteIp",           remoteIpField.text],
 
96
            ["localIp",            localIpField.text],
 
97
 
 
98
            ["ta",                 taField.path],
 
99
            ["taSet",              taSetToggle.checked],
 
100
            ["taDir",              parseInt(taDirSelector.selectedIndex, 10) || 0],
 
101
            ["remoteCertTlsSet",   remoteCertSetToggle.checked],
 
102
            ["remoteCertTls",      parseInt(remoteCertTlsSelector.selectedIndex, 10) || 0],
 
103
            ["cipher",             parseInt(cipherSelector.selectedIndex, 10) || 0],
 
104
            ["compLzo",            compressionToggle.checked]
93
105
        ]
 
106
 
94
107
        var changedFields = [];
95
108
 
96
109
        // Push all fields that differs from the server to chanagedFields.
109
122
        Label {
110
123
            text: i18n.dtr("ubuntu-settings-components", "Server:")
111
124
            font.bold: true
112
 
            color: Theme.palette.normal.baseText
 
125
            color: theme.palette.normal.baseText
113
126
            elide: Text.ElideRight
114
127
            Layout.fillWidth: true
115
128
        }
123
136
        Label {
124
137
            text: i18n.dtr("ubuntu-settings-components", "Port:")
125
138
            font.bold: true
126
 
            color: Theme.palette.normal.baseText
 
139
            color: theme.palette.normal.baseText
127
140
            elide: Text.ElideRight
128
141
            Layout.preferredWidth: units.gu(10)
129
142
        }
177
190
    }
178
191
 
179
192
    VpnRoutesField {
 
193
        id: routesField
180
194
        objectName: "vpnOpenvpnRoutesField"
181
195
        anchors { left: parent.left; right: parent.right }
182
 
        id: routesField
183
196
        neverDefault: connection.neverDefault
184
197
    }
185
198
 
201
214
        Label {
202
215
            text: i18n.dtr("ubuntu-settings-components", "Protocol:")
203
216
            font.bold: true
204
 
            color: Theme.palette.normal.baseText
 
217
            color: theme.palette.normal.baseText
205
218
            elide: Text.ElideRight
206
219
        }
207
220
 
233
246
        }
234
247
    }
235
248
 
236
 
    Label {
237
 
        font.bold: true
238
 
        color: Theme.palette.normal.baseText
239
 
        elide: Text.ElideRight
240
 
        text: i18n.dtr("ubuntu-settings-components", "Client certificate:")
241
 
    }
242
 
 
243
 
    FileSelector {
244
 
        anchors { left: parent.left; right: parent.right }
245
 
        id: certField
246
 
        objectName: "vpnOpenvpnCertField"
247
 
        path: connection.cert
248
 
        chooseLabel: i18n.dtr("ubuntu-settings-components", "Choose Certificate…")
249
 
    }
250
 
 
251
 
    Label {
252
 
        font.bold: true
253
 
        color: Theme.palette.normal.baseText
 
249
    AuthTypeField {
 
250
        id: authTypeField
 
251
        objectName: "vpnOpenvpnAuthTypeField"
 
252
        anchors { left: parent.left; right: parent.right }
 
253
        states: [
 
254
            State {
 
255
                name: "tls"
 
256
                PropertyChanges { target: authTls; visible: true }
 
257
            },
 
258
            State {
 
259
                name: "password"
 
260
                PropertyChanges { target: authPassword; visible: true }
 
261
            },
 
262
            State {
 
263
                name: "passwordtls"
 
264
                PropertyChanges { target: authPassword; visible: true }
 
265
                PropertyChanges { target: authTls; visible: true }
 
266
            },
 
267
            State {
 
268
                name: "static"
 
269
                PropertyChanges { target: authStatic; visible: true }
 
270
                PropertyChanges { target: caLabel; visible: false }
 
271
                PropertyChanges { target: caField; visible: false }
 
272
            }
 
273
        ]
 
274
        type: connection.connectionType
 
275
        onAuthTypeRequested: {
 
276
            switch (index) {
 
277
            case 0: // OpenvpnConnection.TLS
 
278
                state = "tls";
 
279
                break
 
280
            case 1: // OpenvpnConnection.PASSWORD
 
281
                state = "password";
 
282
                break
 
283
            case 2: // OpenvpnConnection.PASSWORD_TLS
 
284
                state = "passwordtls";
 
285
                break
 
286
            case 3: // OpenvpnConnection.STATIC_KEY
 
287
                state = "static";
 
288
                break
 
289
            }
 
290
        }
 
291
        Component.onCompleted: authTypeRequested(connection.connectionType)
 
292
    }
 
293
 
 
294
    Column {
 
295
        id: authPassword
 
296
        anchors { left: parent.left; right: parent.right }
 
297
        visible: false
 
298
        spacing: openVpnEditor.spacing
 
299
 
 
300
        Label {
 
301
            font.bold: true
 
302
            color: theme.palette.normal.baseText
 
303
            elide: Text.ElideRight
 
304
            text: i18n.dtr("ubuntu-settings-components", "Username:")
 
305
        }
 
306
 
 
307
        TextField {
 
308
            id: usernameField
 
309
            anchors { left: parent.left; right: parent.right }
 
310
            objectName: "vpnOpenvpnUsernameField"
 
311
            text: connection.username
 
312
            inputMethodHints: Qt.ImhNoPredictiveText
 
313
        }
 
314
 
 
315
        Label {
 
316
            font.bold: true
 
317
            color: theme.palette.normal.baseText
 
318
            elide: Text.ElideRight
 
319
            text: i18n.dtr("ubuntu-settings-components", "Password:")
 
320
        }
 
321
 
 
322
        TextField {
 
323
            id: passwordField
 
324
            anchors { left: parent.left; right: parent.right }
 
325
            objectName: "vpnOpenvpnPasswordField"
 
326
            text: connection.password
 
327
            echoMode: TextInput.PasswordEchoOnEdit
 
328
        }
 
329
    }
 
330
 
 
331
    Column {
 
332
        id: authTls
 
333
        anchors { left: parent.left; right: parent.right }
 
334
        visible: false
 
335
        spacing: openVpnEditor.spacing
 
336
 
 
337
        Label {
 
338
            font.bold: true
 
339
            color: theme.palette.normal.baseText
 
340
            elide: Text.ElideRight
 
341
            text: i18n.dtr("ubuntu-settings-components", "Client certificate:")
 
342
        }
 
343
 
 
344
        FileSelector {
 
345
            anchors { left: parent.left; right: parent.right }
 
346
            id: certField
 
347
            objectName: "vpnOpenvpnCertField"
 
348
            path: connection.cert
 
349
            chooseLabel: i18n.dtr("ubuntu-settings-components", "Choose Certificate…")
 
350
        }
 
351
 
 
352
        Label {
 
353
            font.bold: true
 
354
            color: theme.palette.normal.baseText
 
355
            elide: Text.ElideRight
 
356
            text: i18n.dtr("ubuntu-settings-components", "Private key:")
 
357
        }
 
358
 
 
359
        FileSelector {
 
360
            anchors { left: parent.left; right: parent.right }
 
361
            id: keyField
 
362
            objectName: "vpnOpenvpnKeyField"
 
363
            path: connection.key
 
364
            chooseLabel: i18n.dtr("ubuntu-settings-components", "Choose Key…")
 
365
        }
 
366
 
 
367
        Label {
 
368
            font.bold: true
 
369
            color: theme.palette.normal.baseText
 
370
            elide: Text.ElideRight
 
371
            text: i18n.dtr("ubuntu-settings-components", "Key password:")
 
372
        }
 
373
 
 
374
        TextField {
 
375
            anchors { left: parent.left; right: parent.right }
 
376
            id: certPassField
 
377
            objectName: "vpnOpenvpnCertPassField"
 
378
            echoMode: TextInput.Password
 
379
            text: connection.certPass
 
380
        }
 
381
    }
 
382
 
 
383
    Label {
 
384
        id: caLabel
 
385
        font.bold: true
 
386
        color: theme.palette.normal.baseText
254
387
        elide: Text.ElideRight
255
388
        text: i18n.dtr("ubuntu-settings-components", "CA certificate:")
256
389
    }
263
396
        chooseLabel: i18n.dtr("ubuntu-settings-components", "Choose Certificate…")
264
397
    }
265
398
 
266
 
    Label {
267
 
        font.bold: true
268
 
        color: Theme.palette.normal.baseText
269
 
        elide: Text.ElideRight
270
 
        text: i18n.dtr("ubuntu-settings-components", "Private key:")
271
 
    }
272
 
 
273
 
    FileSelector {
274
 
        anchors { left: parent.left; right: parent.right }
275
 
        id: keyField
276
 
        objectName: "vpnOpenvpnKeyField"
277
 
        path: connection.key
278
 
        chooseLabel: i18n.dtr("ubuntu-settings-components", "Choose Key…")
279
 
    }
280
 
 
281
 
    Label {
282
 
        font.bold: true
283
 
        color: Theme.palette.normal.baseText
284
 
        elide: Text.ElideRight
285
 
        text: i18n.dtr("ubuntu-settings-components", "Key password:")
286
 
    }
287
 
 
288
 
    TextField {
289
 
        anchors { left: parent.left; right: parent.right }
290
 
        id: certPassField
291
 
        objectName: "vpnOpenvpnCertPassField"
292
 
        echoMode: TextInput.Password
293
 
        text: connection.certPass
 
399
    Column {
 
400
        id: authStatic
 
401
        anchors { left: parent.left; right: parent.right }
 
402
        visible: false
 
403
        spacing: openVpnEditor.spacing
 
404
 
 
405
        Label {
 
406
            font.bold: true
 
407
            color: theme.palette.normal.baseText
 
408
            elide: Text.ElideRight
 
409
            text: i18n.dtr("ubuntu-settings-components", "Static key:")
 
410
        }
 
411
 
 
412
        FileSelector {
 
413
            id: staticKeyField
 
414
            anchors { left: parent.left; right: parent.right }
 
415
            objectName: "vpnOpenvpnStaticKeyField"
 
416
            path: connection.staticKey
 
417
            chooseLabel: i18n.dtr("ubuntu-settings-components", "Choose Key…")
 
418
        }
 
419
 
 
420
        Label {
 
421
            text: i18n.dtr("ubuntu-settings-components", "Key direction:")
 
422
            font.bold: true
 
423
            color: theme.palette.normal.baseText
 
424
            elide: Text.ElideRight
 
425
        }
 
426
 
 
427
        ListItems.ItemSelector {
 
428
            id: staticKeyDirectionSelector
 
429
            objectName: "vpnOpenvpnStaticKeyDirectionSelector"
 
430
            model: [
 
431
                i18n.dtr("ubuntu-settings-components", "None"),
 
432
                0,
 
433
                1,
 
434
            ]
 
435
            selectedIndex: connection.staticKeyDirection
 
436
        }
 
437
 
 
438
        Label {
 
439
            text: i18n.dtr("ubuntu-settings-components", "Remote IP:")
 
440
            font.bold: true
 
441
            color: theme.palette.normal.baseText
 
442
            elide: Text.ElideRight
 
443
        }
 
444
 
 
445
        TextField {
 
446
            id: remoteIpField
 
447
            anchors { left: parent.left; right: parent.right }
 
448
            text: connection.remoteIp
 
449
            objectName: "vpnOpenvpnRemoteIpField"
 
450
            inputMethodHints: Qt.ImhNoPredictiveText
 
451
        }
 
452
 
 
453
        Label {
 
454
            text: i18n.dtr("ubuntu-settings-components", "Local IP:")
 
455
            font.bold: true
 
456
            color: theme.palette.normal.baseText
 
457
            elide: Text.ElideRight
 
458
        }
 
459
 
 
460
        TextField {
 
461
            id: localIpField
 
462
            anchors { left: parent.left; right: parent.right }
 
463
            text: connection.localIp
 
464
            objectName: "vpnOpenvpnLocalIpField"
 
465
            inputMethodHints: Qt.ImhNoPredictiveText
 
466
        }
294
467
    }
295
468
 
296
469
    RowLayout {
310
483
 
311
484
    Label {
312
485
        font.bold: true
313
 
        color: Theme.palette.normal.baseText
 
486
        color: theme.palette.normal.baseText
314
487
        elide: Text.ElideRight
315
488
        text: i18n.dtr("ubuntu-settings-components", "TLS key:")
316
489
        visible: taSetToggle.checked
328
501
    Label {
329
502
        text: i18n.dtr("ubuntu-settings-components", "Key direction:")
330
503
        font.bold: true
331
 
        color: Theme.palette.normal.baseText
 
504
        color: theme.palette.normal.baseText
332
505
        elide: Text.ElideRight
333
506
        visible: taSetToggle.checked
334
507
    }
361
534
 
362
535
    Label {
363
536
        font.bold: true
364
 
        color: Theme.palette.normal.baseText
 
537
        color: theme.palette.normal.baseText
365
538
        elide: Text.ElideRight
366
539
        text: i18n.dtr("ubuntu-settings-components", "Peer certificate TLS type:")
367
540
        visible: remoteCertSetToggle.checked
380
553
 
381
554
    Label {
382
555
        font.bold: true
383
 
        color: Theme.palette.normal.baseText
 
556
        color: theme.palette.normal.baseText
384
557
        elide: Text.ElideRight
385
558
        text: i18n.dtr("ubuntu-settings-components", "Cipher:")
386
559
    }