DBusProxy

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.ObjectG.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.ObjectG.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`.

class DBusProxy : ObjectG , AsyncInitable , DBusInterface , Initable {}

Members

Functions

call
void call(string methodName, glib.variant.VariantG parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Asynchronously invokes the method_name method on proxy.

callFinish
glib.variant.VariantG callFinish(gio.async_result.AsyncResult res)

Finishes an operation started with gio.dbus_proxy.DBusProxy.call.

callSync
glib.variant.VariantG callSync(string methodName, glib.variant.VariantG parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.cancellable.Cancellable cancellable)

Synchronously invokes the method_name method on proxy.

callWithUnixFdList
void callWithUnixFdList(string methodName, glib.variant.VariantG parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.unix_fdlist.UnixFDList fdList, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Like gio.dbus_proxy.DBusProxy.call but also takes a #GUnixFDList object.

callWithUnixFdListFinish
glib.variant.VariantG callWithUnixFdListFinish(gio.unix_fdlist.UnixFDList outFdList, gio.async_result.AsyncResult res)

Finishes an operation started with gio.dbus_proxy.DBusProxy.callWithUnixFdList.

callWithUnixFdListSync
glib.variant.VariantG callWithUnixFdListSync(string methodName, glib.variant.VariantG parameters, gio.types.DBusCallFlags flags, int timeoutMsec, gio.unix_fdlist.UnixFDList fdList, gio.unix_fdlist.UnixFDList outFdList, gio.cancellable.Cancellable cancellable)

Like gio.dbus_proxy.DBusProxy.callSync but also takes and returns #GUnixFDList objects.

connectGPropertiesChanged
ulong connectGPropertiesChanged(T callback, Flag!"After" after)

Connect to GPropertiesChanged signal.

connectGSignal
ulong connectGSignal(string detail, T callback, Flag!"After" after)

Connect to GSignal signal.

getCachedProperty
glib.variant.VariantG getCachedProperty(string propertyName)

Looks up the value for a property from the cache. This call does no blocking IO.

getCachedPropertyNames
string[] getCachedPropertyNames()

Gets the names of all cached properties on proxy.

getConnection
gio.dbus_connection.DBusConnection getConnection()

Gets the connection proxy is for.

getDefaultTimeout
int getDefaultTimeout()

Gets the timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the gio.dbus_proxy.DBusProxy.call and gio.dbus_proxy.DBusProxy.callSync functions.

getFlags
gio.types.DBusProxyFlags getFlags()

Gets the flags that proxy was constructed with.

getInterfaceInfo
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.

getInterfaceName
string getInterfaceName()

Gets the D-Bus interface name proxy is for.

getName
string getName()

Gets the name that proxy was constructed for.

getNameOwner
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 property.

getObjectPath
string getObjectPath()

Gets the object path proxy is for.

setCachedProperty
void setCachedProperty(string propertyName, glib.variant.VariantG value)

If value is not null, sets the cached value for the property with name property_name to the value in value.

setDefaultTimeout
void setDefaultTimeout(int timeoutMsec)

Sets the timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the gio.dbus_proxy.DBusProxy.call and gio.dbus_proxy.DBusProxy.callSync functions.

setInterfaceInfo
void setInterfaceInfo(gio.dbus_interface_info.DBusInterfaceInfo info)

Ensure that interactions with proxy conform to the given interface. See the #GDBusProxy:g-interface-info property for more details.

Static functions

newFinish
gio.dbus_proxy.DBusProxy newFinish(gio.async_result.AsyncResult res)

Finishes creating a #GDBusProxy.

newForBus
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, gio.types.AsyncReadyCallback callback)

Like gio.dbus_proxy.DBusProxy.new_ but takes a #GBusType instead of a #GDBusConnection.

newForBusFinish
gio.dbus_proxy.DBusProxy newForBusFinish(gio.async_result.AsyncResult res)

Finishes creating a #GDBusProxy.

newForBusSync
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)

Like gio.dbus_proxy.DBusProxy.newSync but takes a #GBusType instead of a #GDBusConnection.

newSync
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)

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 gio.types.DBusProxyFlags.DoNotLoadProperties flag is used.

new_
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, gio.types.AsyncReadyCallback callback)

Creates a proxy for accessing interface_name on the remote object at object_path owned by name at connection and asynchronously loads D-Bus properties unless the gio.types.DBusProxyFlags.DoNotLoadProperties flag is used. Connect to the #GDBusProxy::g-properties-changed signal to get notified about property changes.

Mixed In Members

From mixin AsyncInitableT!()

initAsync
void initAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

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 gio.initable.Initable.init_ instead.

initFinish
bool initFinish(gio.async_result.AsyncResult res)

Finishes asynchronous initialization and returns the result. See gio.async_initable.AsyncInitable.initAsync.

newFinish
gobject.object.ObjectG newFinish(gio.async_result.AsyncResult res)

Finishes the async construction for the various g_async_initable_new calls, returning the created object or null on error.

From mixin DBusInterfaceT!()

getObject
gio.dbus_object.DBusObject getObject()

Gets the #GDBusObject that interface_ belongs to, if any.

getInfo
gio.dbus_interface_info.DBusInterfaceInfo getInfo()

Gets D-Bus introspection information for the D-Bus interface implemented by interface_.

setObject
void setObject(gio.dbus_object.DBusObject object)

Sets the #GDBusObject for interface_ to object.

From mixin InitableT!()

init_
bool init_(gio.cancellable.Cancellable cancellable)

Initializes the object implementing the interface.

Inherited Members

From ObjectG

setGObject
void setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectG wrapper.

cPtr
void* cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

ref_
void* ref_(void* gObj)

Calls g_object_ref() on a GObject.

unref
unref(void* gObj)

Calls g_object_unref() on a GObject.

getType
GType getType()

Get the GType of an object.

gType
GType gType [@property getter]

GObject GType property.

self
ObjectG self()

Convenience method to return this cast to a type. For use in D with statements.

getDObject
T getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
ulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectG target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectG target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectG.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectG.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectG.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectG refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectG.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectG.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectG.ref_ and gobject.object.ObjectG.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
ulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.

From AsyncInitable

newvAsync
void newvAsync(gobject.types.GType objectType, uint nParameters, gobject.parameter.Parameter parameters, int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

Helper function for constructing #GAsyncInitable object. This is similar to gobject.object.ObjectG.newv but also initializes the object asynchronously.

initAsync
void initAsync(int ioPriority, gio.cancellable.Cancellable cancellable, gio.types.AsyncReadyCallback callback)

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 gio.initable.Initable.init_ instead.

initFinish
bool initFinish(gio.async_result.AsyncResult res)

Finishes asynchronous initialization and returns the result. See gio.async_initable.AsyncInitable.initAsync.

newFinish
gobject.object.ObjectG newFinish(gio.async_result.AsyncResult res)

Finishes the async construction for the various g_async_initable_new calls, returning the created object or null on error.

From DBusInterface

getObject
gio.dbus_object.DBusObject getObject()

Gets the #GDBusObject that interface_ belongs to, if any.

getInfo
gio.dbus_interface_info.DBusInterfaceInfo getInfo()

Gets D-Bus introspection information for the D-Bus interface implemented by interface_.

setObject
void setObject(gio.dbus_object.DBusObject object)

Sets the #GDBusObject for interface_ to object.

From Initable

init_
bool init_(gio.cancellable.Cancellable cancellable)

Initializes the object implementing the interface.