[gnome] Fix version for gjsosk and gsconnect, add impatience
This commit is contained in:
@ -2,25 +2,30 @@
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
'use strict';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const GObject = imports.gi.GObject;
|
||||
import Config from '../config.js';
|
||||
import * as DBus from './utils/dbus.js';
|
||||
import Device from './device.js';
|
||||
|
||||
const Config = imports.config;
|
||||
const DBus = imports.service.utils.dbus;
|
||||
const Device = imports.service.device;
|
||||
import * as LanBackend from './backends/lan.js';
|
||||
|
||||
const DEVICE_NAME = 'org.gnome.Shell.Extensions.GSConnect.Device';
|
||||
const DEVICE_PATH = '/org/gnome/Shell/Extensions/GSConnect/Device';
|
||||
const DEVICE_IFACE = Config.DBUS.lookup_interface(DEVICE_NAME);
|
||||
|
||||
|
||||
const backends = {
|
||||
lan: LanBackend,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A manager for devices.
|
||||
*/
|
||||
var Manager = GObject.registerClass({
|
||||
const Manager = GObject.registerClass({
|
||||
GTypeName: 'GSConnectManager',
|
||||
Properties: {
|
||||
'active': GObject.ParamSpec.boolean(
|
||||
@ -30,6 +35,13 @@ var Manager = GObject.registerClass({
|
||||
GObject.ParamFlags.READABLE,
|
||||
false
|
||||
),
|
||||
'debug': GObject.ParamSpec.boolean(
|
||||
'debug',
|
||||
'Debug',
|
||||
'Whether debug logging is enabled in GSConnect',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
false
|
||||
),
|
||||
'discoverable': GObject.ParamSpec.boolean(
|
||||
'discoverable',
|
||||
'Discoverable',
|
||||
@ -80,6 +92,21 @@ var Manager = GObject.registerClass({
|
||||
return this._backends;
|
||||
}
|
||||
|
||||
get debug() {
|
||||
if (this._debug === undefined)
|
||||
this._debug = this.settings.get_boolean('debug');
|
||||
|
||||
return this._debug;
|
||||
}
|
||||
|
||||
set debug(value) {
|
||||
if (this._debug === value)
|
||||
return;
|
||||
|
||||
this._debug = value;
|
||||
this._onDebugChanged(this._debug);
|
||||
}
|
||||
|
||||
get devices() {
|
||||
if (this._devices === undefined)
|
||||
this._devices = new Map();
|
||||
@ -198,11 +225,20 @@ var Manager = GObject.registerClass({
|
||||
this.settings.set_string('name', GLib.get_host_name());
|
||||
|
||||
// Bound Properties
|
||||
this.settings.bind('debug', this, 'debug', 0);
|
||||
this.settings.bind('discoverable', this, 'discoverable', 0);
|
||||
this.settings.bind('id', this, 'id', 0);
|
||||
this.settings.bind('name', this, 'name', 0);
|
||||
}
|
||||
|
||||
_onDebugChanged(debug = false) {
|
||||
// If debugging is disabled, install a no-op for speed
|
||||
if (debug && globalThis._debugFunc !== undefined)
|
||||
globalThis.debug = globalThis._debugFunc;
|
||||
else
|
||||
globalThis.debug = () => {};
|
||||
}
|
||||
|
||||
/*
|
||||
* Backends
|
||||
*/
|
||||
@ -235,9 +271,9 @@ var Manager = GObject.registerClass({
|
||||
}
|
||||
|
||||
_loadBackends() {
|
||||
for (const name in imports.service.backends) {
|
||||
for (const name in backends) {
|
||||
try {
|
||||
const module = imports.service.backends[name];
|
||||
const module = backends[name];
|
||||
|
||||
if (module.ChannelService === undefined)
|
||||
continue;
|
||||
@ -270,7 +306,7 @@ var Manager = GObject.registerClass({
|
||||
_loadDevices() {
|
||||
// Load cached devices
|
||||
for (const id of this.settings.get_strv('devices')) {
|
||||
const device = new Device.Device({body: {deviceId: id}});
|
||||
const device = new Device({body: {deviceId: id}});
|
||||
this._exportDevice(device);
|
||||
this.devices.set(id, device);
|
||||
}
|
||||
@ -346,7 +382,7 @@ var Manager = GObject.registerClass({
|
||||
* of known devices if it doesn't exist.
|
||||
*
|
||||
* @param {Core.Packet} packet - An identity packet for the device
|
||||
* @return {Device.Device} A device object
|
||||
* @return {Device} A device object
|
||||
*/
|
||||
_ensureDevice(packet) {
|
||||
let device = this.devices.get(packet.body.deviceId);
|
||||
@ -365,7 +401,7 @@ var Manager = GObject.registerClass({
|
||||
if (unpaired.length === 3)
|
||||
this.discoverable = false;
|
||||
|
||||
device = new Device.Device(packet);
|
||||
device = new Device(packet);
|
||||
this._exportDevice(device);
|
||||
this.devices.set(device.id, device);
|
||||
|
||||
@ -506,3 +542,4 @@ var Manager = GObject.registerClass({
|
||||
}
|
||||
});
|
||||
|
||||
export default Manager;
|
||||
|
||||
Reference in New Issue
Block a user