Package org.gnome.gio

Class DBusConnection

java.lang.Object
All Implemented Interfaces:
Proxy, AsyncInitable, Initable

@Generated("io.github.jwharm.JavaGI") public class DBusConnection extends GObject implements AsyncInitable, Initable
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 IOStream.

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 Gio.busOwnName(org.gnome.gio.BusType, java.lang.String, java.util.Set<org.gnome.gio.BusNameOwnerFlags>, org.gnome.gobject.Closure, org.gnome.gobject.Closure, org.gnome.gobject.Closure), Gio.busWatchName(org.gnome.gio.BusType, java.lang.String, java.util.Set<org.gnome.gio.BusNameWatcherFlags>, org.gnome.gobject.Closure, org.gnome.gobject.Closure) or DBusProxy.newForBus(org.gnome.gio.BusType, java.util.Set<org.gnome.gio.DBusProxyFlags>, org.gnome.gio.DBusInterfaceInfo, java.lang.String, java.lang.String, java.lang.String, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) APIs.

As an exception to the usual GLib rule that a particular object must not be used by two threads at the same time, GDBusConnections methods may be called from any thread. This is so that Gio.busGet(org.gnome.gio.BusType, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) and Gio.busGetSync(org.gnome.gio.BusType, org.gnome.gio.Cancellable) 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, new_(org.gnome.gio.IOStream, java.lang.String, java.util.Set<org.gnome.gio.DBusConnectionFlags>, org.gnome.gio.DBusAuthObserver, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) and Gio.busGet(org.gnome.gio.BusType, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback), and the synchronous versions of those methods, give you an initialized connection. Language bindings for GIO should use Initable.new_(org.gnome.glib.Type, org.gnome.gio.Cancellable, org.gnome.glib.GError[], java.lang.String, java.lang.Object...) or AsyncInitable.newAsync(org.gnome.glib.Type, int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback, java.lang.String, java.lang.Object...), which also initialize the connection.

If you construct an uninitialized GDBusConnection, such as via GObject(org.gnome.glib.Type, java.lang.String, java.lang.Object...), you must initialize it via Initable.init(org.gnome.gio.Cancellable) or AsyncInitable.initAsync(int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) 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 GObject.unref().

An example D-Bus server
Here is an example for a D-Bus server: gdbus-example-server.c

An example for exporting a subtree
Here is an example for exporting a subtree: gdbus-example-subtree.c

An example for file descriptor passing
Here is an example for passing UNIX file descriptors: gdbus-unix-fd-client.c

An example for exporting a GObject
Here is an example for exporting a GObject: gdbus-example-export.c