From 1f5cd7758161271e7e7c38e5a7dc78396f5c56b8 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Sat, 20 May 2017 09:43:18 -0400 Subject: Add support for UI display of phone call duration Adds support to the telephony binding for generating events when a call's state changes to active or disconnected states (when a remote/local party answers or disconnects the call). These events are used to drive a call duration display in the phone app UI. AGL-Bug: SPEC-599 Change-Id: Ib4b0b115ca1d0573a7ae046082627f561f0d8d8a Signed-off-by: Matt Porter --- telephony-binding/gdbus/ofono_voicecall.c | 59 ++++++++++++++++++++++++++++--- telephony-binding/gdbus/ofono_voicecall.h | 5 ++- 2 files changed, 59 insertions(+), 5 deletions(-) (limited to 'telephony-binding/gdbus') diff --git a/telephony-binding/gdbus/ofono_voicecall.c b/telephony-binding/gdbus/ofono_voicecall.c index de6db2f..585bf5f 100644 --- a/telephony-binding/gdbus/ofono_voicecall.c +++ b/telephony-binding/gdbus/ofono_voicecall.c @@ -14,13 +14,64 @@ * limitations under the License. */ +#define _GNU_SOURCE + +#include +#include + +#include + #include "ofono_voicecall_interface.h" -OrgOfonoVoiceCall *ofono_voicecall_new(gchar *op) +const struct afb_binding_interface *interface; + +static void property_changed(OrgOfonoVoiceCall *voice_call, + gchar *property, + GVariant *value) { - return org_ofono_voice_call_proxy_new_for_bus_sync( - G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - "org.ofono", op, NULL, NULL); + GVariant *vvalue; + const gchar *state; + + if (!strcmp(property, "State")) { + vvalue = g_variant_get_variant(value); + state = g_variant_get_string(vvalue, NULL); + g_signal_emit_by_name(voice_call, "call-state-changed", state); + } +} + +OrgOfonoVoiceCall *ofono_voicecall_new(const struct afb_binding_interface *iface, + gchar *op, + void (*call_state_changed)(OrgOfonoVoiceCall *,gchar *)) +{ + OrgOfonoVoiceCall *voice_call; + + interface = iface; + voice_call = org_ofono_voice_call_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, + "org.ofono", op, NULL, NULL); + + if (voice_call) { + g_signal_new("call-state-changed", + G_TYPE_OBJECT, + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_generic, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + + if (g_signal_connect(G_OBJECT(voice_call), "call-state-changed", G_CALLBACK(call_state_changed), NULL) <= 0) { + ERROR(interface, "Failed to connect to signal call-state-changed\n"); + } + + if (g_signal_connect(voice_call, "property-changed", G_CALLBACK(property_changed), NULL) <= 0) { + ERROR(interface, "Failed to connect to signal call-added\n"); + } + } + + return voice_call; } void ofono_voicecall_free(OrgOfonoVoiceCall *voice_call) diff --git a/telephony-binding/gdbus/ofono_voicecall.h b/telephony-binding/gdbus/ofono_voicecall.h index 6405d1b..0c2e749 100644 --- a/telephony-binding/gdbus/ofono_voicecall.h +++ b/telephony-binding/gdbus/ofono_voicecall.h @@ -18,7 +18,10 @@ #include "ofono_voicecall_interface.h" -OrgOfonoVoiceCall *ofono_voicecall_new(gchar *); +OrgOfonoVoiceCall * +ofono_voicecall_new(const struct afb_binding_interface *, + gchar *, + void (*)(OrgOfonoVoiceCall *,gchar *)); void ofono_voicecall_free(OrgOfonoVoiceCall *); void ofono_voicecall_answer(OrgOfonoVoiceCall *); void ofono_voicecall_hangup(OrgOfonoVoiceCall *); -- cgit 1.2.3-korg