From b1a09ebf7ea3ba9471d2376b2b42fc252897278d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Wed, 10 Sep 2014 11:48:33 +0200 Subject: bluetooth: Handle CardRemoved signal --- src/modules/bluetooth/backend-ofono.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/modules/bluetooth') diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c index fe4e2cae8..3f409417b 100644 --- a/src/modules/bluetooth/backend-ofono.c +++ b/src/modules/bluetooth/backend-ofono.c @@ -269,6 +269,24 @@ fail: hf_audio_card_free(card); } +static void hf_audio_agent_card_removed(pa_bluetooth_backend *backend, const char *path) { + struct hf_audio_card *card; + + pa_assert(backend); + pa_assert(path); + + pa_log_debug("HF card removed: %s", path); + + card = pa_hashmap_remove(backend->cards, path); + if (!card) + return; + + if (card->transport) + pa_bluetooth_transport_unlink(card->transport); + + hf_audio_card_free(card); +} + static void hf_audio_agent_get_cards_reply(DBusPendingCall *pending, void *userdata) { DBusMessage *r; pa_dbus_pending *p; @@ -444,6 +462,15 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da dbus_message_iter_recurse(&arg_i, &props_i); hf_audio_agent_card_found(backend, p, &props_i); + } else if (dbus_message_is_signal(m, "org.ofono.HandsfreeAudioManager", "CardRemoved")) { + const char *p; + + if (!dbus_message_get_args(m, &err, DBUS_TYPE_OBJECT_PATH, &p, DBUS_TYPE_INVALID)) { + pa_log_error("Failed to parse org.ofono.HandsfreeAudioManager.CardRemoved: %s", err.message); + goto fail; + } + + hf_audio_agent_card_removed(backend, p); } fail: -- cgit v1.2.1