diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-02-17 19:16:47 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-16 14:28:13 +0100 |
commit | 3595b33648ce6aa78586c820c179c78b84687cf1 (patch) | |
tree | 009e001d2c67250eb2c5700204d2b62ab6009cdf /src | |
parent | 09d2f062c73a62bc32c21d2bcd9249c8a174fe82 (diff) |
iface-modem: load current bands during modem enabling
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-iface-modem.c | 51 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 8 |
2 files changed, 57 insertions, 2 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index d9060d7c..f6e96b59 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -1851,6 +1851,7 @@ static void interface_disabling_step (DisablingContext *ctx); typedef enum { DISABLING_STEP_FIRST, + DISABLING_STEP_CURRENT_BANDS, DISABLING_STEP_MODEM_POWER_DOWN, DISABLING_STEP_CLOSE_PORTS, DISABLING_STEP_LAST @@ -1965,6 +1966,12 @@ interface_disabling_step (DisablingContext *ctx) /* Fall down to next 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: /* 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 @@ -2037,6 +2044,7 @@ typedef enum { ENABLING_STEP_FLOW_CONTROL, ENABLING_STEP_SUPPORTED_CHARSETS, ENABLING_STEP_CHARSET, + ENABLING_STEP_CURRENT_BANDS, ENABLING_STEP_LAST } EnablingStep; @@ -2201,6 +2209,34 @@ setup_charset_ready (MMIfaceModem *self, } 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 interface_enabling_flash_done (MMSerialPort *port, GError *error, gpointer user_data) @@ -2380,6 +2416,19 @@ interface_enabling_step (EnablingContext *ctx) /* Fall down to next 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: /* We are done without errors! */ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); @@ -2579,8 +2628,6 @@ load_supported_bands_ready (MMIfaceModem *self, if (bands_array) { mm_gdbus_modem_set_supported_bands (ctx->skeleton, 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); } diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index f9c3a80e..13d19a0a 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -128,6 +128,14 @@ struct _MMIfaceModem { GAsyncResult *res, 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 */ void (*load_signal_quality) (MMIfaceModem *self, GAsyncReadyCallback callback, |