diff options
author | Frédéric Danis <frederic.danis@linux.intel.com> | 2011-02-04 19:46:17 -0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-02-08 12:44:39 -0600 |
commit | bc793d945cdbc0dbe930ccae9aacc2a9179982c1 (patch) | |
tree | 083c13a9b38d66af2d42cfc7bfb16a90418af609 | |
parent | 67f41014de1fa27ac2f7efe05b26be304b3ce294 (diff) | |
download | ofono-bc793d945cdbc0dbe930ccae9aacc2a9179982c1.tar.bz2 |
bluetooth: Optimize D-Bus call flow
We can call manager GetProperties once inside bluetooth_ref and avoid
calling it every time bluetooth_register_uuid is called.
-rw-r--r-- | plugins/bluetooth.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index 93dd7a13..13f3b3bb 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -409,6 +409,14 @@ done: dbus_message_unref(reply); } +static void get_adapter_properties(const char *path, const char *handle, + gpointer user_data) +{ + bluetooth_send_with_reply(path, BLUEZ_ADAPTER_INTERFACE, + "GetProperties", adapter_properties_cb, + g_strdup(path), g_free, -1, DBUS_TYPE_INVALID); +} + static gboolean adapter_added(DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -541,6 +549,10 @@ static void bluetooth_ref(void) adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties", + manager_properties_cb, NULL, NULL, -1, + DBUS_TYPE_INVALID); + increment: g_atomic_int_inc(&bluetooth_refcount); @@ -576,9 +588,8 @@ int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile) g_hash_table_insert(uuid_hash, g_strdup(uuid), profile); - bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties", - manager_properties_cb, NULL, NULL, -1, - DBUS_TYPE_INVALID); + g_hash_table_foreach(adapter_address_hash, + (GHFunc) get_adapter_properties, NULL); return 0; } |