diff options
author | João Paulo Rechi Vita <jprvita@openbossa.org> | 2014-09-10 11:48:31 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | 2014-09-11 14:00:15 +0300 |
commit | 0e7f303256ff9c156a00b0530c3a90d9a26c07ca (patch) | |
tree | 2570ec0b26f1d6872cf0f035cbc7456dce4b79e2 /src/modules/bluetooth/backend-ofono.c | |
parent | c4c4de532d3837fcc42a50536130a14ed48f5153 (diff) |
bluetooth: Track oFono service
Diffstat (limited to 'src/modules/bluetooth/backend-ofono.c')
-rw-r--r-- | src/modules/bluetooth/backend-ofono.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c index bc92f4a08..ef8b2ce31 100644 --- a/src/modules/bluetooth/backend-ofono.c +++ b/src/modules/bluetooth/backend-ofono.c @@ -384,6 +384,7 @@ static void hf_audio_agent_unregister(pa_bluetooth_backend *backend) { static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *data) { const char *sender; + DBusError err; pa_bluetooth_backend *backend = data; pa_assert(bus); @@ -394,6 +395,41 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da if (!pa_safe_streq(backend->ofono_bus_id, sender) && !pa_streq("org.freedesktop.DBus", sender)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + dbus_error_init(&err); + + if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) { + const char *name, *old_owner, *new_owner; + + if (!dbus_message_get_args(m, &err, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &old_owner, + DBUS_TYPE_STRING, &new_owner, + DBUS_TYPE_INVALID)) { + pa_log_error("Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message); + goto fail; + } + + if (pa_streq(name, OFONO_SERVICE)) { + + if (old_owner && *old_owner) { + pa_log_debug("oFono disappeared"); + + pa_hashmap_remove_all(backend->cards); + + pa_xfree(backend->ofono_bus_id); + backend->ofono_bus_id = NULL; + } + + if (new_owner && *new_owner) { + pa_log_debug("oFono appeared"); + hf_audio_agent_register(backend); + } + } + + } + +fail: + dbus_error_free(&err); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } |