package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gio/Ocgtk_gio/Gio/Wrappers/D_bus_connection/index.html

Module Wrappers.D_bus_connection

type t = [ `d_bus_connection | `object_ ] Gobject.obj
val new_finish : [ `async_result ] Gobject.obj -> (t, GError.t) result

Create a new DBusConnection

val new_for_address_finish : [ `async_result ] Gobject.obj -> (t, GError.t) result

Create a new DBusConnection

val new_for_address_sync : string -> Gio_enums.dbusconnectionflags -> [ `d_bus_auth_observer | `object_ ] Gobject.obj option -> [ `cancellable | `object_ ] Gobject.obj option -> (t, GError.t) result

Create a new DBusConnection

val new_sync : [ `io_stream | `object_ ] Gobject.obj -> string option -> Gio_enums.dbusconnectionflags -> [ `d_bus_auth_observer | `object_ ] Gobject.obj option -> [ `cancellable | `object_ ] Gobject.obj option -> (t, GError.t) result

Create a new DBusConnection

val unregister_subtree : t -> int -> bool

Unregisters a subtree.

val unregister_object : t -> int -> bool

Unregisters an object.

val unexport_menu_model : t -> int -> unit

Reverses the effect of a previous call to g_dbus_connection_export_menu_model().

It is an error to call this function with an ID that wasn't returned from g_dbus_connection_export_menu_model() or to call it with the same ID more than once.

val unexport_action_group : t -> int -> unit

Reverses the effect of a previous call to g_dbus_connection_export_action_group().

It is an error to call this function with an ID that wasn't returned from g_dbus_connection_export_action_group() or to call it with the same ID more than once.

val start_message_processing : t -> unit

If @connection was created with %G_DBUS_CONNECTION_FLAGS_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.

val signal_unsubscribe : t -> int -> unit

Unsubscribes from signals.

Note that there may still be D-Bus traffic to process (relating to this signal subscription) in the current thread-default #GMainContext after this function has returned. You should continue to iterate the #GMainContext until the #GDestroyNotify function passed to g_dbus_connection_signal_subscribe() is called, in order to avoid memory leaks through callbacks queued on the #GMainContext 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.

val set_exit_on_close : t -> bool -> unit

Sets whether the process should be terminated when @connection is closed by the remote peer. See #GDBusConnection: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 %FALSE for the shared session bus connection, you should make sure that your application exits when the user session ends.

val send_message_with_reply_sync : t -> [ `d_bus_message | `object_ ] Gobject.obj -> Gio_enums.dbussendmessageflags -> int -> [ `cancellable | `object_ ] Gobject.obj option -> ([ `d_bus_message | `object_ ] Gobject.obj * UInt32.t, GError.t) result

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 g_dbus_connection_send_message_with_reply() for the asynchronous version of this method.

Unless @flags contain the %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number will be assigned by @connection and set on @message via g_dbus_message_set_serial(). If @out_serial is not %NULL, 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 %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will fail with %G_IO_ERROR_CANCELLED. If @message is not well-formed, the operation fails with %G_IO_ERROR_INVALID_ARGUMENT.

Note that @error is only set if a local in-process error occurred. That is to say that the returned #GDBusMessage object may be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use g_dbus_message_to_gerror() to transcode this to a #GError.

See this servergdbus-server and clientgdbus-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 %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag.

