iface-modem: load allowed/preferred modes during modem enabling

This commit is contained in:
Aleksander Morgado
2012-02-20 12:57:08 +01:00
parent 8396d8a82f
commit 080d046e64
2 changed files with 69 additions and 0 deletions

View File

@@ -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;
@@ -2208,6 +2217,38 @@ setup_charset_ready (MMIfaceModem *self,
interface_enabling_step (ctx);
}
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,
@@ -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) {

View File

@@ -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,