gio.dbus_proxy
Module for [DBusProxy] class
Types 3
[gio.dbus_proxy.DBusProxy] is a base class used for proxies to access a D-Bus interface on a remote object. A [gio.dbus_proxy.DBusProxy] can be constructed for both well-known and unique names.
By default, [gio.dbus_proxy.DBusProxy] will cache all properties (and listen to changes) of the remote object, and proxy all signals that get emitted. This behaviour can be changed by passing suitable [gio.types.DBusProxyFlags] when the proxy is created. If the proxy is for a well-known name, the property cache is flushed when the name owner vanishes and reloaded when a name owner appears.
The unique name owner of the proxy’s name is tracked and can be read from property@Gio.DBusProxy:g-name-owner. Connect to the [gobject.object.ObjectWrap.notify] signal to get notified of changes. Additionally, only signals and property changes emitted from the current name owner are considered and calls are always sent to the current name owner. This avoids a number of race conditions when the name is lost by one owner and claimed by another. However, if no name owner currently exists, then calls will be sent to the well-known name which may result in the message bus launching an owner (unless [gio.types.DBusProxyFlags.DoNotAutoStart] is set).
If the proxy is for a stateless D-Bus service, where the name owner may be started and stopped between calls, the property@Gio.DBusProxy:g-name-owner tracking of [gio.dbus_proxy.DBusProxy] will cause the proxy to drop signal and property changes from the service after it has restarted for the first time. When interacting with a stateless D-Bus service, do not use [gio.dbus_proxy.DBusProxy] — use direct D-Bus method calls and signal connections.
The generic signal@Gio.DBusProxy::g-properties-changed and signal@Gio.DBusProxy::g-signal signals are not very convenient to work with. Therefore, the recommended way of working with proxies is to subclass [gio.dbus_proxy.DBusProxy], and have more natural properties and signals in your derived class. This example shows how this can easily be done using the gdbus-codegen tool.
A [gio.dbus_proxy.DBusProxy] instance can be used from multiple threads but note that all signals (e.g. signal@Gio.DBusProxy::g-signal, signal@Gio.DBusProxy::g-properties-changed and [gobject.object.ObjectWrap.notify]) are emitted in the thread-default main context (see [glib.main_context.MainContext.pushThreadDefault]) of the thread where the instance was constructed.
An example using a proxy for a well-known name can be found in
gdbus-example-watch-proxy.c.DBusProxyGidBuilder builder()Get builder for [gio.dbus_proxy.DBusProxy] Returns: New builder objectgio.dbus_connection.DBusConnection gConnection() @propertyGet `gConnection` property. Returns: The #GDBusConnection the proxy is for.int gDefaultTimeout() @propertyGet `gDefaultTimeout` property. Returns: The timeout to use if -1 (specifying default timeout) is passed as @timeoutmsec in the [gio.dbusproxy.DBusProxy.call] and [gio.dbus_proxy.DBusProxy.callSync...void gDefaultTimeout(int propval) @propertySet `gDefaultTimeout` property. Params: propval = The timeout to use if -1 (specifying default timeout) is passed as @timeoutmsec in the [gio.dbusproxy.DBusProxy.call] and [gio.dbus_proxy.DBusProxy...gio.types.DBusProxyFlags gFlags() @propertyGet `gFlags` property. Returns: Flags from the #GDBusProxyFlags enumeration.gio.dbus_interface_info.DBusInterfaceInfo gInterfaceInfo() @propertyGet `gInterfaceInfo` property. Returns: Ensure that interactions with this proxy conform to the given interface. This is mainly to ensure that malformed data received from the other peer is ignored...void gInterfaceInfo(gio.dbus_interface_info.DBusInterfaceInfo propval) @propertySet `gInterfaceInfo` property. Params: propval = Ensure that interactions with this proxy conform to the given interface. This is mainly to ensure that malformed data received from the other peer i...string gInterfaceName() @propertyGet `gInterfaceName` property. Returns: The D-Bus interface name the proxy is for.string gName() @propertyGet `gName` property. Returns: The well-known or unique name that the proxy is for.string gNameOwner() @propertyGet `gNameOwner` property. Returns: The unique name that owns #GDBusProxy:g-name or null if no-one currently owns that name. You may connect to #GObject::notify signal to track changes to this prop...string gObjectPath() @propertyGet `gObjectPath` property. Returns: The object path the proxy is for.gio.dbus_proxy.DBusProxy newFinish(gio.async_result.AsyncResult res)Finishes creating a #GDBusProxy.gio.dbus_proxy.DBusProxy newForBusFinish(gio.async_result.AsyncResult res)Finishes creating a #GDBusProxy.gio.dbus_proxy.DBusProxy newForBusSync(gio.types.BusType busType, gio.types.DBusProxyFlags flags, gio.dbus_interface_info.DBusInterfaceInfo info, string name, string objectPath, string interfaceName, gio.cancellable.Cancellable cancellable = null)Like [gio.dbus_proxy.DBusProxy.newSync] but takes a #GBusType instead of a #GDBusConnection.gio.dbus_proxy.DBusProxy newSync(gio.dbus_connection.DBusConnection connection, gio.types.DBusProxyFlags flags, gio.dbus_interface_info.DBusInterfaceInfo info, string name, string objectPath, string interfaceName, gio.cancellable.Cancellable cancellable = null)Creates a proxy for accessing interfacename on the remote object at objectpath owned by name at connection and synchronously loads D-Bus properties unless the [gio.types.DBusProxyFlags.DoNotLoadPro...void new_(gio.dbus_connection.DBusConnection connection, gio.types.DBusProxyFlags flags, gio.dbus_interface_info.DBusInterfaceInfo info, string name, string objectPath, string interfaceName, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Creates a proxy for accessing interfacename on the remote object at objectpath owned by name at connection and asynchronously loads D-Bus properties unless the [gio.types.DBusProxyFlags.DoNotLoadPr...void newForBus(gio.types.BusType busType, gio.types.DBusProxyFlags flags, gio.dbus_interface_info.DBusInterfaceInfo info, string name, string objectPath, string interfaceName, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Like [gio.dbusproxy.DBusProxy.new] but takes a #GBusType instead of a #GDBusConnection.void call(string methodName, glib.variant.Variant parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Asynchronously invokes the method_name method on proxy.glib.variant.Variant callFinish(gio.async_result.AsyncResult res)Finishes an operation started with [gio.dbus_proxy.DBusProxy.call].glib.variant.Variant callSync(string methodName, glib.variant.Variant parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.cancellable.Cancellable cancellable = null)Synchronously invokes the method_name method on proxy.void callWithUnixFdList(string methodName, glib.variant.Variant parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.unix_fdlist.UnixFDList fdList = null, gio.cancellable.Cancellable cancellable = null, gio.types.AsyncReadyCallback callback = null)Like [gio.dbus_proxy.DBusProxy.call] but also takes a #GUnixFDList object.glib.variant.Variant callWithUnixFdListFinish(out gio.unix_fdlist.UnixFDList outFdList, gio.async_result.AsyncResult res)Finishes an operation started with [gio.dbus_proxy.DBusProxy.callWithUnixFdList].glib.variant.Variant callWithUnixFdListSync(string methodName, glib.variant.Variant parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.unix_fdlist.UnixFDList fdList, out gio.unix_fdlist.UnixFDList outFdList, gio.cancellable.Cancellable cancellable = null)Like [gio.dbus_proxy.DBusProxy.callSync] but also takes and returns #GUnixFDList objects.glib.variant.Variant getCachedProperty(string propertyName)Looks up the value for a property from the cache. This call does no blocking IO.string[] getCachedPropertyNames()Gets the names of all cached properties on proxy. Returns: A null-terminated array of strings or null if proxy has no cached properties. Free the returned array with [glib.global.strfreev].gio.dbus_connection.DBusConnection getConnection()Gets the connection proxy is for. Returns: A #GDBusConnection owned by proxy. Do not free.int getDefaultTimeout()Gets the timeout to use if -1 (specifying default timeout) is passed as timeoutmsec in the [gio.dbusproxy.DBusProxy.call] and [gio.dbus_proxy.DBusProxy.callSync] functions.gio.types.DBusProxyFlags getFlags()Gets the flags that proxy was constructed with. Returns: Flags from the #GDBusProxyFlags enumeration.gio.dbus_interface_info.DBusInterfaceInfo getInterfaceInfo()Returns the #GDBusInterfaceInfo, if any, specifying the interface that proxy conforms to. See the #GDBusProxy:g-interface-info property for more details. Returns: A #GDBusInterfaceInfo or null. Do ...string getInterfaceName()Gets the D-Bus interface name proxy is for. Returns: A string owned by proxy. Do not free.string getName()Gets the name that proxy was constructed for.string getNameOwner()The unique name that owns the name that proxy is for or null if no-one currently owns that name. You may connect to the #GObject::notify signal to track changes to the #GDBusProxy:g-name-owner prop...string getObjectPath()Gets the object path proxy is for. Returns: A string owned by proxy. Do not free.void setCachedProperty(string propertyName, glib.variant.Variant value = null)If value is not null, sets the cached value for the property with name property_name to the value in value.void setDefaultTimeout(int timeoutMsec)Sets the timeout to use if -1 (specifying default timeout) is passed as timeoutmsec in the [gio.dbusproxy.DBusProxy.call] and [gio.dbus_proxy.DBusProxy.callSync] functions.void setInterfaceInfo(gio.dbus_interface_info.DBusInterfaceInfo info = null)Ensure that interactions with proxy conform to the given interface. See the #GDBusProxy:g-interface-info property for more details.gulong connectGPropertiesChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == glib.variant.Variant)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == string[])))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gio.dbus_proxy.DBusProxy)))
&& Parameters!T.length < 4)Connect to `GPropertiesChanged` signal.gulong connectGSignal(T)(string detail = null, T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == string)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == glib.variant.Variant)))
&& (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gio.dbus_proxy.DBusProxy)))
&& Parameters!T.length < 5)Connect to `GSignal` signal.T gBusType(gio.types.BusType propval)Set `gBusType` property. Params: propval = If this property is not [gio.types.BusType.None], then #GDBusProxy:g-connection must be null and will be set to the #GDBusConnection obtained by calling [...T gConnection(gio.dbus_connection.DBusConnection propval)Set `gConnection` property. Params: propval = The #GDBusConnection the proxy is for. Returns: Builder instance for fluent chainingT gDefaultTimeout(int propval)Set `gDefaultTimeout` property. Params: propval = The timeout to use if -1 (specifying default timeout) is passed as @timeoutmsec in the [gio.dbusproxy.DBusProxy.call] and [gio.dbus_proxy.DBusProxy...T gFlags(gio.types.DBusProxyFlags propval)Set `gFlags` property. Params: propval = Flags from the #GDBusProxyFlags enumeration. Returns: Builder instance for fluent chainingT gInterfaceInfo(gio.dbus_interface_info.DBusInterfaceInfo propval)Set `gInterfaceInfo` property. Params: propval = Ensure that interactions with this proxy conform to the given interface. This is mainly to ensure that malformed data received from the other peer i...T gInterfaceName(string propval)Set `gInterfaceName` property. Params: propval = The D-Bus interface name the proxy is for. Returns: Builder instance for fluent chainingT gName(string propval)Set `gName` property. Params: propval = The well-known or unique name that the proxy is for. Returns: Builder instance for fluent chainingT gObjectPath(string propval)Set `gObjectPath` property. Params: propval = The object path the proxy is for. Returns: Builder instance for fluent chaining