1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-07 04:15:32 +00:00

dbus: Add API to send DTMF

Addresses the calls side of #343
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-11-16 09:12:05 +01:00
parent 0761c4a53a
commit a28d694623
2 changed files with 73 additions and 0 deletions

View file

@ -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);

View file

@ -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>