diff options
Diffstat (limited to 'libmm-glib')
-rw-r--r-- | libmm-glib/mm-3gpp-profile.c | 60 | ||||
-rw-r--r-- | libmm-glib/mm-3gpp-profile.h | 14 |
2 files changed, 68 insertions, 6 deletions
diff --git a/libmm-glib/mm-3gpp-profile.c b/libmm-glib/mm-3gpp-profile.c index 2d00cee3..82590e2a 100644 --- a/libmm-glib/mm-3gpp-profile.c +++ b/libmm-glib/mm-3gpp-profile.c @@ -31,6 +31,7 @@ G_DEFINE_TYPE (MM3gppProfile, mm_3gpp_profile, G_TYPE_OBJECT) #define PROPERTY_ID "profile-id" +#define PROPERTY_NAME "profile-name" #define PROPERTY_APN "apn" #define PROPERTY_ALLOWED_AUTH "allowed-auth" #define PROPERTY_USER "user" @@ -40,6 +41,7 @@ G_DEFINE_TYPE (MM3gppProfile, mm_3gpp_profile, G_TYPE_OBJECT) struct _MM3gppProfilePrivate { gint profile_id; + gchar *profile_name; gchar *apn; MMBearerIpFamily ip_type; MMBearerApnType apn_type; @@ -95,6 +97,9 @@ mm_3gpp_profile_cmp (MM3gppProfile *a, if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE) && (a->priv->apn_type != b->priv->apn_type)) return FALSE; + if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_NAME) && + (a->priv->profile_name != b->priv->profile_name)) + return FALSE; return TRUE; } @@ -182,6 +187,46 @@ mm_3gpp_profile_get_apn (MM3gppProfile *self) /*****************************************************************************/ /** + * mm_3gpp_profile_set_profile_name: + * @self: a #MM3gppProfile. + * @profile_name: Name of the profile. + * + * Sets the name of the profile. + * + * Since: 1.20 + */ +void +mm_3gpp_profile_set_profile_name (MM3gppProfile *self, + const gchar *profile_name) +{ + g_return_if_fail (MM_IS_3GPP_PROFILE (self)); + + g_free (self->priv->profile_name); + self->priv->profile_name = g_strdup (profile_name); +} + +/** + * mm_3gpp_profile_get_profile_name: + * @self: a #MM3gppProfile. + * + * Gets the name of the profile. + * + * Returns: (transfer none): the profile name, or #NULL if not set. Do not free + * the returned value, it is owned by @self. + * + * Since: 1.20 + */ +const gchar * +mm_3gpp_profile_get_profile_name (MM3gppProfile *self) +{ + g_return_val_if_fail (MM_IS_3GPP_PROFILE (self), NULL); + + return self->priv->profile_name; +} + +/*****************************************************************************/ + +/** * mm_3gpp_profile_set_allowed_auth: * @self: a #MM3gppProfile. * @allowed_auth: a bitmask of #MMBearerAllowedAuth values. @@ -399,6 +444,12 @@ mm_3gpp_profile_get_dictionary (MM3gppProfile *self) PROPERTY_ID, g_variant_new_int32 (self->priv->profile_id)); + if (self->priv->profile_name) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_NAME, + g_variant_new_string (self->priv->profile_name)); + if (self->priv->apn) g_variant_builder_add (&builder, "{sv}", @@ -457,7 +508,9 @@ mm_3gpp_profile_consume_string (MM3gppProfile *self, return FALSE; } mm_3gpp_profile_set_profile_id (self, profile_id); - } else if (g_str_equal (key, PROPERTY_APN)) + } else if (g_str_equal (key, PROPERTY_NAME)) + mm_3gpp_profile_set_profile_name (self, value); + else if (g_str_equal (key, PROPERTY_APN)) mm_3gpp_profile_set_apn (self, value); else if (g_str_equal (key, PROPERTY_ALLOWED_AUTH)) { GError *inner_error = NULL; @@ -561,6 +614,10 @@ mm_3gpp_profile_consume_variant (MM3gppProfile *self, mm_3gpp_profile_set_profile_id ( self, g_variant_get_int32 (value)); + else if (g_str_equal (key, PROPERTY_NAME)) + mm_3gpp_profile_set_profile_name ( + self, + g_variant_get_string (value, NULL)); else if (g_str_equal (key, PROPERTY_APN)) mm_3gpp_profile_set_apn ( self, @@ -677,6 +734,7 @@ finalize (GObject *object) { MM3gppProfile *self = MM_3GPP_PROFILE (object); + g_free (self->priv->profile_name); g_free (self->priv->apn); g_free (self->priv->user); g_free (self->priv->password); diff --git a/libmm-glib/mm-3gpp-profile.h b/libmm-glib/mm-3gpp-profile.h index a3974a66..c0d0206a 100644 --- a/libmm-glib/mm-3gpp-profile.h +++ b/libmm-glib/mm-3gpp-profile.h @@ -69,6 +69,8 @@ MM3gppProfile *mm_3gpp_profile_new (void); void mm_3gpp_profile_set_profile_id (MM3gppProfile *self, gint profile_id); +void mm_3gpp_profile_set_profile_name (MM3gppProfile *self, + const gchar *profile_name); void mm_3gpp_profile_set_apn (MM3gppProfile *self, const gchar *apn); void mm_3gpp_profile_set_allowed_auth (MM3gppProfile *self, @@ -83,6 +85,7 @@ void mm_3gpp_profile_set_apn_type (MM3gppProfile *self, MMBearerApnType apn_type); gint mm_3gpp_profile_get_profile_id (MM3gppProfile *self); +const gchar *mm_3gpp_profile_get_profile_name (MM3gppProfile *self); const gchar *mm_3gpp_profile_get_apn (MM3gppProfile *self); MMBearerAllowedAuth mm_3gpp_profile_get_allowed_auth (MM3gppProfile *self); const gchar *mm_3gpp_profile_get_user (MM3gppProfile *self); @@ -112,11 +115,12 @@ gboolean mm_3gpp_profile_consume_variant (MM3gppProfile *self, GError **error); typedef enum { - MM_3GPP_PROFILE_CMP_FLAGS_NONE = 0, - MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_ID = 1 << 1, - MM_3GPP_PROFILE_CMP_FLAGS_NO_AUTH = 1 << 2, - MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE = 1 << 3, - MM_3GPP_PROFILE_CMP_FLAGS_NO_IP_TYPE = 1 << 4, + MM_3GPP_PROFILE_CMP_FLAGS_NONE = 0, + MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_ID = 1 << 1, + MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_NAME = 1 << 2, + MM_3GPP_PROFILE_CMP_FLAGS_NO_AUTH = 1 << 3, + MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE = 1 << 4, + MM_3GPP_PROFILE_CMP_FLAGS_NO_IP_TYPE = 1 << 5, } MM3gppProfileCmpFlags; gboolean mm_3gpp_profile_cmp (MM3gppProfile *a, |