It derives from <GObject>.
<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 <GDBusProxyFlags> 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 dbus-proxy:g-name-owner. Connect to the
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 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 dbus-proxy: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 dbus-proxy:g-properties-changed and
dbus-proxy: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 example shows how this can
easily be done using the ‘gdbus-codegen‘ tool.
A <GDBusProxy> instance can be used from
multiple threads but note that all signals (e.g. dbus-proxy:g-signal, dbus-proxy:g-properties-changed and
object:notify) are emitted in
the thread-default main context (see 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‘.
If this property is not none, then
dbus-proxy:g-connection
must be #f and will be set to the
<GDBusConnection> obtained by calling
bus-get with the value of this property.
Its value is a <GBusType>, or one of its symbols.
It can only be set when the object is made, with #:g-bus-type. It
cannot be read.
The <GDBusConnection> the proxy is for.
Its value is a <GDBusConnection>, or
#f.
It can only be set when the object is made, with #:g-connection.
The timeout to use if -1 (specifying default timeout) is passed as
timeout-msec in the dbus-proxy:call
and dbus-proxy:call-sync functions.
This allows applications to set a proxy-wide timeout for all remote
method invocations on the proxy. If this property is -1, the default
timeout (typically 25 seconds) is used. If set to G_MAXINT, then
no timeout is used.
Its value is a 32-bit integer.
Set it with (set! (dbus-proxy:g-default-timeout self) value).
Flags from the <GDBusProxyFlags>
enumeration.
Its value is a <GDBusProxyFlags> (or, to
set it, a list of its symbols, or one of them).
It can only be set when the object is made, with #:g-flags.
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. The given
<GDBusInterfaceInfo> is said to be the
"expected interface".
The checks performed are:
<GError> is set to
invalid-argument.
g_warning().
GetAll() call or via the
::PropertiesChanged signal (on the
org.freedesktop.DBus.Properties
interface) or set using dbus-proxy:set-cached-property with a type
signature mismatch are ignored and a warning is logged via
g_warning().
Note that these checks are never done on methods, signals and properties
that are not referenced in the given
<GDBusInterfaceInfo>, since extending a
D-Bus interface on the service-side is not considered an ABI break.
Its value is a <GDBusInterfaceInfo>, or
#f.
Set it with (set! (dbus-proxy:g-interface-info self) value).
The D-Bus interface name the proxy is for.
Its value is a string, or #f.
It can only be set when the object is made, with
#:g-interface-name.
The well-known or unique name that the proxy is for.
Its value is a string, or #f.
It can only be set when the object is made, with #:g-name.
The unique name that owns dbus-proxy:g-name or #f if no-one currently owns that
name. You may connect to object:notify signal to track changes to this
property.
Its value is a string, or #f.
It is read only.
The object path the proxy is for.
Its value is a string, or #f.
It can only be set when the object is made, with #:g-object-path.
Asynchronously invokes the method-name method on self.
If method-name contains any dots, then name is split into interface and method name parts. This allows using self for invoking methods on other interfaces.
If the <GDBusConnection> associated with
self is closed then the operation will fail with
closed. If cancellable is canceled, the
operation will fail with cancelled. If
parameters contains a value not compatible with the D-Bus
protocol, the operation fails with
invalid-argument.
If the parameters <GVariant> is
floating, it is consumed. This allows convenient ’inline’ use of
g_variant_new(), e.g.:
g_dbus_proxy_call (proxy,
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
(GAsyncReadyCallback) two_strings_done,
&data);
If self has an expected interface (see dbus-proxy:g-interface-info) and
method-name is referenced by it, then the return value is checked
against the return type.
This is an asynchronous method. When the operation is finished,
callback will be invoked in the thread-default main context (see
main-context:push-thread-default) of the
thread you are calling this method from. You can then call
dbus-proxy:call-finish to get the
result of the operation. See dbus-proxy:call-sync for the synchronous version of this
method.
If callback is #f then the D-Bus method call message will
be sent with the no-reply-expected flag
set.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a string.
Name of method to invoke.
Passed: a <GVariant>, or #f.
A <GVariant> tuple with parameters for the
signal or #f if not passing parameters.
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
Flags from the <GDBusCallFlags> enumeration.
Passed: a 32-bit integer.
The timeout in milliseconds (with G_MAXINT meaning "infinite") or
-1 to use the proxy default timeout.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Passed, or left out: a procedure, or #f.
A GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t care about the result of
the method invocation.
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
The data to pass to callback.
Finishes an operation started with dbus-proxy:call.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a <GAsyncResult>.
A <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-proxy:call.
Returned: a <GVariant>.
#f if error is set. Otherwise a
<GVariant> tuple with return values. Free
with variant:unref.
Synchronously invokes the method-name method on self.
If method-name contains any dots, then name is split into interface and method name parts. This allows using self for invoking methods on other interfaces.
If the <GDBusConnection> associated with
self is disconnected then the operation will fail with
closed. If cancellable is canceled, the
operation will fail with cancelled. If
parameters contains a value not compatible with the D-Bus
protocol, the operation fails with
invalid-argument.
If the parameters <GVariant> is
floating, it is consumed. This allows convenient ’inline’ use of
g_variant_new(), e.g.:
g_dbus_proxy_call_sync (proxy,
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
The calling thread is blocked until a reply is received. See
dbus-proxy:call for the asynchronous
version of this method.
If self has an expected interface (see dbus-proxy:g-interface-info) and
method-name is referenced by it, then the return value is checked
against the return type.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a string.
Name of method to invoke.
Passed: a <GVariant>, or #f.
A <GVariant> tuple with parameters for the
signal or #f if not passing parameters.
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
Flags from the <GDBusCallFlags> enumeration.
Passed: a 32-bit integer.
The timeout in milliseconds (with G_MAXINT meaning "infinite") or
-1 to use the proxy default timeout.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Returned: a <GVariant>.
#f if error is set. Otherwise a
<GVariant> tuple with return values. Free
with variant:unref.
Like dbus-proxy:call but also takes a
<GUnixFDList> object.
This method is only available on UNIX.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a string.
Name of method to invoke.
Passed: a <GVariant>, or #f.
A <GVariant> tuple with parameters for the
signal or #f if not passing parameters.
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
Flags from the <GDBusCallFlags> enumeration.
Passed: a 32-bit integer.
The timeout in milliseconds (with G_MAXINT meaning "infinite") or
-1 to use the proxy default timeout.
Passed, or left out: a <GUnixFDList>, or
#f.
A <GUnixFDList> or #f.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Passed, or left out: a procedure, or #f.
A GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t care about the result of
the method invocation.
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
The data to pass to callback.
Finishes an operation started with dbus-proxy:call-with-unix-fd-list.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a <GAsyncResult>.
A <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-proxy:call-with-unix-fd-list.
Returned: a <GVariant>.
#f if error is set. Otherwise a
<GVariant> tuple with return values. Free
with variant:unref.
Returned: a <GUnixFDList>, or #f.
Return location for a <GUnixFDList> or
#f.
Like dbus-proxy:call-sync but also
takes and returns <GUnixFDList> objects.
This method is only available on UNIX.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a string.
Name of method to invoke.
Passed: a <GVariant>, or #f.
A <GVariant> tuple with parameters for the
signal or #f if not passing parameters.
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
Flags from the <GDBusCallFlags> enumeration.
Passed: a 32-bit integer.
The timeout in milliseconds (with G_MAXINT meaning "infinite") or
-1 to use the proxy default timeout.
Passed, or left out: a <GUnixFDList>, or
#f.
A <GUnixFDList> or #f.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Returned: a <GVariant>.
#f if error is set. Otherwise a
<GVariant> tuple with return values. Free
with variant:unref.
Returned: a <GUnixFDList>, or #f.
Return location for a <GUnixFDList> or
#f.
Looks up the value for a property from the cache. This call does no blocking IO.
If self has an expected interface (see dbus-proxy:g-interface-info) and
property-name is referenced by it, then value is checked
against the type of the property.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a string.
Property name.
Returned: a <GVariant>, or #f.
A reference to the <GVariant> instance that
holds the value for property-name or #f if the value is not
in the cache. The returned reference must be freed with
variant:unref.
Gets the names of all cached properties on self.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a vector, each a string, or #f.
A #f-terminated array of strings or #f if self has
no cached properties. Free the returned array with
strfreev.
Gets the connection self is for.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a <GDBusConnection>.
A <GDBusConnection> owned by self. Do
not free.
Gets the timeout to use if -1 (specifying default timeout) is passed as
timeout-msec in the dbus-proxy:call
and dbus-proxy:call-sync functions.
See the dbus-proxy:g-default-timeout property for more
details.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a 32-bit integer.
Timeout to use for self.
Gets the flags that self was constructed with.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a <GDBusProxyFlags>.
Flags from the <GDBusProxyFlags>
enumeration.
Returns the <GDBusInterfaceInfo>, if
any, specifying the interface that self conforms to. See the
dbus-proxy:g-interface-info property for more
details.
Passed: a <GDBusProxy>.
Returned: a <GDBusInterfaceInfo>, or
#f.
A <GDBusInterfaceInfo> or #f. Do
not unref the returned object, it is owned by self.
Gets the D-Bus interface name self is for.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a string.
A string owned by self. Do not free.
Gets the name that self was constructed for.
When connected to a message bus, this will usually be non-#f.
However, it may be #f for a proxy that communicates using a
peer-to-peer pattern.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a string, or #f.
A string owned by self. Do not free.
The unique name that owns the name that self is for or #f
if no-one currently owns that name. You may connect to the
object:notify signal to track
changes to the dbus-proxy:g-name-owner property.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a string, or #f.
The name owner or #f if no name owner exists. Free with
byte-array:free.
Gets the object path self is for.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Returned: a string.
A string owned by self. Do not free.
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
do-not-load-properties flag is used.
Connect to the dbus-proxy:g-properties-changed signal to get
notified about property changes.
If the do-not-connect-signals flag is not
set, also sets up match rules for signals. Connect to the
dbus-proxy:g-signal signal to
handle signals from the remote object.
If both do-not-load-properties and
do-not-connect-signals are set, this
constructor is guaranteed to complete immediately without blocking.
If name is a well-known name and the
do-not-auto-start and
do-not-auto-start-at-construction flags
aren’t set and no name owner currently exists, the message bus will be
requested to launch a name owner for the name.
This is a failable asynchronous constructor - when the proxy is ready,
callback will be invoked and you can use dbus-proxy:new-finish to get the result.
See dbus-proxy:new-sync and for a
synchronous version of this constructor.
<GDBusProxy> is used in this
[example][class@Gio.DBusProxy#a-watch-proxy-example].
Passed: a <GDBusConnection>.
Passed: a <GDBusProxyFlags>, or a list of
its symbols, or one of them.
Flags used when constructing the proxy.
Passed: a <GDBusInterfaceInfo>, or
#f.
A <GDBusInterfaceInfo> specifying the
minimal interface that proxy conforms to or #f.
Passed: a string, or #f.
A bus name (well-known or unique) or #f if connection is
not a message bus connection.
Passed: a string.
An object path.
Passed: a string.
A D-Bus interface name.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Passed, or left out: a procedure, or #f.
Callback function to invoke when the proxy is ready.
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
User data to pass to callback.
Finishes creating a <GDBusProxy>.
Passed: a <GAsyncResult>.
A <GAsyncResult> obtained from the
GAsyncReadyCallback function passed to
dbus-proxy:new.
Returned: a <GDBusProxy>.
A <GDBusProxy> or #f if error is
set. Free with object:unref.
Like dbus-proxy:new but takes a
<GBusType> instead of a
<GDBusConnection>.
<GDBusProxy> is used in this
[example][class@Gio.DBusProxy#a-watch-proxy-example].
Passed: a <GBusType>, or one of its symbols.
A <GBusType>.
Passed: a <GDBusProxyFlags>, or a list of
its symbols, or one of them.
Flags used when constructing the proxy.
Passed: a <GDBusInterfaceInfo>, or
#f.
A <GDBusInterfaceInfo> specifying the
minimal interface that proxy conforms to or #f.
Passed: a string.
A bus name (well-known or unique).
Passed: a string.
An object path.
Passed: a string.
A D-Bus interface name.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Passed, or left out: a procedure, or #f.
Callback function to invoke when the proxy is ready.
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
User data to pass to callback.
Finishes creating a <GDBusProxy>.
Passed: a <GAsyncResult>.
A <GAsyncResult> obtained from the
GAsyncReadyCallback function passed to
dbus-proxy:new-for-bus.
Returned: a <GDBusProxy>.
A <GDBusProxy> or #f if error is
set. Free with object:unref.
Like dbus-proxy:new-sync but takes a
<GBusType> instead of a
<GDBusConnection>.
<GDBusProxy> is used in this
[example][class@Gio.DBusProxy#a-watch-proxy-example].
Passed: a <GBusType>, or one of its symbols.
A <GBusType>.
Passed: a <GDBusProxyFlags>, or a list of
its symbols, or one of them.
Flags used when constructing the proxy.
Passed: a <GDBusInterfaceInfo>, or
#f.
A <GDBusInterfaceInfo> specifying the
minimal interface that proxy conforms to or #f.
Passed: a string.
A bus name (well-known or unique).
Passed: a string.
An object path.
Passed: a string.
A D-Bus interface name.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Returned: a <GDBusProxy>.
A <GDBusProxy> or #f if error is set.
Free with object:unref.
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
do-not-load-properties flag is used.
If the do-not-connect-signals flag is not
set, also sets up match rules for signals. Connect to the
dbus-proxy:g-signal signal to
handle signals from the remote object.
If both do-not-load-properties and
do-not-connect-signals are set, this
constructor is guaranteed to return immediately without blocking.
If name is a well-known name and the
do-not-auto-start and
do-not-auto-start-at-construction flags
aren’t set and no name owner currently exists, the message bus will be
requested to launch a name owner for the name.
This is a synchronous failable constructor. See dbus-proxy:new and dbus-proxy:new-finish for the asynchronous version.
<GDBusProxy> is used in this
[example][class@Gio.DBusProxy#a-watch-proxy-example].
Passed: a <GDBusConnection>.
Passed: a <GDBusProxyFlags>, or a list of
its symbols, or one of them.
Flags used when constructing the proxy.
Passed: a <GDBusInterfaceInfo>, or
#f.
A <GDBusInterfaceInfo> specifying the
minimal interface that proxy conforms to or #f.
Passed: a string, or #f.
A bus name (well-known or unique) or #f if connection is
not a message bus connection.
Passed: a string.
An object path.
Passed: a string.
A D-Bus interface name.
Passed, or left out: a <GCancellable>, or
#f.
A <GCancellable> or #f.
Returned: a <GDBusProxy>.
A <GDBusProxy> or #f if error is set.
Free with object:unref.
If value is not #f, sets the cached value for the property
with name property-name to the value in value.
If value is #f, then the cached value is removed from the
property cache.
If self has an expected interface (see dbus-proxy:g-interface-info) and
property-name is referenced by it, then value is checked
against the type of the property.
If the value <GVariant> is floating, it
is consumed. This allows convenient ’inline’ use of
g_variant_new(), e.g.
g_dbus_proxy_set_cached_property (proxy,
"SomeProperty",
g_variant_new ("(si)",
"A String",
42));
Normally you will not need to use this method since self is
tracking changes using the
org.freedesktop.DBus.Properties.PropertiesChanged D-Bus signal.
However, for performance reasons an object may decide to not use this
signal for some properties and instead use a proprietary out-of-band
mechanism to transmit changes.
As a concrete example, consider an object with a property
ChatroomParticipants which is an array of strings. Instead of
transmitting the same (long) array every time the property changes, it
is more efficient to only transmit the delta using e.g. signals
ChatroomParticipantJoined(String name) and
ChatroomParticipantParted(String name).
Passed: a <GDBusProxy>.
Passed: a string.
Property name.
Passed, or left out: a <GVariant>, or
#f.
Value for the property or #f to remove it from the cache.
Sets the timeout to use if -1 (specifying default timeout) is passed as
timeout-msec in the dbus-proxy:call
and dbus-proxy:call-sync functions.
See the dbus-proxy:g-default-timeout property for more
details.
Passed: a <GDBusProxy>.
A <GDBusProxy>.
Passed: a 32-bit integer.
Timeout in milliseconds.
Ensure that interactions with self conform to the given interface.
See the dbus-proxy:g-interface-info property for more
details.
Passed: a <GDBusProxy>.
Passed, or left out: a
<GDBusInterfaceInfo>, or #f.
Minimum interface this proxy conforms to or #f to unset.
Connect a handler with (connect object
dbus-proxy:g-properties-changed handler). It is called as
(handler self changed-properties invalidated-properties).
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 #f (either may be empty though).
If the proxy has the flag
get-invalidated-properties set, then
invalidated-properties will always be empty.
This signal corresponds to the PropertiesChanged D-Bus signal on
the org.freedesktop.DBus.Properties interface.
Passed: a <GDBusProxy>.
Passed: a <GVariant>.
A <GVariant> containing the properties that
changed (type: a{sv})
Passed: a vector, each a string.
A #f terminated array of properties that was invalidated
Connect a handler with (connect object dbus-proxy:g-signal
handler). It is called as (handler self sender-name signal-name
parameters).
Emitted when a signal from the remote object and interface that proxy is for, has been received.
Since 2.72 this signal supports detailed connections. You can connect
to the detailed signal g-signal::x in order to receive callbacks
only when signal x is received from the remote object.
Passed: a <GDBusProxy>.
Passed: a string, or #f.
The sender of the signal or #f if the connection is not a bus
connection.
Passed: a string.
The name of the signal.
Passed: a <GVariant>.
A <GVariant> tuple with parameters for the
signal.
Signal class handler for the dbus-proxy:g-properties-changed signal.
To override it in a new class, give register-type #:vfuncs
`((g-properties-changed . ,procedure)). The procedure is called as
(procedure self changed-properties invalidated-properties).
Passed: the class whose implementation to call:
<GDBusProxy>, or a class that derives from it,
or its GType number.
Passed: a <GDBusProxy>.
Passed: a <GVariant>.
Passed: a string.
Signal class handler for the dbus-proxy:g-signal signal.
To override it in a new class, give register-type #:vfuncs
`((g-signal . ,procedure)). The procedure is called as
(procedure self sender-name signal-name parameters).
Passed: the class whose implementation to call:
<GDBusProxy>, or a class that derives from it,
or its GType number.
Passed: a <GDBusProxy>.
Passed: a string.
Passed: a string.
Passed: a <GVariant>.