bluetooth: Add hook to announce late UUIDs
authorMikel Astiz <mikel.astiz@bmw-carit.de>
Tue, 23 Oct 2012 14:41:59 +0000 (16:41 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Thu, 25 Oct 2012 10:17:06 +0000 (13:17 +0300)
UUIDs might be announced at any time, so a hook is needed to notify any
interested module. In practice, the UUIDs are quite stable with the
exception of the pairing procedure, where the UUIDs are reported by
BlueZ as soon as they are discovered.

src/modules/bluetooth/bluetooth-util.c
src/modules/bluetooth/bluetooth-util.h

index 1e8186471bd9fb14740200ee50277472133faa98..272b6cef94c35a84e9eedf699a1df36745873a50 100644 (file)
@@ -383,9 +383,17 @@ static int parse_device_property(pa_bluetooth_discovery *y, pa_bluetooth_device
                     const char *value;
 
                     dbus_message_iter_get_basic(&ai, &value);
+
+                    if (pa_bluetooth_uuid_has(d->uuids, value)) {
+                        dbus_message_iter_next(&ai);
+                        continue;
+                    }
+
                     node = uuid_new(value);
                     PA_LLIST_PREPEND(pa_bluetooth_uuid, d->uuids, node);
 
+                    pa_hook_fire(&d->hooks[PA_BLUETOOTH_DEVICE_HOOK_UUID_ADDED], (char *) value);
+
                     /* Vudentz said the interfaces are here when the UUIDs are announced */
                     if (strcasecmp(HSP_AG_UUID, value) == 0 || strcasecmp(HFP_AG_UUID, value) == 0) {
                         pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.HandsfreeGateway", "GetProperties"));
index 4e3b5f0c9946e31013d195cf9b4888d93fcdee9b..8a3f2ad00d4cbd9289196b6232e5a397d783947c 100644 (file)
@@ -94,6 +94,7 @@ typedef enum pa_bt_audio_state {
 /* Hook data: pa_bluetooth_device pointer. */
 typedef enum pa_bluetooth_device_hook {
     PA_BLUETOOTH_DEVICE_HOOK_REMOVED, /* Call data: NULL. */
+    PA_BLUETOOTH_DEVICE_HOOK_UUID_ADDED, /* Call data: const char *uuid. */
     PA_BLUETOOTH_DEVICE_HOOK_MAX
 } pa_bluetooth_device_hook_t;