static void parse_modem_snapshot (MMCallbackInfo *info, QcdmResult *result) { MMModemCdmaRegistrationState evdo_state, cdma1x_state, new_state; guint8 eri = 0; g_return_if_fail (info != NULL); g_return_if_fail (result != NULL); evdo_state = mm_generic_cdma_query_reg_state_get_callback_evdo_state (info); cdma1x_state = mm_generic_cdma_query_reg_state_get_callback_1x_state (info); /* Roaming? */ if (qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_ERI, &eri)) { char *str; gboolean roaming = FALSE; str = g_strdup_printf ("%u", eri); if (mm_cdma_parse_eri (str, &roaming, NULL, NULL)) { new_state = roaming ? MM_MODEM_CDMA_REGISTRATION_STATE_HOME : MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; if (cdma1x_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) mm_generic_cdma_query_reg_state_set_callback_1x_state (info, new_state); if (evdo_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, new_state); } g_free (str); } }
static gboolean get_roam_value (const gchar *reply, const gchar *tag, gboolean is_eri, gboolean *out_roaming) { gchar *p; gboolean success; guint32 ind = 0; p = strstr (reply, tag); if (!p) return FALSE; p += strlen (tag); while (*p && isspace (*p)) p++; /* Use generic ERI parsing if it's an ERI */ if (is_eri) { success = mm_cdma_parse_eri (p, out_roaming, &ind, NULL); if (success) { /* Sierra redefines ERI 0, 1, and 2 */ if (ind == 0) *out_roaming = FALSE; /* home */ else if (ind == 1 || ind == 2) *out_roaming = TRUE; /* roaming */ } return success; } /* If it's not an ERI, roaming is just true/false */ if (*p == '1') { *out_roaming = TRUE; return TRUE; } else if (*p == '0') { *out_roaming = FALSE; return TRUE; } return FALSE; }