diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-10 17:17:42 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-10 17:47:43 +0200 |
commit | b49ddfe9300429cee5f5648582be01c541df2c82 (patch) | |
tree | 604b0ac41c7f04ea326aa482888ba3534aea21d7 | |
parent | 9812225d93da8a257ae85c9737afdd2b1d9cfda6 (diff) |
iface-modem: skip handling the CURRENT_CAPABILITIES property
It is an unnecessary complication, as long as we can keep the helpers in the interface.
-rw-r--r-- | src/mm-broadband-modem.c | 21 | ||||
-rw-r--r-- | src/mm-iface-modem.c | 121 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 26 |
3 files changed, 58 insertions, 110 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index fd304643..a7a4df77 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -79,7 +79,6 @@ enum { PROP_MODEM_SIM, PROP_MODEM_BEARER_LIST, PROP_MODEM_STATE, - PROP_MODEM_CURRENT_CAPABILITIES, PROP_MODEM_3GPP_REGISTRATION_STATE, PROP_MODEM_3GPP_CS_NETWORK_SUPPORTED, PROP_MODEM_3GPP_PS_NETWORK_SUPPORTED, @@ -107,7 +106,6 @@ struct _MMBroadbandModemPrivate { MMSim *modem_sim; MMBearerList *modem_bearer_list; MMModemState modem_state; - MMModemCapability modem_current_capabilities; /* Implementation helpers */ MMModemCharset modem_current_charset; gboolean modem_cind_supported; @@ -936,7 +934,7 @@ modem_load_supported_modes (MMIfaceModem *self, mode = MM_MODEM_MODE_NONE; /* If the modem has +GSM caps... */ - if (broadband->priv->modem_current_capabilities & MM_MODEM_CAPABILITY_GSM_UMTS) { + if (mm_iface_modem_is_3gpp (self)) { /* There are modems which only support CS connections (e.g. Iridium) */ if (broadband->priv->modem_3gpp_cs_network_supported) mode |= MM_MODEM_MODE_CS; @@ -948,7 +946,7 @@ modem_load_supported_modes (MMIfaceModem *self, } /* If the modem has CDMA caps... */ - if (broadband->priv->modem_current_capabilities & MM_MODEM_CAPABILITY_CDMA_EVDO) { + if (mm_iface_modem_is_cdma (self)) { if (broadband->priv->modem_cdma_cdma1x_network_supported) mode |= MM_MODEM_MODE_2G; if (broadband->priv->modem_cdma_evdo_network_supported) @@ -956,10 +954,8 @@ modem_load_supported_modes (MMIfaceModem *self, } /* If the modem has LTE caps, it does 4G */ - if (broadband->priv->modem_current_capabilities & MM_MODEM_CAPABILITY_LTE || - broadband->priv->modem_current_capabilities & MM_MODEM_CAPABILITY_LTE_ADVANCED) { + if (mm_iface_modem_is_3gpp_lte (self)) mode |= MM_MODEM_MODE_4G; - } g_simple_async_result_set_op_res_gpointer (result, GUINT_TO_POINTER (mode), @@ -6930,9 +6926,6 @@ set_property (GObject *object, case PROP_MODEM_STATE: self->priv->modem_state = g_value_get_enum (value); break; - case PROP_MODEM_CURRENT_CAPABILITIES: - self->priv->modem_current_capabilities = g_value_get_flags (value); - break; case PROP_MODEM_3GPP_REGISTRATION_STATE: self->priv->modem_3gpp_registration_state = g_value_get_enum (value); break; @@ -7022,9 +7015,6 @@ get_property (GObject *object, case PROP_MODEM_STATE: g_value_set_enum (value, self->priv->modem_state); break; - case PROP_MODEM_CURRENT_CAPABILITIES: - g_value_set_flags (value, self->priv->modem_current_capabilities); - break; case PROP_MODEM_3GPP_REGISTRATION_STATE: g_value_set_enum (value, self->priv->modem_3gpp_registration_state); break; @@ -7078,7 +7068,6 @@ mm_broadband_modem_init (MMBroadbandModem *self) MM_TYPE_BROADBAND_MODEM, MMBroadbandModemPrivate); self->priv->modem_state = MM_MODEM_STATE_UNKNOWN; - self->priv->modem_current_capabilities = MM_MODEM_CAPABILITY_NONE; self->priv->modem_3gpp_registration_regex = mm_3gpp_creg_regex_get (TRUE); self->priv->modem_current_charset = MM_MODEM_CHARSET_UNKNOWN; self->priv->modem_3gpp_registration_state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN; @@ -7419,10 +7408,6 @@ mm_broadband_modem_class_init (MMBroadbandModemClass *klass) MM_IFACE_MODEM_STATE); g_object_class_override_property (object_class, - PROP_MODEM_CURRENT_CAPABILITIES, - MM_IFACE_MODEM_CURRENT_CAPABILITIES); - - g_object_class_override_property (object_class, PROP_MODEM_3GPP_REGISTRATION_STATE, MM_IFACE_MODEM_3GPP_REGISTRATION_STATE); diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 62eac35f..c094b578 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -3037,7 +3037,7 @@ initialization_context_complete_and_free_if_cancelled (InitializationContext *ct } #undef UINT_REPLY_READY_FN -#define UINT_REPLY_READY_FN(NAME,DISPLAY) \ +#define UINT_REPLY_READY_FN(NAME,DISPLAY,FATAL) \ static void \ load_##NAME##_ready (MMIfaceModem *self, \ GAsyncResult *res, \ @@ -3050,41 +3050,27 @@ initialization_context_complete_and_free_if_cancelled (InitializationContext *ct MM_IFACE_MODEM_GET_INTERFACE (self)->load_##NAME##_finish (self, res, &error)); \ \ if (error) { \ - mm_warn ("couldn't load %s: '%s'", DISPLAY, error->message); \ - g_error_free (error); \ + if (FATAL) { \ + g_propagate_error (&ctx->fatal_error, error); \ + g_prefix_error (&ctx->fatal_error, "couldn't load %s: ", DISPLAY); \ + /* Jump to the last step */ \ + ctx->step = INITIALIZATION_STEP_LAST; \ + } else { \ + mm_warn ("couldn't load %s: '%s'", DISPLAY, error->message); \ + g_error_free (error); \ + /* Go on to next step */ \ + ctx->step++; \ + } \ + } else { \ + /* Go on to next step */ \ + ctx->step++; \ } \ \ - /* Go on to next step */ \ - ctx->step++; \ interface_initialization_step (ctx); \ } -static void -load_current_capabilities_ready (MMIfaceModem *self, - GAsyncResult *res, - InitializationContext *ctx) -{ - /* We have the property in the interface bound to the property in the - * skeleton. */ - g_object_set (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, - MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_capabilities_finish (self, - res, - &ctx->fatal_error), - NULL); - if (ctx->fatal_error) { - g_prefix_error (&ctx->fatal_error, - "couldn't load Current Capabilities: "); - /* Jump to the last step */ - ctx->step = INITIALIZATION_STEP_LAST; - } else - /* Go on to next step */ - ctx->step++; - - interface_initialization_step (ctx); -} - -UINT_REPLY_READY_FN (modem_capabilities, "Modem Capabilities") +UINT_REPLY_READY_FN (current_capabilities, "Current Capabilities", TRUE) +UINT_REPLY_READY_FN (modem_capabilities, "Modem Capabilities", FALSE) STR_REPLY_READY_FN (manufacturer, "Manufacturer") STR_REPLY_READY_FN (model, "Model") STR_REPLY_READY_FN (revision, "Revision") @@ -3643,6 +3629,7 @@ mm_iface_modem_initialize (MMIfaceModem *self, /* Set all initial property defaults */ mm_gdbus_modem_set_sim (skeleton, NULL); + mm_gdbus_modem_set_current_capabilities (skeleton, MM_MODEM_CAPABILITY_NONE); mm_gdbus_modem_set_modem_capabilities (skeleton, MM_MODEM_CAPABILITY_NONE); mm_gdbus_modem_set_max_bearers (skeleton, 0); mm_gdbus_modem_set_max_active_bearers (skeleton, 0); @@ -3669,10 +3656,6 @@ mm_iface_modem_initialize (MMIfaceModem *self, g_object_bind_property (self, MM_IFACE_MODEM_STATE, skeleton, "state", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - /* Bind our Capabilities property */ - g_object_bind_property (self, MM_IFACE_MODEM_CURRENT_CAPABILITIES, - skeleton, "current-capabilities", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_set (self, MM_IFACE_MODEM_DBUS_SKELETON, skeleton, @@ -3706,75 +3689,66 @@ mm_iface_modem_shutdown (MMIfaceModem *self) /*****************************************************************************/ -gboolean -mm_iface_modem_is_3gpp (MMIfaceModem *self) +MMModemCapability +mm_iface_modem_get_current_capabilities (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; + MMModemCapability current = MM_MODEM_CAPABILITY_NONE; + MmGdbusModem *skeleton; g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, + MM_IFACE_MODEM_DBUS_SKELETON, &skeleton, NULL); - return (capabilities & MM_MODEM_CAPABILITY_3GPP); + if (skeleton) { + current = mm_gdbus_modem_get_current_capabilities (skeleton); + g_object_unref (skeleton); + } + + return current; } gboolean -mm_iface_modem_is_3gpp_lte (MMIfaceModem *self) +mm_iface_modem_is_3gpp (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP); +} - return (capabilities & MM_MODEM_CAPABILITY_3GPP_LTE); +gboolean +mm_iface_modem_is_3gpp_lte (MMIfaceModem *self) +{ + return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP_LTE); } gboolean mm_iface_modem_is_cdma (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); - - return (capabilities & MM_MODEM_CAPABILITY_CDMA_EVDO); + return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_CDMA_EVDO); } gboolean mm_iface_modem_is_3gpp_only (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + MMModemCapability capabilities; + capabilities = mm_iface_modem_get_current_capabilities (self); return !((MM_MODEM_CAPABILITY_3GPP ^ capabilities) & capabilities); } gboolean mm_iface_modem_is_3gpp_lte_only (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + MMModemCapability capabilities; + capabilities = mm_iface_modem_get_current_capabilities (self); return !((MM_MODEM_CAPABILITY_3GPP_LTE ^ capabilities) & capabilities); } gboolean mm_iface_modem_is_cdma_only (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + MMModemCapability capabilities; + capabilities = mm_iface_modem_get_current_capabilities (self); return !((MM_MODEM_CAPABILITY_CDMA_EVDO ^ capabilities) & capabilities); } @@ -3816,15 +3790,6 @@ iface_modem_init (gpointer g_iface) g_object_interface_install_property (g_iface, - g_param_spec_flags (MM_IFACE_MODEM_CURRENT_CAPABILITIES, - "Current capabilities", - "Current capabilities of the modem", - MM_TYPE_MODEM_CAPABILITY, - MM_MODEM_CAPABILITY_NONE, - G_PARAM_READWRITE)); - - g_object_interface_install_property - (g_iface, g_param_spec_object (MM_IFACE_MODEM_BEARER_LIST, "Bearer list", "List of bearers handled by the modem", diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index a9e54bb2..3040303f 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -31,11 +31,10 @@ #define MM_IS_IFACE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_MODEM)) #define MM_IFACE_MODEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_MODEM, MMIfaceModem)) -#define MM_IFACE_MODEM_DBUS_SKELETON "iface-modem-dbus-skeleton" -#define MM_IFACE_MODEM_CURRENT_CAPABILITIES "iface-modem-current-capabilities" -#define MM_IFACE_MODEM_STATE "iface-modem-state" -#define MM_IFACE_MODEM_SIM "iface-modem-sim" -#define MM_IFACE_MODEM_BEARER_LIST "iface-modem-bearer-list" +#define MM_IFACE_MODEM_DBUS_SKELETON "iface-modem-dbus-skeleton" +#define MM_IFACE_MODEM_STATE "iface-modem-state" +#define MM_IFACE_MODEM_SIM "iface-modem-sim" +#define MM_IFACE_MODEM_BEARER_LIST "iface-modem-bearer-list" typedef struct _MMIfaceModem MMIfaceModem; @@ -298,15 +297,14 @@ struct _MMIfaceModem { GType mm_iface_modem_get_type (void); -/* Check whether this modem has 3GPP capabilities */ -gboolean mm_iface_modem_is_3gpp (MMIfaceModem *self); -gboolean mm_iface_modem_is_3gpp_only (MMIfaceModem *self); -gboolean mm_iface_modem_is_3gpp_lte (MMIfaceModem *self); -gboolean mm_iface_modem_is_3gpp_lte_only (MMIfaceModem *self); - -/* Check whether this modem has CDMA capabilities */ -gboolean mm_iface_modem_is_cdma (MMIfaceModem *self); -gboolean mm_iface_modem_is_cdma_only (MMIfaceModem *self); +/* Helpers to query capabilities */ +MMModemCapability mm_iface_modem_get_current_capabilities (MMIfaceModem *self); +gboolean mm_iface_modem_is_3gpp (MMIfaceModem *self); +gboolean mm_iface_modem_is_3gpp_only (MMIfaceModem *self); +gboolean mm_iface_modem_is_3gpp_lte (MMIfaceModem *self); +gboolean mm_iface_modem_is_3gpp_lte_only (MMIfaceModem *self); +gboolean mm_iface_modem_is_cdma (MMIfaceModem *self); +gboolean mm_iface_modem_is_cdma_only (MMIfaceModem *self); /* Initialize Modem interface (async) */ void mm_iface_modem_initialize (MMIfaceModem *self, |