val send_message_with_reply_finish : t -> [ `async_result ] Gobject.obj -> ([ `d_bus_message | `object_ ] Gobject.obj, GError.t) result

Finishes an operation started with g_dbus_connection_send_message_with_reply().

Note that @error is only set if a local in-process error occurred. That is to say that the returned #GDBusMessage object may be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use g_dbus_message_to_gerror() to transcode this to a #GError.

See this servergdbus-server and clientgdbus-unix-fd-client for an example of how to use this low-level API to send and receive UNIX file descriptors.

val send_message : t -> [ `d_bus_message | `object_ ] Gobject.obj -> Gio_enums.dbussendmessageflags -> (bool * UInt32.t, GError.t) result

Asynchronously sends @message to the peer represented by @connection.

Unless @flags contain the %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number will be assigned by @connection and set on @message via g_dbus_message_set_serial(). If @out_serial is not %NULL, 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 %G_IO_ERROR_CLOSED. If @message is not well-formed, the operation fails with %G_IO_ERROR_INVALID_ARGUMENT.

See this servergdbus-server and clientgdbus-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 %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag.

val remove_filter : t -> int -> unit

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 g_dbus_connection_remove_filter(), so you cannot just free data that the filter might be using. Instead, you should pass a #GDestroyNotify to g_dbus_connection_add_filter(), which will be called when it is guaranteed that the data is no longer needed.

val is_closed : t -> bool

Gets whether @connection is closed.

val get_unique_name : t -> string option

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.

val get_stream : t -> [ `io_stream | `object_ ] Gobject.obj

Gets the underlying stream used for IO.

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.

val get_peer_credentials : t -> [ `credentials | `object_ ] Gobject.obj option

Gets the credentials of the authenticated peer. This will always return %NULL unless @connection acted as a server (e.g. %G_DBUS_CONNECTION_FLAGS_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 %NULL for message bus clients.

val get_last_serial : t -> UInt32.t

Retrieves the last serial number assigned to a #GDBusMessage on the current thread. This includes messages sent via both low-level API such as g_dbus_connection_send_message() as well as high-level API such as g_dbus_connection_emit_signal(), g_dbus_connection_call() or g_dbus_proxy_call().

val get_guid : t -> string

The GUID of the peer performing the role of server when authenticating. See #GDBusConnection:guid for more details.

val get_flags : t -> Gio_enums.dbusconnectionflags

Gets the flags used to construct this connection

val get_exit_on_close : t -> bool

Gets whether the process is terminated when @connection is closed by the remote peer. See #GDBusConnection:exit-on-close for more details.

val get_capabilities : t -> Gio_enums.dbuscapabilityflags

Gets the capabilities negotiated with the remote peer

val flush_sync : t -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Synchronously flushes @connection. The calling thread is blocked until this is done. See g_dbus_connection_flush() for the asynchronous version of this method and more details about what it does.

val flush_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an operation started with g_dbus_connection_flush().

val export_menu_model : t -> string -> [ `menu_model | `object_ ] Gobject.obj -> (int, GError.t) result

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 %G_MENU_EXPORTER_MAX_SECTION_SIZE items is not supported and results in undefined behavior.

You can unexport the menu model using g_dbus_connection_unexport_menu_model() with the return value of this function.

val export_action_group : t -> string -> [ `action_group ] Gobject.obj -> (int, GError.t) result

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 g_dbus_connection_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.

val emit_signal : t -> string option -> string -> string -> string -> Gvariant.t option -> (bool, GError.t) result

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 (%G_IO_ERROR_INVALID_ARGUMENT), or if @connection has been closed (%G_IO_ERROR_CLOSED).

val close_sync : t -> [ `cancellable | `object_ ] Gobject.obj option -> (bool, GError.t) result

Synchronously closes @connection. The calling thread is blocked until this is done. See g_dbus_connection_close() for the asynchronous version of this method and more details about what it does.

val close_finish : t -> [ `async_result ] Gobject.obj -> (bool, GError.t) result

Finishes an operation started with g_dbus_connection_close().

val call_sync : t -> string option -> string -> string -> string -> Gvariant.t option -> Gvariant_type.t option -> Gio_enums.dbuscallflags -> int -> [ `cancellable | `object_ ] Gobject.obj option -> (Gvariant.t, GError.t) result

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 %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will fail with %G_IO_ERROR_CANCELLED. If @parameters contains a value not compatible with the D-Bus protocol, the operation fails with %G_IO_ERROR_INVALID_ARGUMENT.

If @reply_type is non-%NULL 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-%NULL return value will be of this type.

If the @parameters #GVariant is floating, it is consumed. This allows convenient 'inline' use of g_variant_new(), e.g.: |<!-- language="C" --> 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 g_dbus_connection_call() for the asynchronous version of this method.

val call_finish : t -> [ `async_result ] Gobject.obj -> (Gvariant.t, GError.t) result

Finishes an operation started with g_dbus_connection_call().

val get_closed : t -> bool

Get property: closed