summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rw-r--r--binding/telephony-binding.c20
2 files changed, 27 insertions, 6 deletions
diff --git a/README.md b/README.md
index f4473c7..839d6a7 100644
--- a/README.md
+++ b/README.md
@@ -16,12 +16,13 @@ Telephony service allows respective clients access to the Handsfree Profile via
## Events
-| Name | Description | JSON Event Data |
-|---------------------|--------------------------------------|---------------------------------------------|
-| callStateChanged | Call status change event | see callStateChanged event |
-| dialingCall | Outgoing call events | {"colp": "3305551212"} |
-| incomingCall | Incoming call events | {"clip": "3305551212"} |
-| terminatedCall | Terminated call event | *empty JSON response* |
+| Name | Description | JSON Event Data |
+|---------------------|-----------------------------------------|---------------------------------------------|
+| callStateChanged | Call status change event | see callStateChanged event |
+| dialingCall | Outgoing call events | {"colp": "3305551212"} |
+| incomingCall | Incoming call events | {"clip": "3305551212"} |
+| terminatedCall | Terminated call event | *empty JSON response* |
+| online | Connected status of Handsfree Profile | {"connected": true} |
### callStateChanged Event
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);