3gpp-profile: Add profile name
QMI modems also report a profile name, and that value can be used to select and update a specific profile.
This commit is contained in:

committed by
Aleksander Morgado

parent
c3fe738e7d
commit
8ecf7fc83e
@@ -898,6 +898,9 @@ build_profile_human (GPtrArray *array,
|
|||||||
|
|
||||||
g_ptr_array_add (array, g_strdup_printf ("profile-id: %u", mm_3gpp_profile_get_profile_id (profile)));
|
g_ptr_array_add (array, g_strdup_printf ("profile-id: %u", mm_3gpp_profile_get_profile_id (profile)));
|
||||||
|
|
||||||
|
if ((aux = mm_3gpp_profile_get_profile_name (profile)) != NULL)
|
||||||
|
g_ptr_array_add (array, g_strdup_printf (" profile name: %s", aux));
|
||||||
|
|
||||||
if ((aux = mm_3gpp_profile_get_apn (profile)) != NULL)
|
if ((aux = mm_3gpp_profile_get_apn (profile)) != NULL)
|
||||||
g_ptr_array_add (array, g_strdup_printf (" apn: %s", aux));
|
g_ptr_array_add (array, g_strdup_printf (" apn: %s", aux));
|
||||||
|
|
||||||
@@ -945,6 +948,9 @@ build_profile_keyvalue (GPtrArray *array,
|
|||||||
str = g_string_new ("");
|
str = g_string_new ("");
|
||||||
g_string_append_printf (str, "profile-id: %u", mm_3gpp_profile_get_profile_id (profile));
|
g_string_append_printf (str, "profile-id: %u", mm_3gpp_profile_get_profile_id (profile));
|
||||||
|
|
||||||
|
if ((aux = mm_3gpp_profile_get_profile_name (profile)) != NULL)
|
||||||
|
g_string_append_printf (str, ", profile-name: %s", aux);
|
||||||
|
|
||||||
if ((aux = mm_3gpp_profile_get_apn (profile)) != NULL)
|
if ((aux = mm_3gpp_profile_get_apn (profile)) != NULL)
|
||||||
g_string_append_printf (str, ", apn: %s", aux);
|
g_string_append_printf (str, ", apn: %s", aux);
|
||||||
|
|
||||||
|
@@ -1588,6 +1588,8 @@ mm_3gpp_profile_get_ip_type
|
|||||||
mm_3gpp_profile_set_ip_type
|
mm_3gpp_profile_set_ip_type
|
||||||
mm_3gpp_profile_get_profile_id
|
mm_3gpp_profile_get_profile_id
|
||||||
mm_3gpp_profile_set_profile_id
|
mm_3gpp_profile_set_profile_id
|
||||||
|
mm_3gpp_profile_get_profile_name
|
||||||
|
mm_3gpp_profile_set_profile_name
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
mm_3gpp_profile_new_from_dictionary
|
mm_3gpp_profile_new_from_dictionary
|
||||||
mm_3gpp_profile_new_from_string
|
mm_3gpp_profile_new_from_string
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
G_DEFINE_TYPE (MM3gppProfile, mm_3gpp_profile, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (MM3gppProfile, mm_3gpp_profile, G_TYPE_OBJECT)
|
||||||
|
|
||||||
#define PROPERTY_ID "profile-id"
|
#define PROPERTY_ID "profile-id"
|
||||||
|
#define PROPERTY_NAME "profile-name"
|
||||||
#define PROPERTY_APN "apn"
|
#define PROPERTY_APN "apn"
|
||||||
#define PROPERTY_ALLOWED_AUTH "allowed-auth"
|
#define PROPERTY_ALLOWED_AUTH "allowed-auth"
|
||||||
#define PROPERTY_USER "user"
|
#define PROPERTY_USER "user"
|
||||||
@@ -40,6 +41,7 @@ G_DEFINE_TYPE (MM3gppProfile, mm_3gpp_profile, G_TYPE_OBJECT)
|
|||||||
|
|
||||||
struct _MM3gppProfilePrivate {
|
struct _MM3gppProfilePrivate {
|
||||||
gint profile_id;
|
gint profile_id;
|
||||||
|
gchar *profile_name;
|
||||||
gchar *apn;
|
gchar *apn;
|
||||||
MMBearerIpFamily ip_type;
|
MMBearerIpFamily ip_type;
|
||||||
MMBearerApnType apn_type;
|
MMBearerApnType apn_type;
|
||||||
@@ -95,6 +97,9 @@ mm_3gpp_profile_cmp (MM3gppProfile *a,
|
|||||||
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE) &&
|
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE) &&
|
||||||
(a->priv->apn_type != b->priv->apn_type))
|
(a->priv->apn_type != b->priv->apn_type))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_NAME) &&
|
||||||
|
(a->priv->profile_name != b->priv->profile_name))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -181,6 +186,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:
|
* mm_3gpp_profile_set_allowed_auth:
|
||||||
* @self: a #MM3gppProfile.
|
* @self: a #MM3gppProfile.
|
||||||
@@ -399,6 +444,12 @@ mm_3gpp_profile_get_dictionary (MM3gppProfile *self)
|
|||||||
PROPERTY_ID,
|
PROPERTY_ID,
|
||||||
g_variant_new_int32 (self->priv->profile_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)
|
if (self->priv->apn)
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
@@ -457,7 +508,9 @@ mm_3gpp_profile_consume_string (MM3gppProfile *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
mm_3gpp_profile_set_profile_id (self, profile_id);
|
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);
|
mm_3gpp_profile_set_apn (self, value);
|
||||||
else if (g_str_equal (key, PROPERTY_ALLOWED_AUTH)) {
|
else if (g_str_equal (key, PROPERTY_ALLOWED_AUTH)) {
|
||||||
GError *inner_error = NULL;
|
GError *inner_error = NULL;
|
||||||
@@ -561,6 +614,10 @@ mm_3gpp_profile_consume_variant (MM3gppProfile *self,
|
|||||||
mm_3gpp_profile_set_profile_id (
|
mm_3gpp_profile_set_profile_id (
|
||||||
self,
|
self,
|
||||||
g_variant_get_int32 (value));
|
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))
|
else if (g_str_equal (key, PROPERTY_APN))
|
||||||
mm_3gpp_profile_set_apn (
|
mm_3gpp_profile_set_apn (
|
||||||
self,
|
self,
|
||||||
@@ -677,6 +734,7 @@ finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
MM3gppProfile *self = MM_3GPP_PROFILE (object);
|
MM3gppProfile *self = MM_3GPP_PROFILE (object);
|
||||||
|
|
||||||
|
g_free (self->priv->profile_name);
|
||||||
g_free (self->priv->apn);
|
g_free (self->priv->apn);
|
||||||
g_free (self->priv->user);
|
g_free (self->priv->user);
|
||||||
g_free (self->priv->password);
|
g_free (self->priv->password);
|
||||||
|
@@ -69,6 +69,8 @@ MM3gppProfile *mm_3gpp_profile_new (void);
|
|||||||
|
|
||||||
void mm_3gpp_profile_set_profile_id (MM3gppProfile *self,
|
void mm_3gpp_profile_set_profile_id (MM3gppProfile *self,
|
||||||
gint profile_id);
|
gint profile_id);
|
||||||
|
void mm_3gpp_profile_set_profile_name (MM3gppProfile *self,
|
||||||
|
const gchar *profile_name);
|
||||||
void mm_3gpp_profile_set_apn (MM3gppProfile *self,
|
void mm_3gpp_profile_set_apn (MM3gppProfile *self,
|
||||||
const gchar *apn);
|
const gchar *apn);
|
||||||
void mm_3gpp_profile_set_allowed_auth (MM3gppProfile *self,
|
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);
|
MMBearerApnType apn_type);
|
||||||
|
|
||||||
gint mm_3gpp_profile_get_profile_id (MM3gppProfile *self);
|
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);
|
const gchar *mm_3gpp_profile_get_apn (MM3gppProfile *self);
|
||||||
MMBearerAllowedAuth mm_3gpp_profile_get_allowed_auth (MM3gppProfile *self);
|
MMBearerAllowedAuth mm_3gpp_profile_get_allowed_auth (MM3gppProfile *self);
|
||||||
const gchar *mm_3gpp_profile_get_user (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);
|
GError **error);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MM_3GPP_PROFILE_CMP_FLAGS_NONE = 0,
|
MM_3GPP_PROFILE_CMP_FLAGS_NONE = 0,
|
||||||
MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_ID = 1 << 1,
|
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_PROFILE_NAME = 1 << 2,
|
||||||
MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE = 1 << 3,
|
MM_3GPP_PROFILE_CMP_FLAGS_NO_AUTH = 1 << 3,
|
||||||
MM_3GPP_PROFILE_CMP_FLAGS_NO_IP_TYPE = 1 << 4,
|
MM_3GPP_PROFILE_CMP_FLAGS_NO_APN_TYPE = 1 << 4,
|
||||||
|
MM_3GPP_PROFILE_CMP_FLAGS_NO_IP_TYPE = 1 << 5,
|
||||||
} MM3gppProfileCmpFlags;
|
} MM3gppProfileCmpFlags;
|
||||||
|
|
||||||
gboolean mm_3gpp_profile_cmp (MM3gppProfile *a,
|
gboolean mm_3gpp_profile_cmp (MM3gppProfile *a,
|
||||||
|
Reference in New Issue
Block a user