diff options
author | Forrest Zhao <forrest.zhao@intel.com> | 2010-01-27 16:24:23 +0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-27 09:50:24 +0100 |
commit | 57013cfa0d58ec03b5cd3a3dce7a884dec9c43c6 (patch) | |
tree | 37cb73385c78102387eb13efa6c491fb8f6ba548 /gdbus | |
parent | 2bece5fe0dcab28faf69e8e1596d090f6c591107 (diff) |
Introduce g_dbus_setup_private() to gdbus
g_dbus_setup_private() is used to setup private DBusConnection
Diffstat (limited to 'gdbus')
-rw-r--r-- | gdbus/gdbus.h | 3 | ||||
-rw-r--r-- | gdbus/mainloop.c | 65 |
2 files changed, 55 insertions, 13 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index dc5092fd..77b8aee1 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -40,6 +40,9 @@ typedef gboolean (* GDBusSignalFunction) (DBusConnection *connection, DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, DBusError *error); +DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, + DBusError *error); + gboolean g_dbus_request_name(DBusConnection *connection, const char *name, DBusError *error); diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c index b8be0440..80c61b79 100644 --- a/gdbus/mainloop.c +++ b/gdbus/mainloop.c @@ -262,11 +262,36 @@ static inline void setup_dbus_with_main_loop(DBusConnection *conn) NULL, NULL); } +static gboolean setup_bus(DBusConnection *conn, const char *name, + DBusError *error) +{ + gboolean result; + DBusDispatchStatus status; + + if (name != NULL) { + result = g_dbus_request_name(conn, name, error); + + if (error != NULL) { + if (dbus_error_is_set(error) == TRUE) + return FALSE; + } + + if (result == FALSE) + return FALSE; + } + + setup_dbus_with_main_loop(conn); + + status = dbus_connection_get_dispatch_status(conn); + queue_dispatch(conn, status); + + return TRUE; +} + DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, DBusError *error) { DBusConnection *conn; - DBusDispatchStatus status; gboolean result; conn = dbus_bus_get(type, error); @@ -279,24 +304,38 @@ DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, if (conn == NULL) return NULL; - if (name != NULL) { - result = g_dbus_request_name(conn, name, error); + result = setup_bus(conn, name, error); - if (error != NULL) { - if (dbus_error_is_set(error) == TRUE) - result = FALSE; - } + if (result == FALSE) { + dbus_connection_unref(conn); + return NULL; + } + + return conn; +} + +DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, + DBusError *error) +{ + DBusConnection *conn; + gboolean result; - if (result == FALSE) { - dbus_connection_unref(conn); + conn = dbus_bus_get_private(type, error); + + if (error != NULL) { + if (dbus_error_is_set(error) == TRUE) return NULL; - } } - setup_dbus_with_main_loop(conn); + if (conn == NULL) + return NULL; - status = dbus_connection_get_dispatch_status(conn); - queue_dispatch(conn, status); + result = setup_bus(conn, name, error); + + if (result == FALSE) { + dbus_connection_unref(conn); + return NULL; + } return conn; } |