diff options
author | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2019-03-27 16:58:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@automotivelinux.org> | 2019-03-27 16:58:52 +0000 |
commit | 4d31aa48b0c43612532d1e4dd965291554d3b399 (patch) | |
tree | a5d9ca5ec9618a53fb2a6f1d1109e5904cceb540 /binding/telephony-binding.c | |
parent | da5ec72c481abe93534e40e89e38d825a86a6b6d (diff) | |
parent | ad3202c2ed31b8cb6fc8193f159c8f26a31e4663 (diff) |
Merge "binding: telephony: add online event for hfp status"halibut_7.99.1halibut/7.99.17.99.1
Diffstat (limited to 'binding/telephony-binding.c')
-rw-r--r-- | binding/telephony-binding.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c index a013196..c7feac6 100644 --- a/binding/telephony-binding.c +++ b/binding/telephony-binding.c @@ -35,6 +35,7 @@ static afb_event_t call_state_changed_event; static afb_event_t dialing_call_event; static afb_event_t incoming_call_event; static afb_event_t terminated_call_event; +static afb_event_t online_event; static void dial(afb_req_t request) { @@ -102,6 +103,14 @@ static void subscribe(afb_req_t request) afb_req_subscribe(request, incoming_call_event); } else if (!strcasecmp(value, "terminatedCall")) { afb_req_subscribe(request, terminated_call_event); + } else if (!strcasecmp(value, "online")) { + json_object *jresp = json_object_new_object(); + + afb_req_subscribe(request, online_event); + + json_object_object_add(jresp, "connected", + json_object_new_boolean(ofono_manager_get_default_modem_online())); + afb_event_push(online_event, jresp); } else { afb_req_fail(request, "failed", "Invalid event"); return; @@ -240,11 +249,21 @@ static void ofono_modem_signal_callback( ofono_manager_set_default_modem((const char *) address); if (ofono_manager_get_default_modem_valid()) { + json_object *jresp = json_object_new_object(); + ofono_init_default_modem(); + + json_object_object_add(jresp, "connected", json_object_new_boolean(TRUE)); + afb_event_push(online_event, jresp); } } else if (!g_strcmp0(ofono_manager_get_default_modem_address(), address)) { + json_object *jresp = json_object_new_object(); + AFB_NOTICE("Removing modem: (%s)", address); ofono_manager_invalidate_default_modem(); + + json_object_object_add(jresp, "connected", json_object_new_boolean(FALSE)); + afb_event_push(online_event, jresp); } g_free(address); @@ -286,6 +305,7 @@ static int ofono_init(afb_api_t api) dialing_call_event = afb_daemon_make_event("dialingCall"); incoming_call_event = afb_daemon_make_event("incomingCall"); terminated_call_event = afb_daemon_make_event("terminatedCall"); + online_event = afb_daemon_make_event("online"); /* Start the main loop thread */ pthread_create(&tid, NULL, main_loop_thread, NULL); |