:right-sidebar: True DBusServer =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.26 .. class:: DBusServer(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.Initable` ``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 `__\. 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 :obj:`~gi.repository.Gio.bus_own_name`\. An example of peer-to-peer communication with GDBus can be found in `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 :obj:`~gi.repository.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. Constructors ------------ .. rst-class:: interim-class .. class:: DBusServer :no-index: .. classmethod:: new_sync(address: str, flags: ~gi.repository.Gio.DBusServerFlags, guid: str, observer: ~gi.repository.Gio.DBusAuthObserver | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.DBusServer Creates a new D-Bus server that listens on the first address in ``address`` that works. Once constructed, you can use :func:`~gi.repository.Gio.DBusServer.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-:const:`None` :obj:`~gi.repository.Gio.DBusAuthObserver`\. Connect to the :obj:`~gi.repository.Gio.DBusServer`\::new-connection signal to handle incoming connections. The returned :obj:`~gi.repository.Gio.DBusServer` isn't active - you have to start it with :func:`~gi.repository.Gio.DBusServer.start`. :obj:`~gi.repository.Gio.DBusServer` is used in this [example][gdbus-peer-to-peer]. This is a synchronous failable constructor. There is currently no asynchronous version. .. versionadded:: 2.26 :param address: A D-Bus address. :param flags: Flags from the :obj:`~gi.repository.Gio.DBusServerFlags` enumeration. :param guid: A D-Bus GUID. :param observer: A :obj:`~gi.repository.Gio.DBusAuthObserver` or :const:`None`. :param cancellable: A :obj:`~gi.repository.Gio.Cancellable` or :const:`None`. Methods ------- .. rst-class:: interim-class .. class:: DBusServer :no-index: .. method:: get_client_address() -> str Gets a `D-Bus address `__ string that can be used by clients to connect to ``server``\. This is valid and non-empty if initializing the :obj:`~gi.repository.Gio.DBusServer` succeeded. .. versionadded:: 2.26 .. method:: get_flags() -> ~gi.repository.Gio.DBusServerFlags Gets the flags for ``server``\. .. versionadded:: 2.26 .. method:: get_guid() -> str Gets the GUID for ``server``\, as provided to :func:`~gi.repository.Gio.DBusServer.new_sync`. .. versionadded:: 2.26 .. method:: is_active() -> bool Gets whether ``server`` is active. .. versionadded:: 2.26 .. method:: start() -> None Starts ``server``\. .. versionadded:: 2.26 .. method:: stop() -> None Stops ``server``\. .. versionadded:: 2.26 Properties ---------- .. rst-class:: interim-class .. class:: DBusServer :no-index: .. attribute:: props.active :type: bool The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.address :type: str The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.authentication_observer :type: ~gi.repository.Gio.DBusAuthObserver The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.client_address :type: str The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.flags :type: ~gi.repository.Gio.DBusServerFlags The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.guid :type: str The type of the None singleton. .. versionadded:: 2.26 Signals ------- .. rst-class:: interim-class .. class:: DBusServer.signals :no-index: .. method:: new_connection(connection: ~gi.repository.Gio.DBusConnection) -> bool The type of the None singleton. .. versionadded:: 2.26 :param connection: A :obj:`~gi.repository.Gio.DBusConnection` for the new connection.