iface-modem: skip handling the CURRENT_CAPABILITIES property

It is an unnecessary complication, as long as we can keep the helpers in the interface.
This commit is contained in:
Aleksander Morgado
2012-04-10 17:17:42 +02:00
parent 9812225d93
commit b49ddfe930
3 changed files with 60 additions and 112 deletions

View File

@@ -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;
@@ -7418,10 +7407,6 @@ mm_broadband_modem_class_init (MMBroadbandModemClass *klass)
PROP_MODEM_STATE,
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);

View File

@@ -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)
/*****************************************************************************/
MMModemCapability
mm_iface_modem_get_current_capabilities (MMIfaceModem *self)
{
MMModemCapability current = MM_MODEM_CAPABILITY_NONE;
MmGdbusModem *skeleton;
g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
NULL);
if (skeleton) {
current = mm_gdbus_modem_get_current_capabilities (skeleton);
g_object_unref (skeleton);
}
return current;
}
gboolean
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 (capabilities & MM_MODEM_CAPABILITY_3GPP);
return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP);
}
gboolean
mm_iface_modem_is_3gpp_lte (MMIfaceModem *self)
{
MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE;
g_object_get (self,
MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities,
NULL);
return (capabilities & MM_MODEM_CAPABILITY_3GPP_LTE);
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);
}
@@ -3814,15 +3788,6 @@ iface_modem_init (gpointer g_iface)
MM_MODEM_STATE_UNKNOWN,
G_PARAM_READWRITE));
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,

View File

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