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

util: Make dtmf tone checking function public

Moves the function out of calls-call.c into util.c
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-11-16 15:18:54 +01:00
parent 4c2717c362
commit afd1034dd1
3 changed files with 22 additions and 11 deletions

View file

@ -340,16 +340,6 @@ calls_call_get_protocol (CallsCall *self)
return CALLS_CALL_GET_CLASS (self)->get_protocol (self);
}
static inline gboolean
tone_key_is_valid (gchar key)
{
return
(key >= '0' && key <= '9')
|| (key >= 'A' && key <= 'D')
|| key == '*'
|| key == '#';
}
/**
* calls_call_can_dtmf:
* @self: a #CallsCall
@ -379,7 +369,7 @@ calls_call_send_dtmf_tone (CallsCall *self,
gchar key)
{
g_return_if_fail (CALLS_IS_CALL (self));
g_return_if_fail (tone_key_is_valid (key));
g_return_if_fail (dtmf_tone_key_is_valid (key));
CALLS_CALL_GET_CLASS (self)->send_dtmf_tone (self, key);
}

View file

@ -254,3 +254,22 @@ get_protocol_from_address_with_fallback (const char *target)
return protocol;
}
/**
* dtmf_tone_is_valid:
* @key:
*
* Checks if @key is a valid DTMF keytone
*
* Returns: %TRUE if @key is 0-9, A-D, * or #, %FALSE otherwise
*/
gboolean
dtmf_tone_key_is_valid (gchar key)
{
return
(key >= '0' && key <= '9')
|| (key >= 'A' && key <= 'D')
|| key == '*'
|| key == '#';
}

View file

@ -141,6 +141,8 @@ gboolean calls_find_in_store (GListModel *list,
const char* get_protocol_from_address (const char *target);
const char* get_protocol_from_address_with_fallback (const char *target);
gboolean dtmf_tone_key_is_valid (char key);
G_END_DECLS
#endif /* CALLS__UTIL_H__ */