aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lassalle <andrewlassalle@chromium.org>2021-10-14 11:57:26 -0700
committerAleksander Morgado <aleksander@aleksander.es>2021-10-17 17:56:44 +0200
commit8ecf7fc83e8ef0e1985b6a57da5bb25b26e43c72 (patch)
tree225485b57d5a0fb796ee57ac66fe72428473503f
parentc3fe738e7d69c97c701469095852bd068ce08b98 (diff)
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.
-rw-r--r--cli/mmcli-output.c6
-rw-r--r--docs/reference/libmm-glib/libmm-glib-sections.txt2
-rw-r--r--libmm-glib/mm-3gpp-profile.c60
-rw-r--r--libmm-glib/mm-3gpp-profile.h14
4 files changed, 76 insertions, 6 deletions
diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c
index 9be366e1..c012c1bd 100644
--- a/cli/mmcli-output.c
+++ b/cli/mmcli-output.c
@@ -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)));
+ 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)
g_ptr_array_add (array, g_strdup_printf (" apn: %s", aux));
@@ -945,6 +948,9 @@ build_profile_keyvalue (GPtrArray *array,
str = g_string_new ("");
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)
g_string_append_printf (str, ", apn: %s", aux);
diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt
index 81de02ad..2f96519c 100644
--- a/docs/reference/libmm-glib/libmm-glib-sections.txt
+++ b/docs/reference/libmm-glib/libmm-glib-sections.txt
@@ -1588,6 +1588,8 @@ mm_3gpp_profile_get_ip_type
mm_3gpp_profile_set_ip_type
mm_3gpp_profile_get_profile_id
mm_3gpp_profile_set_profile_id
+mm_3gpp_profile_get_profile_name
+mm_3gpp_profile_set_profile_name
<SUBSECTION Private>
mm_3gpp_profile_new_from_dictionary
mm_3gpp_profile_new_from_string
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,