diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-02-20 12:57:08 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-16 14:28:15 +0100 |
commit | 080d046e643a203b7f37c464e38108f6083943ed (patch) | |
tree | cbf2b544f47e44a929509ed9537affd56ece20fe /src | |
parent | 8396d8a82f05a548d5bc5c058713b413964d7c0a (diff) |
iface-modem: load allowed/preferred modes during modem enabling
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-iface-modem.c | 59 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 10 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index f6e96b59..ce47f58c 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -1852,6 +1852,7 @@ static void interface_disabling_step (DisablingContext *ctx); typedef enum { DISABLING_STEP_FIRST, DISABLING_STEP_CURRENT_BANDS, + DISABLING_STEP_ALLOWED_MODES, DISABLING_STEP_MODEM_POWER_DOWN, DISABLING_STEP_CLOSE_PORTS, DISABLING_STEP_LAST @@ -1972,6 +1973,13 @@ interface_disabling_step (DisablingContext *ctx) /* Fall down to next step */ ctx->step++; + case DISABLING_STEP_ALLOWED_MODES: + /* Clear allowed/preferred modes */ + mm_gdbus_modem_set_allowed_modes (ctx->skeleton, MM_MODEM_MODE_NONE); + mm_gdbus_modem_set_preferred_mode (ctx->skeleton, MM_MODEM_MODE_NONE); + /* 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 @@ -2044,6 +2052,7 @@ typedef enum { ENABLING_STEP_FLOW_CONTROL, ENABLING_STEP_SUPPORTED_CHARSETS, ENABLING_STEP_CHARSET, + ENABLING_STEP_ALLOWED_MODES, ENABLING_STEP_CURRENT_BANDS, ENABLING_STEP_LAST } EnablingStep; @@ -2209,6 +2218,38 @@ setup_charset_ready (MMIfaceModem *self, } static void +load_allowed_modes_ready (MMIfaceModem *self, + GAsyncResult *res, + EnablingContext *ctx) +{ + MMModemMode allowed = MM_MODEM_MODE_NONE; + MMModemMode preferred = MM_MODEM_MODE_NONE; + GError *error = NULL; + + if (!MM_IFACE_MODEM_GET_INTERFACE (self)->load_allowed_modes_finish (self, + res, + &allowed, + &preferred, + &error)) { + /* Errors when getting allowed/preferred won't be critical */ + mm_warn ("couldn't load current allowed/preferred modes: '%s'", error->message); + g_error_free (error); + + /* If errors getting allowed modes, assume allowed=supported, + * and none preferred */ + allowed = mm_gdbus_modem_get_supported_modes (ctx->skeleton); + preferred = MM_MODEM_MODE_NONE; + } + + mm_gdbus_modem_set_allowed_modes (ctx->skeleton, allowed); + mm_gdbus_modem_set_preferred_mode (ctx->skeleton, preferred); + + /* Done, Go on to next step */ + ctx->step++; + interface_enabling_step (ctx); +} + +static void load_current_bands_ready (MMIfaceModem *self, GAsyncResult *res, EnablingContext *ctx) @@ -2416,6 +2457,24 @@ interface_enabling_step (EnablingContext *ctx) /* Fall down to next step */ ctx->step++; + case ENABLING_STEP_ALLOWED_MODES: + if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_allowed_modes && + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_allowed_modes_finish) { + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_allowed_modes ( + ctx->self, + (GAsyncReadyCallback)load_allowed_modes_ready, + ctx); + return; + } + + /* If no way to get allowed modes, assume allowed=supported, + * and none preferred */ + mm_gdbus_modem_set_allowed_modes (ctx->skeleton, + mm_gdbus_modem_get_supported_modes (ctx->skeleton)); + mm_gdbus_modem_set_preferred_mode (ctx->skeleton, MM_MODEM_MODE_NONE); + /* 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) { diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index 13d19a0a..8e6a4bcf 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -120,6 +120,16 @@ struct _MMIfaceModem { GAsyncResult *res, GError **error); + /* Loading of the AllowedModes and PreferredMode properties */ + void (*load_allowed_modes) (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*load_allowed_modes_finish) (MMIfaceModem *self, + GAsyncResult *res, + MMModemMode *allowed, + MMModemMode *preferred, + GError **error); + /* Loading of the SupportedBands property */ void (*load_supported_bands) (MMIfaceModem *self, GAsyncReadyCallback callback, |