[pulseaudio-discuss] [RFCv3 09/20] bluetooth: Track org.ofono.HandsfreeAudioManager.CardAdded

jprvita at gmail.com jprvita at gmail.com
Sun Apr 21 20:07:39 PDT 2013


From: João Paulo Rechi Vita <jprvita at openbossa.org>

When a new HF card is created in runtime it has to be parsed and a
transport has to be created for it.
---
 src/modules/bluetooth/bluetooth-util.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 26623a4..f0ebbcb 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1719,6 +1719,25 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
         }
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+    } else if (dbus_message_is_signal(m, "org.ofono.HandsfreeAudioManager", "CardAdded")) {
+        const char *path;
+        DBusMessageIter arg_i, props_i;
+
+        if (!dbus_message_iter_init(m, &arg_i) || !pa_streq(dbus_message_get_signature(m), "oa{sv}")) {
+            pa_log_error("Failed to parse org.ofono.HandsfreeAudioManager.CardAdded");
+            goto fail;
+        }
+
+        dbus_message_iter_get_basic(&arg_i, &path);
+
+        pa_assert_se(dbus_message_iter_next(&arg_i));
+        pa_assert(dbus_message_iter_get_arg_type(&arg_i) == DBUS_TYPE_ARRAY);
+
+        dbus_message_iter_recurse(&arg_i, &props_i);
+
+        hfagent_card_found(y, path, &props_i);
+
     }
 
 fail:
@@ -2491,6 +2510,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
                 ",arg0='org.bluez.MediaTransport1'",
                 "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
                 "arg0='org.ofono'",
+                "type='signal',sender='org.ofono',interface='org.ofono.HandsfreeAudioManager',member='CardAdded'",
                 NULL) < 0) {
         pa_log("Failed to add D-Bus matches: %s", err.message);
         goto fail;
@@ -2576,6 +2596,7 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
             "type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesRemoved'",
             "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
             "arg0='org.ofono'",
+            "type='signal',sender='org.ofono',interface='org.ofono.HandsfreeAudioManager',member='CardAdded'",
             NULL);
 
         if (y->filter_added)
-- 
1.7.11.7



More information about the pulseaudio-discuss mailing list