Class DBusConnection

All Implemented Interfaces:
PointerInterface

public class DBusConnection extends Object
The #GDBusConnection type is used for D-Bus connections to remote
peers such as a message buses. It is a low-level API that offers a
lot of flexibility. For instance, it lets you establish a connection
over any transport that can by represented as a #GIOStream.

This class is rarely used directly in D-Bus clients. If you are writing
a D-Bus client, it is often easier to use the g_bus_own_name(),
g_bus_watch_name() or g_dbus_proxy_new_for_bus() APIs.

As an exception to the usual GLib rule that a particular object must not
be used by two threads at the same time, #GDBusConnection's methods may be
called from any thread. This is so that g_bus_get() and g_bus_get_sync()
can safely return the same #GDBusConnection when called from any thread.

Most of the ways to obtain a #GDBusConnection automatically initialize it
(i.e. connect to D-Bus): for instance, g_dbus_connection_new() and
g_bus_get(), and the synchronous versions of those methods, give you an
initialized connection. Language bindings for GIO should use
g_initable_new() or g_async_initable_new_async(), which also initialize the
connection.

If you construct an uninitialized #GDBusConnection, such as via
g_object_new(), you must initialize it via g_initable_init() or
g_async_initable_init_async() before using its methods or properties.
Calling methods or accessing properties on a #GDBusConnection that has not
completed initialization successfully is considered to be invalid, and leads
to undefined behaviour. In particular, if initialization fails with a
#GError, the only valid thing you can do with that #GDBusConnection is to
free it with g_object_unref().

## An example D-Bus server # {#gdbus-server}

Here is an example for a D-Bus server:
[gdbus-example-server.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-server.c)

## An example for exporting a subtree # {#gdbus-subtree-server}

Here is an example for exporting a subtree:
[gdbus-example-subtree.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-subtree.c)

## An example for file descriptor passing # {#gdbus-unix-fd-client}

Here is an example for passing UNIX file descriptors:
[gdbus-unix-fd-client.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-unix-fd-client.c)

## An example for exporting a GObject # {#gdbus-export}

