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:14 +0100 |
commit | a22875ffece0ce823882a653c9c212e1ebb4963c (patch) | |
tree | c33cc896a79cbb79ab9b6edd9ae1d3bae3ca9a3e /gdbus | |
parent | 27be9cd90e7aaa96af669282e5c7e34dbb38fbfa (diff) | |
download | connman-a22875ffece0ce823882a653c9c212e1ebb4963c.tar.gz connman-a22875ffece0ce823882a653c9c212e1ebb4963c.tar.bz2 connman-a22875ffece0ce823882a653c9c212e1ebb4963c.zip |
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; } |