aboutsummaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
Diffstat (limited to 'binding')
-rw-r--r--binding/telephony-binding.c20
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);