Skip to content

overrides: Allow DBus methods with file descriptor lists

Philip Chimento requested to merge ptomato/gjs:204-dbus-file-handles into master

For DBus proxies, we now allow calling methods with an extra Gio.UnixFDList argument. This does not break existing code because we already allowed a bunch of arguments in any order. Gio.DBusProxy.call() is the same under the hood as Gio.DBusProxy.call_with_unix_fd_list(), only with a null FD list parameter, so we can replace the former with the latter.

Previously, synchronously called DBus proxy methods would return an unpacked GVariant. Now, if called with a Gio.UnixFDList they will return [unpacked GVariant, FDList]. This also does not break existing code because it was not possible to call a method with an FDList before, and the return value is unchanged if not calling with an FDList. This does mean, unfortunately, that if you have a method with an 'h' in its return signature but not in its argument signatures, you will have to call it with an empty FDList in order to receive an FDList with the return value, if calling synchronously.

On the DBus service side, when receiving a method call, we now pass the FDList received from DBus to the called method. Previously, sync methods were passed the parameters, and async methods were passed the parameters plus the Gio.DBusInvocation object. Appending the Gio.UnixFDList to those parameters also should not break existing code, although it could if the method examines the number of arguments. (That is unlikely, since DBus doesn't have methods with variable arguments.)

Closes #204 (closed)

Merge request reports