aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Voegl <lvoegl@tdt.de>2024-02-09 14:39:49 +0100
committerAleksander Morgado <aleksander@aleksander.es>2024-03-04 09:11:36 +0000
commitf8295bd641694cb911bc219ac843676f6fb27534 (patch)
treeb6bfd0b98314b335049b25ba182bed077567d728 /src
parentad6772df34b776d32c26d7e527d5ac698fe2412f (diff)
cinterion: keep dual-sim order
mm_parse_uint_list() sorts available SIMs and possibly changes the order of the active / non-active SIM. A custom parser is added, which keeps the order of all SIMs. Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cinterion/mm-modem-helpers-cinterion.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/plugins/cinterion/mm-modem-helpers-cinterion.c b/src/plugins/cinterion/mm-modem-helpers-cinterion.c
index 7c16fc4f..b17b0050 100644
--- a/src/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/src/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -585,21 +585,37 @@ mm_cinterion_get_available_from_simlocal (const gchar *response,
GError **error)
{
g_autoptr(GArray) tmp_available = NULL;
+ g_auto(GStrv) sim_groups = NULL;
GError *inner_error = NULL;
+ guint sim_length;
+ guint i;
if (!response) {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Missing response");
return FALSE;
}
- tmp_available = mm_parse_uint_list (response, &inner_error);
- if (inner_error) {
- g_propagate_error (error, inner_error);
- return FALSE;
+ sim_groups = mm_split_string_groups (response);
+ sim_length = g_strv_length (sim_groups);
+ tmp_available = g_array_sized_new (FALSE, FALSE, sizeof (gboolean), sim_length);
+
+ for (i = 0; i < sim_length; i++) {
+ guint index_value;
+ gboolean is_available;
+
+ if (!mm_get_uint_from_str (sim_groups[i], &index_value)) {
+ inner_error = g_error_new (MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Could not parse SIM index value '%s'",
+ sim_groups[i]);
+ g_propagate_error (error, inner_error);
+ return FALSE;
+ }
+ is_available = (gboolean) index_value;
+ g_array_append_val (tmp_available, is_available);
}
*available = g_steal_pointer (&tmp_available);
-
return TRUE;
}