[gnome] Update extensions

This commit is contained in:
2026-06-10 11:03:09 -04:00
parent 20fc1e4e75
commit 6c973853c6
394 changed files with 12513 additions and 1340 deletions

View File

@ -411,9 +411,9 @@ export const ChannelService = GObject.registerClass({
/**
* Broadcast an identity packet
*
* If @address is not %null it may specify an IPv4 or IPv6 address to send
* the identity packet directly to, otherwise it will be broadcast to the
* default address, 255.255.255.255.
* If {@link address] is not %null it may specify an IPv4 or IPv6 address
* to send the identity packet directly to, otherwise it will be broadcast
* to the default address, 255.255.255.255.
*
* @param {string} [address] - An optional target IPv4 or IPv6 address
*/
@ -773,9 +773,8 @@ export const Channel = GObject.registerClass({
// Starting with protocol version 8, the devices are expected to
// exchange identity packets again after TLS negotiation
if (this.identity.body.protocolVersion >= 8) {
if (this.identity.body.protocolVersion >= 8)
await this._exchangeIdentities();
}
} catch (e) {
this.close();
throw e;
@ -803,9 +802,8 @@ export const Channel = GObject.registerClass({
// Starting with protocol version 8, the devices are expected to
// exchange identity packets again after TLS negotiation
if (this.identity.body.protocolVersion >= 8) {
if (this.identity.body.protocolVersion >= 8)
await this._exchangeIdentities();
}
} catch (e) {
this.close();
throw e;

View File

@ -463,8 +463,8 @@ const Store = GObject.registerClass({
}
/**
* Lookup a contact for each address object in @addresses and return a
* dictionary of address (eg. phone number) to contact object.
* Lookup a contact for each address object in {@link addresses} and return
* a dictionary of address (eg. phone number) to contact object.
*
* { "555-5555": { "name": "...", "numbers": [], ... } }
*

View File

@ -41,7 +41,7 @@ const Default = new Map();
* followed by a call to `release()`.
*
* @param {string} name - The module name
* @returns {*} The default instance of a component
* @returns {object} The default instance of a component
*/
export function acquire(name) {
if (functionOverrides.acquire)

View File

@ -9,6 +9,12 @@ import GObject from 'gi://GObject';
import * as DBus from '../utils/dbus.js';
// DesktopAppInfo is no longer in Gio in GNOME 49
let GioUnix;
GioUnix = import('gi://GioUnix?version=2.0').catch(() => {
GioUnix = Gio;
});
const _nodeInfo = Gio.DBusNodeInfo.new_for_xml(`
<node>
@ -100,7 +106,7 @@ const Listener = GObject.registerClass({
path: `/org/gnome/desktop/notifications/application/${app}/`,
});
const appInfo = Gio.DesktopAppInfo.new(
const appInfo = GioUnix.DesktopAppInfo.new(
appSettings.get_string('application-id')
);
@ -140,10 +146,10 @@ const Listener = GObject.registerClass({
}
/**
* Try and find a well-known name for @sender on the session bus
* Try and find a well-known name for {@link sender} on the session bus
*
* @param {string} sender - A DBus unique name (eg. :1.2282)
* @param {string} appName - @appName passed to Notify() (Optional)
* @param {string} appName - appName passed to Notify() (Optional)
* @returns {string} A well-known name or %null
*/
async _getAppId(sender, appName) {
@ -185,7 +191,7 @@ const Listener = GObject.registerClass({
}
/**
* Try and find the application name for @sender
* Try and find the application name for {@link sender}
*
* @param {string} sender - A DBus unique name
* @param {string} [appName] - `appName` supplied by Notify()
@ -198,7 +204,7 @@ const Listener = GObject.registerClass({
try {
const appId = await this._getAppId(sender, appName);
const appInfo = Gio.DesktopAppInfo.new(`${appId}.desktop`);
const appInfo = GioUnix.DesktopAppInfo.new(`${appId}.desktop`);
this._names[appName] = appInfo.get_name();
appName = appInfo.get_name();
} catch {
@ -213,10 +219,26 @@ const Listener = GObject.registerClass({
*
* @param {DBus.Interface} iface - The DBus interface
* @param {string} name - The DBus method name
* @param {GLib.Variant} parameters - The method parameters
* @param {Gio.DBusMethodInvocation} invocation - The method invocation info
* @param {GLib.Variant|Gio.DBusMethodInvocation} param1 - The method parameters or invocation (GNOME 50+ changed order)
* @param {Gio.DBusMethodInvocation|GLib.Variant} param2 - The method invocation or parameters (GNOME 50+ changed order)
*/
async _onHandleMethodCall(iface, name, parameters, invocation) {
async _onHandleMethodCall(iface, name, param1, param2) {
let invocation, parameters;
// GNOME 50+ changed the callback signature from
// (iface, name, parameters, invocation) to
// (iface, name, invocation, parameters)
// Detect which order is being used
if (param1 instanceof GLib.Variant) {
// Old order: parameters, invocation
parameters = param1;
invocation = param2;
} else {
// New order: invocation, parameters
invocation = param1;
parameters = param2;
}
try {
// Check if notifications are disabled in desktop settings
if (!this._settings.get_boolean('show-banners'))
@ -357,7 +379,7 @@ const Listener = GObject.registerClass({
if (application === 'org.gnome.Shell.Extensions.GSConnect')
return;
const appInfo = Gio.DesktopAppInfo.new(`${application}.desktop`);
const appInfo = GioUnix.DesktopAppInfo.new(`${application}.desktop`);
// Try to get an icon for the notification
if (!notification.hasOwnProperty('icon'))

View File

@ -80,7 +80,7 @@ class Stream {
}
/**
* Gradually raise or lower the stream volume to @value
* Gradually raise or lower the stream volume to {@link value}
*
* @param {number} value - A number in the range 0-1
* @param {number} [duration] - Duration to fade in seconds

View File

@ -107,7 +107,7 @@ export class Packet {
/**
* Check if the packet has a payload.
*
* @returns {boolean} %true if @packet has a payload
* @returns {boolean} %true if the packet has a payload
*/
hasPayload() {
if (!this.hasOwnProperty('payloadSize'))
@ -386,7 +386,7 @@ export const ChannelService = GObject.registerClass({
}
/**
* Broadcast directly to @address or the whole network if %null
* Broadcast directly to {@link address} or the whole network if %null
*
* @param {string} [address] - A string address
*/

View File

@ -17,7 +17,11 @@ import('gi://GIRepository?version=3.0').catch(() => {
import('gi://GIRepository?version=2.0').catch(() => {});
});
import('gi://GioUnix?version=2.0').catch(() => {}); // Set version for optional dependency
// DesktopAppInfo is no longer in Gio in GNOME 49
let GioUnix;
GioUnix = import('gi://GioUnix?version=2.0').catch(() => {
GioUnix = Gio;
});
import system from 'system';
@ -206,10 +210,11 @@ const Service = GObject.registerClass({
}
_preferences() {
Gio.Subprocess.new(
[`${Config.PACKAGE_DATADIR}/gsconnect-preferences`],
Gio.SubprocessFlags.NONE
const _launcher = Gio.SubprocessLauncher.new(
{flags: Gio.SubprocessFlags.NONE}
);
_launcher.set_cwd(Config.PACKAGE_DATADIR);
_launcher.spawnv(['gjs', '-m', 'gsconnect-preferences.js']);
}
/**
@ -296,7 +301,7 @@ const Service = GObject.registerClass({
// Ensure our handlers are registered
try {
const appInfo = Gio.DesktopAppInfo.new(`${Config.APP_ID}.desktop`);
const appInfo = GioUnix.DesktopAppInfo.new(`${Config.APP_ID}.desktop`);
appInfo.add_supports_type('x-scheme-handler/sms');
appInfo.add_supports_type('x-scheme-handler/tel');
} catch (e) {
@ -435,6 +440,15 @@ const Service = GObject.registerClass({
'<device-id>'
);
this.add_main_option(
'name',
'n'.charCodeAt(0),
GLib.OptionFlags.NONE,
GLib.OptionArg.STRING,
_('Target Device Name'),
'<device-name>'
);
/**
* Pairing
*/
@ -710,6 +724,32 @@ const Service = GObject.registerClass({
this._cliAction(device, 'shareText', GLib.Variant.new_string(text));
}
_findDeviceID(name) {
const result = Gio.DBus.session.call_sync(
'org.gnome.Shell.Extensions.GSConnect',
'/org/gnome/Shell/Extensions/GSConnect',
'org.freedesktop.DBus.ObjectManager',
'GetManagedObjects',
null,
null,
Gio.DBusCallFlags.NONE,
-1,
null
);
const variant = result.unpack()[0].unpack();
let device;
for (let object of Object.values(variant)) {
object = object.recursiveUnpack();
device = object['org.gnome.Shell.Extensions.GSConnect.Device'];
if (name === device.Name)
return device.Id;
}
return null;
}
vfunc_handle_local_options(options) {
try {
if (options.contains('version')) {
@ -731,11 +771,15 @@ const Service = GObject.registerClass({
// We need a device for anything else; exit since this is probably
// the daemon being started.
if (!options.contains('device'))
let id = null;
if (options.contains('device')) {
id = options.lookup_value('device', null).unpack();
} else if (options.contains('name')) {
const name = options.lookup_value('name', null).unpack();
id = this._findDeviceID(name); // May return null if no match found
}
if (id === null)
return -1;
const id = options.lookup_value('device', null).unpack();
// Pairing
if (options.contains('pair')) {
this._cliAction(id, 'pair');

View File

@ -531,8 +531,8 @@ const Device = GObject.registerClass({
}
/**
* Get the position of a GMenuItem with @actionName in the top level of the
* device menu.
* Get the position of a GMenuItem with {@link actionName} in the top level
* of the device menu.
*
* @param {string} actionName - An action name with scope (eg. device.foo)
* @returns {number} An 0-based index or -1 if not found
@ -755,7 +755,7 @@ const Device = GObject.registerClass({
}
/**
* Reject the transfer payload described by @packet.
* Reject the transfer payload described by {@link packet}.
*
* @param {Core.Packet} packet - A packet
* @returns {void}

View File

@ -194,7 +194,7 @@ String.prototype.toPhoneNumber = function () {
* A simple equality check for phone numbers based on `toPhoneNumber()`
*
* @param {string} number - A phone number string to compare
* @returns {boolean} If `this` and @number are equivalent phone numbers
* @returns {boolean} If `this` and {@link number} are equivalent phone numbers
*/
String.prototype.equalsPhoneNumber = function (number) {
const a = this.toPhoneNumber();
@ -241,7 +241,7 @@ Gio.File.rm_rf = function (file) {
/**
* Extend GLib.Variant with a static method to recursively pack a variant
*
* @param {*} [obj] - May be a GLib.Variant, Array, standard Object or literal.
* @param {object} [obj] - May be a GLib.Variant, Array, standard Object or literal.
* @returns {GLib.Variant} The resulting GVariant
*/
function _full_pack(obj) {
@ -297,8 +297,8 @@ GLib.Variant.full_pack = _full_pack;
/**
* Extend GLib.Variant with a method to recursively deepUnpack() a variant
*
* @param {*} [obj] - May be a GLib.Variant, Array, standard Object or literal.
* @returns {*} The resulting object
* @param {object} [obj] - May be a GLib.Variant, Array, standard Object or literal.
* @returns {object} The resulting object
*/
function _full_unpack(obj) {
obj = (obj === undefined) ? this : obj;
@ -353,7 +353,7 @@ GLib.Variant.prototype.full_unpack = _full_unpack;
* @param {string} keyPath - Absolute path to a private key in PEM format
* @param {string} commonName - A unique common name for the certificate
* @returns {Gio.TlsCertificate} A TLS certificate
* @throws MissingOpensslError on missing openssl binary
* @throws {MissingOpensslError} on missing openssl binary
*/
Gio.TlsCertificate.new_for_paths = function (certPath, keyPath, commonName = null) {
if (GLib.find_program_in_path(Config.OPENSSL_PATH) === null) {

View File

@ -394,7 +394,7 @@ const Manager = GObject.registerClass({
}
/**
* Return a device for @packet, creating it and adding it to the list of
* Return a device for {@link packet}, creating it and adding it to the list of
* of known devices if it doesn't exist.
*
* @param {Core.Packet} packet - An identity packet for the device

View File

@ -440,7 +440,7 @@ const ContactsPlugin = GObject.registerClass({
}
/**
* Request the vCards for @uids.
* Request the vCards for {@link uids}.
*
* @param {string[]} uids - A list of contact UIDs
*/

View File

@ -316,7 +316,7 @@ const MousepadPlugin = GObject.registerClass({
}
/**
* Send an echo/ACK of @input, if requested
* Send an echo/ACK of {@link input}, if requested
*
* @param {object} input - The body of a 'kdeconnect.mousepad.request'
*/

View File

@ -120,7 +120,7 @@ const RunCommandPlugin = GObject.registerClass({
}
/**
* Handle a request to execute the local command with the UUID @key
* Handle a request to execute the local command with the UUID {@link key}
*
* @param {string} key - The UUID of the local command
*/
@ -233,7 +233,7 @@ const RunCommandPlugin = GObject.registerClass({
commands() {}
/**
* Send a request to execute the remote command with the UUID @key
* Send a request to execute the remote command with the UUID {@link key}
*
* @param {string} key - The UUID of the remote command
*/

View File

@ -263,8 +263,8 @@ const SFTPPlugin = GObject.registerClass({
}
/**
* Remove all host keys from ~/.ssh/known_hosts for @host in the port range
* used by KDE Connect (1739-1764).
* Remove all host keys from ~/.ssh/known_hosts for {@link host} in the
* port range used by KDE Connect (1739-1764).
*
* @param {string} host - A hostname or IP address
*/

View File

@ -506,7 +506,7 @@ const SMSPlugin = GObject.registerClass({
}
/**
* Try to find a thread_id in @smsPlugin for @addresses.
* Try to find a thread_id in for {@link addresses}.
*
* @param {object[]} addresses - a list of address objects
* @returns {string|null} a thread ID

View File

@ -113,7 +113,7 @@ const SystemVolumePlugin = GObject.registerClass({
}
/**
* Update the cache for @stream
* Update the cache for {@link stream}
*
* @param {"Gvc.MixerStream"} stream - The stream to cache
* @returns {object} The updated cache object

View File

@ -14,7 +14,7 @@ import system from 'system';
/**
* Return a random color
*
* @param {*} [salt] - If not %null, will be used as salt for generating a color
* @param {string} [salt] - If not %null, will be used as salt for generating a color
* @param {number} alpha - A value in the [0...1] range for the alpha channel
* @returns {Gdk.RGBA} A new Gdk.RGBA object generated from the input
*/
@ -72,8 +72,8 @@ function getFgRGBA(rgba) {
/**
* Get a GdkPixbuf for @path, allowing the corrupt JPEG's KDE Connect sometimes
* sends. This function is synchronous.
* Get a GdkPixbuf for {@link path}, allowing the corrupt JPEG's KDE Connect
* sometimes sends. This function is synchronous.
*
* @param {string} path - A local file path
* @param {number} size - Size in pixels
@ -159,7 +159,7 @@ function getNumberTypeLabel(type) {
}
/**
* Get a display number from @contact for @address.
* Get a display number from {@link contact} for {@link address}.
*
* @param {object} contact - A contact object
* @param {string} address - A phone number

View File

@ -1077,7 +1077,7 @@ export const Window = GObject.registerClass({
}
/**
* Find the thread row for @contacts
* Find the thread row for {@link contacts}
*
* @param {object[]} contacts - A contact group
* @returns {ConversationSummary|null} The thread row or %null
@ -1160,7 +1160,7 @@ export const Window = GObject.registerClass({
}
/**
* Try and find an existing conversation widget for @message.
* Try and find an existing conversation widget for {@link message}.
*
* @param {object} message - A message object
* @returns {Conversation|null} A conversation widget or %null
@ -1202,8 +1202,8 @@ export const Window = GObject.registerClass({
}
/**
* Set the contents of the message entry. If @pending is %false set the
* message of the currently selected conversation, otherwise mark the
* Set the contents of the message entry. If {@link pending} is %false set
* the message of the currently selected conversation, otherwise mark the
* message to be set for the next selected conversation.
*
* @param {string} message - The message to place in the entry

View File

@ -111,11 +111,26 @@ export const Interface = GObject.registerClass({
* @param {Gio.DBusInterfaceInfo} info - The DBus interface
* @param {Gio.DBusInterface} iface - The DBus interface
* @param {string} name - The DBus method name
* @param {GLib.Variant} parameters - The method parameters
* @param {Gio.DBusMethodInvocation} invocation - The method invocation info
* @param {GLib.Variant|Gio.DBusMethodInvocation} param1 - The method parameters or invocation (GNOME 50+ changed order)
* @param {Gio.DBusMethodInvocation|GLib.Variant} param2 - The method invocation or parameters (GNOME 50+ changed order)
*/
async _call(info, iface, name, parameters, invocation) {
async _call(info, iface, name, param1, param2) {
let retval;
let invocation, parameters;
// GNOME 50+ changed the callback signature from
// (iface, name, parameters, invocation) to
// (iface, name, invocation, parameters)
// Detect which order is being used
if (param1 instanceof GLib.Variant) {
// Old order: parameters, invocation
parameters = param1;
invocation = param2;
} else {
// New order: invocation, parameters
invocation = param1;
parameters = param2;
}
// Invoke the instance method
try {
@ -241,7 +256,7 @@ export const Interface = GObject.registerClass({
});
/**
* Get a new, dedicated DBus connection on @busType
* Get a new, dedicated DBus connection on {@link busType}
*
* @param {Gio.BusType} [busType] - a Gio.BusType constant
* @param {Gio.Cancellable} [cancellable] - an optional Gio.Cancellable

View File

@ -74,9 +74,9 @@ const _numberRegex = new RegExp(
/**
* Searches @str for URLs and returns an array of objects with %url
* Searches {@link str} for URLs and returns an array of objects with %url
* properties showing the matched URL string, and %pos properties indicating
* the position within @str where the URL was found.
* the position within {@link str} where the URL was found.
*
* @param {string} str - the string to search
* @returns {object[]} the list of match objects, as described above