diff --git a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml index 8f3fbaba4..a774a5147 100644 --- a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml +++ b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml @@ -58,6 +58,9 @@ SPDX-License-Identifier: GPL-2.0-or-later "" + + false + false diff --git a/data/org.gnome.Shell.Extensions.GSConnect.xml b/data/org.gnome.Shell.Extensions.GSConnect.xml index 9f77964b1..ea65fd3ca 100644 --- a/data/org.gnome.Shell.Extensions.GSConnect.xml +++ b/data/org.gnome.Shell.Extensions.GSConnect.xml @@ -12,6 +12,8 @@ SPDX-License-Identifier: GPL-2.0-or-later + + diff --git a/data/ui/preferences-device-panel.ui b/data/ui/preferences-device-panel.ui index 48d406255..3300f58f8 100644 --- a/data/ui/preferences-device-panel.ui +++ b/data/ui/preferences-device-panel.ui @@ -2515,14 +2515,14 @@ SPDX-License-Identifier: GPL-2.0-or-later + + + Device Settings - - - 0 @@ -2545,88 +2545,228 @@ SPDX-License-Identifier: GPL-2.0-or-later True False - + True - False - - - False - 6 - end - - - - - + False + + + True + False + + + False + 6 + end + + + + + + + + + True + False + True + + + True + True + 2 + + + + + False + False + 0 + - - - Pair - True - True - True - settings.pair + + + False + 16 + + + + True + False + + + True + False + start + 🔑 + + + 0 + 1 + + + + + True + False + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + 0 + + True True - 2 + 0 + + + - False - False - 0 + page0 + page0 - - - False - 6 - - - True - False + + + True + False + + + False + 6 + end - + + + + + + + + Request pairing True - False - start - Device is unpaired - - - + True + True + settings.pair - 0 - 0 + True + True + 2 + + + False + False + 0 + + + + + False + 6 - + + True - False - start - You may configure this device before pairing + False + + + True + False + start + Device is unpaired + + + + + + 0 + 0 + + + + + True + False + start + You may configure this device before pairing + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + - 0 - 1 + True + True + 0 - True - True + False + False 0 - False - False - 0 + 1 @@ -2636,11 +2776,17 @@ SPDX-License-Identifier: GPL-2.0-or-later - 0 - 0 + 0 + 0 3 + + + + + + diff --git a/src/preferences/device.js b/src/preferences/device.js index 002eb5833..f91de320b 100644 --- a/src/preferences/device.js +++ b/src/preferences/device.js @@ -262,7 +262,10 @@ var Panel = GObject.registerClass({ }, Template: 'resource:///org/gnome/Shell/Extensions/GSConnect/ui/preferences-device-panel.ui', Children: [ - 'sidebar', 'stack', 'infobar', + 'sidebar', 'stack', + + // Pairing process + 'infobar', 'infobar_stack', 'infobar_pair', 'infobar_verify', 'verifycode', // Sharing 'sharing', 'sharing-page', @@ -313,7 +316,7 @@ var Panel = GObject.registerClass({ path: `/org/gnome/shell/extensions/gsconnect/device/${device.id}/`, }); - // Infobar + // Pairing infobar this.device.bind_property( 'paired', this.infobar, @@ -321,6 +324,20 @@ var Panel = GObject.registerClass({ (GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN) ); + this.device.connect('notify::pairing', () => { + if (this.device.pairing) + this.infobar_stack.visible_child = this.infobar_verify; + else + this.infobar_stack.visible_child = this.infobar_pair; + + }); + + this.device.bind_property( + 'verify-code', + this.verifycode, + 'label', + GObject.BindingFlags.SYNC_CREATE + ); this._setupActions(); diff --git a/src/service/device.js b/src/service/device.js index 5149b7974..60feff5e4 100644 --- a/src/service/device.js +++ b/src/service/device.js @@ -66,6 +66,13 @@ var Device = GObject.registerClass({ GObject.ParamFlags.READABLE, null ), + 'pairing': GObject.ParamSpec.boolean( + 'pairing', + 'Pairing', + 'Whether the device is in the process of being paired', + GObject.ParamFlags.READABLE, + false + ), 'paired': GObject.ParamSpec.boolean( 'paired', 'Paired', @@ -73,6 +80,13 @@ var Device = GObject.registerClass({ GObject.ParamFlags.READABLE, false ), + 'verify-code': GObject.ParamSpec.string( + 'verify-code', + 'verifyCode', + 'The verification code for device pairing', + GObject.ParamFlags.READABLE, + null + ), 'type': GObject.ParamSpec.string( 'type', 'Type', @@ -193,7 +207,6 @@ var Device = GObject.registerClass({ if (lanBackend && lanBackend.certificate) localCert = lanBackend.certificate; - let verificationKey = ''; if (localCert && remoteCert) { let a = localCert.pubkey_der(); @@ -222,6 +235,10 @@ var Device = GObject.registerClass({ return this.settings.get_string('name'); } + get pairing() { + return this.settings.get_boolean('pairing'); + } + get paired() { return this.settings.get_boolean('paired'); } @@ -822,6 +839,7 @@ var Device = GObject.registerClass({ // The device is requesting pairing } else { this._notifyPairRequest(); + this._setPairing(true); } // Device is requesting unpairing/rejecting our request } else { @@ -872,6 +890,8 @@ var Device = GObject.registerClass({ _resetPairRequest() { this.hideNotification('pair-request'); + this._setPairing(false); + if (this._incomingPairRequest) { GLib.source_remove(this._incomingPairRequest); this._incomingPairRequest = 0; @@ -883,6 +903,16 @@ var Device = GObject.registerClass({ } } + /** + * Set the internal pairing state of the device and emit ::notify + * + * @param {boolean} pairing - The pairing state to set + */ + _setPairing(pairing) { + this.settings.set_boolean('pairing', pairing); + this.notify('pairing'); + } + /** * Set the internal paired state of the device and emit ::notify * @@ -947,6 +977,8 @@ var Device = GObject.registerClass({ body: {pair: true}, }); + this._setPairing(true); + this._outgoingPairRequest = GLib.timeout_add_seconds( GLib.PRIORITY_DEFAULT, 30, diff --git a/src/utils/remote.js b/src/utils/remote.js index ca5e94189..269e96605 100644 --- a/src/utils/remote.js +++ b/src/utils/remote.js @@ -20,7 +20,9 @@ const _PROPERTIES = { 'IconName': 'icon-name', 'Id': 'id', 'Name': 'name', + 'Pairing': 'pairing', 'Paired': 'paired', + 'VerifyCode': 'verify-code', 'Type': 'type', }; @@ -90,6 +92,13 @@ var Device = GObject.registerClass({ GObject.ParamFlags.READABLE, null ), + 'pairing': GObject.ParamSpec.boolean( + 'pairing', + 'Pairing', + 'Whether the device is in the process of being paired', + GObject.ParamFlags.READABLE, + null + ), 'paired': GObject.ParamSpec.boolean( 'paired', 'Paired', @@ -97,6 +106,13 @@ var Device = GObject.registerClass({ GObject.ParamFlags.READABLE, null ), + 'verify-code': GObject.ParamSpec.string( + 'verify-code', + 'verifyCode', + 'The verification code for device pairing', + GObject.ParamFlags.READABLE, + null + ), 'type': GObject.ParamSpec.string( 'type', 'deviceType', @@ -155,10 +171,18 @@ var Device = GObject.registerClass({ return this._get('Name', 'Unknown'); } + get pairing() { + return this._get('Pairing', false); + } + get paired() { return this._get('Paired', false); } + get verify_code() { + return this._get('VerifyCode', false); + } + get service() { return this._service; }