aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-02-28 22:11:47 -0800
committerDan Williams <dcbw@redhat.com>2010-02-28 22:11:47 -0800
commit9d7cb0ddcf69993903c5bc51bbbfbd3a57f55413 (patch)
tree9798285507007913dea471307aba2736e96cf942 /src
parent27ede83bd33f570504d25d370422e23034c8f529 (diff)
gsm: fix direct registration info requests
Diffstat (limited to 'src')
-rw-r--r--src/mm-generic-gsm.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 58f0f9a0..6f88a031 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -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