diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-10-15 10:30:00 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-10-15 10:30:00 +0200 |
commit | 395b22178c4f6dd24d552e82d2d46dfb24c65297 (patch) | |
tree | b2bfd84ac1fc1f23bf3c2455000d29a7b28ed236 /plugins/simtech/mm-modem-helpers-simtech.c | |
parent | 1a17996ccb3560c29e2a27c596ad0e9c7bbaaa61 (diff) |
simtech: handle 'VOICE CALL' URCs
Just processing and parsing them for now, so that they don't interfere
with other commands:
$ sudo mmcli --call 1 --accept
error: couldn't accept the call: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Failed: Couldn't accept the call: Unhandled response '
VOICE CALL: BEGIN''
Diffstat (limited to 'plugins/simtech/mm-modem-helpers-simtech.c')
-rw-r--r-- | plugins/simtech/mm-modem-helpers-simtech.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/simtech/mm-modem-helpers-simtech.c b/plugins/simtech/mm-modem-helpers-simtech.c index e25bc118..5926c44f 100644 --- a/plugins/simtech/mm-modem-helpers-simtech.c +++ b/plugins/simtech/mm-modem-helpers-simtech.c @@ -93,3 +93,58 @@ mm_simtech_call_info_list_free (GList *call_info_list) { mm_3gpp_call_info_list_free (call_info_list); } + +/*****************************************************************************/ + +/* + * <CR><LF>VOICE CALL: BEGIN<CR><LF> + * <CR><LF>VOICE CALL: END: 000041<CR><LF> + */ +GRegex * +mm_simtech_get_voice_call_urc_regex (void) +{ + return g_regex_new ("\\r\\nVOICE CALL:\\s*([A-Z]+)(?::\\s*(\\d+))?\\r\\n", + G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); +} + +gboolean +mm_simtech_parse_voice_call_urc (GMatchInfo *match_info, + gboolean *start_or_stop, + guint *duration, + GError **error) +{ + GError *inner_error = NULL; + gchar *str; + + str = mm_get_string_unquoted_from_match_info (match_info, 1); + if (!str) { + inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Couldn't read voice call URC action"); + goto out; + } + + if (g_strcmp0 (str, "BEGIN") == 0) { + *start_or_stop = TRUE; + *duration = 0; + goto out; + } + + if (g_strcmp0 (str, "END") == 0) { + *start_or_stop = FALSE; + if (!mm_get_uint_from_match_info (match_info, 2, duration)) + *duration = 0; + goto out; + } + + inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unknown voice call URC action: %s", str); + +out: + g_free (str); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + + return TRUE; +} |