diff --git a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml index b3693731a..1ead96aac 100644 --- a/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml +++ b/data/org.gnome.Shell.Extensions.GSConnect.gschema.xml @@ -51,6 +51,9 @@ "" + + false + false diff --git a/data/org.gnome.Shell.Extensions.GSConnect.xml b/data/org.gnome.Shell.Extensions.GSConnect.xml index d7795399b..1def3dbd5 100644 --- a/data/org.gnome.Shell.Extensions.GSConnect.xml +++ b/data/org.gnome.Shell.Extensions.GSConnect.xml @@ -6,6 +6,8 @@ + + diff --git a/data/ui/preferences-device-panel.ui b/data/ui/preferences-device-panel.ui index 4e24d65a1..6506f47a9 100644 --- a/data/ui/preferences-device-panel.ui +++ b/data/ui/preferences-device-panel.ui @@ -2508,14 +2508,14 @@ + + + Device Settings - - - 0 @@ -2538,88 +2538,228 @@ 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 @@ -2629,11 +2769,17 @@ - 0 - 0 + 0 + 0 3 + + + + + + diff --git a/src/preferences/device.js b/src/preferences/device.js index 8c836ec20..90bb9dae5 100644 --- a/src/preferences/device.js +++ b/src/preferences/device.js @@ -258,7 +258,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', @@ -309,7 +312,7 @@ var Panel = GObject.registerClass({ path: `/org/gnome/shell/extensions/gsconnect/device/${device.id}/`, }); - // Infobar + // Pairing infobar this.device.bind_property( 'paired', this.infobar, @@ -317,6 +320,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 4691f7c69..78278c269 100644 --- a/src/service/device.js +++ b/src/service/device.js @@ -62,6 +62,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', @@ -69,6 +76,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', @@ -189,7 +203,6 @@ var Device = GObject.registerClass({ if (lanBackend && lanBackend.certificate) localCert = lanBackend.certificate; - let verificationKey = ''; if (localCert && remoteCert) { let a = localCert.pubkey_der(); @@ -218,6 +231,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'); } @@ -818,6 +835,7 @@ var Device = GObject.registerClass({ // The device is requesting pairing } else { this._notifyPairRequest(); + this._setPairing(true); } // Device is requesting unpairing/rejecting our request } else { @@ -868,6 +886,8 @@ var Device = GObject.registerClass({ _resetPairRequest() { this.hideNotification('pair-request'); + this._setPairing(false); + if (this._incomingPairRequest) { GLib.source_remove(this._incomingPairRequest); this._incomingPairRequest = 0; @@ -879,6 +899,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 * @@ -943,6 +973,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 7a1c27b6b..29adbf15b 100644 --- a/src/utils/remote.js +++ b/src/utils/remote.js @@ -16,7 +16,9 @@ const _PROPERTIES = { 'IconName': 'icon-name', 'Id': 'id', 'Name': 'name', + 'Pairing': 'pairing', 'Paired': 'paired', + 'VerifyCode': 'verify-code', 'Type': 'type', }; @@ -86,6 +88,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', @@ -93,6 +102,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', @@ -151,10 +167,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; }