diff options
author | Matt Porter <mporter@konsulko.com> | 2018-06-20 22:02:38 -0400 |
---|---|---|
committer | Matt Porter <mporter@konsulko.com> | 2018-06-20 22:02:38 -0400 |
commit | e31431b389c5a078058cf971c636608718180562 (patch) | |
tree | d3d9fe5d255f453f822be2678f0d52073d99803c | |
parent | 0446b890d9e36de48a7e2634bcecf36c3878f561 (diff) |
Send connection status upon event subscribeguppy_6.90.0guppy/6.90.0flounder_5.99.6flounder_5.99.5flounder_5.99.4flounder_5.99.3flounder_5.99.2flounder_5.99.1flounder/5.99.6flounder/5.99.5flounder/5.99.4flounder/5.99.3flounder/5.99.2flounder/5.99.16.90.05.99.65.99.55.99.45.99.35.99.25.99.1
When the status event is subscribed, immediately
send the current PBAP connection status.
Bug-AGL: SPEC-1519
Change-Id: I222789f81040c80fb67dac63c889c96586ba0dbd
Signed-off-by: Matt Porter <mporter@konsulko.com>
-rw-r--r-- | binding/bluetooth-pbap-binding.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/binding/bluetooth-pbap-binding.c b/binding/bluetooth-pbap-binding.c index 73279be..28a90b2 100644 --- a/binding/bluetooth-pbap-binding.c +++ b/binding/bluetooth-pbap-binding.c @@ -443,16 +443,26 @@ static void status(struct afb_req request) static void subscribe(struct afb_req request) { const char *value = afb_req_value(request, "value"); - if (value) { - if (!g_strcmp0(value, "status")) { - afb_req_subscribe(request, status_event); - } else { - afb_req_fail(request, "failed", "Invalid event"); - return; - } + + if (!value) { + afb_req_fail(request, "failed", "No event"); + return; } - afb_req_success(request, NULL, NULL); + if (!g_strcmp0(value, "status")) { + afb_req_subscribe(request, status_event); + afb_req_success(request, NULL, NULL); + + struct json_object *event, *status; + event = json_object_new_object(); + g_mutex_lock(&connected_mutex); + status = json_object_new_boolean(connected); + g_mutex_unlock(&connected_mutex); + json_object_object_add(event, "connected", status); + afb_event_push(status_event, event); + } else { + afb_req_fail(request, "failed", "Invalid event"); + } } static void unsubscribe(struct afb_req request) |