summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-02-17 19:00:46 -0300
committerMarcel Holtmann <marcel@holtmann.org>2011-02-17 16:00:00 -0800
commita0dce4c015bdba3324cd6d24085cd4ab52d33a66 (patch)
tree1b1f01ebef804a10cfc5cd231d2cde4b395a90dc
parente7f8041acd12f9d10b2eb153222f37d05ccc8d19 (diff)
downloadofono-a0dce4c015bdba3324cd6d24085cd4ab52d33a66.tar.bz2
bluetooth: add a bluetoothd connect watch
This fix a issue with sending DBus messages when bluetoothd is not up yet.
-rw-r--r--plugins/bluetooth.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 32be96e6..8ca9f5f4 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -742,6 +742,18 @@ static void bluetooth_remove_all_modem(gpointer key, gpointer value,
profile->remove_all();
}
+static void bluetooth_connect(DBusConnection *connection, void *user_data)
+{
+ bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
+ manager_properties_cb, NULL, NULL, -1,
+ DBUS_TYPE_INVALID);
+
+ bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
+ find_adapter_cb, NULL, NULL, -1,
+ DBUS_TYPE_STRING, &adapter_any_name,
+ DBUS_TYPE_INVALID);
+}
+
static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
{
if (uuid_hash == NULL)
@@ -763,7 +775,8 @@ static void bluetooth_ref(void)
connection = ofono_dbus_get_connection();
bluetooth_watch = g_dbus_add_service_watch(connection, BLUEZ_SERVICE,
- NULL, bluetooth_disconnect, NULL, NULL);
+ bluetooth_connect,
+ bluetooth_disconnect, NULL, NULL);
adapter_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
BLUEZ_MANAGER_INTERFACE,
@@ -791,15 +804,6 @@ 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);
-
- bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
- find_adapter_cb, NULL, NULL, -1,
- DBUS_TYPE_STRING, &adapter_any_name,
- DBUS_TYPE_INVALID);
-
increment:
g_atomic_int_inc(&bluetooth_refcount);