diff options
author | Dan Williams <dcbw@redhat.com> | 2010-02-09 23:44:23 -0800 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-02-09 23:44:23 -0800 |
commit | d8ea5ea003f6e06520ec1254d89ec5fec5438d18 (patch) | |
tree | 76c714f6a011dbc69a5b1e89263c2c0c456b8c1c /src | |
parent | 95dd4b5be1ebb0408be6e282eb20e2c45df1f253 (diff) |
gsm: fix initial PIN checking for devices that echo by default
If the modem echoed commands by default (since we may not have
initialized the modem yet), the echoed command would confuse
the PIN check reply parser.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-generic-gsm.c | 8 | ||||
-rw-r--r-- | src/mm-modem-base.c | 12 | ||||
-rw-r--r-- | src/mm-modem-base.h | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c index fb141915..d26f1171 100644 --- a/src/mm-generic-gsm.c +++ b/src/mm-generic-gsm.c @@ -203,8 +203,8 @@ pin_check_done (MMSerialPort *port, if (error) info->error = g_error_copy (error); - else if (g_str_has_prefix (response->str, "+CPIN: ")) { - const char *str = response->str + 7; + else if (response && strstr (response->str, "+CPIN: ")) { + const char *str = strstr (response->str, "+CPIN: ") + 7; if (g_str_has_prefix (str, "READY")) { mm_modem_base_set_unlock_required (MM_MODEM_BASE (info->modem), NULL); @@ -328,7 +328,9 @@ initial_pin_check_done (MMModem *modem, GError *error, gpointer user_data) g_return_if_fail (MM_IS_GENERIC_GSM (modem)); priv = MM_GENERIC_GSM_GET_PRIVATE (modem); - if (error && priv->pin_check_tries++ < 3) { + if ( error + && priv->pin_check_tries++ < 3 + && !mm_modem_base_get_unlock_required (MM_MODEM_BASE (modem))) { /* Try it again a few times */ if (priv->pin_check_timeout) g_source_remove (priv->pin_check_timeout); diff --git a/src/mm-modem-base.c b/src/mm-modem-base.c index 6e9ee75f..43ec6f84 100644 --- a/src/mm-modem-base.c +++ b/src/mm-modem-base.c @@ -170,7 +170,17 @@ mm_modem_base_get_valid (MMModemBase *self) return MM_MODEM_BASE_GET_PRIVATE (self)->valid; } -void mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required) +const char * +mm_modem_base_get_unlock_required (MMModemBase *self) +{ + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL); + + return MM_MODEM_BASE_GET_PRIVATE (self)->unlock_required; +} + +void +mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required) { MMModemBasePrivate *priv; const char *dbus_path; diff --git a/src/mm-modem-base.h b/src/mm-modem-base.h index 9078f3f2..db2b5fb6 100644 --- a/src/mm-modem-base.h +++ b/src/mm-modem-base.h @@ -60,6 +60,8 @@ void mm_modem_base_set_valid (MMModemBase *self, gboolean mm_modem_base_get_valid (MMModemBase *self); +const char *mm_modem_base_get_unlock_required (MMModemBase *self); + void mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required); |