diff options
author | Dan Williams <dcbw@redhat.com> | 2012-10-07 11:09:10 -0500 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-12-04 17:36:43 +0000 |
commit | f9056cf5fe5ce67ad0b530c9af1977860231dde2 (patch) | |
tree | 80c053fcc2ddcbc868147ad41cbbcff69387826e | |
parent | 2e1ba392a29107c9bf9413113aff7b98a963da21 (diff) | |
download | dbus-glib-f9056cf5fe5ce67ad0b530c9af1977860231dde2.tar.gz |
Add dbus_g_connection_open_private() for private D-Bus sockets
Like dbus_g_connection_open() but for private bus sockets, calling
dbus_connection_open_private() and ensuring the dbus-glib types are
initialized.
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55730
-rw-r--r-- | dbus/dbus-glib.h | 3 | ||||
-rw-r--r-- | dbus/dbus-gmain.c | 43 |
2 files changed, 46 insertions, 0 deletions
diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h index 9a2076f..bd5784c 100644 --- a/dbus/dbus-glib.h +++ b/dbus/dbus-glib.h @@ -103,6 +103,9 @@ void dbus_g_thread_init (void); DBusGConnection* dbus_g_connection_open (const gchar *address, GError **error); +DBusGConnection* dbus_g_connection_open_private (const gchar *address, + GMainContext *context, + GError **error); DBusGConnection* dbus_g_bus_get (DBusBusType type, GError **error); DBusGConnection* dbus_g_bus_get_private (DBusBusType type, diff --git a/dbus/dbus-gmain.c b/dbus/dbus-gmain.c index e6ce52b..dec199d 100644 --- a/dbus/dbus-gmain.c +++ b/dbus/dbus-gmain.c @@ -705,6 +705,49 @@ dbus_g_connection_open (const gchar *address, } /** + * dbus_g_connection_open_private: + * @address: address of the connection to open + * @context: the #GMainContext or %NULL for default context + * @error: address where an error can be returned. + * + * Returns a private connection to the given address; this + * connection does not talk to a bus daemon and thus the caller + * must set up any authentication by itself. If the address + * refers to a message bus, the caller must call dbus_bus_register(). + * + * (Internally, calls dbus_connection_open_private() then calls + * dbus_connection_setup_with_g_main() on the result.) + * + * Returns: (transfer full): a #DBusGConnection + */ +DBusGConnection * +dbus_g_connection_open_private (const gchar *address, + GMainContext *context, + GError **error) +{ + DBusConnection *connection; + DBusError derror; + + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + _dbus_g_value_types_init (); + + dbus_error_init (&derror); + + connection = dbus_connection_open_private (address, &derror); + if (connection == NULL) + { + dbus_set_g_error (error, &derror); + dbus_error_free (&derror); + return NULL; + } + + dbus_connection_setup_with_g_main (connection, context); + + return DBUS_G_CONNECTION_FROM_CONNECTION (connection); +} + +/** * dbus_g_bus_get: * @type: bus type * @error: address where an error can be returned. |