## DBusGConnection DBusGConnection — DBus Connection |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <dbus/dbus-glib.h>

                        DBusGConnection;
    #define             DBUS_TYPE_G_CONNECTION
    DBusGConnection *   dbus_g_bus_get                      (DBusBusType type,
                                                             GError **error);
    DBusGConnection *   dbus_g_bus_get_private              (DBusBusType type,
                                                             GMainContext *context,
                                                             GError **error);
    void                dbus_g_thread_init                  (void);
    DBusGConnection *   dbus_g_connection_open              (const gchar *address,
                                                             GError **error);
    DBusGConnection *   dbus_g_connection_ref               (DBusGConnection *connection);
    void                dbus_g_connection_unref             (DBusGConnection *connection);
    void                dbus_g_connection_flush             (DBusGConnection *connection);
    DBusConnection *    dbus_g_connection_get_connection    (DBusGConnection *gconnection);
    void                dbus_g_connection_register_g_object (DBusGConnection *connection,
                                                             const char *at_path,
                                                             GObject *object);
    void                dbus_g_connection_unregister_g_object
                                                            (DBusGConnection *connection,
                                                             GObject *object);
    GObject *           dbus_g_connection_lookup_g_object   (DBusGConnection *connection,
                                                             const char *at_path);

## Description

A DBusGConnection is a boxed type abstracting a DBusConnection.

## Details

### DBusGConnection

    typedef struct _DBusGConnection DBusGConnection;

A DBusGConnection is a boxed type abstracting a DBusConnection from libdbus.

### DBUS_TYPE_G_CONNECTION

    #define DBUS_TYPE_G_CONNECTION   (dbus_g_connection_get_g_type ())

Expands to a function call returning the boxed GType of a DBusGConnection.

Returns : | the GLib type

### dbus_g_bus_get ()

    DBusGConnection *   dbus_g_bus_get                      (DBusBusType type,
                                                             GError **error);

Returns a connection to the given bus. The connection is a global variable shared with other callers of this function.

(Internally, calls `dbus_bus_get()` then calls `dbus_connection_setup_with_g_main()` on the result.)

`type` : | bus type
`error` : | address where an error can be returned.
Returns : | a DBusConnection

### dbus_g_bus_get_private ()

    DBusGConnection *   dbus_g_bus_get_private              (DBusBusType type,
                                                             GMainContext *context,
                                                             GError **error);

Returns a connection to the given bus. The connection will be a private non-shared connection and should be closed when usage is complete.

Internally this function calls `dbus_bus_get_private()` then calls `dbus_connection_setup_with_g_main()` on the result; see the documentation of the former function for more information on private connections.

`type` : | bus type
`context` : | Mainloop context to attach to
`error` : | address where an error can be returned.
Returns : | a DBusConnection

### dbus_g_thread_init ()

    void                dbus_g_thread_init                  (void);

Initializes the D-BUS thread system. This function may only be called once and must be called prior to calling any other function in the D-BUS API.

### dbus_g_connection_open ()

    DBusGConnection *   dbus_g_connection_open              (const gchar *address,
                                                             GError **error);

Returns a connection to the given address.

(Internally, calls `dbus_connection_open()` then calls `dbus_connection_setup_with_g_main()` on the result.)

`address` : | address of the connection to open
`error` : | address where an error can be returned.
Returns : | a DBusConnection

### dbus_g_connection_ref ()

    DBusGConnection *   dbus_g_connection_ref               (DBusGConnection *connection);

Increment refcount on a DBusGConnection

`connection` : | the DBusGConnection to ref
Returns : | the connection that was ref'd

### dbus_g_connection_unref ()

    void                dbus_g_connection_unref             (DBusGConnection *connection);

Decrement refcount on a DBusGConnection

`connection` : | the connection to unref

### dbus_g_connection_flush ()

    void                dbus_g_connection_flush             (DBusGConnection *connection);

Blocks until outgoing calls and signal emissions have been sent.

`connection` : | the DBusGConnection to flush

### dbus_g_connection_get_connection ()

    DBusConnection *    dbus_g_connection_get_connection    (DBusGConnection *gconnection);

Get the DBusConnection corresponding to this DBusGConnection. The return value does not have its refcount incremented.

`gconnection` : | a DBusGConnection
Returns : | DBusConnection

### dbus_g_connection_register_g_object ()

    void                dbus_g_connection_register_g_object (DBusGConnection *connection,
                                                             const char *at_path,
                                                             GObject *object);

Registers a GObject at the given path. Properties, methods, and signals of the object can then be accessed remotely. Methods are only available if method introspection data has been added to the object's class with `dbus_g_object_type_install_info()`.

The registration will be cancelled if either the DBusConnection or the GObject gets finalized, or if `dbus_g_connection_unregister_g_object()` is used.

Note: If an object is registered multiple times, the first registration takes priority for cases such as turning an object into an object path.

`connection` : | the D-BUS connection
`at_path` : | the path where the object will live (the object's name)
`object` : | the object

### dbus_g_connection_unregister_g_object ()

    void                dbus_g_connection_unregister_g_object
                                                            (DBusGConnection *connection,
                                                             GObject *object);

Removes `object` from any object paths at which it is exported on `connection`. Properties, methods, and signals of the object can no longer be accessed remotely.

`connection` : | the D-BUS connection
`object` : | the object

### dbus_g_connection_lookup_g_object ()

    GObject *           dbus_g_connection_lookup_g_object   (DBusGConnection *connection,
                                                             const char *at_path);

FIXME

`connection` : | a DBusGConnection
`at_path` : | path
Returns : | the object at path `at_path`

## See Also

DBusConnection