Package ch.bailu.gtk.gio
Class DBusProxy
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gio.DBusProxy
- All Implemented Interfaces:
PointerInterface
- Direct Known Subclasses:
ClientProxy
,LocationProxy
,ManagerProxy
#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
#GDBusProxy:g-name-owner. Connect to the #GObject::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 #GDBusProxy: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 #GDBusProxy::g-properties-changed and
#GDBusProxy::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][gdbus-example-gdbus-codegen] shows how this can
easily be done using the [gdbus-codegen][gdbus-codegen] tool.
A #GDBusProxy instance can be used from multiple threads but note
that all signals (e.g. #GDBusProxy::g-signal, #GDBusProxy::g-properties-changed
and #GObject::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://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-watch-proxy.c)
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
#GDBusProxy:g-name-owner. Connect to the #GObject::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 #GDBusProxy: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 #GDBusProxy::g-properties-changed and
#GDBusProxy::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][gdbus-example-gdbus-codegen] shows how this can
easily be done using the [gdbus-codegen][gdbus-codegen] tool.
A #GDBusProxy instance can be used from multiple threads but note
that all signals (e.g. #GDBusProxy::g-signal, #GDBusProxy::g-properties-changed
and #GObject::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://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-watch-proxy.c)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
_new
(DBusConnection connection, int flags, DBusInterfaceInfo info, Str name, Str object_path, Str interface_name, Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, Pointer user_data) 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
%G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.Implements interfaceAsyncInitable
.Implements interfaceDBusInterface
.Implements interfaceInitable
.void
call
(Str method_name, Variant parameters, int flags, int timeout_msec, Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously invokes the @method_name method on @proxy.void
call
(String method_name, Variant parameters, int flags, int timeout_msec, Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously invokes the @method_name method on @proxy.callFinish
(AsyncResult res) Finishes an operation started with g_dbus_proxy_call().callSync
(Str method_name, Variant parameters, int flags, int timeout_msec, Cancellable cancellable) Synchronously invokes the @method_name method on @proxy.callSync
(String method_name, Variant parameters, int flags, int timeout_msec, Cancellable cancellable) Synchronously invokes the @method_name method on @proxy.void
callWithUnixFdList
(Str method_name, Variant parameters, int flags, int timeout_msec, UnixFDList fd_list, Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, Pointer user_data) Like g_dbus_proxy_call() but also takes a #GUnixFDList object.void
callWithUnixFdList
(String method_name, Variant parameters, int flags, int timeout_msec, UnixFDList fd_list, Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, Pointer user_data) Like g_dbus_proxy_call() but also takes a #GUnixFDList object.getCachedProperty
(Str property_name) Looks up the value for a property from the cache.getCachedProperty
(String property_name) Looks up the value for a property from the cache.static ClassHandler
Gets the connection @proxy is for.int
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.int
getFlags()
Gets the flags that @proxy was constructed with.static int
Returns the #GDBusInterfaceInfo, if any, specifying the interface
that @proxy conforms to.Gets the D-Bus interface name @proxy is for.getName()
Gets the name that @proxy was constructed for.The unique name that owns the name that @proxy is for or %NULL if
no-one currently owns that name.Gets the object path @proxy is for.static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
static DBusProxy
Finishes creating a #GDBusProxy.static void
newForBus
(int bus_type, int flags, DBusInterfaceInfo info, Str name, Str object_path, Str interface_name, Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, Pointer user_data) Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection.static DBusProxy
Finishes creating a #GDBusProxy.static DBusProxy
newForBusSyncDBusProxy
(int bus_type, int flags, DBusInterfaceInfo info, Str name, Str object_path, Str interface_name, Cancellable cancellable) Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.static DBusProxy
newForBusSyncDBusProxy
(int bus_type, int flags, DBusInterfaceInfo info, String name, String object_path, String interface_name, Cancellable cancellable) Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.static DBusProxy
newSyncDBusProxy
(DBusConnection connection, int flags, DBusInterfaceInfo info, Str name, Str object_path, Str interface_name, 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
%G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.static DBusProxy
newSyncDBusProxy
(DBusConnection connection, int flags, DBusInterfaceInfo info, String name, String object_path, String interface_name, 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
%G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.onGSignal
(DBusProxy.OnGSignal signal) Connect to signal "g-signal".void
setCachedProperty
(Str property_name, Variant value) If @value is not %NULL, sets the cached value for the property with
name @property_name to the value in @value.void
setCachedProperty
(String property_name, Variant value) If @value is not %NULL, sets the cached value for the property with
name @property_name to the value in @value.void
setDefaultTimeout
(int timeout_msec) 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.void
Ensure that interactions with @proxy conform to the given
interface.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_G_SIGNAL
- See Also:
-
-
Constructor Details
-
DBusProxy
-
-
Method Details
-
getClassHandler
-
newFinishDBusProxy
Finishes creating a #GDBusProxy.- Parameters:
res
- A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to g_dbus_proxy_new().- Returns:
- A #GDBusProxy or %NULL if @error is set. Free with g_object_unref().
- Throws:
AllocationError
-
newForBusFinishDBusProxy
Finishes creating a #GDBusProxy.- Parameters:
res
- A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to g_dbus_proxy_new_for_bus().- Returns:
- A #GDBusProxy or %NULL if @error is set. Free with g_object_unref().
- Throws:
AllocationError
-
newForBusSyncDBusProxy
public static DBusProxy newForBusSyncDBusProxy(int bus_type, int flags, @Nullable DBusInterfaceInfo info, @Nonnull Str name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nullable Cancellable cancellable) throws AllocationError Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
#GDBusProxy is used in this [example][gdbus-wellknown-proxy].- Parameters:
bus_type
- A #GBusType.flags
- Flags used when constructing the proxy.info
- A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.name
- A bus name (well-known or unique).object_path
- An object path.interface_name
- A D-Bus interface name.cancellable
- A #GCancellable or %NULL.- Returns:
- A #GDBusProxy or %NULL if error is set. Free with g_object_unref().
- Throws:
AllocationError
-
newForBusSyncDBusProxy
public static DBusProxy newForBusSyncDBusProxy(int bus_type, int flags, @Nullable DBusInterfaceInfo info, String name, String object_path, String interface_name, @Nullable Cancellable cancellable) throws AllocationError Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
#GDBusProxy is used in this [example][gdbus-wellknown-proxy].- Parameters:
bus_type
- A #GBusType.flags
- Flags used when constructing the proxy.info
- A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.name
- A bus name (well-known or unique).object_path
- An object path.interface_name
- A D-Bus interface name.cancellable
- A #GCancellable or %NULL.- Returns:
- A #GDBusProxy or %NULL if error is set. Free with g_object_unref().
- Throws:
AllocationError
-
newSyncDBusProxy
public static DBusProxy newSyncDBusProxy(@Nonnull DBusConnection connection, int flags, @Nullable DBusInterfaceInfo info, @Nullable Str name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nullable Cancellable cancellable) throws AllocationError 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.
If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up
match rules for signals. Connect to the #GDBusProxy::g-signal signal
to handle signals from the remote object.
If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and
%G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is
guaranteed to return immediately without blocking.
If @name is a well-known name and the
%G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_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 g_dbus_proxy_new()
and g_dbus_proxy_new_finish() for the asynchronous version.
#GDBusProxy is used in this [example][gdbus-wellknown-proxy].- Parameters:
connection
- A #GDBusConnection.flags
- Flags used when constructing the proxy.info
- A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.name
- A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.object_path
- An object path.interface_name
- A D-Bus interface name.cancellable
- A #GCancellable or %NULL.- Returns:
- A #GDBusProxy or %NULL if error is set. Free with g_object_unref().
- Throws:
AllocationError
-
newSyncDBusProxy
public static DBusProxy newSyncDBusProxy(@Nonnull DBusConnection connection, int flags, @Nullable DBusInterfaceInfo info, String name, String object_path, String interface_name, @Nullable Cancellable cancellable) throws AllocationError 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.
If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up
match rules for signals. Connect to the #GDBusProxy::g-signal signal
to handle signals from the remote object.
If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and
%G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is
guaranteed to return immediately without blocking.
If @name is a well-known name and the
%G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_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 g_dbus_proxy_new()
and g_dbus_proxy_new_finish() for the asynchronous version.
#GDBusProxy is used in this [example][gdbus-wellknown-proxy].- Parameters:
connection
- A #GDBusConnection.flags
- Flags used when constructing the proxy.info
- A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.name
- A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.object_path
- An object path.interface_name
- A D-Bus interface name.cancellable
- A #GCancellable or %NULL.- Returns:
- A #GDBusProxy or %NULL if error is set. Free with g_object_unref().
- Throws:
AllocationError
-
call
public void call(@Nonnull Str method_name, @Nullable Variant parameters, int flags, int timeout_msec, @Nullable Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously invokes the @method_name method on @proxy.
If @method_name contains any dots, then @name is split into interface and
method name parts. This allows using @proxy for invoking methods on
other interfaces.
If the #GDBusConnection associated with @proxy is closed then
the operation will fail with %G_IO_ERROR_CLOSED. If
@cancellable is canceled, the operation will fail with
%G_IO_ERROR_CANCELLED. If @parameters contains a value not
compatible with the D-Bus protocol, the operation fails with
%G_IO_ERROR_INVALID_ARGUMENT.
If the @parameters #GVariant is floating, it is consumed. This allows
convenient 'inline' use of g_variant_new(), e.g.:<!-- language="C" --> 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 @proxy has an expected interface (see
#GDBusProxy: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][g-main-context-push-thread-default]
of the thread you are calling this method from.
You can then call g_dbus_proxy_call_finish() to get the result of
the operation. See g_dbus_proxy_call_sync() for the synchronous
version of this method.
If @callback is %NULL then the D-Bus method call message will be sent with
the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set.- Parameters:
method_name
- Name of method to invoke.parameters
- A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.flags
- Flags from the #GDBusCallFlags enumeration.timeout_msec
- The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout.cancellable
- A #GCancellable or %NULL.callback
- A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't care about the result of the method invocation.user_data
- The data to pass to @callback.
-
call
public void call(String method_name, @Nullable Variant parameters, int flags, int timeout_msec, @Nullable Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously invokes the @method_name method on @proxy.
If @method_name contains any dots, then @name is split into interface and
method name parts. This allows using @proxy for invoking methods on
other interfaces.
If the #GDBusConnection associated with @proxy is closed then
the operation will fail with %G_IO_ERROR_CLOSED. If
@cancellable is canceled, the operation will fail with
%G_IO_ERROR_CANCELLED. If @parameters contains a value not
compatible with the D-Bus protocol, the operation fails with
%G_IO_ERROR_INVALID_ARGUMENT.
If the @parameters #GVariant is floating, it is consumed. This allows
convenient 'inline' use of g_variant_new(), e.g.:<!-- language="C" --> 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 @proxy has an expected interface (see
#GDBusProxy: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][g-main-context-push-thread-default]
of the thread you are calling this method from.
You can then call g_dbus_proxy_call_finish() to get the result of
the operation. See g_dbus_proxy_call_sync() for the synchronous
version of this method.
If @callback is %NULL then the D-Bus method call message will be sent with
the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set.- Parameters:
method_name
- Name of method to invoke.parameters
- A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.flags
- Flags from the #GDBusCallFlags enumeration.timeout_msec
- The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout.cancellable
- A #GCancellable or %NULL.callback
- A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't care about the result of the method invocation.user_data
- The data to pass to @callback.
-
callFinish
Finishes an operation started with g_dbus_proxy_call().- Parameters:
res
- A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call().- Returns:
- %NULL if @error is set. Otherwise a #GVariant tuple with return values. Free with g_variant_unref().
- Throws:
AllocationError
-
callSync
public Variant callSync(@Nonnull Str method_name, @Nullable Variant parameters, int flags, int timeout_msec, @Nullable Cancellable cancellable) throws AllocationError Synchronously invokes the @method_name method on @proxy.
If @method_name contains any dots, then @name is split into interface and
method name parts. This allows using @proxy for invoking methods on
other interfaces.
If the #GDBusConnection associated with @proxy is disconnected then
the operation will fail with %G_IO_ERROR_CLOSED. If
@cancellable is canceled, the operation will fail with
%G_IO_ERROR_CANCELLED. If @parameters contains a value not
compatible with the D-Bus protocol, the operation fails with
%G_IO_ERROR_INVALID_ARGUMENT.
If the @parameters #GVariant is floating, it is consumed. This allows
convenient 'inline' use of g_variant_new(), e.g.:<!-- language="C" --> 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
g_dbus_proxy_call() for the asynchronous version of this
method.
If @proxy has an expected interface (see
#GDBusProxy:g-interface-info) and @method_name is referenced by it,
then the return value is checked against the return type.- Parameters:
method_name
- Name of method to invoke.parameters
- A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.flags
- Flags from the #GDBusCallFlags enumeration.timeout_msec
- The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout.cancellable
- A #GCancellable or %NULL.- Returns:
- %NULL if @error is set. Otherwise a #GVariant tuple with return values. Free with g_variant_unref().
- Throws:
AllocationError
-
callSync
public Variant callSync(String method_name, @Nullable Variant parameters, int flags, int timeout_msec, @Nullable Cancellable cancellable) throws AllocationError Synchronously invokes the @method_name method on @proxy.
If @method_name contains any dots, then @name is split into interface and
method name parts. This allows using @proxy for invoking methods on
other interfaces.
If the #GDBusConnection associated with @proxy is disconnected then
the operation will fail with %G_IO_ERROR_CLOSED. If
@cancellable is canceled, the operation will fail with
%G_IO_ERROR_CANCELLED. If @parameters contains a value not
compatible with the D-Bus protocol, the operation fails with
%G_IO_ERROR_INVALID_ARGUMENT.
If the @parameters #GVariant is floating, it is consumed. This allows
convenient 'inline' use of g_variant_new(), e.g.:<!-- language="C" --> 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
g_dbus_proxy_call() for the asynchronous version of this
method.
If @proxy has an expected interface (see
#GDBusProxy:g-interface-info) and @method_name is referenced by it,
then the return value is checked against the return type.- Parameters:
method_name
- Name of method to invoke.parameters
- A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.flags
- Flags from the #GDBusCallFlags enumeration.timeout_msec
- The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout.cancellable
- A #GCancellable or %NULL.- Returns:
- %NULL if @error is set. Otherwise a #GVariant tuple with return values. Free with g_variant_unref().
- Throws:
AllocationError
-
callWithUnixFdList
public void callWithUnixFdList(@Nonnull Str method_name, @Nullable Variant parameters, int flags, int timeout_msec, @Nullable UnixFDList fd_list, @Nullable Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Like g_dbus_proxy_call() but also takes a #GUnixFDList object.
This method is only available on UNIX.- Parameters:
method_name
- Name of method to invoke.parameters
- A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.flags
- Flags from the #GDBusCallFlags enumeration.timeout_msec
- The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout.fd_list
- A #GUnixFDList or %NULL.cancellable
- A #GCancellable or %NULL.callback
- A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't care about the result of the method invocation.user_data
- The data to pass to @callback.
-
callWithUnixFdList
public void callWithUnixFdList(String method_name, @Nullable Variant parameters, int flags, int timeout_msec, @Nullable UnixFDList fd_list, @Nullable Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Like g_dbus_proxy_call() but also takes a #GUnixFDList object.
This method is only available on UNIX.- Parameters:
method_name
- Name of method to invoke.parameters
- A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.flags
- Flags from the #GDBusCallFlags enumeration.timeout_msec
- The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout.fd_list
- A #GUnixFDList or %NULL.cancellable
- A #GCancellable or %NULL.callback
- A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't care about the result of the method invocation.user_data
- The data to pass to @callback.
-
getCachedProperty
Looks up the value for a property from the cache. This call does no
blocking IO.
If @proxy has an expected interface (see
#GDBusProxy:g-interface-info) and @property_name is referenced by
it, then @value is checked against the type of the property.- Parameters:
property_name
- Property name.- Returns:
- A reference to the #GVariant instance that holds the value for @property_name or %NULL if the value is not in the cache. The returned reference must be freed with g_variant_unref().
-
getCachedProperty
Looks up the value for a property from the cache. This call does no
blocking IO.
If @proxy has an expected interface (see
#GDBusProxy:g-interface-info) and @property_name is referenced by
it, then @value is checked against the type of the property.- Parameters:
property_name
- Property name.- Returns:
- A reference to the #GVariant instance that holds the value for @property_name or %NULL if the value is not in the cache. The returned reference must be freed with g_variant_unref().
-
getConnection
Gets the connection @proxy is for.- Returns:
- A #GDBusConnection owned by @proxy. Do not free.
-
getDefaultTimeout
public int getDefaultTimeout()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.
See the #GDBusProxy:g-default-timeout property for more details.- Returns:
- Timeout to use for @proxy.
-
getFlags
public int getFlags()Gets the flags that @proxy was constructed with.- Returns:
- Flags from the #GDBusProxyFlags enumeration.
-
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 not unref the returned object, it is owned by @proxy.
-
getInterfaceName
Gets the D-Bus interface name @proxy is for.- Returns:
- A string owned by @proxy. Do not free.
-
getName
Gets the name that @proxy was constructed for.
When connected to a message bus, this will usually be non-%NULL.
However, it may be %NULL for a proxy that communicates using a peer-to-peer
pattern.- Returns:
- A string owned by @proxy. Do not free.
-
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.- Returns:
- The name owner or %NULL if no name owner exists. Free with g_free().
-
getObjectPath
Gets the object path @proxy is for.- Returns:
- A string owned by @proxy. Do not free.
-
setCachedProperty
If @value is not %NULL, sets the cached value for the property with
name @property_name to the value in @value.
If @value is %NULL, then the cached value is removed from the
property cache.
If @proxy has an expected interface (see
#GDBusProxy: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.<!-- language="C" --> 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 @proxy
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)`.- Parameters:
property_name
- Property name.value
- Value for the property or %NULL to remove it from the cache.
-
setCachedProperty
If @value is not %NULL, sets the cached value for the property with
name @property_name to the value in @value.
If @value is %NULL, then the cached value is removed from the
property cache.
If @proxy has an expected interface (see
#GDBusProxy: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.<!-- language="C" --> 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 @proxy
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)`.- Parameters:
property_name
- Property name.value
- Value for the property or %NULL to remove it from the cache.
-
setDefaultTimeout
public void setDefaultTimeout(int timeout_msec) 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.
See the #GDBusProxy:g-default-timeout property for more details.- Parameters:
timeout_msec
- Timeout in milliseconds.
-
setInterfaceInfo
Ensure that interactions with @proxy conform to the given
interface. See the #GDBusProxy:g-interface-info property for more
details.- Parameters:
info
- Minimum interface this proxy conforms to or %NULL to unset.
-
onGSignal
Connect to signal "g-signal".
SeeDBusProxy.OnGSignal.onGSignal(ch.bailu.gtk.type.Str, ch.bailu.gtk.type.Str, ch.bailu.gtk.glib.Variant)
for signal description.
FieldSIGNAL_ON_G_SIGNAL
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
_new
public static void _new(@Nonnull DBusConnection connection, int flags, @Nullable DBusInterfaceInfo info, @Nullable Str name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nullable Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, @Nullable Pointer user_data) 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
%G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. Connect to
the #GDBusProxy::g-properties-changed signal to get notified about
property changes.
If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up
match rules for signals. Connect to the #GDBusProxy::g-signal signal
to handle signals from the remote object.
If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and
%G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is
guaranteed to complete immediately without blocking.
If @name is a well-known name and the
%G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_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
g_dbus_proxy_new_finish() to get the result.
See g_dbus_proxy_new_sync() and for a synchronous version of this constructor.
#GDBusProxy is used in this [example][gdbus-wellknown-proxy].- Parameters:
connection
- A #GDBusConnection.flags
- Flags used when constructing the proxy.info
- A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.name
- A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.object_path
- An object path.interface_name
- A D-Bus interface name.cancellable
- A #GCancellable or %NULL.callback
- Callback function to invoke when the proxy is ready.user_data
- User data to pass to @callback.
-
newForBus
public static void newForBus(int bus_type, int flags, @Nullable DBusInterfaceInfo info, @Nonnull Str name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nullable Cancellable cancellable, DBusProxy.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
#GDBusProxy is used in this [example][gdbus-wellknown-proxy].- Parameters:
bus_type
- A #GBusType.flags
- Flags used when constructing the proxy.info
- A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.name
- A bus name (well-known or unique).object_path
- An object path.interface_name
- A D-Bus interface name.cancellable
- A #GCancellable or %NULL.callback
- Callback function to invoke when the proxy is ready.user_data
- User data to pass to @callback.
-
asAsyncInitable
Implements interfaceAsyncInitable
. Call this to get access to interface functions.- Returns:
AsyncInitable
-
asDBusInterface
Implements interfaceDBusInterface
. Call this to get access to interface functions.- Returns:
DBusInterface
-
asInitable
Implements interfaceInitable
. Call this to get access to interface functions.- Returns:
Initable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-