iface-modem-3gpp: let caller decide the maximum registration timeout

This commit is contained in:
Aleksander Morgado
2012-03-15 14:14:49 +01:00
parent 787a651f19
commit cc4e469b1a
3 changed files with 15 additions and 11 deletions
+7 -8
View File
@@ -2101,15 +2101,12 @@ modem_3gpp_scan_networks (MMIfaceModem3gpp *self,
/*****************************************************************************/
/* Register in network (3GPP interface) */
/* Maximum time to wait for a successful registration when polling
* periodically */
#define MAX_3GPP_REGISTRATION_CHECK_WAIT_TIME 60
typedef struct {
MMBroadbandModem *self;
GSimpleAsyncResult *result;
GCancellable *cancellable;
GTimer *timer;
guint max_registration_time;
} RegisterIn3gppNetworkContext;
static void
@@ -2199,7 +2196,7 @@ run_all_3gpp_registration_checks_ready (MMBroadbandModem *self,
}
/* Don't spend too much time waiting to get registered */
if (g_timer_elapsed (ctx->timer, NULL) > MAX_3GPP_REGISTRATION_CHECK_WAIT_TIME) {
if (g_timer_elapsed (ctx->timer, NULL) > ctx->max_registration_time) {
mm_dbg ("3GPP registration check timed out");
mm_iface_modem_3gpp_update_cs_registration_state (MM_IFACE_MODEM_3GPP (self),
MM_MODEM_3GPP_REGISTRATION_STATE_IDLE,
@@ -2258,7 +2255,8 @@ register_in_3gpp_network_ready (MMBroadbandModem *self,
static void
modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
const gchar *network_id,
const gchar *operator_id,
guint max_registration_time,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -2274,6 +2272,7 @@ modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
ctx = g_new0 (RegisterIn3gppNetworkContext, 1);
ctx->self = g_object_ref (self);
ctx->max_registration_time = max_registration_time;
ctx->result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
@@ -2286,8 +2285,8 @@ modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
g_object_ref (ctx->cancellable);
/* If the user sent a specific network to use, lock it in. */
if (network_id && network_id[0]) {
command = g_strdup_printf ("+COPS=1,2,\"%s\"", network_id);
if (operator_id && operator_id[0]) {
command = g_strdup_printf ("+COPS=1,2,\"%s\"", operator_id);
broadband->priv->modem_3gpp_manual_registration = TRUE;
}
/* If no specific network was given, and the modem is not registered and not
+5 -2
View File
@@ -124,6 +124,7 @@ register_in_network_ready (MMIfaceModem3gpp *self,
void
mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
const gchar *operator_id,
guint max_registration_time,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -136,6 +137,7 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->register_in_network (
self,
operator_id,
max_registration_time,
(GAsyncReadyCallback)register_in_network_ready,
result);
}
@@ -161,7 +163,7 @@ handle_register_ready (MMIfaceModem3gpp *self,
static gboolean
handle_register (MmGdbusModem3gpp *skeleton,
GDBusMethodInvocation *invocation,
const gchar *network_id,
const gchar *operator_id,
MMIfaceModem3gpp *self)
{
MMModemState modem_state;
@@ -191,7 +193,8 @@ handle_register (MmGdbusModem3gpp *skeleton,
case MM_MODEM_STATE_SEARCHING:
case MM_MODEM_STATE_REGISTERED:
mm_iface_modem_3gpp_register_in_network (self,
network_id,
operator_id,
60,
(GAsyncReadyCallback)handle_register_ready,
dbus_call_context_new (skeleton,
invocation,
+3 -1
View File
@@ -140,7 +140,8 @@ struct _MMIfaceModem3gpp {
/* Try to register in the network */
void (* register_in_network) (MMIfaceModem3gpp *self,
const gchar *network_id,
const gchar *operator_id,
guint max_registration_time,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*register_in_network_finish) (MMIfaceModem3gpp *self,
@@ -244,6 +245,7 @@ gboolean mm_iface_modem_3gpp_register_in_network_finish (MMIfaceModem3gpp *self,
GError **error);
void mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
const gchar *operator_id,
guint max_registration_time,
GAsyncReadyCallback callback,
gpointer user_data);