aboutsummaryrefslogtreecommitdiffstats
path: root/binding/bluetooth-api.c
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2019-03-07 03:39:16 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-03-07 03:39:16 +0000
commit66d4abbb3c5462ceb65148ea5ee13645d588d55e (patch)
treeb6af99cbae368cd50514377bdc8a29a31d1246e3 /binding/bluetooth-api.c
parent0f98b3a52cf873c391e3287cee9fe614d02a2884 (diff)
parent5fca83cd4aca5f276be73d99cd5ca04302bed6f3 (diff)
Merge "binding: bluetooth: add adapter_changes event"
Diffstat (limited to 'binding/bluetooth-api.c')
-rw-r--r--binding/bluetooth-api.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c
index 9ce0541..4c1165c 100644
--- a/binding/bluetooth-api.c
+++ b/binding/bluetooth-api.c
@@ -249,6 +249,9 @@ void call_work_destroy(struct call_work *cw)
static afb_event_t get_event_from_value(struct bluetooth_state *ns,
const char *value)
{
+ if (!g_strcmp0(value, "adapter_changes"))
+ return ns->adapter_changes_event;
+
if (!g_strcmp0(value, "device_changes"))
return ns->device_changes_event;
@@ -305,18 +308,27 @@ static void bluez_devices_signal_callback(
GVariant *val = NULL;
if (g_strcmp0(key, BLUEZ_DEVICE_INTERFACE) &&
- g_strcmp0(key, BLUEZ_MEDIATRANSPORT_INTERFACE))
+ g_strcmp0(key, BLUEZ_MEDIATRANSPORT_INTERFACE) &&
+ g_strcmp0(key, BLUEZ_ADAPTER_INTERFACE))
continue;
array1 = g_variant_iter_new(var);
while (g_variant_iter_next(array1, "{&sv}", &name, &val)) {
- if (!g_strcmp0(key, BLUEZ_DEVICE_INTERFACE))
+ if (!g_strcmp0(key, BLUEZ_DEVICE_INTERFACE)) {
ret = device_property_dbus2json(jobj,
name, val, &is_config, &error);
- else
+ } else if (!g_strcmp0(key, BLUEZ_MEDIATRANSPORT_INTERFACE)) {
ret = mediatransport_property_dbus2json(jobj,
name, val, &is_config, &error);
+ } else if (!g_strcmp0(key, BLUEZ_ADAPTER_INTERFACE)) {
+ ret = adapter_property_dbus2json(jobj,
+ name, val, &is_config, &error);
+ event = ns->adapter_changes_event;
+ } else {
+ ret = TRUE;
+ }
+
g_variant_unref(val);
if (!ret) {
AFB_DEBUG("%s property %s - %s",
@@ -383,6 +395,12 @@ static void bluez_devices_signal_callback(
json_object_object_add(jresp, "type",
json_object_new_string("playback"));
event = ns->media_event;
+ /* adapter removal */
+ } else if (split_length(path) == 4) {
+ json_object_object_add(jresp, "action",
+ json_object_new_string("removed"));
+ event = ns->adapter_changes_event;
+ /* device removal */
} else if (split_length(path) == 5) {
json_object_object_add(jresp, "action",
json_object_new_string("removed"));
@@ -515,6 +533,8 @@ static struct bluetooth_state *bluetooth_init(GMainLoop *loop)
AFB_INFO("connected to dbus");
+ ns->adapter_changes_event =
+ afb_daemon_make_event("adapter_changes");
ns->device_changes_event =
afb_daemon_make_event("device_changes");
ns->media_event =