DBusProxy
GDBusProxy
is a base class used for proxies to access a D-Bus interface on a remote object. A GDBusProxy
can be constructed for both well-known and unique names.
By default, GDBusProxy
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 flags@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.
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 signal@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 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START
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 GDBusProxy
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 GDBusProxy
— 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 GDBusProxy
, and have more natural properties and signals in your derived class. This migrating-gdbus.html#using-gdbus-codegen shows how this can easily be done using the gdbus-codegen.html tool.
A GDBusProxy
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 signal@GObject.Object::notify) are emitted in the thread-default main context (see method@GLib.MainContext.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
.
Skipped during bindings generation
parameter
out_fd_list
: out_fd_list: Out parameter is not supportedparameter
out_fd_list
: out_fd_list: Out parameter is not supportedmethod
g-bus-type
: Property has no getter nor settermethod
g-connection
: Property has no getter nor settermethod
g-default-timeout
: Property has no getter nor settermethod
g-flags
: Property has no getter nor settermethod
g-interface-info
: Property has no getter nor settermethod
g-interface-name
: Property has no getter nor settermethod
g-name
: Property has no getter nor settermethod
g-name-owner
: Property has no getter nor settermethod
g-object-path
: Property has no getter nor setter
Since
2.26
Constructors
Finishes creating a #GDBusProxy.
Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
Creates a proxy for accessing @interface_name on the remote object at @object_path owned by @name at @connection and synchronously loads D-Bus properties unless the %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.
Properties
Functions
Asynchronously invokes the @method_name method on @proxy.
Finishes an operation started with g_dbus_proxy_call().
Synchronously invokes the @method_name method on @proxy.
Like g_dbus_proxy_call() but also takes a #GUnixFDList object.
Emitted when one or more D-Bus properties on @proxy changes. The local cache has already been updated when this signal fires. Note that both @changed_properties and @invalidated_properties are guaranteed to never be null (either may be empty though).
Emitted when a signal from the remote object and interface that @proxy is for, has been received.
Looks up the value for a property from the cache. This call does no blocking IO.
Gets the names of all cached properties on @proxy.
Gets the connection @proxy is for.
Gets the timeout to use if -1 (specifying default timeout) is passed as @timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
Gets the flags that @proxy was constructed with.
Gets D-Bus introspection information for the D-Bus interface implemented by @interface_.
Returns the #GDBusInterfaceInfo, if any, specifying the interface that @proxy conforms to. See the #GDBusProxy:g-interface-info property for more details.
Gets the D-Bus interface name @proxy is for.
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 property.
Gets the #GDBusObject that @interface_ belongs to, if any.
Gets the object path @proxy is for.
Initializes the object implementing the interface.
Starts asynchronous initialization of the object implementing the interface. This must be done before any real use of the object after initial construction. If the object also implements #GInitable you can optionally call g_initable_init() instead.
Finishes asynchronous initialization and returns the result. See g_async_initable_init_async().
Finishes the async construction for the various g_async_initable_new calls, returning the created object or null on error.
If @value is not null, sets the cached value for the property with name @property_name to the value in @value.
Sets the timeout to use if -1 (specifying default timeout) is passed as @timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
Ensure that interactions with @proxy conform to the given interface. See the #GDBusProxy:g-interface-info property for more details.
Sets the #GDBusObject for @interface_ to @object.