[gnome] Update extensions for version 48

This commit is contained in:
2025-03-29 17:52:56 -04:00
parent e01589e836
commit a84b79ca08
153 changed files with 3479 additions and 2189 deletions

View File

@ -18,6 +18,7 @@ import system from 'system';
import './init.js';
import Config from '../config.js';
import Device from './device.js';
import Manager from './manager.js';
import * as ServiceUI from './ui/service.js';
@ -45,6 +46,61 @@ const Service = GObject.registerClass({
this._initOptions();
}
_migrateConfiguration() {
if (!Device.validateName(this.settings.get_string('name')))
this.settings.set('name', GLib.get_host_name().slice(0, 32));
const [certPath, keyPath] = [
GLib.build_filenamev([Config.CONFIGDIR, 'certificate.pem']),
GLib.build_filenamev([Config.CONFIGDIR, 'private.pem']),
];
const certificate = Gio.TlsCertificate.new_for_paths(certPath, keyPath,
null);
if (Device.validateId(certificate.common_name))
return;
// Remove the old certificate, serving as the single source of truth
// for the device ID
try {
Gio.File.new_for_path(certPath).delete(null);
Gio.File.new_for_path(keyPath).delete(null);
} catch {
// Silence errors
}
// For each device, remove it entirely if it violates the device ID
// constraints, otherwise mark it unpaired to preserve the settings.
const deviceList = this.settings.get_strv('devices').filter(id => {
const settingsPath = `/org/gnome/shell/extensions/gsconnect/device/${id}/`;
if (!Device.validateId(id)) {
GLib.spawn_command_line_async(`dconf reset -f ${settingsPath}`);
Gio.File.rm_rf(GLib.build_filenamev([Config.CACHEDIR, id]));
debug(`Invalid device ID ${id} removed.`);
return false;
}
const settings = new Gio.Settings({
settings_schema: Config.GSCHEMA.lookup(
'org.gnome.Shell.Extensions.GSConnect.Device', true),
path: settingsPath,
});
settings.set_boolean('paired', false);
return true;
});
this.settings.set_strv('devices', deviceList);
// Notify the user
const notification = Gio.Notification.new(_('Settings Migrated'));
notification.set_body(_('GSConnect has updated to support changes to the KDE Connect protocol. Some devices may need to be repaired.'));
notification.set_icon(new Gio.ThemedIcon({name: 'dialog-warning'}));
notification.set_priority(Gio.NotificationPriority.HIGH);
this.send_notification('settings-migrated', notification);
// Finally, reset the service ID to trigger re-generation.
this.settings.reset('id');
}
get settings() {
if (this._settings === undefined) {
this._settings = new Gio.Settings({
@ -154,7 +210,7 @@ const Service = GObject.registerClass({
/**
* Report a service-level error
*
* @param {Object} error - An Error or object with name, message and stack
* @param {object} error - An Error or object with name, message and stack
*/
notify_error(error) {
try {
@ -241,6 +297,9 @@ const Service = GObject.registerClass({
// GActions & GSettings
this._initActions();
// TODO: remove after a reasonable period of time
this._migrateConfiguration();
this.manager.start();
}
@ -699,4 +758,3 @@ const Service = GObject.registerClass({
});
await (new Service()).runAsync([system.programInvocationName].concat(ARGV));