Class DBusServer.Builder<B extends DBusServer.Builder<B>>

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

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

      public B setAddress(String address)
      The D-Bus address to listen on.
      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
    • setFlags

      public B setFlags(Set<DBusServerFlags> flags)
      Flags from the GDBusServerFlags 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 server.

      See GDBusConnection:guid for more details.

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

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

      public B onNewConnection(DBusServer.NewConnectionCallback handler)

      Emitted when a new authenticated connection has been made. Use g_dbus_connection_get_peer_credentials() to figure out what identity (if any), was authenticated.

      If you want to accept the connection, take a reference to the connection object and return true. When you are done with the connection call g_dbus_connection_close() and give up your reference. Note that the other peer may disconnect at any time - a typical thing to do when accepting a connection is to listen to the GDBusConnection::closed signal.

      If GDBusServer:flags contains DBusServerFlags.RUN_IN_THREAD then the signal is emitted in a new thread dedicated to the connection. Otherwise the signal is emitted in the thread-default main context (see MainContext#pushThreadDefault) of the thread that server was constructed in.

      You are guaranteed that signal handlers for this signal runs before incoming messages on connection are processed. This means that it's suitable to call g_dbus_connection_register_object() or similar from the signal handler.

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