gsm: add new property to track which facility locks are enabled
The property EnabledFacilityLocks on the .Modem.Gsm.Card interface is a bit mask that indicates which of the various personalization codes from 3GPP TS 22.022, plus the SIM PIN lock and SIM PIN2 lock, are enabled. The set of facility locks supported by the modem is determined at the time the modem is initialized, and the state of each supported lock (enabled or disabled) is determined. When the state of a lock changes, a property-change signal is sent out. Note that ModemManager only supports enabling and disabling SIM-PIN, via the EnablePin method on Modem.Gsm.Card.
This commit is contained in:

committed by
Dan Williams

parent
e7b6b2dc1c
commit
eede5bb621
@@ -819,6 +819,151 @@ mm_gsm_parse_cscs_support_response (const char *reply,
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Map two letter facility codes into flag values. There are
|
||||
* many more facilities defined (for various flavors of call
|
||||
* barring); we only map the ones we care about. */
|
||||
static MMModemGsmFacility
|
||||
mm_gsm_string_to_facility (const char *string)
|
||||
{
|
||||
g_return_val_if_fail (string != NULL, MM_MODEM_GSM_FACILITY_NONE);
|
||||
|
||||
if (!strcmp (string, "SC"))
|
||||
return MM_MODEM_GSM_FACILITY_SIM;
|
||||
else if (!strcmp (string, "PS"))
|
||||
return MM_MODEM_GSM_FACILITY_PH_SIM;
|
||||
else if (!strcmp (string, "PF"))
|
||||
return MM_MODEM_GSM_FACILITY_PH_FSIM;
|
||||
else if (!strcmp (string, "FD"))
|
||||
return MM_MODEM_GSM_FACILITY_FIXED_DIALING;
|
||||
else if (!strcmp (string, "PN"))
|
||||
return MM_MODEM_GSM_FACILITY_NET_PERS;
|
||||
else if (!strcmp (string, "PU"))
|
||||
return MM_MODEM_GSM_FACILITY_NET_SUB_PERS;
|
||||
else if (!strcmp (string, "PP"))
|
||||
return MM_MODEM_GSM_FACILITY_PROVIDER_PERS;
|
||||
else if (!strcmp (string, "PC"))
|
||||
return MM_MODEM_GSM_FACILITY_CORP_PERS;
|
||||
else
|
||||
return MM_MODEM_GSM_FACILITY_NONE;
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
char *
|
||||
mm_gsm_get_facility_name (MMModemGsmFacility facility)
|
||||
{
|
||||
switch (facility) {
|
||||
case MM_MODEM_GSM_FACILITY_SIM:
|
||||
return "SC";
|
||||
case MM_MODEM_GSM_FACILITY_PH_SIM:
|
||||
return "PS";
|
||||
case MM_MODEM_GSM_FACILITY_PH_FSIM:
|
||||
return "PF";
|
||||
case MM_MODEM_GSM_FACILITY_FIXED_DIALING:
|
||||
return "FD";
|
||||
case MM_MODEM_GSM_FACILITY_NET_PERS:
|
||||
return "PN";
|
||||
case MM_MODEM_GSM_FACILITY_NET_SUB_PERS:
|
||||
return "PU";
|
||||
case MM_MODEM_GSM_FACILITY_PROVIDER_PERS:
|
||||
return "PP";
|
||||
case MM_MODEM_GSM_FACILITY_CORP_PERS:
|
||||
return "PC";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_gsm_parse_clck_test_response (const char *reply,
|
||||
MMModemGsmFacility *out_facilities)
|
||||
{
|
||||
MMModemGsmFacility facilities = MM_MODEM_GSM_FACILITY_NONE;
|
||||
GRegex *r;
|
||||
GMatchInfo *match_info;
|
||||
char *p, *str;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (reply != NULL, FALSE);
|
||||
g_return_val_if_fail (out_facilities != NULL, FALSE);
|
||||
|
||||
/* the general format is:
|
||||
*
|
||||
* +CLCK: ("SC","AO","AI","PN")
|
||||
*/
|
||||
p = strchr (reply, '(');
|
||||
if (p)
|
||||
p++;
|
||||
else {
|
||||
p = strchr (reply, '"');
|
||||
if (!p)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Now parse each facility */
|
||||
r = g_regex_new ("\\s*\"([^,\\)]+)\"\\s*", 0, 0, NULL);
|
||||
if (!r)
|
||||
return FALSE;
|
||||
|
||||
if (g_regex_match_full (r, p, strlen (p), 0, 0, &match_info, NULL)) {
|
||||
while (g_match_info_matches (match_info)) {
|
||||
str = g_match_info_fetch (match_info, 1);
|
||||
if (str)
|
||||
facilities |= mm_gsm_string_to_facility (str);
|
||||
g_free (str);
|
||||
|
||||
g_match_info_next (match_info, NULL);
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
g_match_info_free (match_info);
|
||||
g_regex_unref (r);
|
||||
|
||||
if (success)
|
||||
*out_facilities = facilities;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_gsm_parse_clck_response (const char *reply, gboolean *enabled)
|
||||
{
|
||||
GRegex *r;
|
||||
GMatchInfo *match_info;
|
||||
char *p, *str;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (reply != NULL, FALSE);
|
||||
g_return_val_if_fail (enabled != NULL, FALSE);
|
||||
|
||||
p = strchr (reply, ':');
|
||||
if (p)
|
||||
p++;
|
||||
|
||||
r = g_regex_new ("\\s*([01])\\s*", 0, 0, NULL);
|
||||
if (!r)
|
||||
return FALSE;
|
||||
|
||||
if (g_regex_match (r, p, 0, &match_info)) {
|
||||
success = TRUE;
|
||||
str = g_match_info_fetch (match_info, 1);
|
||||
if (str) {
|
||||
if (*str == '0')
|
||||
*enabled = FALSE;
|
||||
else if (*str == '1')
|
||||
*enabled = TRUE;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
g_match_info_free (match_info);
|
||||
g_regex_unref (r);
|
||||
return success;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
MMModemGsmAccessTech
|
||||
mm_gsm_string_to_access_tech (const char *string)
|
||||
{
|
||||
|
Reference in New Issue
Block a user