1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-04 20:07:36 +00:00

call: Allow for the inability to stop DTMF tones

Some implementations, like oFono, only allow fixed-length tones to be
sent to the network, not started and stopped at will.  To account for
this, we make the tone_start member function nullable and add a new
function, calls_call_tone_stoppable, to determine whether there is a
stop function.
This commit is contained in:
Bob Ham 2018-05-31 10:20:17 +00:00
parent 40afb187c2
commit dd815fa86f
2 changed files with 67 additions and 27 deletions

View file

@ -192,21 +192,6 @@ tone_key_is_valid (gchar key)
|| key == '#';
}
#define DEFINE_CALL_TONE_FUNC(which) \
void \
calls_call_tone_##which (CallsCall *self, \
gchar key) \
{ \
CallsCallInterface *iface; \
\
g_return_if_fail (CALLS_IS_CALL (self)); \
g_return_if_fail (tone_key_is_valid (key)); \
\
iface = CALLS_CALL_GET_IFACE (self); \
g_return_if_fail (iface->tone_##which != NULL); \
\
return iface->tone_##which (self, key); \
}
/**
* calls_call_tone_start:
@ -219,14 +204,68 @@ tone_key_is_valid (gchar key)
* value for @key.
*
*/
DEFINE_CALL_TONE_FUNC (start);
void
calls_call_tone_start (CallsCall *self,
gchar key)
{
CallsCallInterface *iface;
g_return_if_fail (CALLS_IS_CALL (self));
g_return_if_fail (tone_key_is_valid (key));
iface = CALLS_CALL_GET_IFACE (self);
g_return_if_fail (iface->tone_start != NULL);
iface->tone_start (self, key);
}
/**
* calls_call_tone_stoppable:
* @self: a #CallsCall
*
* Determine whether tones for this call can be stopped by calling
* #calls_call_tone_stop. Some implementations will only allow
* fixed-length tones to be played. In that case, this function
* should return FALSE.
*
* Returns: whether calls to #calls_call_tone_stop will do anything
*
*/
gboolean
calls_call_tone_stoppable (CallsCall *self)
{
CallsCallInterface *iface;
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
iface = CALLS_CALL_GET_IFACE (self);
return iface->tone_stop != NULL;
}
/**
* calls_call_tone_stop:
* @self: a #CallsCall
* @key: which tone to stop
*
* Stop playing a DTMF tone previously started with #calls_call_tone_start.
* Stop playing a DTMF tone previously started with
* #calls_call_tone_start.
*
*/
DEFINE_CALL_TONE_FUNC (stop);
void
calls_call_tone_stop (CallsCall *self,
gchar key)
{
CallsCallInterface *iface;
g_return_if_fail (CALLS_IS_CALL (self));
g_return_if_fail (tone_key_is_valid (key));
iface = CALLS_CALL_GET_IFACE (self);
if (!iface->tone_stop)
{
return;
}
iface->tone_stop (self, key);
}

View file

@ -65,15 +65,16 @@ struct _CallsCallInterface
};
const gchar * calls_call_get_number (CallsCall *self);
const gchar * calls_call_get_name (CallsCall *self);
CallsCallState calls_call_get_state (CallsCall *self);
void calls_call_answer (CallsCall *self);
void calls_call_hang_up (CallsCall *self);
void calls_call_tone_start (CallsCall *self,
gchar key);
void calls_call_tone_stop (CallsCall *self,
gchar key);
const gchar * calls_call_get_number (CallsCall *self);
const gchar * calls_call_get_name (CallsCall *self);
CallsCallState calls_call_get_state (CallsCall *self);
void calls_call_answer (CallsCall *self);
void calls_call_hang_up (CallsCall *self);
void calls_call_tone_start (CallsCall *self,
gchar key);
gboolean calls_call_tone_stoppable (CallsCall *self);
void calls_call_tone_stop (CallsCall *self,
gchar key);
G_END_DECLS