## D-Bus Addresses

D-Bus Addresses — D-Bus connection endpoints

## Synopsis

    #include <gio/gio.h>

    gboolean            g_dbus_is_address                   (const gchar *string);
    gboolean            g_dbus_is_supported_address         (const gchar *string,
                                                             GError **error);
    void                g_dbus_address_get_stream           (const gchar *address,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GIOStream *         g_dbus_address_get_stream_finish    (GAsyncResult *res,
                                                             gchar **out_guid,
                                                             GError **error);
    GIOStream *         g_dbus_address_get_stream_sync      (const gchar *address,
                                                             gchar **out_guid,
                                                             GCancellable *cancellable,
                                                             GError **error);
    gchar *             g_dbus_address_get_for_bus_sync     (GBusType bus_type,
                                                             GCancellable *cancellable,
                                                             GError **error);

## Description

Routines for working with D-Bus addresses. A D-Bus address is a string like "unix:tmpdir=/tmp/my-app-name". The exact format of addresses is explained in detail in the D-Bus specification.

## Details

### g_dbus_is_address ()

    gboolean            g_dbus_is_address                   (const gchar *string);

Checks if `string` is a D-Bus address.

This doesn't check if `string` is actually supported by GDBusServer or GDBusConnection - use `g_dbus_is_supported_address()` to do more checks.

`string` : | A string.
Returns : | `TRUE` if `string` is a valid D-Bus address, `FALSE` otherwise.

Since 2.26

### g_dbus_is_supported_address ()

    gboolean            g_dbus_is_supported_address         (const gchar *string,
                                                             GError **error);

Like `g_dbus_is_address()` but also checks if the library suppors the transports in `string` and that key/value pairs for each transport are valid.

`string` : | A string.
`error` : | Return location for error or `NULL`.
Returns : | `TRUE` if `string` is a valid D-Bus address that is supported by this library, `FALSE` if `error` is set.

Since 2.26

### g_dbus_address_get_stream ()

    void                g_dbus_address_get_stream           (const gchar *address,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Asynchronously connects to an endpoint specified by `address` and sets up the connection so it is in a state to run the client-side of the D-Bus authentication conversation.

When the operation is finished, `callback` will be invoked. You can then call `g_dbus_address_get_stream_finish()` to get the result of the operation.

This is an asynchronous failable function. See `g_dbus_address_get_stream_sync()` for the synchronous version.

`address` : | A valid D-Bus address.
`cancellable` : | A GCancellable or `NULL`.
`callback` : | A GAsyncReadyCallback to call when the request is satisfied.
`user_data` : | Data to pass to `callback`.

Since 2.26

### g_dbus_address_get_stream_finish ()

    GIOStream *         g_dbus_address_get_stream_finish    (GAsyncResult *res,
                                                             gchar **out_guid,
                                                             GError **error);

Finishes an operation started with `g_dbus_address_get_stream()`.

`res` : | A GAsyncResult obtained from the GAsyncReadyCallback passed to `g_dbus_address_get_stream()`.
`out_guid` : | `NULL` or return location to store the GUID extracted from `address`, if any.
`error` : | Return location for error or `NULL`.
Returns : | A GIOStream or `NULL` if `error` is set. [transfer full]

Since 2.26

### g_dbus_address_get_stream_sync ()

    GIOStream *         g_dbus_address_get_stream_sync      (const gchar *address,
                                                             gchar **out_guid,
                                                             GCancellable *cancellable,
                                                             GError **error);

Synchronously connects to an endpoint specified by `address` and sets up the connection so it is in a state to run the client-side of the D-Bus authentication conversation.

This is a synchronous failable function. See `g_dbus_address_get_stream()` for the asynchronous version.

`address` : | A valid D-Bus address.
`out_guid` : | `NULL` or return location to store the GUID extracted from `address`, if any.
`cancellable` : | A GCancellable or `NULL`.
`error` : | Return location for error or `NULL`.
Returns : | A GIOStream or `NULL` if `error` is set. [transfer full]

Since 2.26

### g_dbus_address_get_for_bus_sync ()

    gchar *             g_dbus_address_get_for_bus_sync     (GBusType bus_type,
                                                             GCancellable *cancellable,
                                                             GError **error);

Synchronously looks up the D-Bus address for the well-known message bus instance specified by `bus_type`. This may involve using various platform specific mechanisms.

`bus_type` : | A GBusType.
`cancellable` : | A GCancellable or `NULL`.
`error` : | Return location for error or `NULL`.
Returns : | A valid D-Bus address string for `bus_type` or `NULL` if `error` is set.

Since 2.26