iface-modem-simple: include setting bands during simple Connect()

This commit is contained in:
Aleksander Morgado
2012-03-15 14:14:41 +01:00
parent a34f51b0a5
commit f0c5e5145e
+51 -2
View File
@@ -32,7 +32,8 @@ typedef enum {
CONNECTION_STEP_FIRST,
CONNECTION_STEP_UNLOCK_CHECK,
CONNECTION_STEP_ENABLE,
CONNECTION_STEP_ALLOWED_MODE,
CONNECTION_STEP_ALLOWED_MODES,
CONNECTION_STEP_ALLOWED_BANDS,
CONNECTION_STEP_REGISTER,
CONNECTION_STEP_BEARER,
CONNECTION_STEP_CONNECT,
@@ -145,6 +146,29 @@ set_allowed_modes_ready (MMBaseModem *self,
connection_step (ctx);
}
static void
set_allowed_bands_ready (MMBaseModem *self,
GAsyncResult *res,
ConnectionContext *ctx)
{
GError *error = NULL;
if (!mm_iface_modem_set_allowed_bands_finish (MM_IFACE_MODEM (self), res, &error)) {
/* If setting allowed bands is unsupported, keep on */
if (!g_error_matches (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED)) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
connection_context_free (ctx);
return;
}
}
/* Allowed bands set... almost there! */
ctx->step++;
connection_step (ctx);
}
static void
enable_ready (MMBaseModem *self,
GAsyncResult *res,
@@ -271,7 +295,7 @@ connection_step (ConnectionContext *ctx)
ctx);
return;
case CONNECTION_STEP_ALLOWED_MODE: {
case CONNECTION_STEP_ALLOWED_MODES: {
MMModemMode allowed_modes = MM_MODEM_MODE_ANY;
MMModemMode preferred_mode = MM_MODEM_MODE_NONE;
@@ -289,6 +313,31 @@ connection_step (ConnectionContext *ctx)
return;
}
case CONNECTION_STEP_ALLOWED_BANDS: {
GArray *array;
const MMModemBand *allowed_bands = NULL;
guint n_allowed_bands = 0;
guint i;
mm_info ("Simple connect state (%d/%d): Allowed bands",
ctx->step, CONNECTION_STEP_LAST);
mm_common_connect_properties_get_allowed_bands (ctx->properties,
&allowed_bands,
&n_allowed_bands);
array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_allowed_bands);
for (i = 0; i < n_allowed_bands; i++)
g_array_insert_val (array, i, allowed_bands[i]);
mm_iface_modem_set_allowed_bands (MM_IFACE_MODEM (ctx->self),
array,
(GAsyncReadyCallback)set_allowed_bands_ready,
ctx);
g_array_unref (array);
return;
}
case CONNECTION_STEP_REGISTER:
mm_info ("Simple connect state (%d/%d): Register",
ctx->step, CONNECTION_STEP_LAST);