Klasse DBusServer

Alle implementierten Schnittstellen:
PointerInterface

public class DBusServer extends PropertyHolder
`GDBusServer` is a helper for listening to and accepting D-Bus
connections. This can be used to create a new D-Bus server, allowing two
peers to use the D-Bus protocol for their own specialized communication.
A server instance provided in this way will not perform message routing or
implement the
[`org.freedesktop.DBus` interface](https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-messages).

To just export an object on a well-known name on a message bus, such as the
session or system bus, you should instead use [func@Gio.bus_own_name].

An example of peer-to-peer communication with GDBus can be found
in [gdbus-example-peer.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-peer.c).

Note that a minimal `GDBusServer` will accept connections from any
peer. In many use-cases it will be necessary to add a
[class@Gio.DBusAuthObserver] that only accepts connections that have
successfully authenticated as the same user that is running the
`GDBusServer`. Since GLib 2.68 this can be achieved more simply by passing
the `G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER` flag to the
server.

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

  • Felddetails

  • Konstruktordetails

  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newSyncDBusServer

      public static DBusServer newSyncDBusServer(@Nonnull Str address, int flags, @Nonnull Str guid, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable) throws AllocationError
      Creates a new D-Bus server that listens on the first address in
      @address that works.

      Once constructed, you can use g_dbus_server_get_client_address() to
      get a D-Bus address string that clients can use to connect.

      To have control over the available authentication mechanisms and
      the users that are authorized to connect, it is strongly recommended
      to provide a non-%NULL #GDBusAuthObserver.

      Connect to the #GDBusServer::new-connection signal to handle
      incoming connections.

      The returned #GDBusServer isn't active - you have to start it with
      g_dbus_server_start().

      #GDBusServer is used in this [example](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-peer.c).

      This is a synchronous failable constructor. There is currently no
      asynchronous version.
      Parameter:
      address - A D-Bus address.
      flags - Flags from the #GDBusServerFlags enumeration.
      guid - A D-Bus GUID.
      observer - A #GDBusAuthObserver or %NULL.
      cancellable - A #GCancellable or %NULL.
      Gibt zurück:
      A #GDBusServer or %NULL if @error is set. Free with g_object_unref().
      Löst aus:
      AllocationError
    • newSyncDBusServer

      public static DBusServer newSyncDBusServer(String address, int flags, String guid, @Nullable DBusAuthObserver observer, @Nullable Cancellable cancellable) throws AllocationError
      Creates a new D-Bus server that listens on the first address in
      @address that works.

      Once constructed, you can use g_dbus_server_get_client_address() to
      get a D-Bus address string that clients can use to connect.

      To have control over the available authentication mechanisms and
      the users that are authorized to connect, it is strongly recommended
      to provide a non-%NULL #GDBusAuthObserver.

      Connect to the #GDBusServer::new-connection signal to handle
      incoming connections.

      The returned #GDBusServer isn't active - you have to start it with
      g_dbus_server_start().

      #GDBusServer is used in this [example](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-peer.c).

      This is a synchronous failable constructor. There is currently no
      asynchronous version.
      Parameter:
      address - A D-Bus address.
      flags - Flags from the #GDBusServerFlags enumeration.
      guid - A D-Bus GUID.
      observer - A #GDBusAuthObserver or %NULL.
      cancellable - A #GCancellable or %NULL.
      Gibt zurück:
      A #GDBusServer or %NULL if @error is set. Free with g_object_unref().
      Löst aus:
      AllocationError
    • getClientAddress

      public Str getClientAddress()
      Gets a
      [D-Bus address](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses)
      string that can be used by clients to connect to @server.

      This is valid and non-empty if initializing the #GDBusServer succeeded.
      Gibt zurück:
      A D-Bus address string. Do not free, the string is owned by @server.
    • getFlags

      public int getFlags()
      Gets the flags for @server.
      Gibt zurück:
      A set of flags from the #GDBusServerFlags enumeration.
    • getGuid

      public Str getGuid()
      Gets the GUID for @server, as provided to g_dbus_server_new_sync().
      Gibt zurück:
      A D-Bus GUID. Do not free this string, it is owned by @server.
    • isActive

      public boolean isActive()
      Gets whether @server is active.
      Gibt zurück:
      %TRUE if server is active, %FALSE otherwise.
    • start

      public void start()
      Starts @server.
    • stop

      public void stop()
      Stops @server.
    • onNewConnection

      public SignalHandler onNewConnection(DBusServer.OnNewConnection signal)
      Connect to signal "new-connection".
      See DBusServer.OnNewConnection.onNewConnection(ch.bailu.gtk.gio.DBusConnection) for signal description.
      Field SIGNAL_ON_NEW_CONNECTION contains original signal name and can be used as resource reference.
      Parameter:
      signal - callback function (lambda).
      Gibt zurück:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asInitable

      public Initable asInitable()
      Implements interface Initable. Call this to get access to interface functions.
      Gibt zurück:
      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()