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:
@@ -192,21 +192,6 @@ tone_key_is_valid (gchar key)
|
|||||||
|| 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:
|
* calls_call_tone_start:
|
||||||
@@ -219,14 +204,68 @@ tone_key_is_valid (gchar key)
|
|||||||
* value for @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:
|
* calls_call_tone_stop:
|
||||||
* @self: a #CallsCall
|
* @self: a #CallsCall
|
||||||
* @key: which tone to stop
|
* @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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,15 +65,16 @@ struct _CallsCallInterface
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const gchar * calls_call_get_number (CallsCall *self);
|
const gchar * calls_call_get_number (CallsCall *self);
|
||||||
const gchar * calls_call_get_name (CallsCall *self);
|
const gchar * calls_call_get_name (CallsCall *self);
|
||||||
CallsCallState calls_call_get_state (CallsCall *self);
|
CallsCallState calls_call_get_state (CallsCall *self);
|
||||||
void calls_call_answer (CallsCall *self);
|
void calls_call_answer (CallsCall *self);
|
||||||
void calls_call_hang_up (CallsCall *self);
|
void calls_call_hang_up (CallsCall *self);
|
||||||
void calls_call_tone_start (CallsCall *self,
|
void calls_call_tone_start (CallsCall *self,
|
||||||
gchar key);
|
gchar key);
|
||||||
void calls_call_tone_stop (CallsCall *self,
|
gboolean calls_call_tone_stoppable (CallsCall *self);
|
||||||
gchar key);
|
void calls_call_tone_stop (CallsCall *self,
|
||||||
|
gchar key);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user