Class DBusConnection.Builder<B extends DBusConnection.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
BuilderInterface
Enclosing class:
DBusConnection

public static class DBusConnection.Builder<B extends DBusConnection.Builder<B>> extends GObject.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
Since:
2.26
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public DBusConnection build()
      Finish building the DBusConnection object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to DBusConnection.
      Overrides:
      build in class GObject.Builder<B extends DBusConnection.Builder<B>>
      Returns:
      a new instance of DBusConnection with the properties that were set in the Builder object.
    • setAddress

      public B setAddress(String address)
      A D-Bus address specifying potential endpoints that can be used when establishing the connection.
      Parameters:
      address - the value for the address property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • setAuthenticationObserver

      public B setAuthenticationObserver(DBusAuthObserver authenticationObserver)
      A GDBusAuthObserver object to assist in the authentication process or null.
      Parameters:
      authenticationObserver - the value for the authentication-observer property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • setExitOnClose

      public B setExitOnClose(boolean exitOnClose)

      A boolean specifying whether the process will be terminated (by calling raise(SIGTERM)) if the connection is closed by the remote peer.

      Note that GDBusConnection objects returned by g_bus_get_finish() and g_bus_get_sync() will (usually) have this property set to true.

      Parameters:
      exitOnClose - the value for the exit-on-close property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • setFlags

      public B setFlags(Set<DBusConnectionFlags> flags)
      Flags from the GDBusConnectionFlags enumeration.
      Parameters:
      flags - the value for the flags property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • setGuid

      public B setGuid(String guid)

      The GUID of the peer performing the role of server when authenticating.

      If you are constructing a GDBusConnection and pass DBusConnectionFlags.AUTHENTICATION_SERVER in the GDBusConnection:flags property then you must also set this property to a valid guid.

      If you are constructing a GDBusConnection and pass DBusConnectionFlags.AUTHENTICATION_CLIENT in the GDBusConnection:flags property you will be able to read the GUID of the other peer here after the connection has been successfully initialized.

      Note that the D-Bus specification uses the term ‘UUID’ to refer to this, whereas GLib consistently uses the term ‘GUID’ for historical reasons.

      Despite its name, the format of GDBusConnection:guid does not follow RFC 4122 or the Microsoft GUID format.

      Parameters:
      guid - the value for the guid property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • setStream

      public B setStream(IOStream stream)

      The underlying GIOStream used for I/O.

      If this is passed on construction and is a GSocketConnection, then the corresponding GSocket will be put into non-blocking mode.

      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.

      Parameters:
      stream - the value for the stream property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • setFlags

      public B setFlags(DBusConnectionFlags... flags)
      Flags from the GDBusConnectionFlags enumeration.
      Parameters:
      flags - the value for the flags property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
    • onClosed

      public B onClosed(DBusConnection.ClosedCallback handler)

      Emitted when the connection is closed.

      The cause of this event can be

      • If g_dbus_connection_close() is called. In this case remotePeerVanished is set to false and error is null.

      • If the remote peer closes the connection. In this case remotePeerVanished is set to true and error is set.

      • If the remote peer sends invalid or malformed data. In this case remotePeerVanished is set to false and error is set.

      Upon receiving this signal, you should give up your reference to connection. You are guaranteed that this signal is emitted only once.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.26
      See Also: