diff options
author | Clément Bénier <clement.benier@iot.bzh> | 2018-12-13 02:20:29 +0100 |
---|---|---|
committer | Clément Bénier <clement.benier@iot.bzh> | 2018-12-13 02:20:29 +0100 |
commit | 18019a5e9da7085d2fda7cfd6bc74417f11bfe36 (patch) | |
tree | 9421b6ae8320005ee29a4b403bc1dae77d7ac2a7 | |
parent | f812dd06ec66fe18b9c79b7afd7c6bf444335c1b (diff) |
telephony-binding: handle vshl interfacesandbox/benierc/vshl
- subscribe to vhsl controlphone
- parse event
Change-Id: I3be9a5a8c8e95516468e2f45c269ae0393f9df25
Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
-rw-r--r-- | binding/telephony-binding.c | 68 | ||||
-rw-r--r-- | conf.d/wgt/config.xml.in | 1 |
2 files changed, 69 insertions, 0 deletions
diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c index 50d3638..6ae079a 100644 --- a/binding/telephony-binding.c +++ b/binding/telephony-binding.c @@ -325,10 +325,24 @@ static const afb_verb_t verbs[]= { { } }; +static int phonecontrol_init(afb_api_t api) +{ + AFB_NOTICE("PHONECONTROL_INIT"); + struct json_object *events = json_object_new_object(); + struct json_object *array_events = json_object_new_array(); + json_object_array_add(array_events, json_object_new_string("dial")); + json_object_object_add(events, "actions", array_events); + + return afb_api_call_sync(api, "vshl", "phonecontrol/subscribe", events, NULL, NULL, NULL); +} + static int init(afb_api_t api) { AFB_NOTICE("Initializing telephony service"); + + phonecontrol_init(api); + AFB_NOTICE("ZZZZZZZZZZZ"); return ofono_init(api); } @@ -373,10 +387,64 @@ static void process_connection_event(afb_api_t api, struct json_object *object) } } +static void process_phonecontrol_event(afb_api_t api, struct json_object *object) +{ + struct json_object *val = NULL, *payload = NULL; + const char *action = NULL; + const char *number = NULL; + struct json_object *response = json_object_new_object(); + struct json_object *payload_response = json_object_new_object(); + + json_object_object_add(response, "action", json_object_new_string("call_activated")); + json_object_object_add(response, "payload", payload_response); + + json_object_object_get_ex(object, "action", &val); + if (!val) + return; + action = json_object_get_string(val); + if (g_strcmp0("dial", action)) + return; + + json_object_object_get_ex(object, "payload", &payload); + if (!payload) + return; + + json_object_object_get_ex(payload, "callid", &val); + if (!val) + return; + json_object_object_add(payload_response, "callid", val); + json_object_object_get_ex(payload, "value", &val); + if (!val) + return; + number = json_object_get_string(val); + + AFB_DEBUG("dial: %s...\n", number); + if(!vcm) { + AFB_ERROR("No vcm initialised"); + return; + } + afb_api_call_sync(api, "vshl", "phonecontrol/publish", response, NULL, NULL, NULL); + if (voice_call) { + json_object_object_add(response, "action", json_object_new_string("call_failed")); + afb_api_call_sync(api, "vshl", "phonecontrol/publish", response, NULL, NULL, NULL); + AFB_ERROR("dial: cannot dial with active call"); + return; + } + + if (!ofono_voicecallmanager_dial(vcm, (gchar *)number, "")) { + json_object_object_add(response, "action", json_object_new_string("call_failed")); + afb_api_call_sync(api, "vshl", "phonecontrol/publish", response, NULL, NULL, NULL); + AFB_ERROR("dial fail"); + return; + } +} + static void onevent(afb_api_t api, const char *event, struct json_object *object) { if (!g_ascii_strcasecmp(event, "Bluetooth-Manager/device_changes")) process_connection_event(api, object); + else if (!g_ascii_strcasecmp(event, "vshl/phonecontrol/dial")) + process_phonecontrol_event(api, object); else AFB_ERROR("Unsupported event: %s\n", event); } diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in index 1c8b8f2..ad44550 100644 --- a/conf.d/wgt/config.xml.in +++ b/conf.d/wgt/config.xml.in @@ -19,6 +19,7 @@ <feature name="urn:AGL:widget:required-api"> <param name="Bluetooth-Manager" value="ws" /> + <param name="vshl" value="ws" /> </feature> <feature name="urn:AGL:widget:required-binding"> |