diff options
-rw-r--r-- | libmm-common/mm-common-bearer-properties.c | 35 | ||||
-rw-r--r-- | libmm-common/mm-common-bearer-properties.h | 5 | ||||
-rw-r--r-- | libmm-common/mm-common-helpers.c | 23 | ||||
-rw-r--r-- | libmm-common/mm-common-helpers.h | 18 |
4 files changed, 72 insertions, 9 deletions
diff --git a/libmm-common/mm-common-bearer-properties.c b/libmm-common/mm-common-bearer-properties.c index 7515c612..cae4caa8 100644 --- a/libmm-common/mm-common-bearer-properties.c +++ b/libmm-common/mm-common-bearer-properties.c @@ -27,6 +27,7 @@ G_DEFINE_TYPE (MMCommonBearerProperties, mm_common_bearer_properties, G_TYPE_OBJ #define PROPERTY_IP_TYPE "ip-type" #define PROPERTY_NUMBER "number" #define PROPERTY_ALLOW_ROAMING "allow-roaming" +#define PROPERTY_RM_PROTOCOL "rm-protocol" struct _MMCommonBearerPropertiesPrivate { /* APN */ @@ -42,6 +43,8 @@ struct _MMCommonBearerPropertiesPrivate { /* Roaming allowance */ gboolean allow_roaming_set; gboolean allow_roaming; + /* Protocol of the Rm interface */ + MMModemCdmaRmProtocol rm_protocol; }; /*****************************************************************************/ @@ -94,6 +97,13 @@ mm_common_bearer_properties_set_number (MMCommonBearerProperties *self, self->priv->number = g_strdup (number); } +void +mm_common_bearer_properties_set_rm_protocol (MMCommonBearerProperties *self, + MMModemCdmaRmProtocol protocol) +{ + self->priv->rm_protocol = protocol; +} + /*****************************************************************************/ const gchar * @@ -132,6 +142,12 @@ mm_common_bearer_properties_get_number (MMCommonBearerProperties *self) return self->priv->number; } +MMModemCdmaRmProtocol +mm_common_bearer_properties_get_rm_protocol (MMCommonBearerProperties *self) +{ + return self->priv->rm_protocol; +} + /*****************************************************************************/ GVariant * @@ -181,6 +197,12 @@ mm_common_bearer_properties_get_dictionary (MMCommonBearerProperties *self) PROPERTY_ALLOW_ROAMING, g_variant_new_boolean (self->priv->allow_roaming)); + if (self->priv->rm_protocol) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_RM_PROTOCOL, + g_variant_new_uint32 (self->priv->rm_protocol)); + return g_variant_ref_sink (g_variant_builder_end (&builder)); } @@ -212,7 +234,17 @@ mm_common_bearer_properties_consume_string (MMCommonBearerProperties *self, mm_common_bearer_properties_set_allow_roaming (self, allow_roaming); } else if (g_str_equal (key, PROPERTY_NUMBER)) mm_common_bearer_properties_set_number (self, value); - else { + else if (g_str_equal (key, PROPERTY_RM_PROTOCOL)) { + GError *inner_error = NULL; + MMModemCdmaRmProtocol protocol; + + protocol = mm_common_get_rm_protocol_from_string (value, &inner_error); + if (inner_error) { + g_propagate_error (error, inner_error); + return FALSE; + } + mm_common_bearer_properties_set_rm_protocol (self, protocol); + } else { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS, @@ -376,6 +408,7 @@ mm_common_bearer_properties_init (MMCommonBearerProperties *self) /* Some defaults */ self->priv->allow_roaming = TRUE; + self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; } static void diff --git a/libmm-common/mm-common-bearer-properties.h b/libmm-common/mm-common-bearer-properties.h index 32449a29..4e9454b8 100644 --- a/libmm-common/mm-common-bearer-properties.h +++ b/libmm-common/mm-common-bearer-properties.h @@ -69,6 +69,9 @@ void mm_common_bearer_properties_set_allow_roaming ( void mm_common_bearer_properties_set_number ( MMCommonBearerProperties *properties, const gchar *number); +void mm_common_bearer_properties_set_rm_protocol ( + MMCommonBearerProperties *properties, + MMModemCdmaRmProtocol protocol); const gchar *mm_common_bearer_properties_get_apn ( MMCommonBearerProperties *properties); @@ -82,6 +85,8 @@ gboolean mm_common_bearer_properties_get_allow_roaming ( MMCommonBearerProperties *properties); const gchar *mm_common_bearer_properties_get_number ( MMCommonBearerProperties *properties); +MMModemCdmaRmProtocol mm_common_bearer_properties_get_rm_protocol ( + MMCommonBearerProperties *properties); gboolean mm_common_bearer_properties_consume_string (MMCommonBearerProperties *self, const gchar *key, diff --git a/libmm-common/mm-common-helpers.c b/libmm-common/mm-common-helpers.c index fb52b475..5410a313 100644 --- a/libmm-common/mm-common-helpers.c +++ b/libmm-common/mm-common-helpers.c @@ -375,6 +375,29 @@ mm_common_get_boolean_from_string (const gchar *value, return FALSE; } +MMModemCdmaRmProtocol +mm_common_get_rm_protocol_from_string (const gchar *str, + GError **error) +{ + GEnumClass *enum_class; + guint i; + + enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_CDMA_RM_PROTOCOL)); + + + for (i = 0; enum_class->values[i].value_nick; i++) { + if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick)) + return enum_class->values[i].value; + } + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMModemCdmaRmProtocol value", + str); + return MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; +} + GVariant * mm_common_build_bands_unknown (void) { diff --git a/libmm-common/mm-common-helpers.h b/libmm-common/mm-common-helpers.h index c14dc4b2..34119744 100644 --- a/libmm-common/mm-common-helpers.h +++ b/libmm-common/mm-common-helpers.h @@ -25,14 +25,16 @@ gchar *mm_common_get_modes_string (MMModemMode mode); gchar *mm_common_get_bands_string (const MMModemBand *bands, guint n_bands); -MMModemMode mm_common_get_modes_from_string (const gchar *str, - GError **error); -void mm_common_get_bands_from_string (const gchar *str, - MMModemBand **bands, - guint *n_bands, - GError **error); -gboolean mm_common_get_boolean_from_string (const gchar *value, - GError **error); +MMModemMode mm_common_get_modes_from_string (const gchar *str, + GError **error); +void mm_common_get_bands_from_string (const gchar *str, + MMModemBand **bands, + guint *n_bands, + GError **error); +gboolean mm_common_get_boolean_from_string (const gchar *value, + GError **error); +MMModemCdmaRmProtocol mm_common_get_rm_protocol_from_string (const gchar *str, + GError **error); GArray *mm_common_bands_variant_to_garray (GVariant *variant); MMModemBand *mm_common_bands_variant_to_array (GVariant *variant, |