:right-sidebar: True DBusConnection =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.26 .. class:: DBusConnection(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.AsyncInitable`, :class:`~gi.repository.Gio.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 :obj:`~gi.repository.Gio.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 :obj:`~gi.repository.Gio.bus_own_name`\, :obj:`~gi.repository.Gio.bus_watch_name` or :obj:`~gi.repository.Gio.DBusProxy.new_for_bus` APIs. As an exception to the usual GLib rule that a particular object must not be used by two threads at the same time, ``GDBusConnection``\s methods may be called from any thread. This is so that :obj:`~gi.repository.Gio.bus_get` and :obj:`~gi.repository.Gio.bus_get_sync` 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, :obj:`~gi.repository.Gio.DBusConnection.new` and :obj:`~gi.repository.Gio.bus_get`\, and the synchronous versions of those methods, give you an initialized connection. Language bindings for GIO should use :obj:`~gi.repository.Gio.Initable.new` or :obj:`~gi.repository.Gio.AsyncInitable.new_async`\, which also initialize the connection. If you construct an uninitialized ``GDBusConnection``\, such as via :obj:`~gi.repository.GObject.Object.new`\, you must initialize it via :obj:`~gi.repository.Gio.Initable.init` or :obj:`~gi.repository.Gio.AsyncInitable.init_async` 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 :obj:`~gi.repository.GObject.Object.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 :obj:`~gi.repository.GObject.Object`\: `gdbus-example-export.c `__ Constructors ------------ .. rst-class:: interim-class .. class:: DBusConnection :no-index: .. classmethod:: new_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.DBusConnection Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.new`. .. versionadded:: 2.26 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.new`. .. classmethod:: new_for_address_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.DBusConnection Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.new_for_address`. .. versionadded:: 2.26 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.new` .. classmethod:: new_for_address_sync(address: str, flags: ~gi.repository.Gio.DBusConnectionFlags, observer: ~gi.repository.Gio.DBusAuthObserver | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.DBusConnection Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by ``address`` which must be in the `D-Bus address format `__\. This constructor can only be used to initiate client-side connections - use :func:`~gi.repository.Gio.DBusConnection.new_sync` if you need to act as the server. In particular, ``flags`` cannot contain the :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_SERVER`, :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_ALLOW_ANONYMOUS` or :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_REQUIRE_SAME_USER` flags. This is a synchronous failable constructor. See :func:`~gi.repository.Gio.DBusConnection.new_for_address` for the asynchronous version. If ``observer`` is not :const:`None` it may be used to control the authentication process. .. versionadded:: 2.26 :param address: a D-Bus address :param flags: flags describing how to make the connection :param observer: a :obj:`~gi.repository.Gio.DBusAuthObserver` or :const:`None` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. classmethod:: new_sync(stream: ~gi.repository.Gio.IOStream, guid: str | None, flags: ~gi.repository.Gio.DBusConnectionFlags, observer: ~gi.repository.Gio.DBusAuthObserver | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.DBusConnection Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by ``stream``\. If ``stream`` is a :obj:`~gi.repository.Gio.SocketConnection`\, then the corresponding :obj:`~gi.repository.Gio.Socket` will be put into non-blocking mode. The D-Bus connection will interact with ``stream`` from a worker thread. As a result, the caller should not interact with ``stream`` after this method has been called, except by calling :func:`~gi.repository.GObject.GObject.Object.unref` on it. If ``observer`` is not :const:`None` it may be used to control the authentication process. This is a synchronous failable constructor. See :func:`~gi.repository.Gio.DBusConnection.new` for the asynchronous version. .. versionadded:: 2.26 :param stream: a :obj:`~gi.repository.Gio.IOStream` :param guid: the GUID to use if authenticating as a server or :const:`None` :param flags: flags describing how to make the connection :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:: DBusConnection :no-index: .. method:: add_filter(filter_function: ~typing.Callable[[~gi.repository.Gio.DBusConnection, ~gi.repository.Gio.DBusMessage, bool, ~typing.Any], ~gi.repository.Gio.DBusMessage | None], user_data: ~typing.Any = None) -> int Adds a message filter. Filters are handlers that are run on all incoming and outgoing messages, prior to standard dispatch. Filters are run in the order that they were added. The same handler can be added as a filter more than once, in which case it will be run more than once. Filters added during a filter callback won't be run on the message being processed. Filter functions are allowed to modify and even drop messages. Note that filters are run in a dedicated message handling thread so they can't block and, generally, can't do anything but signal a worker thread. Also note that filters are rarely needed - use API such as :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply`, :func:`~gi.repository.Gio.DBusConnection.signal_subscribe` or :func:`~gi.repository.Gio.DBusConnection.call` instead. If a filter consumes an incoming message the message is not dispatched anywhere else - not even the standard dispatch machinery (that API such as :func:`~gi.repository.Gio.DBusConnection.signal_subscribe` and :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply` relies on) will see the message. Similarly, if a filter consumes an outgoing message, the message will not be sent to the other peer. If ``user_data_free_func`` is non-:const:`None`, it will be called (in the thread-default main context of the thread you are calling this method from) at some point after ``user_data`` is no longer needed. (It is not guaranteed to be called synchronously when the filter is removed, and may be called after ``connection`` has been destroyed.) .. versionadded:: 2.26 :param filter_function: a filter function :param user_data: user data to pass to ``filter_function`` .. method:: call(bus_name: str | None, object_path: str, interface_name: str, method_name: str, parameters: ~gi.repository.GLib.Variant | None, reply_type: ~gi.repository.GLib.VariantType | None, flags: ~gi.repository.Gio.DBusCallFlags, timeout_msec: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously invokes the ``method_name`` method on the ``interface_name`` D-Bus interface on the remote object at ``object_path`` owned by ``bus_name``\. If ``connection`` is closed then the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. If ``cancellable`` is canceled, the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED`. If ``parameters`` contains a value not compatible with the D-Bus protocol, the operation fails with :const:`~gi.repository.Gio.IOErrorEnum.INVALID_ARGUMENT`. If ``reply_type`` is non-:const:`None` then the reply will be checked for having this type and an error will be raised if it does not match. Said another way, if you give a ``reply_type`` then any non-:const:`None` return value will be of this type. Unless it’s %G_VARIANT_TYPE_UNIT, the ``reply_type`` will be a tuple containing one or more values. If the ``parameters`` :obj:`~gi.repository.GLib.Variant` is floating, it is consumed. This allows convenient 'inline' use of :func:`~gi.repository.GLib.Variant.new`, e.g.: .. code-block:: C :dedent: g_dbus_connection_call (connection, "org.freedesktop.StringThings", "/org/freedesktop/StringThings", "org.freedesktop.StringThings", "TwoStrings", g_variant_new ("(ss)", "Thing One", "Thing Two"), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, (GAsyncReadyCallback) two_strings_done, NULL); This is an asynchronous method. When the operation is finished, ``callback`` will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call :func:`~gi.repository.Gio.DBusConnection.call_finish` to get the result of the operation. See :func:`~gi.repository.Gio.DBusConnection.call_sync` for the synchronous version of this function. If ``callback`` is :const:`None` then the D-Bus method call message will be sent with the :const:`~gi.repository.Gio.DBusMessageFlags.NO_REPLY_EXPECTED` flag set. .. versionadded:: 2.26 :param bus_name: a unique or well-known bus name or :const:`None` if ``connection`` is not a message bus connection :param object_path: path of remote object :param interface_name: D-Bus interface to invoke method on :param method_name: the name of the method to invoke :param parameters: a :obj:`~gi.repository.GLib.Variant` tuple with parameters for the method or :const:`None` if not passing parameters :param reply_type: the expected type of the reply (which will be a tuple), or :const:`None` :param flags: flags from the :obj:`~gi.repository.Gio.DBusCallFlags` enumeration :param timeout_msec: the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied or :const:`None` if you don't care about the result of the method invocation :param user_data: the data to pass to ``callback`` .. method:: call_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.GLib.Variant Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.call`. .. versionadded:: 2.26 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.call` .. method:: call_sync(bus_name: str | None, object_path: str, interface_name: str, method_name: str, parameters: ~gi.repository.GLib.Variant | None, reply_type: ~gi.repository.GLib.VariantType | None, flags: ~gi.repository.Gio.DBusCallFlags, timeout_msec: int, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.GLib.Variant Synchronously invokes the ``method_name`` method on the ``interface_name`` D-Bus interface on the remote object at ``object_path`` owned by ``bus_name``\. If ``connection`` is closed then the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. If ``cancellable`` is canceled, the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED`. If ``parameters`` contains a value not compatible with the D-Bus protocol, the operation fails with :const:`~gi.repository.Gio.IOErrorEnum.INVALID_ARGUMENT`. If ``reply_type`` is non-:const:`None` then the reply will be checked for having this type and an error will be raised if it does not match. Said another way, if you give a ``reply_type`` then any non-:const:`None` return value will be of this type. If the ``parameters`` :obj:`~gi.repository.GLib.Variant` is floating, it is consumed. This allows convenient 'inline' use of :func:`~gi.repository.GLib.Variant.new`, e.g.: .. code-block:: C :dedent: g_dbus_connection_call_sync (connection, "org.freedesktop.StringThings", "/org/freedesktop/StringThings", "org.freedesktop.StringThings", "TwoStrings", g_variant_new ("(ss)", "Thing One", "Thing Two"), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); The calling thread is blocked until a reply is received. See :func:`~gi.repository.Gio.DBusConnection.call` for the asynchronous version of this method. .. versionadded:: 2.26 :param bus_name: a unique or well-known bus name or :const:`None` if ``connection`` is not a message bus connection :param object_path: path of remote object :param interface_name: D-Bus interface to invoke method on :param method_name: the name of the method to invoke :param parameters: a :obj:`~gi.repository.GLib.Variant` tuple with parameters for the method or :const:`None` if not passing parameters :param reply_type: the expected type of the reply, or :const:`None` :param flags: flags from the :obj:`~gi.repository.Gio.DBusCallFlags` enumeration :param timeout_msec: the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. method:: call_with_unix_fd_list(bus_name: str | None, object_path: str, interface_name: str, method_name: str, parameters: ~gi.repository.GLib.Variant | None, reply_type: ~gi.repository.GLib.VariantType | None, flags: ~gi.repository.Gio.DBusCallFlags, timeout_msec: int, fd_list: ~gi.repository.Gio.UnixFDList | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Like :func:`~gi.repository.Gio.DBusConnection.call` but also takes a :obj:`~gi.repository.Gio.UnixFDList` object. The file descriptors normally correspond to %G_VARIANT_TYPE_HANDLE values in the body of the message. For example, if a message contains two file descriptors, ``fd_list`` would have length 2, and ``g_variant_new_handle (0)`` and ``g_variant_new_handle (1)`` would appear somewhere in the body of the message (not necessarily in that order!) to represent the file descriptors at indexes 0 and 1 respectively. When designing D-Bus APIs that are intended to be interoperable, please note that non-GDBus implementations of D-Bus can usually only access file descriptors if they are referenced in this way by a value of type %G_VARIANT_TYPE_HANDLE in the body of the message. This method is only available on UNIX. .. versionadded:: 2.30 :param bus_name: a unique or well-known bus name or :const:`None` if ``connection`` is not a message bus connection :param object_path: path of remote object :param interface_name: D-Bus interface to invoke method on :param method_name: the name of the method to invoke :param parameters: a :obj:`~gi.repository.GLib.Variant` tuple with parameters for the method or :const:`None` if not passing parameters :param reply_type: the expected type of the reply, or :const:`None` :param flags: flags from the :obj:`~gi.repository.Gio.DBusCallFlags` enumeration :param timeout_msec: the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout :param fd_list: a :obj:`~gi.repository.Gio.UnixFDList` or :const:`None` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied or :const:`None` if you don't \* care about the result of the method invocation :param user_data: The data to pass to ``callback``\. .. method:: call_with_unix_fd_list_finish(res: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[~gi.repository.GLib.Variant, ~gi.repository.Gio.UnixFDList] Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.call_with_unix_fd_list`. The file descriptors normally correspond to %G_VARIANT_TYPE_HANDLE values in the body of the message. For example, if :func:`~gi.repository.GLib.Variant.get_handle` returns 5, that is intended to be a reference to the file descriptor that can be accessed by ``g_unix_fd_list_get (*out_fd_list, 5, ...)``\. When designing D-Bus APIs that are intended to be interoperable, please note that non-GDBus implementations of D-Bus can usually only access file descriptors if they are referenced in this way by a value of type %G_VARIANT_TYPE_HANDLE in the body of the message. .. versionadded:: 2.30 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.call_with_unix_fd_list` .. method:: call_with_unix_fd_list_sync(bus_name: str | None, object_path: str, interface_name: str, method_name: str, parameters: ~gi.repository.GLib.Variant | None, reply_type: ~gi.repository.GLib.VariantType | None, flags: ~gi.repository.Gio.DBusCallFlags, timeout_msec: int, fd_list: ~gi.repository.Gio.UnixFDList | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~typing.Tuple[~gi.repository.GLib.Variant, ~gi.repository.Gio.UnixFDList] Like :func:`~gi.repository.Gio.DBusConnection.call_sync` but also takes and returns :obj:`~gi.repository.Gio.UnixFDList` objects. See :func:`~gi.repository.Gio.DBusConnection.call_with_unix_fd_list` and :func:`~gi.repository.Gio.DBusConnection.call_with_unix_fd_list_finish` for more details. This method is only available on UNIX. .. versionadded:: 2.30 :param bus_name: a unique or well-known bus name or :const:`None` if ``connection`` is not a message bus connection :param object_path: path of remote object :param interface_name: D-Bus interface to invoke method on :param method_name: the name of the method to invoke :param parameters: a :obj:`~gi.repository.GLib.Variant` tuple with parameters for the method or :const:`None` if not passing parameters :param reply_type: the expected type of the reply, or :const:`None` :param flags: flags from the :obj:`~gi.repository.Gio.DBusCallFlags` enumeration :param timeout_msec: the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout :param fd_list: a :obj:`~gi.repository.Gio.UnixFDList` or :const:`None` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. method:: close(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Closes ``connection``\. Note that this never causes the process to exit (this might only happen if the other end of a shared message bus connection disconnects, see :obj:`~gi.repository.Gio.DBusConnection`\:exit-on-close). Once the connection is closed, operations such as sending a message will return with the error :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. Closing a connection will not automatically flush the connection so queued messages may be lost. Use :func:`~gi.repository.Gio.DBusConnection.flush` if you need such guarantees. If ``connection`` is already closed, this method fails with :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. When ``connection`` has been closed, the :obj:`~gi.repository.Gio.DBusConnection`\::closed signal is emitted in the [thread-default main context][g-main-context-push-thread-default] of the thread that ``connection`` was constructed in. This is an asynchronous method. When the operation is finished, ``callback`` will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call :func:`~gi.repository.Gio.DBusConnection.close_finish` to get the result of the operation. See :func:`~gi.repository.Gio.DBusConnection.close_sync` for the synchronous version. .. versionadded:: 2.26 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied or :const:`None` if you don't care about the result :param user_data: The data to pass to ``callback`` .. method:: close_finish(res: ~gi.repository.Gio.AsyncResult) -> bool Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.close`. .. versionadded:: 2.26 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.close` .. method:: close_sync(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Synchronously closes ``connection``\. The calling thread is blocked until this is done. See :func:`~gi.repository.Gio.DBusConnection.close` for the asynchronous version of this method and more details about what it does. .. versionadded:: 2.26 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. method:: emit_signal(destination_bus_name: str | None, object_path: str, interface_name: str, signal_name: str, parameters: ~gi.repository.GLib.Variant | None = None) -> bool Emits a signal. If the parameters GVariant is floating, it is consumed. This can only fail if ``parameters`` is not compatible with the D-Bus protocol (:const:`~gi.repository.Gio.IOErrorEnum.INVALID_ARGUMENT`), or if ``connection`` has been closed (:const:`~gi.repository.Gio.IOErrorEnum.CLOSED`). .. versionadded:: 2.26 :param destination_bus_name: the unique bus name for the destination for the signal or :const:`None` to emit to all listeners :param object_path: path of remote object :param interface_name: D-Bus interface to emit a signal on :param signal_name: the name of the signal to emit :param parameters: a :obj:`~gi.repository.GLib.Variant` tuple with parameters for the signal or :const:`None` if not passing parameters .. method:: export_action_group(object_path: str, action_group: ~gi.repository.Gio.ActionGroup) -> int Exports ``action_group`` on ``connection`` at ``object_path``\. The implemented D-Bus API should be considered private. It is subject to change in the future. A given object path can only have one action group exported on it. If this constraint is violated, the export will fail and 0 will be returned (with ``error`` set accordingly). You can unexport the action group using :obj:`~gi.repository.Gio.DBusConnection.unexport_action_group` with the return value of this function. The thread default main context is taken at the time of this call. All incoming action activations and state change requests are reported from this context. Any changes on the action group that cause it to emit signals must also come from this same context. Since incoming action activations and state change requests are rather likely to cause changes on the action group, this effectively limits a given action group to being exported from only one main context. .. versionadded:: 2.32 :param object_path: a D-Bus object path :param action_group: an action group .. method:: export_menu_model(object_path: str, menu: ~gi.repository.Gio.MenuModel) -> int Exports ``menu`` on ``connection`` at ``object_path``\. The implemented D-Bus API should be considered private. It is subject to change in the future. An object path can only have one menu model exported on it. If this constraint is violated, the export will fail and 0 will be returned (with ``error`` set accordingly). Exporting menus with sections containing more than :const:`~gi.repository.Gio.MENU_EXPORTER_MAX_SECTION_SIZE` items is not supported and results in undefined behavior. You can unexport the menu model using :func:`~gi.repository.Gio.DBusConnection.unexport_menu_model` with the return value of this function. .. versionadded:: 2.32 :param object_path: a D-Bus object path :param menu: a :obj:`~gi.repository.Gio.MenuModel` .. method:: flush(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously flushes ``connection``\, that is, writes all queued outgoing message to the transport and then flushes the transport (using :func:`~gi.repository.Gio.OutputStream.flush_async`). This is useful in programs that wants to emit a D-Bus signal and then exit immediately. Without flushing the connection, there is no guaranteed that the message has been sent to the networking buffers in the OS kernel. This is an asynchronous method. When the operation is finished, ``callback`` will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call :func:`~gi.repository.Gio.DBusConnection.flush_finish` to get the result of the operation. See :func:`~gi.repository.Gio.DBusConnection.flush_sync` for the synchronous version. .. versionadded:: 2.26 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied or :const:`None` if you don't care about the result :param user_data: The data to pass to ``callback`` .. method:: flush_finish(res: ~gi.repository.Gio.AsyncResult) -> bool Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.flush`. .. versionadded:: 2.26 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.flush` .. method:: flush_sync(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Synchronously flushes ``connection``\. The calling thread is blocked until this is done. See :func:`~gi.repository.Gio.DBusConnection.flush` for the asynchronous version of this method and more details about what it does. .. versionadded:: 2.26 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. method:: get_capabilities() -> ~gi.repository.Gio.DBusCapabilityFlags Gets the capabilities negotiated with the remote peer .. versionadded:: 2.26 .. method:: get_exit_on_close() -> bool Gets whether the process is terminated when ``connection`` is closed by the remote peer. See :obj:`~gi.repository.Gio.DBusConnection`\:exit-on-close for more details. .. versionadded:: 2.26 .. method:: get_flags() -> ~gi.repository.Gio.DBusConnectionFlags Gets the flags used to construct this connection .. versionadded:: 2.60 .. method:: get_guid() -> str The GUID of the peer performing the role of server when authenticating. See :obj:`~gi.repository.Gio.DBusConnection`\:guid for more details. .. versionadded:: 2.26 .. method:: get_last_serial() -> int Retrieves the last serial number assigned to a :obj:`~gi.repository.Gio.DBusMessage` on the current thread. This includes messages sent via both low-level API such as :func:`~gi.repository.Gio.DBusConnection.send_message` as well as high-level API such as :func:`~gi.repository.Gio.DBusConnection.emit_signal`, :func:`~gi.repository.Gio.DBusConnection.call` or :func:`~gi.repository.Gio.DBusProxy.call`. .. versionadded:: 2.34 .. method:: get_peer_credentials() -> ~gi.repository.Gio.Credentials | None Gets the credentials of the authenticated peer. This will always return :const:`None` unless ``connection`` acted as a server (e.g. :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_SERVER` was passed) when set up and the client passed credentials as part of the authentication process. In a message bus setup, the message bus is always the server and each application is a client. So this method will always return :const:`None` for message bus clients. .. versionadded:: 2.26 .. method:: get_stream() -> ~gi.repository.Gio.IOStream Gets the underlying stream used for IO. While the :obj:`~gi.repository.Gio.DBusConnection` is active, it will interact with this stream from a worker thread, so it is not safe to interact with the stream directly. .. versionadded:: 2.26 .. method:: get_unique_name() -> str | None Gets the unique name of ``connection`` as assigned by the message bus. This can also be used to figure out if ``connection`` is a message bus connection. .. versionadded:: 2.26 .. method:: is_closed() -> bool Gets whether ``connection`` is closed. .. versionadded:: 2.26 .. classmethod:: new(guid: str | None, flags: ~gi.repository.Gio.DBusConnectionFlags, observer: ~gi.repository.Gio.DBusAuthObserver | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by ``stream``\. If ``stream`` is a :obj:`~gi.repository.Gio.SocketConnection`\, then the corresponding :obj:`~gi.repository.Gio.Socket` will be put into non-blocking mode. The D-Bus connection will interact with ``stream`` from a worker thread. As a result, the caller should not interact with ``stream`` after this method has been called, except by calling :func:`~gi.repository.GObject.GObject.Object.unref` on it. If ``observer`` is not :const:`None` it may be used to control the authentication process. When the operation is finished, ``callback`` will be invoked. You can then call :func:`~gi.repository.Gio.DBusConnection.new_finish` to get the result of the operation. This is an asynchronous failable constructor. See :func:`~gi.repository.Gio.DBusConnection.new_sync` for the synchronous version. .. versionadded:: 2.26 :param guid: the GUID to use if authenticating as a server or :const:`None` :param flags: flags describing how to make the connection :param observer: a :obj:`~gi.repository.Gio.DBusAuthObserver` or :const:`None` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to ``callback`` .. classmethod:: new_for_address(flags: ~gi.repository.Gio.DBusConnectionFlags, observer: ~gi.repository.Gio.DBusAuthObserver | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by ``address`` which must be in the `D-Bus address format `__\. This constructor can only be used to initiate client-side connections - use :func:`~gi.repository.Gio.DBusConnection.new` if you need to act as the server. In particular, ``flags`` cannot contain the :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_SERVER`, :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_ALLOW_ANONYMOUS` or :const:`~gi.repository.Gio.DBusConnectionFlags.AUTHENTICATION_REQUIRE_SAME_USER` flags. When the operation is finished, ``callback`` will be invoked. You can then call :func:`~gi.repository.Gio.DBusConnection.new_for_address_finish` to get the result of the operation. If ``observer`` is not :const:`None` it may be used to control the authentication process. This is an asynchronous failable constructor. See :func:`~gi.repository.Gio.DBusConnection.new_for_address_sync` for the synchronous version. .. versionadded:: 2.26 :param flags: flags describing how to make the connection :param observer: a :obj:`~gi.repository.Gio.DBusAuthObserver` or :const:`None` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to ``callback`` .. method:: register_object(object_path: str, interface_info: ~gi.repository.Gio.DBusInterfaceInfo, method_call_closure: ~gi.repository.GObject.Closure | None = None, get_property_closure: ~gi.repository.GObject.Closure | None = None, set_property_closure: ~gi.repository.GObject.Closure | None = None) -> int Registers callbacks for exported objects at ``object_path`` with the D-Bus interface that is described in ``interface_info``\. Calls to functions in ``vtable`` (and ``user_data_free_func``\) will happen in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. Note that all :obj:`~gi.repository.GLib.Variant` values passed to functions in ``vtable`` will match the signature given in ``interface_info`` - if a remote caller passes incorrect values, the ``org.freedesktop.DBus.Error.InvalidArgs`` is returned to the remote caller. Additionally, if the remote caller attempts to invoke methods or access properties not mentioned in ``interface_info`` the ``org.freedesktop.DBus.Error.UnknownMethod`` resp. ``org.freedesktop.DBus.Error.InvalidArgs`` errors are returned to the caller. It is considered a programming error if the :obj:`~gi.repository.Gio.DBusInterfaceGetPropertyFunc` function in ``vtable`` returns a :obj:`~gi.repository.GLib.Variant` of incorrect type. If an existing callback is already registered at ``object_path`` and ``interface_name``\, then ``error`` is set to :const:`~gi.repository.Gio.IOErrorEnum.EXISTS`. GDBus automatically implements the standard D-Bus interfaces org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable and org.freedesktop.Peer, so you don't have to implement those for the objects you export. You can implement org.freedesktop.DBus.Properties yourself, e.g. to handle getting and setting of properties asynchronously. Note that the reference count on ``interface_info`` will be incremented by 1 (unless allocated statically, e.g. if the reference count is -1, see :func:`~gi.repository.Gio.DBusInterfaceInfo.ref`) for as long as the object is exported. Also note that ``vtable`` will be copied. See this [server][gdbus-server] for an example of how to use this method. .. versionadded:: 2.26 :param object_path: the object path to register at :param interface_info: introspection data for the interface :param method_call_closure: :param get_property_closure: :param set_property_closure: .. method:: register_subtree(object_path: str, vtable: ~gi.repository.Gio.DBusSubtreeVTable, flags: ~gi.repository.Gio.DBusSubtreeFlags, user_data: ~typing.Any, user_data_free_func: ~typing.Callable[[~typing.Any], None]) -> int Registers a whole subtree of dynamic objects. The ``enumerate`` and ``introspection`` functions in ``vtable`` are used to convey, to remote callers, what nodes exist in the subtree rooted by ``object_path``\. When handling remote calls into any node in the subtree, first the ``enumerate`` function is used to check if the node exists. If the node exists or the :const:`~gi.repository.Gio.DBusSubtreeFlags.DISPATCH_TO_UNENUMERATED_NODES` flag is set the ``introspection`` function is used to check if the node supports the requested method. If so, the ``dispatch`` function is used to determine where to dispatch the call. The collected :obj:`~gi.repository.Gio.DBusInterfaceVTable` and :obj:`~gi.repository.gpointer` will be used to call into the interface vtable for processing the request. All calls into user-provided code will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. If an existing subtree is already registered at ``object_path`` or then ``error`` is set to :const:`~gi.repository.Gio.IOErrorEnum.EXISTS`. Note that it is valid to register regular objects (using :func:`~gi.repository.Gio.DBusConnection.register_object`) in a subtree registered with :func:`~gi.repository.Gio.DBusConnection.register_subtree` - if so, the subtree handler is tried as the last resort. One way to think about a subtree handler is to consider it a fallback handler for object paths not registered via :func:`~gi.repository.Gio.DBusConnection.register_object` or other bindings. Note that ``vtable`` will be copied so you cannot change it after registration. See this [server][gdbus-subtree-server] for an example of how to use this method. .. versionadded:: 2.26 :param object_path: the object path to register the subtree at :param vtable: a :obj:`~gi.repository.Gio.DBusSubtreeVTable` to enumerate, introspect and dispatch nodes in the subtree :param flags: flags used to fine tune the behavior of the subtree :param user_data: data to pass to functions in ``vtable`` :param user_data_free_func: function to call when the subtree is unregistered .. method:: remove_filter(filter_id: int) -> None Removes a filter. Note that since filters run in a different thread, there is a race condition where it is possible that the filter will be running even after calling :func:`~gi.repository.Gio.DBusConnection.remove_filter`, so you cannot just free data that the filter might be using. Instead, you should pass a :obj:`~gi.repository.GLib.DestroyNotify` to :func:`~gi.repository.Gio.DBusConnection.add_filter`, which will be called when it is guaranteed that the data is no longer needed. .. versionadded:: 2.26 :param filter_id: an identifier obtained from :func:`~gi.repository.Gio.DBusConnection.add_filter` .. method:: send_message(message: ~gi.repository.Gio.DBusMessage, flags: ~gi.repository.Gio.DBusSendMessageFlags) -> ~typing.Tuple[bool, int] Asynchronously sends ``message`` to the peer represented by ``connection``\. Unless ``flags`` contain the :const:`~gi.repository.Gio.DBusSendMessageFlags.PRESERVE_SERIAL` flag, the serial number will be assigned by ``connection`` and set on ``message`` via :func:`~gi.repository.Gio.DBusMessage.set_serial`. If ``out_serial`` is not :const:`None`, then the serial number used will be written to this location prior to submitting the message to the underlying transport. While it has a ``volatile`` qualifier, this is a historical artifact and the argument passed to it should not be ``volatile``\. If ``connection`` is closed then the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. If ``message`` is not well-formed, the operation fails with :const:`~gi.repository.Gio.IOErrorEnum.INVALID_ARGUMENT`. See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors. Note that ``message`` must be unlocked, unless ``flags`` contain the :const:`~gi.repository.Gio.DBusSendMessageFlags.PRESERVE_SERIAL` flag. .. versionadded:: 2.26 :param message: a :obj:`~gi.repository.Gio.DBusMessage` :param flags: flags affecting how the message is sent .. method:: send_message_with_reply(message: ~gi.repository.Gio.DBusMessage, flags: ~gi.repository.Gio.DBusSendMessageFlags, timeout_msec: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> int Asynchronously sends ``message`` to the peer represented by ``connection``\. Unless ``flags`` contain the :const:`~gi.repository.Gio.DBusSendMessageFlags.PRESERVE_SERIAL` flag, the serial number will be assigned by ``connection`` and set on ``message`` via :func:`~gi.repository.Gio.DBusMessage.set_serial`. If ``out_serial`` is not :const:`None`, then the serial number used will be written to this location prior to submitting the message to the underlying transport. While it has a ``volatile`` qualifier, this is a historical artifact and the argument passed to it should not be ``volatile``\. If ``connection`` is closed then the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. If ``cancellable`` is canceled, the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED`. If ``message`` is not well-formed, the operation fails with :const:`~gi.repository.Gio.IOErrorEnum.INVALID_ARGUMENT`. This is an asynchronous method. When the operation is finished, ``callback`` will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply_finish` to get the result of the operation. See :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply_sync` for the synchronous version. Note that ``message`` must be unlocked, unless ``flags`` contain the :const:`~gi.repository.Gio.DBusSendMessageFlags.PRESERVE_SERIAL` flag. See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors. .. versionadded:: 2.26 :param message: a :obj:`~gi.repository.Gio.DBusMessage` :param flags: flags affecting how the message is sent :param timeout_msec: the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied or :const:`None` if you don't care about the result :param user_data: The data to pass to ``callback`` .. method:: send_message_with_reply_finish(res: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.DBusMessage Finishes an operation started with :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply`. Note that ``error`` is only set if a local in-process error occurred. That is to say that the returned :obj:`~gi.repository.Gio.DBusMessage` object may be of type :const:`~gi.repository.Gio.DBusMessageType.ERROR`. Use :func:`~gi.repository.Gio.DBusMessage.to_gerror` to transcode this to a :obj:`~gi.repository.GLib.Error`\. See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors. .. versionadded:: 2.26 :param res: a :obj:`~gi.repository.Gio.AsyncResult` obtained from the :obj:`~gi.repository.Gio.AsyncReadyCallback` passed to :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply` .. method:: send_message_with_reply_sync(message: ~gi.repository.Gio.DBusMessage, flags: ~gi.repository.Gio.DBusSendMessageFlags, timeout_msec: int, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~typing.Tuple[~gi.repository.Gio.DBusMessage, int] Synchronously sends ``message`` to the peer represented by ``connection`` and blocks the calling thread until a reply is received or the timeout is reached. See :func:`~gi.repository.Gio.DBusConnection.send_message_with_reply` for the asynchronous version of this method. Unless ``flags`` contain the :const:`~gi.repository.Gio.DBusSendMessageFlags.PRESERVE_SERIAL` flag, the serial number will be assigned by ``connection`` and set on ``message`` via :func:`~gi.repository.Gio.DBusMessage.set_serial`. If ``out_serial`` is not :const:`None`, then the serial number used will be written to this location prior to submitting the message to the underlying transport. While it has a ``volatile`` qualifier, this is a historical artifact and the argument passed to it should not be ``volatile``\. If ``connection`` is closed then the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`. If ``cancellable`` is canceled, the operation will fail with :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED`. If ``message`` is not well-formed, the operation fails with :const:`~gi.repository.Gio.IOErrorEnum.INVALID_ARGUMENT`. Note that ``error`` is only set if a local in-process error occurred. That is to say that the returned :obj:`~gi.repository.Gio.DBusMessage` object may be of type :const:`~gi.repository.Gio.DBusMessageType.ERROR`. Use :func:`~gi.repository.Gio.DBusMessage.to_gerror` to transcode this to a :obj:`~gi.repository.GLib.Error`\. See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors. Note that ``message`` must be unlocked, unless ``flags`` contain the :const:`~gi.repository.Gio.DBusSendMessageFlags.PRESERVE_SERIAL` flag. .. versionadded:: 2.26 :param message: a :obj:`~gi.repository.Gio.DBusMessage` :param flags: flags affecting how the message is sent. :param timeout_msec: the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` .. method:: set_exit_on_close(exit_on_close: bool) -> None Sets whether the process should be terminated when ``connection`` is closed by the remote peer. See :obj:`~gi.repository.Gio.DBusConnection`\:exit-on-close for more details. Note that this function should be used with care. Most modern UNIX desktops tie the notion of a user session with the session bus, and expect all of a user's applications to quit when their bus connection goes away. If you are setting ``exit_on_close`` to :const:`False` for the shared session bus connection, you should make sure that your application exits when the user session ends. .. versionadded:: 2.26 :param exit_on_close: whether the process should be terminated when ``connection`` is closed by the remote peer .. method:: signal_subscribe(sender: str | None, interface_name: str | None, member: str | None, object_path: str | None, arg0: str | None, flags: ~gi.repository.Gio.DBusSignalFlags, callback: ~typing.Callable[[~gi.repository.Gio.DBusConnection, str | None, str, str, str, ~gi.repository.GLib.Variant, ~typing.Any], None], user_data: ~typing.Any = None) -> int Subscribes to signals on ``connection`` and invokes ``callback`` whenever the signal is received. Note that ``callback`` will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. If ``connection`` is not a message bus connection, ``sender`` must be :const:`None`. If ``sender`` is a well-known name note that ``callback`` is invoked with the unique name for the owner of ``sender``\, not the well-known name as one would expect. This is because the message bus rewrites the name. As such, to avoid certain race conditions, users should be tracking the name owner of the well-known name and use that when processing the received signal. If one of :const:`~gi.repository.Gio.DBusSignalFlags.MATCH_ARG0_NAMESPACE` or :const:`~gi.repository.Gio.DBusSignalFlags.MATCH_ARG0_PATH` are given, ``arg0`` is interpreted as part of a namespace or path. The first argument of a signal is matched against that part as specified by D-Bus. If ``user_data_free_func`` is non-:const:`None`, it will be called (in the thread-default main context of the thread you are calling this method from) at some point after ``user_data`` is no longer needed. (It is not guaranteed to be called synchronously when the signal is unsubscribed from, and may be called after ``connection`` has been destroyed.) As ``callback`` is potentially invoked in a different thread from where it’s emitted, it’s possible for this to happen after :func:`~gi.repository.Gio.DBusConnection.signal_unsubscribe` has been called in another thread. Due to this, ``user_data`` should have a strong reference which is freed with ``user_data_free_func``\, rather than pointing to data whose lifecycle is tied to the signal subscription. For example, if a :obj:`~gi.repository.GObject.Object` is used to store the subscription ID from :func:`~gi.repository.Gio.DBusConnection.signal_subscribe`, a strong reference to that :obj:`~gi.repository.GObject.Object` must be passed to ``user_data``\, and :func:`~gi.repository.GObject.GObject.Object.unref` passed to ``user_data_free_func``\. You are responsible for breaking the resulting reference count cycle by explicitly unsubscribing from the signal when dropping the last external reference to the :obj:`~gi.repository.GObject.Object`\. Alternatively, a weak reference may be used. It is guaranteed that if you unsubscribe from a signal using :func:`~gi.repository.Gio.DBusConnection.signal_unsubscribe` from the same thread which made the corresponding :func:`~gi.repository.Gio.DBusConnection.signal_subscribe` call, ``callback`` will not be invoked after :func:`~gi.repository.Gio.DBusConnection.signal_unsubscribe` returns. The returned subscription identifier is an opaque value which is guaranteed to never be zero. This function can never fail. .. versionadded:: 2.26 :param sender: sender name to match on (unique or well-known name) or :const:`None` to listen from all senders :param interface_name: D-Bus interface name to match on or :const:`None` to match on all interfaces :param member: D-Bus signal name to match on or :const:`None` to match on all signals :param object_path: object path to match on or :const:`None` to match on all object paths :param arg0: contents of first string argument to match on or :const:`None` to match on all kinds of arguments :param flags: :obj:`~gi.repository.Gio.DBusSignalFlags` describing how arg0 is used in subscribing to the signal :param callback: callback to invoke when there is a signal matching the requested data :param user_data: user data to pass to ``callback`` .. method:: signal_unsubscribe(subscription_id: int) -> None Unsubscribes from signals. Note that there may still be D-Bus traffic to process (relating to this signal subscription) in the current thread-default :obj:`~gi.repository.GLib.MainContext` after this function has returned. You should continue to iterate the :obj:`~gi.repository.GLib.MainContext` until the :obj:`~gi.repository.GLib.DestroyNotify` function passed to :func:`~gi.repository.Gio.DBusConnection.signal_subscribe` is called, in order to avoid memory leaks through callbacks queued on the :obj:`~gi.repository.GLib.MainContext` after it’s stopped being iterated. Alternatively, any idle source with a priority lower than %G_PRIORITY_DEFAULT that was scheduled after unsubscription, also indicates that all resources of this subscription are released. .. versionadded:: 2.26 :param subscription_id: a subscription id obtained from :func:`~gi.repository.Gio.DBusConnection.signal_subscribe` .. method:: start_message_processing() -> None If ``connection`` was created with :const:`~gi.repository.Gio.DBusConnectionFlags.DELAY_MESSAGE_PROCESSING`, this method starts processing messages. Does nothing on if ``connection`` wasn't created with this flag or if the method has already been called. .. versionadded:: 2.26 .. method:: unexport_action_group(export_id: int) -> None Reverses the effect of a previous call to :obj:`~gi.repository.Gio.DBusConnection.export_action_group`\. It is an error to call this function with an ID that wasn’t returned from :obj:`~gi.repository.Gio.DBusConnection.export_action_group` or to call it with the same ID more than once. .. versionadded:: 2.32 :param export_id: the ID from :obj:`~gi.repository.Gio.DBusConnection.export_action_group` .. method:: unexport_menu_model(export_id: int) -> None Reverses the effect of a previous call to :func:`~gi.repository.Gio.DBusConnection.export_menu_model`. It is an error to call this function with an ID that wasn't returned from :func:`~gi.repository.Gio.DBusConnection.export_menu_model` or to call it with the same ID more than once. .. versionadded:: 2.32 :param export_id: the ID from :func:`~gi.repository.Gio.DBusConnection.export_menu_model` .. method:: unregister_object(registration_id: int) -> bool Unregisters an object. .. versionadded:: 2.26 :param registration_id: a registration id obtained from :func:`~gi.repository.Gio.DBusConnection.register_object` .. method:: unregister_subtree(registration_id: int) -> bool Unregisters a subtree. .. versionadded:: 2.26 :param registration_id: a subtree registration id obtained from :func:`~gi.repository.Gio.DBusConnection.register_subtree` Properties ---------- .. rst-class:: interim-class .. class:: DBusConnection :no-index: .. 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.capabilities :type: ~gi.repository.Gio.DBusCapabilityFlags The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.closed :type: bool The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.exit_on_close :type: bool The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.flags :type: ~gi.repository.Gio.DBusConnectionFlags The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.guid :type: str The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.stream :type: ~gi.repository.Gio.IOStream The type of the None singleton. .. versionadded:: 2.26 .. attribute:: props.unique_name :type: str The type of the None singleton. .. versionadded:: 2.26 Signals ------- .. rst-class:: interim-class .. class:: DBusConnection.signals :no-index: .. method:: closed(remote_peer_vanished: bool, error: ~gi.repository.GLib.GError | None = None) -> None The type of the None singleton. .. versionadded:: 2.26 :param remote_peer_vanished: :const:`True` if ``connection`` is closed because the remote peer closed its end of the connection :param error: a :obj:`~gi.repository.GLib.Error` with more details about the event or :const:`None`