aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-modem-anydata-cdma.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-04-05 18:46:53 -0700
committerDan Williams <dcbw@redhat.com>2010-04-05 18:46:53 -0700
commitf3dd034aadd16d42f93a682b15a7801537e89d7d (patch)
treed11b5cd62d2b20ccfd7e332463d860cd7429e171 /plugins/mm-modem-anydata-cdma.c
parent49c363d83af84021f74f04c8141313d21e75821b (diff)
cdma: fix subclass registration state checking in error paths (rh #569067)
The generic CDMA superclass already checks minimal registration state, and when some of the additional query_registration_state() subclass checks were being performed, if the device returned an error (if it didn't support the subclass' specific registration command like *STATE or ^SYSINFO) the superclass' registration state checks would be thrown away. Fix that by specifying the behavior of the subclass' query_registration_state() methods to ignore most errors and leave the superclass' registration state intact if a non-critical error occurs.
Diffstat (limited to 'plugins/mm-modem-anydata-cdma.c')
-rw-r--r--plugins/mm-modem-anydata-cdma.c45
1 files changed, 12 insertions, 33 deletions
diff --git a/plugins/mm-modem-anydata-cdma.c b/plugins/mm-modem-anydata-cdma.c
index cb3b72c7..c7cca460 100644
--- a/plugins/mm-modem-anydata-cdma.c
+++ b/plugins/mm-modem-anydata-cdma.c
@@ -123,15 +123,8 @@ evdo_state_done (MMAtSerialPort *port,
GRegex *r;
GMatchInfo *match_info;
- info->error = mm_modem_check_removed (info->modem, error);
- if (info->error) {
- if (info->modem) {
- /* If HSTATE returned an error, assume the device is not EVDO capable
- * or EVDO is not registered.
- */
- mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
- }
-
+ if (error) {
+ /* Leave superclass' reg state alone if AT*HSTATE isn't supported */
mm_callback_info_schedule (info);
return;
}
@@ -143,13 +136,8 @@ evdo_state_done (MMAtSerialPort *port,
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
if (!r) {
/* Parse error; warn about it and assume EVDO is not available */
- g_warning ("AnyData(%s): failed to create EVDO state regex: (%d) %s",
- __func__,
- error ? error->code : -1,
- error && error->message ? error->message : "(unknown)");
- mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
- mm_callback_info_schedule (info);
- return;
+ g_warning ("AnyDATA(%s): *HSTATE parse regex creation failed.", __func__);
+ goto done;
}
g_regex_match (r, reply, 0, &match_info);
@@ -185,8 +173,8 @@ evdo_state_done (MMAtSerialPort *port,
}
}
+done:
mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, reg_state);
-
mm_callback_info_schedule (info);
}
@@ -202,17 +190,8 @@ state_done (MMAtSerialPort *port,
GRegex *r;
GMatchInfo *match_info;
- info->error = mm_modem_check_removed (info->modem, error);
- if (info->error) {
- if (info->modem) {
- /* Assume if we got this far, we're registered even if an error
- * occurred. We're not sure if all AnyData CDMA modems support
- * the *STATE and *HSTATE commands.
- */
- mm_generic_cdma_query_reg_state_set_callback_1x_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED);
- mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
- }
-
+ if (error) {
+ /* Leave superclass' reg state alone if AT*STATE isn't supported */
mm_callback_info_schedule (info);
return;
}
@@ -223,9 +202,7 @@ state_done (MMAtSerialPort *port,
r = g_regex_new ("\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*([^,\\)]*)\\s*,.*",
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
if (!r) {
- info->error = g_error_new_literal (MM_MODEM_ERROR,
- MM_MODEM_ERROR_GENERAL,
- "Could not parse sysinfo results (regex creation failed).");
+ g_warning ("AnyDATA(%s): *STATE parse regex creation failed.", __func__);
mm_callback_info_schedule (info);
return;
}
@@ -254,7 +231,7 @@ state_done (MMAtSerialPort *port,
reg_state = MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED;
break;
default:
- g_message ("ANYDATA: unknown *STATE (%d); assuming no service.", val);
+ g_warning ("ANYDATA: unknown *STATE (%d); assuming no service.", val);
/* fall through */
case 0: /* NO SERVICE */
break;
@@ -270,13 +247,15 @@ state_done (MMAtSerialPort *port,
static void
query_registration_state (MMGenericCdma *cdma,
+ MMModemCdmaRegistrationState cur_cdma_state,
+ MMModemCdmaRegistrationState cur_evdo_state,
MMModemCdmaRegistrationStateFn callback,
gpointer user_data)
{
MMCallbackInfo *info;
MMAtSerialPort *port;
- info = mm_generic_cdma_query_reg_state_callback_info_new (cdma, callback, user_data);
+ info = mm_generic_cdma_query_reg_state_callback_info_new (cdma, cur_cdma_state, cur_evdo_state, callback, user_data);
port = mm_generic_cdma_get_best_at_port (cdma, &info->error);
if (!port) {