diff options
-rw-r--r-- | plugins/xmm/mm-modem-helpers-xmm.c | 31 | ||||
-rw-r--r-- | plugins/xmm/mm-modem-helpers-xmm.h | 3 |
2 files changed, 34 insertions, 0 deletions
diff --git a/plugins/xmm/mm-modem-helpers-xmm.c b/plugins/xmm/mm-modem-helpers-xmm.c index 0dc48f00..a8ede4cf 100644 --- a/plugins/xmm/mm-modem-helpers-xmm.c +++ b/plugins/xmm/mm-modem-helpers-xmm.c @@ -560,3 +560,34 @@ mm_xmm_build_xact_set_command (const MMModemModeCombination *mode, return g_string_free (command, FALSE); } + +/*****************************************************************************/ +/* Get mode to apply when ANY */ + +MMModemMode +mm_xmm_get_modem_mode_any (const GArray *combinations) +{ + guint i; + MMModemMode any = MM_MODEM_MODE_NONE; + guint any_bits_set = 0; + + for (i = 0; i < combinations->len; i++) { + MMModemModeCombination *combination; + guint bits_set; + + combination = &g_array_index (combinations, MMModemModeCombination, i); + if (combination->preferred != MM_MODEM_MODE_NONE) + continue; + bits_set = mm_count_bits_set (combination->allowed); + if (bits_set > any_bits_set) { + any_bits_set = bits_set; + any = combination->allowed; + } + } + + /* If combinations were processed via mm_xmm_parse_uact_test_response(), + * we're sure that there will be at least one combination with preferred + * 'none', so there must be some valid combination as result */ + g_assert (any != MM_MODEM_MODE_NONE); + return any; +} diff --git a/plugins/xmm/mm-modem-helpers-xmm.h b/plugins/xmm/mm-modem-helpers-xmm.h index 11c95483..abe11905 100644 --- a/plugins/xmm/mm-modem-helpers-xmm.h +++ b/plugins/xmm/mm-modem-helpers-xmm.h @@ -36,4 +36,7 @@ gchar *mm_xmm_build_xact_set_command (const MMModemModeCombination *mode, const GArray *bands, GError **error); +/* Mode to apply when ANY */ +MMModemMode mm_xmm_get_modem_mode_any (const GArray *combinations); + #endif /* MM_MODEM_HELPERS_XMM_H */ |