Class DBusProxy

All Implemented Interfaces:
PointerInterface
Direct Known Subclasses:
ClientProxy, LocationProxy, ManagerProxy

public class DBusProxy extends Object
#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)

https://docs.gtk.org/gio/class.DBusProxy.html

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newFinishDBusProxy

      public static DBusProxy newFinishDBusProxy(@Nonnull AsyncResult res) throws AllocationError
      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

      public static DBusProxy newForBusFinishDBusProxy(@Nonnull AsyncResult res) throws AllocationError
      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

      public Variant callFinish(@Nonnull AsyncResult res) throws AllocationError
      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

      public Variant getCachedProperty(@Nonnull Str property_name)
      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

      public Variant getCachedProperty(String property_name)
      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

      public DBusConnection 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

      public DBusInterfaceInfo 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

      public Str getInterfaceName()
      Gets the D-Bus interface name @proxy is for.
      Returns:
      A string owned by @proxy. Do not free.
    • getName

      public Str 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

      public Str 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

      public Str getObjectPath()
      Gets the object path @proxy is for.
      Returns:
      A string owned by @proxy. Do not free.
    • setCachedProperty

      public void setCachedProperty(@Nonnull Str property_name, @Nullable Variant value)
      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

      public void setCachedProperty(String property_name, @Nullable Variant value)
      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

      public void setInterfaceInfo(@Nullable DBusInterfaceInfo info)
      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

      public SignalHandler onGSignal(DBusProxy.OnGSignal signal)
      Connect to signal "g-signal".
      See DBusProxy.OnGSignal.onGSignal(ch.bailu.gtk.type.Str, ch.bailu.gtk.type.Str, ch.bailu.gtk.glib.Variant) for signal description.
      Field SIGNAL_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

      public AsyncInitable asAsyncInitable()
      Implements interface AsyncInitable. Call this to get access to interface functions.
      Returns:
      AsyncInitable
    • asDBusInterface

      public DBusInterface asDBusInterface()
      Implements interface DBusInterface. Call this to get access to interface functions.
      Returns:
      DBusInterface
    • asInitable

      public Initable asInitable()
      Implements interface Initable. Call this to get access to interface functions.
      Returns:
      Initable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()