Gio.DBusProxy

const Gio = imports.gi.Gio;

let dBusProxy = new Gio.DBusProxy({
    g_bus_type: value,
    g_connection: value,
    g_default_timeout: value,
    g_flags: value,
    g_interface_name: value,
    g_name: value,
    g_object_path: value,
});
  

Gio.DBusProxy is a base class used for proxies to access a D-Bus interface on a remote object. A Gio.DBusProxy can be constructed for both well-known and unique names.

By default, Gio.DBusProxy will cache all properties (and listen to changes) of the remote object, and proxy all signals that gets emitted. This behaviour can be changed by passing suitable Gio.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.

If a Gio.DBusProxy is used for a well-known name, the owner of the name is tracked and can be read from Gio.DBusProxy.g_name_owner. Connect to the GObject.Object::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.DBusProxyFlags.do_not_auto_start is set).

The generic Gio.DBusProxy::g-properties-changed and Gio.DBusProxy::g-signal signals are not very convenient to work with. Therefore, the recommended way of working with proxies is to subclass Gio.DBusProxy, and have more natural properties and signals in your derived class. This [example][gdbus-example-gdbus-codegen] shows how this can easily be done using the [gdbus-codegen][gdbus-codegen] tool.

A Gio.DBusProxy instance can be used from multiple threads but note that all signals (e.g. Gio.DBusProxy::g-signal, Gio.DBusProxy::g-properties-changed and GObject.Object::notify) are emitted in the [thread-default main context][g-main-context-push-thread-default] 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](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-watch-proxy.c)

Since 2.26

Hierarchy

  • GObject.Object
    • Gio.DBusProxy