summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/Dialer.qml30
-rw-r--r--app/api/Telephony.qml4
-rw-r--r--telephony-binding/gdbus/ofono_voicecall.c59
-rw-r--r--telephony-binding/gdbus/ofono_voicecall.h5
-rw-r--r--telephony-binding/telephony-binding.c12
5 files changed, 99 insertions, 11 deletions
diff --git a/app/Dialer.qml b/app/Dialer.qml
index 99610fd..51f6a53 100644
--- a/app/Dialer.qml
+++ b/app/Dialer.qml
@@ -25,10 +25,30 @@ import 'api' as API
Item {
id: root
+ function getTime() {
+ return new Date().getTime()
+ }
+
+ // Elapsed time in hh:mm:ss format
+ function getElapsedTimeString(startTime) {
+ var seconds = Math.floor((getTime() - startTime) / 1000);
+ var time = new Date(null);
+ time.setSeconds(seconds);
+ return time.toISOString().substr(11, 8);
+ }
+
+ Timer {
+ id: callTimer
+ interval: 1000
+ repeat: true
+ property var startTime
+ onTriggered: callStatusLabel.text = getElapsedTimeString(startTime)
+ }
+
API.Telephony {
id: telephony
url: bindingAddress
- property string callStatus: "idle"
+ property string callStatus: "disconnected"
property string callClipColp: ""
onCallStatusChanged: {
@@ -36,9 +56,13 @@ Item {
ringtone.active = true
callStatusLabel.text = "Incoming call from " + callClipColp
} else if (callStatus == "dialing") {
- callStatusLabel.text = "Calling " + callClipColp
- } else if (callStatus == "idle") {
+ callStatusLabel.text = "Dialing " + callClipColp
+ } else if (callStatus == "active") {
+ callTimer.startTime = getTime()
+ callTimer.restart()
+ } else if (callStatus == "disconnected") {
ringtone.active = false
+ callTimer.stop()
callStatusLabel.text = ""
}
}
diff --git a/app/api/Telephony.qml b/app/api/Telephony.qml
index b42af4f..c7d9218 100644
--- a/app/api/Telephony.qml
+++ b/app/api/Telephony.qml
@@ -65,7 +65,9 @@ WebSocket {
callClipColp = data.colp
callStatus = "dialing"
} else if (event == "telephony/terminatedCall") {
- callStatus = "idle"
+ callStatus = "disconnected"
+ } else if (event == "telephony/callStateChanged") {
+ callStatus = data.state
}
break
}
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 <string.h>
+#include <unistd.h>
+
+#include <afb/afb-binding.h>
+
#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 *);
diff --git a/telephony-binding/telephony-binding.c b/telephony-binding/telephony-binding.c
index 00115d2..41164f0 100644
--- a/telephony-binding/telephony-binding.c
+++ b/telephony-binding/telephony-binding.c
@@ -81,6 +81,14 @@ static void answer(struct afb_req request)
}
}
+static void call_state_changed_cb(OrgOfonoVoiceCall *vc, gchar *state)
+{
+ struct json_object *call_state;
+ call_state = json_object_new_object();
+ json_object_object_add(call_state, "state", json_object_new_string(state));
+ afb_daemon_broadcast_event(interface->daemon, "callStateChanged", call_state);
+}
+
static void incoming_call_cb(OrgOfonoVoiceCallManager *manager, gchar *op, gchar *clip)
{
struct json_object *call_info;
@@ -88,7 +96,7 @@ static void incoming_call_cb(OrgOfonoVoiceCallManager *manager, gchar *op, gchar
call_info = json_object_new_object();
json_object_object_add(call_info, "clip", json_object_new_string(clip));
afb_daemon_broadcast_event(interface->daemon, "incomingCall", call_info);
- incoming_call = ofono_voicecall_new(op);
+ incoming_call = ofono_voicecall_new(interface, op, call_state_changed_cb);
}
static void dialing_call_cb(OrgOfonoVoiceCallManager *manager, gchar *op, gchar *colp)
@@ -98,7 +106,7 @@ static void dialing_call_cb(OrgOfonoVoiceCallManager *manager, gchar *op, gchar
call_info = json_object_new_object();
json_object_object_add(call_info, "colp", json_object_new_string(colp));
afb_daemon_broadcast_event(interface->daemon, "dialingCall", call_info);
- voice_call = ofono_voicecall_new(op);
+ voice_call = ofono_voicecall_new(interface, op, call_state_changed_cb);
}
static void terminated_call_cb(OrgOfonoVoiceCallManager *manager, gchar *op)