iface-modem: load current bands during modem enabling

This commit is contained in:
Aleksander Morgado
2012-02-17 19:16:47 +01:00
parent 09d2f062c7
commit 3595b33648
2 changed files with 57 additions and 2 deletions

View File

@@ -1851,6 +1851,7 @@ static void interface_disabling_step (DisablingContext *ctx);
typedef enum { typedef enum {
DISABLING_STEP_FIRST, DISABLING_STEP_FIRST,
DISABLING_STEP_CURRENT_BANDS,
DISABLING_STEP_MODEM_POWER_DOWN, DISABLING_STEP_MODEM_POWER_DOWN,
DISABLING_STEP_CLOSE_PORTS, DISABLING_STEP_CLOSE_PORTS,
DISABLING_STEP_LAST DISABLING_STEP_LAST
@@ -1965,6 +1966,12 @@ interface_disabling_step (DisablingContext *ctx)
/* Fall down to next step */ /* Fall down to next step */
ctx->step++; ctx->step++;
case DISABLING_STEP_CURRENT_BANDS:
/* Clear current bands */
mm_gdbus_modem_set_bands (ctx->skeleton, mm_common_build_bands_unknown ());
/* Fall down to next step */
ctx->step++;
case DISABLING_STEP_MODEM_POWER_DOWN: case DISABLING_STEP_MODEM_POWER_DOWN:
/* CFUN=0 is dangerous and often will shoot devices in the head (that's /* CFUN=0 is dangerous and often will shoot devices in the head (that's
* what it's supposed to do). So don't use CFUN=0 by default, but let * what it's supposed to do). So don't use CFUN=0 by default, but let
@@ -2037,6 +2044,7 @@ typedef enum {
ENABLING_STEP_FLOW_CONTROL, ENABLING_STEP_FLOW_CONTROL,
ENABLING_STEP_SUPPORTED_CHARSETS, ENABLING_STEP_SUPPORTED_CHARSETS,
ENABLING_STEP_CHARSET, ENABLING_STEP_CHARSET,
ENABLING_STEP_CURRENT_BANDS,
ENABLING_STEP_LAST ENABLING_STEP_LAST
} EnablingStep; } EnablingStep;
@@ -2200,6 +2208,34 @@ setup_charset_ready (MMIfaceModem *self,
interface_enabling_step (ctx); interface_enabling_step (ctx);
} }
static void
load_current_bands_ready (MMIfaceModem *self,
GAsyncResult *res,
EnablingContext *ctx)
{
GArray *bands_array;
GError *error = NULL;
bands_array = MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_bands_finish (self, res, &error);
if (bands_array) {
mm_gdbus_modem_set_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (bands_array));
g_array_unref (bands_array);
} else
mm_gdbus_modem_set_bands (ctx->skeleton, mm_common_build_bands_unknown ());
/* Errors when getting current bands won't be critical */
if (error) {
mm_warn ("couldn't load current Bands: '%s'", error->message);
g_error_free (error);
}
/* Done, Go on to next step */
ctx->step++;
interface_enabling_step (ctx);
}
static void static void
interface_enabling_flash_done (MMSerialPort *port, interface_enabling_flash_done (MMSerialPort *port,
GError *error, GError *error,
@@ -2380,6 +2416,19 @@ interface_enabling_step (EnablingContext *ctx)
/* Fall down to next step */ /* Fall down to next step */
ctx->step++; ctx->step++;
case ENABLING_STEP_CURRENT_BANDS:
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_current_bands &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_current_bands_finish) {
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_current_bands (
ctx->self,
(GAsyncReadyCallback)load_current_bands_ready,
ctx);
return;
} else
mm_gdbus_modem_set_bands (ctx->skeleton, mm_common_build_bands_unknown ());
/* Fall down to next step */
ctx->step++;
case ENABLING_STEP_LAST: case ENABLING_STEP_LAST:
/* We are done without errors! */ /* We are done without errors! */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
@@ -2579,8 +2628,6 @@ load_supported_bands_ready (MMIfaceModem *self,
if (bands_array) { if (bands_array) {
mm_gdbus_modem_set_supported_bands (ctx->skeleton, mm_gdbus_modem_set_supported_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (bands_array)); mm_common_bands_garray_to_variant (bands_array));
mm_gdbus_modem_set_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (bands_array));
g_array_unref (bands_array); g_array_unref (bands_array);
} }

View File

@@ -128,6 +128,14 @@ struct _MMIfaceModem {
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Loading of the Bands property */
void (*load_current_bands) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
GArray * (*load_current_bands_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Loading of the SignalQuality property */ /* Loading of the SignalQuality property */
void (*load_signal_quality) (MMIfaceModem *self, void (*load_signal_quality) (MMIfaceModem *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,