gsm: fix direct registration info requests

This commit is contained in:
Dan Williams
2010-02-28 22:11:47 -08:00
parent 27ede83bd3
commit 9d7cb0ddcf

View File

@@ -1250,8 +1250,7 @@ get_reg_status_done (MMSerialPort *port,
GMatchInfo *match_info;
char *tmp;
guint id;
g_warn_if_fail (info == priv->pending_reg_info);
gboolean status_done;
if (error) {
info->error = g_error_copy (error);
@@ -1285,31 +1284,38 @@ get_reg_status_done (MMSerialPort *port,
g_regex_unref (r);
}
if ( reg_status >= 0
&& !reg_status_updated (self, reg_status, &info->error)
&& priv->pending_reg_info) {
g_clear_error (&info->error);
if (reg_status >= 0) {
/* Update cached registration status */
status_done = reg_status_updated (self, reg_status, &info->error);
/* Not registered yet; poll registration status again */
id = g_timeout_add_seconds (1, reg_status_again, info);
mm_callback_info_set_data (info, REG_STATUS_AGAIN_TAG,
GUINT_TO_POINTER (id),
reg_status_again_remove);
return;
/* If we're waiting for automatic registration to complete and it's
* not done yet, check again in a few seconds.
*/
if ((info == priv->pending_reg_info) && !status_done) {
g_clear_error (&info->error);
/* Not registered yet; poll registration status again */
id = g_timeout_add_seconds (1, reg_status_again, info);
mm_callback_info_set_data (info, REG_STATUS_AGAIN_TAG,
GUINT_TO_POINTER (id),
reg_status_again_remove);
return;
}
}
reg_done:
/* This will schedule the callback for us */
mm_generic_gsm_pending_registration_stop (self);
if (info == priv->pending_reg_info) {
/* For pending registration, this will schedule the callback for us */
mm_generic_gsm_pending_registration_stop (self);
} else {
/* Otherwise for a direct registration request, schedule the callback now */
mm_callback_info_schedule (info);
}
}
static void
get_registration_status (MMSerialPort *port, MMCallbackInfo *info)
{
MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (info->modem);
g_warn_if_fail (info == priv->pending_reg_info);
mm_serial_port_queue_command (port, "+CREG?", 10, get_reg_status_done, info);
}
@@ -1418,14 +1424,28 @@ get_registration_info (MMModemGsmNetwork *self,
MMModemGsmNetworkRegInfoFn callback,
gpointer user_data)
{
MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self);
MMCallbackInfo *info;
MMSerialPort *port = priv->primary;
info = mm_callback_info_new_full (MM_MODEM (self),
gsm_network_reg_info_invoke,
G_CALLBACK (callback),
user_data);
mm_callback_info_schedule (info);
if (mm_port_get_connected (MM_PORT (priv->primary))) {
if (!priv->secondary) {
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_CONNECTED,
"Cannot get registration info while connected");
mm_callback_info_schedule (info);
return;
}
/* Use secondary port if primary is connected */
port = priv->secondary;
}
get_registration_status (port, info);
}
void