[calls] dbus: Add API to send DTMF
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] dbus: Add API to send DTMF
- Date: Tue, 23 Nov 2021 09:39:53 +0000 (UTC)
commit a28d6946238e46d37d1a750fb9bde70d3254d74b
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Tue Nov 16 09:12:05 2021 +0100
dbus: Add API to send DTMF
Addresses the calls side of #343
src/calls-dbus-manager.c | 59 +++++++++++++++++++++++++++++++++++++++
src/dbus/org.gnome.Calls.Call.xml | 14 ++++++++++
2 files changed, 73 insertions(+)
---
diff --git a/src/calls-dbus-manager.c b/src/calls-dbus-manager.c
index 1c7e0dfa..ac28517f 100644
--- a/src/calls-dbus-manager.c
+++ b/src/calls-dbus-manager.c
@@ -124,6 +124,64 @@ static gboolean
}
+static gboolean
+on_handle_call_send_dtmf (CallsDBusCallsCall *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *dtmf_tone,
+ CallsCall *call)
+{
+ g_return_val_if_fail (CALLS_DBUS_IS_CALLS_CALL (skeleton), FALSE);
+ g_return_val_if_fail (CALLS_IS_CALL (call), FALSE);
+
+ if (!calls_call_can_dtmf (call)) {
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "This call is not DTMF capable");
+ return TRUE;
+ }
+
+ if (!dtmf_tone || !*dtmf_tone) {
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Cannot send empty DTMF tone");
+ return TRUE;
+ }
+
+ if (dtmf_tone[1] != '\0') {
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Key '%s' must be a single valid tone",
+ dtmf_tone);
+ return TRUE;
+ }
+
+ if (!dtmf_tone_key_is_valid (*dtmf_tone)) {
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "The key %s is not a valid DTMF tone",
+ dtmf_tone);
+ return TRUE;
+ }
+
+ if (calls_call_get_state (call) != CALLS_CALL_STATE_ACTIVE) {
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Can't send DTMF tone because call is inactive");
+ return TRUE;
+ }
+
+ calls_call_send_dtmf_tone (call, *dtmf_tone);
+ calls_dbus_calls_call_complete_send_dtmf (skeleton, invocation);
+
+ return TRUE;
+}
+
+
static void
call_added_cb (CallsDBusManager *self, CallsCall *call)
{
@@ -144,6 +202,7 @@ call_added_cb (CallsDBusManager *self, CallsCall *call)
g_object_connect (iface,
"object_signal::handle-accept", G_CALLBACK (on_handle_call_accept), call,
"object_signal::handle-hangup", G_CALLBACK (on_handle_call_hangup), call,
+ "object-signal::handle-send_dtmf", G_CALLBACK (on_handle_call_send_dtmf), call,
NULL);
g_object_bind_property (call, "state", iface, "state", G_BINDING_SYNC_CREATE);
g_object_bind_property (call, "inbound", iface, "inbound", G_BINDING_SYNC_CREATE);
diff --git a/src/dbus/org.gnome.Calls.Call.xml b/src/dbus/org.gnome.Calls.Call.xml
index 9fac6f67..5c7b8bd4 100644
--- a/src/dbus/org.gnome.Calls.Call.xml
+++ b/src/dbus/org.gnome.Calls.Call.xml
@@ -24,6 +24,13 @@
<interface name="org.gnome.Calls.Call">
<method name="Accept"/>
<method name="Hangup"/>
+ <method name="SendDtmf">
+ <arg name="Tone" type="s" direction="in">
+ <doc:doc>
+ <doc:summary>A one character string. One of: 0-9,A-D,* or #.</doc:summary>
+ </doc:doc>
+ </arg>
+ </method>
<property name="Inbound" type="b" access="read"/>
<property name="State" type="u" access="read"/>
<property name="Id" type="s" access="read">
@@ -62,5 +69,12 @@
</doc:description>
</doc:doc>
</property>
+ <property name="CanDtmf" type="b" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>Whether the call can do DTMF</doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
</interface>
</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]