Here is an example for exporting a #GObject:
[gdbus-example-export.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-export.c)

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

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newFinishDBusConnection

      public static DBusConnection newFinishDBusConnection(@Nonnull AsyncResult res) throws AllocationError
      Finishes an operation started with g_dbus_connection_new().
      Parameters:
      res - a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_new().
      Returns:
      a #GDBusConnection or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • newForAddressFinishDBusConnection

      public static DBusConnection newForAddressFinishDBusConnection(@Nonnull AsyncResult res) throws AllocationError
      Finishes an operation started with g_dbus_connection_new_for_address().
      Parameters:
      res - a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_new()
      Returns:
      a #GDBusConnection or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • newForAddressSyncDBusConnection

      public static DBusConnection newForAddressSyncDBusConnection(@Nonnull Str address, int flags, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable) throws AllocationError
      Synchronously connects and sets up a D-Bus client connection for
      exchanging D-Bus messages with an endpoint specified by @address
      which must be in the
      [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).

      This constructor can only be used to initiate client-side
      connections - use g_dbus_connection_new_sync() if you need to act
      as the server. In particular, @flags cannot contain the
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER,
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS or
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER flags.

      This is a synchronous failable constructor. See
      g_dbus_connection_new_for_address() for the asynchronous version.

      If @observer is not %NULL it may be used to control the
      authentication process.
      Parameters:
      address - a D-Bus address
      flags - flags describing how to make the connection
      observer - a #GDBusAuthObserver or %NULL
      cancellable - a #GCancellable or %NULL
      Returns:
      a #GDBusConnection or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • newForAddressSyncDBusConnection

      public static DBusConnection newForAddressSyncDBusConnection(String address, int flags, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable) throws AllocationError
      Synchronously connects and sets up a D-Bus client connection for
      exchanging D-Bus messages with an endpoint specified by @address
      which must be in the
      [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).

      This constructor can only be used to initiate client-side
      connections - use g_dbus_connection_new_sync() if you need to act
      as the server. In particular, @flags cannot contain the
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER,
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS or
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER flags.

      This is a synchronous failable constructor. See
      g_dbus_connection_new_for_address() for the asynchronous version.

      If @observer is not %NULL it may be used to control the
      authentication process.
      Parameters:
      address - a D-Bus address
      flags - flags describing how to make the connection
      observer - a #GDBusAuthObserver or %NULL
      cancellable - a #GCancellable or %NULL
      Returns:
      a #GDBusConnection or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • newSyncDBusConnection

      public static DBusConnection newSyncDBusConnection(@Nonnull IOStream stream, @Nullable Str guid, int flags, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable) throws AllocationError
      Synchronously sets up a D-Bus connection for exchanging D-Bus messages
      with the end represented by @stream.

      If @stream is a #GSocketConnection, then the corresponding #GSocket
      will be put into non-blocking mode.

      The D-Bus connection will interact with @stream from a worker thread.
      As a result, the caller should not interact with @stream after this
      method has been called, except by calling g_object_unref() on it.

      If @observer is not %NULL it may be used to control the
      authentication process.

      This is a synchronous failable constructor. See
      g_dbus_connection_new() for the asynchronous version.
      Parameters:
      stream - a #GIOStream
      guid - the GUID to use if authenticating as a server or %NULL
      flags - flags describing how to make the connection
      observer - a #GDBusAuthObserver or %NULL
      cancellable - a #GCancellable or %NULL
      Returns:
      a #GDBusConnection or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • newSyncDBusConnection

      public static DBusConnection newSyncDBusConnection(@Nonnull IOStream stream, String guid, int flags, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable) throws AllocationError
      Synchronously sets up a D-Bus connection for exchanging D-Bus messages
      with the end represented by @stream.

      If @stream is a #GSocketConnection, then the corresponding #GSocket
      will be put into non-blocking mode.

      The D-Bus connection will interact with @stream from a worker thread.
      As a result, the caller should not interact with @stream after this
      method has been called, except by calling g_object_unref() on it.

      If @observer is not %NULL it may be used to control the
      authentication process.

      This is a synchronous failable constructor. See
      g_dbus_connection_new() for the asynchronous version.
      Parameters:
      stream - a #GIOStream
      guid - the GUID to use if authenticating as a server or %NULL
      flags - flags describing how to make the connection
      observer - a #GDBusAuthObserver or %NULL
      cancellable - a #GCancellable or %NULL
      Returns:
      a #GDBusConnection or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • addFilter

      public int addFilter(DBusConnection.OnDBusMessageFilterFunction filter_function, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func)
      Adds a message filter. Filters are handlers that are run on all
      incoming and outgoing messages, prior to standard dispatch. Filters
      are run in the order that they were added. The same handler can be
      added as a filter more than once, in which case it will be run more
      than once. Filters added during a filter callback won't be run on
      the message being processed. Filter functions are allowed to modify
      and even drop messages.

      Note that filters are run in a dedicated message handling thread so
      they can't block and, generally, can't do anything but signal a
      worker thread. Also note that filters are rarely needed - use API
      such as g_dbus_connection_send_message_with_reply(),
      g_dbus_connection_signal_subscribe() or g_dbus_connection_call() instead.

      If a filter consumes an incoming message the message is not
      dispatched anywhere else - not even the standard dispatch machinery
      (that API such as g_dbus_connection_signal_subscribe() and
      g_dbus_connection_send_message_with_reply() relies on) will see the
      message. Similarly, if a filter consumes an outgoing message, the
      message will not be sent to the other peer.

      If @user_data_free_func is non-%NULL, it will be called (in the
      thread-default main context of the thread you are calling this
      method from) at some point after @user_data is no longer
      needed. (It is not guaranteed to be called synchronously when the
      filter is removed, and may be called after @connection has been
      destroyed.)
      Parameters:
      filter_function - a filter function
      user_data - user data to pass to @filter_function
      user_data_free_func - function to free @user_data with when filter is removed or %NULL
      Returns:
      a filter identifier that can be used with g_dbus_connection_remove_filter()
    • call

      public void call(@Nullable Str bus_name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nonnull Str method_name, @Nullable Variant parameters, @Nullable VariantType reply_type, int flags, int timeout_msec, @Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously invokes the @method_name method on the
      @interface_name D-Bus interface on the remote object at
      @object_path owned by @bus_name.

      If @connection 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 @reply_type is non-%NULL then the reply will be checked for having this type and an
      error will be raised if it does not match. Said another way, if you give a @reply_type
      then any non-%NULL return value will be of this type. Unless it’s
      %G_VARIANT_TYPE_UNIT, the @reply_type will be a tuple containing one or more
      values.

      If the @parameters #GVariant is floating, it is consumed. This allows
      convenient 'inline' use of g_variant_new(), e.g.:
      <!-- language="C" -->
        g_dbus_connection_call (connection,
                                "org.freedesktop.StringThings",
                                "/org/freedesktop/StringThings",
                                "org.freedesktop.StringThings",
                                "TwoStrings",
                                g_variant_new ("(ss)",
                                               "Thing One",
                                               "Thing Two"),
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL,
                                (GAsyncReadyCallback) two_strings_done,
                                NULL);
       


      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_connection_call_finish() to get the result of the operation.
      See g_dbus_connection_call_sync() for the synchronous version of this
      function.

      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:
      bus_name - a unique or well-known bus name or %NULL if @connection is not a message bus connection
      object_path - path of remote object
      interface_name - D-Bus interface to invoke method on
      method_name - the name of the method to invoke
      parameters - a #GVariant tuple with parameters for the method or %NULL if not passing parameters
      reply_type - the expected type of the reply (which will be a tuple), or %NULL
      flags - flags from the #GDBusCallFlags enumeration
      timeout_msec - the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no 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 bus_name, String object_path, String interface_name, String method_name, @Nullable Variant parameters, @Nullable VariantType reply_type, int flags, int timeout_msec, @Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously invokes the @method_name method on the
      @interface_name D-Bus interface on the remote object at
      @object_path owned by @bus_name.

      If @connection 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 @reply_type is non-%NULL then the reply will be checked for having this type and an
      error will be raised if it does not match. Said another way, if you give a @reply_type
      then any non-%NULL return value will be of this type. Unless it’s
      %G_VARIANT_TYPE_UNIT, the @reply_type will be a tuple containing one or more
      values.

      If the @parameters #GVariant is floating, it is consumed. This allows
      convenient 'inline' use of g_variant_new(), e.g.:
      <!-- language="C" -->
        g_dbus_connection_call (connection,
                                "org.freedesktop.StringThings",
                                "/org/freedesktop/StringThings",
                                "org.freedesktop.StringThings",
                                "TwoStrings",
                                g_variant_new ("(ss)",
                                               "Thing One",
                                               "Thing Two"),
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL,
                                (GAsyncReadyCallback) two_strings_done,
                                NULL);
       


      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_connection_call_finish() to get the result of the operation.
      See g_dbus_connection_call_sync() for the synchronous version of this
      function.

      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:
      bus_name - a unique or well-known bus name or %NULL if @connection is not a message bus connection
      object_path - path of remote object
      interface_name - D-Bus interface to invoke method on
      method_name - the name of the method to invoke
      parameters - a #GVariant tuple with parameters for the method or %NULL if not passing parameters
      reply_type - the expected type of the reply (which will be a tuple), or %NULL
      flags - flags from the #GDBusCallFlags enumeration
      timeout_msec - the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no 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_connection_call().
      Parameters:
      res - a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_call()
      Returns:
      %NULL if @error is set. Otherwise a non-floating #GVariant tuple with return values. Free with g_variant_unref().
      Throws:
      AllocationError
    • callSync

      public Variant callSync(@Nullable Str bus_name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nonnull Str method_name, @Nullable Variant parameters, @Nullable VariantType reply_type, int flags, int timeout_msec, @Nullable Cancellable cancellable) throws AllocationError
      Synchronously invokes the @method_name method on the
      @interface_name D-Bus interface on the remote object at
      @object_path owned by @bus_name.

      If @connection 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 @reply_type is non-%NULL then the reply will be checked for having
      this type and an error will be raised if it does not match. Said
      another way, if you give a @reply_type then any non-%NULL return
      value will be of this type.

      If the @parameters #GVariant is floating, it is consumed.
      This allows convenient 'inline' use of g_variant_new(), e.g.:
      <!-- language="C" -->
        g_dbus_connection_call_sync (connection,
                                     "org.freedesktop.StringThings",
                                     "/org/freedesktop/StringThings",
                                     "org.freedesktop.StringThings",
                                     "TwoStrings",
                                     g_variant_new ("(ss)",
                                                    "Thing One",
                                                    "Thing Two"),
                                     NULL,
                                     G_DBUS_CALL_FLAGS_NONE,
                                     -1,
                                     NULL,
                                     &error);
       


      The calling thread is blocked until a reply is received. See
      g_dbus_connection_call() for the asynchronous version of
      this method.
      Parameters:
      bus_name - a unique or well-known bus name or %NULL if @connection is not a message bus connection
      object_path - path of remote object
      interface_name - D-Bus interface to invoke method on
      method_name - the name of the method to invoke
      parameters - a #GVariant tuple with parameters for the method or %NULL if not passing parameters
      reply_type - the expected type of the reply, or %NULL
      flags - flags from the #GDBusCallFlags enumeration
      timeout_msec - the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout
      cancellable - a #GCancellable or %NULL
      Returns:
      %NULL if @error is set. Otherwise a non-floating #GVariant tuple with return values. Free with g_variant_unref().
      Throws:
      AllocationError
    • callSync

      public Variant callSync(String bus_name, String object_path, String interface_name, String method_name, @Nullable Variant parameters, @Nullable VariantType reply_type, int flags, int timeout_msec, @Nullable Cancellable cancellable) throws AllocationError
      Synchronously invokes the @method_name method on the
      @interface_name D-Bus interface on the remote object at
      @object_path owned by @bus_name.

      If @connection 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 @reply_type is non-%NULL then the reply will be checked for having
      this type and an error will be raised if it does not match. Said
      another way, if you give a @reply_type then any non-%NULL return
      value will be of this type.

      If the @parameters #GVariant is floating, it is consumed.
      This allows convenient 'inline' use of g_variant_new(), e.g.:
      <!-- language="C" -->
        g_dbus_connection_call_sync (connection,
                                     "org.freedesktop.StringThings",
                                     "/org/freedesktop/StringThings",
                                     "org.freedesktop.StringThings",
                                     "TwoStrings",
                                     g_variant_new ("(ss)",
                                                    "Thing One",
                                                    "Thing Two"),
                                     NULL,
                                     G_DBUS_CALL_FLAGS_NONE,
                                     -1,
                                     NULL,
                                     &error);
       


      The calling thread is blocked until a reply is received. See
      g_dbus_connection_call() for the asynchronous version of
      this method.
      Parameters:
      bus_name - a unique or well-known bus name or %NULL if @connection is not a message bus connection
      object_path - path of remote object
      interface_name - D-Bus interface to invoke method on
      method_name - the name of the method to invoke
      parameters - a #GVariant tuple with parameters for the method or %NULL if not passing parameters
      reply_type - the expected type of the reply, or %NULL
      flags - flags from the #GDBusCallFlags enumeration
      timeout_msec - the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout
      cancellable - a #GCancellable or %NULL
      Returns:
      %NULL if @error is set. Otherwise a non-floating #GVariant tuple with return values. Free with g_variant_unref().
      Throws:
      AllocationError
    • callWithUnixFdList

      public void callWithUnixFdList(@Nullable Str bus_name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nonnull Str method_name, @Nullable Variant parameters, @Nullable VariantType reply_type, int flags, int timeout_msec, @Nullable UnixFDList fd_list, @Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Like g_dbus_connection_call() but also takes a #GUnixFDList object.

      The file descriptors normally correspond to %G_VARIANT_TYPE_HANDLE
      values in the body of the message. For example, if a message contains
      two file descriptors, @fd_list would have length 2, and
      `g_variant_new_handle (0)` and `g_variant_new_handle (1)` would appear
      somewhere in the body of the message (not necessarily in that order!)
      to represent the file descriptors at indexes 0 and 1 respectively.

      When designing D-Bus APIs that are intended to be interoperable,
      please note that non-GDBus implementations of D-Bus can usually only
      access file descriptors if they are referenced in this way by a
      value of type %G_VARIANT_TYPE_HANDLE in the body of the message.

      This method is only available on UNIX.
      Parameters:
      bus_name - a unique or well-known bus name or %NULL if @connection is not a message bus connection
      object_path - path of remote object
      interface_name - D-Bus interface to invoke method on
      method_name - the name of the method to invoke
      parameters - a #GVariant tuple with parameters for the method or %NULL if not passing parameters
      reply_type - the expected type of the reply, or %NULL
      flags - flags from the #GDBusCallFlags enumeration
      timeout_msec - the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no 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 bus_name, String object_path, String interface_name, String method_name, @Nullable Variant parameters, @Nullable VariantType reply_type, int flags, int timeout_msec, @Nullable UnixFDList fd_list, @Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Like g_dbus_connection_call() but also takes a #GUnixFDList object.

      The file descriptors normally correspond to %G_VARIANT_TYPE_HANDLE
      values in the body of the message. For example, if a message contains
      two file descriptors, @fd_list would have length 2, and
      `g_variant_new_handle (0)` and `g_variant_new_handle (1)` would appear
      somewhere in the body of the message (not necessarily in that order!)
      to represent the file descriptors at indexes 0 and 1 respectively.

      When designing D-Bus APIs that are intended to be interoperable,
      please note that non-GDBus implementations of D-Bus can usually only
      access file descriptors if they are referenced in this way by a
      value of type %G_VARIANT_TYPE_HANDLE in the body of the message.

      This method is only available on UNIX.
      Parameters:
      bus_name - a unique or well-known bus name or %NULL if @connection is not a message bus connection
      object_path - path of remote object
      interface_name - D-Bus interface to invoke method on
      method_name - the name of the method to invoke
      parameters - a #GVariant tuple with parameters for the method or %NULL if not passing parameters
      reply_type - the expected type of the reply, or %NULL
      flags - flags from the #GDBusCallFlags enumeration
      timeout_msec - the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no 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.
    • close

      public void close(@Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Closes @connection. Note that this never causes the process to
      exit (this might only happen if the other end of a shared message
      bus connection disconnects, see #GDBusConnection:exit-on-close).

      Once the connection is closed, operations such as sending a message
      will return with the error %G_IO_ERROR_CLOSED. Closing a connection
      will not automatically flush the connection so queued messages may
      be lost. Use g_dbus_connection_flush() if you need such guarantees.

      If @connection is already closed, this method fails with
      %G_IO_ERROR_CLOSED.

      When @connection has been closed, the #GDBusConnection::closed
      signal is emitted in the
      [thread-default main context][g-main-context-push-thread-default]
      of the thread that @connection was constructed in.

      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_connection_close_finish() to get the result of the
      operation. See g_dbus_connection_close_sync() for the synchronous
      version.
      Parameters:
      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
      user_data - The data to pass to @callback
    • closeFinish

      public boolean closeFinish(@Nonnull AsyncResult res) throws AllocationError
      Finishes an operation started with g_dbus_connection_close().
      Parameters:
      res - a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_close()
      Returns:
      %TRUE if the operation succeeded, %FALSE if @error is set
      Throws:
      AllocationError
    • closeSync

      public boolean closeSync(@Nullable Cancellable cancellable) throws AllocationError
      Synchronously closes @connection. The calling thread is blocked
      until this is done. See g_dbus_connection_close() for the
      asynchronous version of this method and more details about what it
      does.
      Parameters:
      cancellable - a #GCancellable or %NULL
      Returns:
      %TRUE if the operation succeeded, %FALSE if @error is set
      Throws:
      AllocationError
    • emitSignal

      public boolean emitSignal(@Nullable Str destination_bus_name, @Nonnull Str object_path, @Nonnull Str interface_name, @Nonnull Str signal_name, @Nullable Variant parameters) throws AllocationError
      Emits a signal.

      If the parameters GVariant is floating, it is consumed.

      This can only fail if @parameters is not compatible with the D-Bus protocol
      (%G_IO_ERROR_INVALID_ARGUMENT), or if @connection has been closed
      (%G_IO_ERROR_CLOSED).
      Parameters:
      destination_bus_name - the unique bus name for the destination for the signal or %NULL to emit to all listeners
      object_path - path of remote object
      interface_name - D-Bus interface to emit a signal on
      signal_name - the name of the signal to emit
      parameters - a #GVariant tuple with parameters for the signal or %NULL if not passing parameters
      Returns:
      %TRUE unless @error is set
      Throws:
      AllocationError
    • emitSignal

      public boolean emitSignal(String destination_bus_name, String object_path, String interface_name, String signal_name, @Nullable Variant parameters) throws AllocationError
      Emits a signal.

      If the parameters GVariant is floating, it is consumed.

      This can only fail if @parameters is not compatible with the D-Bus protocol
      (%G_IO_ERROR_INVALID_ARGUMENT), or if @connection has been closed
      (%G_IO_ERROR_CLOSED).
      Parameters:
      destination_bus_name - the unique bus name for the destination for the signal or %NULL to emit to all listeners
      object_path - path of remote object
      interface_name - D-Bus interface to emit a signal on
      signal_name - the name of the signal to emit
      parameters - a #GVariant tuple with parameters for the signal or %NULL if not passing parameters
      Returns:
      %TRUE unless @error is set
      Throws:
      AllocationError
    • exportActionGroup

      public int exportActionGroup(@Nonnull Str object_path, @Nonnull ActionGroup action_group) throws AllocationError
      Exports @action_group on @connection at @object_path.

      The implemented D-Bus API should be considered private. It is
      subject to change in the future.

      A given object path can only have one action group exported on it.
      If this constraint is violated, the export will fail and 0 will be
      returned (with @error set accordingly).

      You can unexport the action group using
      g_dbus_connection_unexport_action_group() with the return value of
      this function.

      The thread default main context is taken at the time of this call.
      All incoming action activations and state change requests are
      reported from this context. Any changes on the action group that
      cause it to emit signals must also come from this same context.
      Since incoming action activations and state change requests are
      rather likely to cause changes on the action group, this effectively
      limits a given action group to being exported from only one main
      context.
      Parameters:
      object_path - a D-Bus object path
      action_group - a #GActionGroup
      Returns:
      the ID of the export (never zero), or 0 in case of failure
      Throws:
      AllocationError
    • exportActionGroup

      public int exportActionGroup(String object_path, @Nonnull ActionGroup action_group) throws AllocationError
      Exports @action_group on @connection at @object_path.

      The implemented D-Bus API should be considered private. It is
      subject to change in the future.

      A given object path can only have one action group exported on it.
      If this constraint is violated, the export will fail and 0 will be
      returned (with @error set accordingly).

      You can unexport the action group using
      g_dbus_connection_unexport_action_group() with the return value of
      this function.

      The thread default main context is taken at the time of this call.
      All incoming action activations and state change requests are
      reported from this context. Any changes on the action group that
      cause it to emit signals must also come from this same context.
      Since incoming action activations and state change requests are
      rather likely to cause changes on the action group, this effectively
      limits a given action group to being exported from only one main
      context.
      Parameters:
      object_path - a D-Bus object path
      action_group - a #GActionGroup
      Returns:
      the ID of the export (never zero), or 0 in case of failure
      Throws:
      AllocationError
    • exportMenuModel

      public int exportMenuModel(@Nonnull Str object_path, @Nonnull MenuModel menu) throws AllocationError
      Exports @menu on @connection at @object_path.

      The implemented D-Bus API should be considered private.
      It is subject to change in the future.

      An object path can only have one menu model exported on it. If this
      constraint is violated, the export will fail and 0 will be
      returned (with @error set accordingly).

      You can unexport the menu model using
      g_dbus_connection_unexport_menu_model() with the return value of
      this function.
      Parameters:
      object_path - a D-Bus object path
      menu - a #GMenuModel
      Returns:
      the ID of the export (never zero), or 0 in case of failure
      Throws:
      AllocationError
    • exportMenuModel

      public int exportMenuModel(String object_path, @Nonnull MenuModel menu) throws AllocationError
      Exports @menu on @connection at @object_path.

      The implemented D-Bus API should be considered private.
      It is subject to change in the future.

      An object path can only have one menu model exported on it. If this
      constraint is violated, the export will fail and 0 will be
      returned (with @error set accordingly).

      You can unexport the menu model using
      g_dbus_connection_unexport_menu_model() with the return value of
      this function.
      Parameters:
      object_path - a D-Bus object path
      menu - a #GMenuModel
      Returns:
      the ID of the export (never zero), or 0 in case of failure
      Throws:
      AllocationError
    • flush

      public void flush(@Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously flushes @connection, that is, writes all queued
      outgoing message to the transport and then flushes the transport
      (using g_output_stream_flush_async()). This is useful in programs
      that wants to emit a D-Bus signal and then exit immediately. Without
      flushing the connection, there is no guaranteed that the message has
      been sent to the networking buffers in the OS kernel.

      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_connection_flush_finish() to get the result of the
      operation. See g_dbus_connection_flush_sync() for the synchronous
      version.
      Parameters:
      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
      user_data - The data to pass to @callback
    • flushFinish

      public boolean flushFinish(@Nonnull AsyncResult res) throws AllocationError
      Finishes an operation started with g_dbus_connection_flush().
      Parameters:
      res - a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_flush()
      Returns:
      %TRUE if the operation succeeded, %FALSE if @error is set
      Throws:
      AllocationError
    • flushSync

      public boolean flushSync(@Nullable Cancellable cancellable) throws AllocationError
      Synchronously flushes @connection. The calling thread is blocked
      until this is done. See g_dbus_connection_flush() for the
      asynchronous version of this method and more details about what it
      does.
      Parameters:
      cancellable - a #GCancellable or %NULL
      Returns:
      %TRUE if the operation succeeded, %FALSE if @error is set
      Throws:
      AllocationError
    • getCapabilities

      public int getCapabilities()
      Gets the capabilities negotiated with the remote peer
      Returns:
      zero or more flags from the #GDBusCapabilityFlags enumeration
    • getExitOnClose

      public boolean getExitOnClose()
      Gets whether the process is terminated when @connection is
      closed by the remote peer. See
      #GDBusConnection:exit-on-close for more details.
      Returns:
      whether the process is terminated when @connection is closed by the remote peer
    • getFlags

      public int getFlags()
      Gets the flags used to construct this connection
      Returns:
      zero or more flags from the #GDBusConnectionFlags enumeration
    • getGuid

      public Str getGuid()
      The GUID of the peer performing the role of server when
      authenticating. See #GDBusConnection:guid for more details.
      Returns:
      The GUID. Do not free this string, it is owned by @connection.
    • getLastSerial

      public int getLastSerial()
      Retrieves the last serial number assigned to a #GDBusMessage on
      the current thread. This includes messages sent via both low-level
      API such as g_dbus_connection_send_message() as well as
      high-level API such as g_dbus_connection_emit_signal(),
      g_dbus_connection_call() or g_dbus_proxy_call().
      Returns:
      the last used serial or zero when no message has been sent within the current thread
    • getPeerCredentials

      public Credentials getPeerCredentials()
      Gets the credentials of the authenticated peer. This will always
      return %NULL unless @connection acted as a server
      (e.g. %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER was passed)
      when set up and the client passed credentials as part of the
      authentication process.

      In a message bus setup, the message bus is always the server and
      each application is a client. So this method will always return
      %NULL for message bus clients.
      Returns:
      a #GCredentials or %NULL if not available. Do not free this object, it is owned by @connection.
    • getStream

      public IOStream getStream()
      Gets the underlying stream used for IO.

      While the #GDBusConnection is active, it will interact with this
      stream from a worker thread, so it is not safe to interact with
      the stream directly.
      Returns:
      the stream used for IO
    • getUniqueName

      public Str getUniqueName()
      Gets the unique name of @connection as assigned by the message
      bus. This can also be used to figure out if @connection is a
      message bus connection.
      Returns:
      the unique name or %NULL if @connection is not a message bus connection. Do not free this string, it is owned by @connection.
    • isClosed

      public boolean isClosed()
      Gets whether @connection is closed.
      Returns:
      %TRUE if the connection is closed, %FALSE otherwise
    • registerObject

      public int registerObject(@Nonnull Str object_path, @Nonnull DBusInterfaceInfo interface_info, @Nullable DBusInterfaceVTable vtable, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func) throws AllocationError
      Registers callbacks for exported objects at @object_path with the
      D-Bus interface that is described in @interface_info.

      Calls to functions in @vtable (and @user_data_free_func) will happen
      in the
      [thread-default main context][g-main-context-push-thread-default]
      of the thread you are calling this method from.

      Note that all #GVariant values passed to functions in @vtable will match
      the signature given in @interface_info - if a remote caller passes
      incorrect values, the `org.freedesktop.DBus.Error.InvalidArgs`
      is returned to the remote caller.

      Additionally, if the remote caller attempts to invoke methods or
      access properties not mentioned in @interface_info the
      `org.freedesktop.DBus.Error.UnknownMethod` resp.
      `org.freedesktop.DBus.Error.InvalidArgs` errors
      are returned to the caller.

      It is considered a programming error if the
      #GDBusInterfaceGetPropertyFunc function in @vtable returns a
      #GVariant of incorrect type.

      If an existing callback is already registered at @object_path and
      @interface_name, then @error is set to %G_IO_ERROR_EXISTS.

      GDBus automatically implements the standard D-Bus interfaces
      org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable
      and org.freedesktop.Peer, so you don't have to implement those for the
      objects you export. You can implement org.freedesktop.DBus.Properties
      yourself, e.g. to handle getting and setting of properties asynchronously.

      Note that the reference count on @interface_info will be
      incremented by 1 (unless allocated statically, e.g. if the
      reference count is -1, see g_dbus_interface_info_ref()) for as long
      as the object is exported. Also note that @vtable will be copied.

      See this [server][gdbus-server] for an example of how to use this method.
      Parameters:
      object_path - the object path to register at
      interface_info - introspection data for the interface
      vtable - a #GDBusInterfaceVTable to call into or %NULL
      user_data - data to pass to functions in @vtable
      user_data_free_func - function to call when the object path is unregistered
      Returns:
      0 if @error is set, otherwise a registration id (never 0) that can be used with g_dbus_connection_unregister_object()
      Throws:
      AllocationError
    • registerObject

      public int registerObject(String object_path, @Nonnull DBusInterfaceInfo interface_info, @Nullable DBusInterfaceVTable vtable, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func) throws AllocationError
      Registers callbacks for exported objects at @object_path with the
      D-Bus interface that is described in @interface_info.

      Calls to functions in @vtable (and @user_data_free_func) will happen
      in the
      [thread-default main context][g-main-context-push-thread-default]
      of the thread you are calling this method from.

      Note that all #GVariant values passed to functions in @vtable will match
      the signature given in @interface_info - if a remote caller passes
      incorrect values, the `org.freedesktop.DBus.Error.InvalidArgs`
      is returned to the remote caller.

      Additionally, if the remote caller attempts to invoke methods or
      access properties not mentioned in @interface_info the
      `org.freedesktop.DBus.Error.UnknownMethod` resp.
      `org.freedesktop.DBus.Error.InvalidArgs` errors
      are returned to the caller.

      It is considered a programming error if the
      #GDBusInterfaceGetPropertyFunc function in @vtable returns a
      #GVariant of incorrect type.

      If an existing callback is already registered at @object_path and
      @interface_name, then @error is set to %G_IO_ERROR_EXISTS.

      GDBus automatically implements the standard D-Bus interfaces
      org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable
      and org.freedesktop.Peer, so you don't have to implement those for the
      objects you export. You can implement org.freedesktop.DBus.Properties
      yourself, e.g. to handle getting and setting of properties asynchronously.

      Note that the reference count on @interface_info will be
      incremented by 1 (unless allocated statically, e.g. if the
      reference count is -1, see g_dbus_interface_info_ref()) for as long
      as the object is exported. Also note that @vtable will be copied.

      See this [server][gdbus-server] for an example of how to use this method.
      Parameters:
      object_path - the object path to register at
      interface_info - introspection data for the interface
      vtable - a #GDBusInterfaceVTable to call into or %NULL
      user_data - data to pass to functions in @vtable
      user_data_free_func - function to call when the object path is unregistered
      Returns:
      0 if @error is set, otherwise a registration id (never 0) that can be used with g_dbus_connection_unregister_object()
      Throws:
      AllocationError
    • registerObjectWithClosures

      public int registerObjectWithClosures(@Nonnull Str object_path, @Nonnull DBusInterfaceInfo interface_info, @Nullable Closure method_call_closure, @Nullable Closure get_property_closure, @Nullable Closure set_property_closure) throws AllocationError
      Version of g_dbus_connection_register_object() using closures instead of a
      #GDBusInterfaceVTable for easier binding in other languages.
      Parameters:
      object_path - The object path to register at.
      interface_info - Introspection data for the interface.
      method_call_closure - #GClosure for handling incoming method calls.
      get_property_closure - #GClosure for getting a property.
      set_property_closure - #GClosure for setting a property.
      Returns:
      0 if @error is set, otherwise a registration ID (never 0) that can be used with g_dbus_connection_unregister_object() .
      Throws:
      AllocationError
    • registerObjectWithClosures

      public int registerObjectWithClosures(String object_path, @Nonnull DBusInterfaceInfo interface_info, @Nullable Closure method_call_closure, @Nullable Closure get_property_closure, @Nullable Closure set_property_closure) throws AllocationError
      Version of g_dbus_connection_register_object() using closures instead of a
      #GDBusInterfaceVTable for easier binding in other languages.
      Parameters:
      object_path - The object path to register at.
      interface_info - Introspection data for the interface.
      method_call_closure - #GClosure for handling incoming method calls.
      get_property_closure - #GClosure for getting a property.
      set_property_closure - #GClosure for setting a property.
      Returns:
      0 if @error is set, otherwise a registration ID (never 0) that can be used with g_dbus_connection_unregister_object() .
      Throws:
      AllocationError
    • registerSubtree

      public int registerSubtree(@Nonnull Str object_path, @Nonnull DBusSubtreeVTable vtable, int flags, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func) throws AllocationError
      Registers a whole subtree of dynamic objects.

      The @enumerate and @introspection functions in @vtable are used to
      convey, to remote callers, what nodes exist in the subtree rooted
      by @object_path.

      When handling remote calls into any node in the subtree, first the
      @enumerate function is used to check if the node exists. If the node exists
      or the %G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is set
      the @introspection function is used to check if the node supports the
      requested method. If so, the @dispatch function is used to determine
      where to dispatch the call. The collected #GDBusInterfaceVTable and
      #gpointer will be used to call into the interface vtable for processing
      the request.

      All calls into user-provided code will be invoked in the
      [thread-default main context][g-main-context-push-thread-default]
      of the thread you are calling this method from.

      If an existing subtree is already registered at @object_path or
      then @error is set to %G_IO_ERROR_EXISTS.

      Note that it is valid to register regular objects (using
      g_dbus_connection_register_object()) in a subtree registered with
      g_dbus_connection_register_subtree() - if so, the subtree handler
      is tried as the last resort. One way to think about a subtree
      handler is to consider it a fallback handler for object paths not
      registered via g_dbus_connection_register_object() or other bindings.

      Note that @vtable will be copied so you cannot change it after
      registration.

      See this [server][gdbus-subtree-server] for an example of how to use
      this method.
      Parameters:
      object_path - the object path to register the subtree at
      vtable - a #GDBusSubtreeVTable to enumerate, introspect and dispatch nodes in the subtree
      flags - flags used to fine tune the behavior of the subtree
      user_data - data to pass to functions in @vtable
      user_data_free_func - function to call when the subtree is unregistered
      Returns:
      0 if @error is set, otherwise a subtree registration ID (never 0) that can be used with g_dbus_connection_unregister_subtree()
      Throws:
      AllocationError
    • registerSubtree

      public int registerSubtree(String object_path, @Nonnull DBusSubtreeVTable vtable, int flags, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func) throws AllocationError
      Registers a whole subtree of dynamic objects.

      The @enumerate and @introspection functions in @vtable are used to
      convey, to remote callers, what nodes exist in the subtree rooted
      by @object_path.

      When handling remote calls into any node in the subtree, first the
      @enumerate function is used to check if the node exists. If the node exists
      or the %G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is set
      the @introspection function is used to check if the node supports the
      requested method. If so, the @dispatch function is used to determine
      where to dispatch the call. The collected #GDBusInterfaceVTable and
      #gpointer will be used to call into the interface vtable for processing
      the request.

      All calls into user-provided code will be invoked in the
      [thread-default main context][g-main-context-push-thread-default]
      of the thread you are calling this method from.

      If an existing subtree is already registered at @object_path or
      then @error is set to %G_IO_ERROR_EXISTS.

      Note that it is valid to register regular objects (using
      g_dbus_connection_register_object()) in a subtree registered with
      g_dbus_connection_register_subtree() - if so, the subtree handler
      is tried as the last resort. One way to think about a subtree
      handler is to consider it a fallback handler for object paths not
      registered via g_dbus_connection_register_object() or other bindings.

      Note that @vtable will be copied so you cannot change it after
      registration.

      See this [server][gdbus-subtree-server] for an example of how to use
      this method.
      Parameters:
      object_path - the object path to register the subtree at
      vtable - a #GDBusSubtreeVTable to enumerate, introspect and dispatch nodes in the subtree
      flags - flags used to fine tune the behavior of the subtree
      user_data - data to pass to functions in @vtable
      user_data_free_func - function to call when the subtree is unregistered
      Returns:
      0 if @error is set, otherwise a subtree registration ID (never 0) that can be used with g_dbus_connection_unregister_subtree()
      Throws:
      AllocationError
    • removeFilter

      public void removeFilter(int filter_id)
      Removes a filter.

      Note that since filters run in a different thread, there is a race
      condition where it is possible that the filter will be running even
      after calling g_dbus_connection_remove_filter(), so you cannot just
      free data that the filter might be using. Instead, you should pass
      a #GDestroyNotify to g_dbus_connection_add_filter(), which will be
      called when it is guaranteed that the data is no longer needed.
      Parameters:
      filter_id - an identifier obtained from g_dbus_connection_add_filter()
    • sendMessageWithReplyFinish

      public DBusMessage sendMessageWithReplyFinish(@Nonnull AsyncResult res) throws AllocationError
      Finishes an operation started with g_dbus_connection_send_message_with_reply().

      Note that @error is only set if a local in-process error
      occurred. That is to say that the returned #GDBusMessage object may
      be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use
      g_dbus_message_to_gerror() to transcode this to a #GError.

      See this [server][gdbus-server] and [client][gdbus-unix-fd-client]
      for an example of how to use this low-level API to send and receive
      UNIX file descriptors.
      Parameters:
      res - a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_send_message_with_reply()
      Returns:
      a locked #GDBusMessage or %NULL if @error is set
      Throws:
      AllocationError
    • setExitOnClose

      public void setExitOnClose(boolean exit_on_close)
      Sets whether the process should be terminated when @connection is
      closed by the remote peer. See #GDBusConnection:exit-on-close for
      more details.

      Note that this function should be used with care. Most modern UNIX
      desktops tie the notion of a user session with the session bus, and expect
      all of a user's applications to quit when their bus connection goes away.
      If you are setting @exit_on_close to %FALSE for the shared session
      bus connection, you should make sure that your application exits
      when the user session ends.
      Parameters:
      exit_on_close - whether the process should be terminated when @connection is closed by the remote peer
    • signalSubscribe

      public int signalSubscribe(@Nullable Str sender, @Nullable Str interface_name, @Nullable Str member, @Nullable Str object_path, @Nullable Str arg0, int flags, DBusConnection.OnDBusSignalCallback callback, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func)
      Subscribes to signals on @connection and invokes @callback with a whenever
      the signal is received. Note that @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.

      If @connection is not a message bus connection, @sender must be
      %NULL.

      If @sender is a well-known name note that @callback is invoked with
      the unique name for the owner of @sender, not the well-known name
      as one would expect. This is because the message bus rewrites the
      name. As such, to avoid certain race conditions, users should be
      tracking the name owner of the well-known name and use that when
      processing the received signal.

      If one of %G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE or
      %G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH are given, @arg0 is
      interpreted as part of a namespace or path. The first argument
      of a signal is matched against that part as specified by D-Bus.

      If @user_data_free_func is non-%NULL, it will be called (in the
      thread-default main context of the thread you are calling this
      method from) at some point after @user_data is no longer
      needed. (It is not guaranteed to be called synchronously when the
      signal is unsubscribed from, and may be called after @connection
      has been destroyed.)

      As @callback is potentially invoked in a different thread from where it’s
      emitted, it’s possible for this to happen after
      g_dbus_connection_signal_unsubscribe() has been called in another thread.
      Due to this, @user_data should have a strong reference which is freed with
      @user_data_free_func, rather than pointing to data whose lifecycle is tied
      to the signal subscription. For example, if a #GObject is used to store the
      subscription ID from g_dbus_connection_signal_subscribe(), a strong reference
      to that #GObject must be passed to @user_data, and g_object_unref() passed to
      @user_data_free_func. You are responsible for breaking the resulting
      reference count cycle by explicitly unsubscribing from the signal when
      dropping the last external reference to the #GObject. Alternatively, a weak
      reference may be used.

      It is guaranteed that if you unsubscribe from a signal using
      g_dbus_connection_signal_unsubscribe() from the same thread which made the
      corresponding g_dbus_connection_signal_subscribe() call, @callback will not
      be invoked after g_dbus_connection_signal_unsubscribe() returns.

      The returned subscription identifier is an opaque value which is guaranteed
      to never be zero.

      This function can never fail.
      Parameters:
      sender - sender name to match on (unique or well-known name) or %NULL to listen from all senders
      interface_name - D-Bus interface name to match on or %NULL to match on all interfaces
      member - D-Bus signal name to match on or %NULL to match on all signals
      object_path - object path to match on or %NULL to match on all object paths
      arg0 - contents of first string argument to match on or %NULL to match on all kinds of arguments
      flags - #GDBusSignalFlags describing how arg0 is used in subscribing to the signal
      callback - callback to invoke when there is a signal matching the requested data
      user_data - user data to pass to @callback
      user_data_free_func - function to free @user_data with when subscription is removed or %NULL
      Returns:
      a subscription identifier that can be used with g_dbus_connection_signal_unsubscribe()
    • signalSubscribe

      public int signalSubscribe(String sender, String interface_name, String member, String object_path, String arg0, int flags, DBusConnection.OnDBusSignalCallback callback, @Nullable Pointer user_data, DBusConnection.OnDestroyNotify user_data_free_func)
      Subscribes to signals on @connection and invokes @callback with a whenever
      the signal is received. Note that @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.

      If @connection is not a message bus connection, @sender must be
      %NULL.

      If @sender is a well-known name note that @callback is invoked with
      the unique name for the owner of @sender, not the well-known name
      as one would expect. This is because the message bus rewrites the
      name. As such, to avoid certain race conditions, users should be
      tracking the name owner of the well-known name and use that when
      processing the received signal.

      If one of %G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE or
      %G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH are given, @arg0 is
      interpreted as part of a namespace or path. The first argument
      of a signal is matched against that part as specified by D-Bus.

      If @user_data_free_func is non-%NULL, it will be called (in the
      thread-default main context of the thread you are calling this
      method from) at some point after @user_data is no longer
      needed. (It is not guaranteed to be called synchronously when the
      signal is unsubscribed from, and may be called after @connection
      has been destroyed.)

      As @callback is potentially invoked in a different thread from where it’s
      emitted, it’s possible for this to happen after
      g_dbus_connection_signal_unsubscribe() has been called in another thread.
      Due to this, @user_data should have a strong reference which is freed with
      @user_data_free_func, rather than pointing to data whose lifecycle is tied
      to the signal subscription. For example, if a #GObject is used to store the
      subscription ID from g_dbus_connection_signal_subscribe(), a strong reference
      to that #GObject must be passed to @user_data, and g_object_unref() passed to
      @user_data_free_func. You are responsible for breaking the resulting
      reference count cycle by explicitly unsubscribing from the signal when
      dropping the last external reference to the #GObject. Alternatively, a weak
      reference may be used.

      It is guaranteed that if you unsubscribe from a signal using
      g_dbus_connection_signal_unsubscribe() from the same thread which made the
      corresponding g_dbus_connection_signal_subscribe() call, @callback will not
      be invoked after g_dbus_connection_signal_unsubscribe() returns.

      The returned subscription identifier is an opaque value which is guaranteed
      to never be zero.

      This function can never fail.
      Parameters:
      sender - sender name to match on (unique or well-known name) or %NULL to listen from all senders
      interface_name - D-Bus interface name to match on or %NULL to match on all interfaces
      member - D-Bus signal name to match on or %NULL to match on all signals
      object_path - object path to match on or %NULL to match on all object paths
      arg0 - contents of first string argument to match on or %NULL to match on all kinds of arguments
      flags - #GDBusSignalFlags describing how arg0 is used in subscribing to the signal
      callback - callback to invoke when there is a signal matching the requested data
      user_data - user data to pass to @callback
      user_data_free_func - function to free @user_data with when subscription is removed or %NULL
      Returns:
      a subscription identifier that can be used with g_dbus_connection_signal_unsubscribe()
    • signalUnsubscribe

      public void signalUnsubscribe(int subscription_id)
      Unsubscribes from signals.

      Note that there may still be D-Bus traffic to process (relating to this
      signal subscription) in the current thread-default #GMainContext after this
      function has returned. You should continue to iterate the #GMainContext
      until the #GDestroyNotify function passed to
      g_dbus_connection_signal_subscribe() is called, in order to avoid memory
      leaks through callbacks queued on the #GMainContext after it’s stopped being
      iterated.
      Alternatively, any idle source with a priority lower than %G_PRIORITY_DEFAULT
      that was scheduled after unsubscription, also indicates that all resources
      of this subscription are released.
      Parameters:
      subscription_id - a subscription id obtained from g_dbus_connection_signal_subscribe()
    • startMessageProcessing

      public void startMessageProcessing()
      If @connection was created with
      %G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method
      starts processing messages. Does nothing on if @connection wasn't
      created with this flag or if the method has already been called.
    • unexportActionGroup

      public void unexportActionGroup(int export_id)
      Reverses the effect of a previous call to
      g_dbus_connection_export_action_group().

      It is an error to call this function with an ID that wasn't returned
      from g_dbus_connection_export_action_group() or to call it with the
      same ID more than once.
      Parameters:
      export_id - the ID from g_dbus_connection_export_action_group()
    • unexportMenuModel

      public void unexportMenuModel(int export_id)
      Reverses the effect of a previous call to
      g_dbus_connection_export_menu_model().

      It is an error to call this function with an ID that wasn't returned
      from g_dbus_connection_export_menu_model() or to call it with the
      same ID more than once.
      Parameters:
      export_id - the ID from g_dbus_connection_export_menu_model()
    • unregisterObject

      public boolean unregisterObject(int registration_id)
      Unregisters an object.
      Parameters:
      registration_id - a registration id obtained from g_dbus_connection_register_object()
      Returns:
      %TRUE if the object was unregistered, %FALSE otherwise
    • unregisterSubtree

      public boolean unregisterSubtree(int registration_id)
      Unregisters a subtree.
      Parameters:
      registration_id - a subtree registration id obtained from g_dbus_connection_register_subtree()
      Returns:
      %TRUE if the subtree was unregistered, %FALSE otherwise
    • onClosed

      public SignalHandler onClosed(DBusConnection.OnClosed signal)
      Connect to signal "closed".
      See DBusConnection.OnClosed.onClosed(boolean, ch.bailu.gtk.glib.Error) for signal description.
      Field SIGNAL_ON_CLOSED 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 IOStream stream, @Nullable Str guid, int flags, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously sets up a D-Bus connection for exchanging D-Bus messages
      with the end represented by @stream.

      If @stream is a #GSocketConnection, then the corresponding #GSocket
      will be put into non-blocking mode.

      The D-Bus connection will interact with @stream from a worker thread.
      As a result, the caller should not interact with @stream after this
      method has been called, except by calling g_object_unref() on it.

      If @observer is not %NULL it may be used to control the
      authentication process.

      When the operation is finished, @callback will be invoked. You can
      then call g_dbus_connection_new_finish() to get the result of the
      operation.

      This is an asynchronous failable constructor. See
      g_dbus_connection_new_sync() for the synchronous
      version.
      Parameters:
      stream - a #GIOStream
      guid - the GUID to use if authenticating as a server or %NULL
      flags - flags describing how to make the connection
      observer - a #GDBusAuthObserver or %NULL
      cancellable - a #GCancellable or %NULL
      callback - a #GAsyncReadyCallback to call when the request is satisfied
      user_data - the data to pass to @callback
    • newForAddress

      public static void newForAddress(@Nonnull Str address, int flags, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable, DBusConnection.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously connects and sets up a D-Bus client connection for
      exchanging D-Bus messages with an endpoint specified by @address
      which must be in the
      [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).

      This constructor can only be used to initiate client-side
      connections - use g_dbus_connection_new() if you need to act as the
      server. In particular, @flags cannot contain the
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER,
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS or
      %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER flags.

      When the operation is finished, @callback will be invoked. You can
      then call g_dbus_connection_new_for_address_finish() to get the result of
      the operation.

      If @observer is not %NULL it may be used to control the
      authentication process.

      This is an asynchronous failable constructor. See
      g_dbus_connection_new_for_address_sync() for the synchronous
      version.
      Parameters:
      address - a D-Bus address
      flags - flags describing how to make the connection
      observer - a #GDBusAuthObserver or %NULL
      cancellable - a #GCancellable or %NULL
      callback - a #GAsyncReadyCallback to call when the request is satisfied
      user_data - the data to pass to @callback
    • asAsyncInitable

      public AsyncInitable asAsyncInitable()
      Implements interface AsyncInitable. Call this to get access to interface functions.
      Returns:
      AsyncInitable
    • 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()