libmm-glib: new 'profile-source' in 3GPP profile

Not applicable to bearer properties, as this is exclusively a proflie
management setting, unrelated to connection attempts.
This commit is contained in:
Aleksander Morgado
2021-11-26 21:18:53 +01:00
parent f6a91b2250
commit 50fc0101f5
5 changed files with 76 additions and 0 deletions

View File

@@ -1655,6 +1655,8 @@ mm_3gpp_profile_get_enabled
mm_3gpp_profile_set_enabled
mm_3gpp_profile_get_roaming_allowance
mm_3gpp_profile_set_roaming_allowance
mm_3gpp_profile_get_profile_source
mm_3gpp_profile_set_profile_source
<SUBSECTION Private>
mm_3gpp_profile_new_from_dictionary
mm_3gpp_profile_new_from_string

View File

@@ -48,6 +48,7 @@ G_DEFINE_TYPE (MM3gppProfile, mm_3gpp_profile, G_TYPE_OBJECT)
#define PROPERTY_ACCESS_TYPE_PREFERENCE "access-type-preference"
#define PROPERTY_ENABLED "profile-enabled"
#define PROPERTY_ROAMING_ALLOWANCE "roaming-allowance"
#define PROPERTY_SOURCE "profile-source"
struct _MM3gppProfilePrivate {
gint profile_id;
@@ -59,6 +60,7 @@ struct _MM3gppProfilePrivate {
gboolean enabled;
gboolean enabled_set;
MMBearerRoamingAllowance roaming_allowance;
MMBearerProfileSource profile_source;
/* Optional authentication settings */
MMBearerAllowedAuth allowed_auth;
@@ -123,6 +125,9 @@ mm_3gpp_profile_cmp (MM3gppProfile *a,
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_ROAMING_ALLOWANCE) &&
(a->priv->roaming_allowance != b->priv->roaming_allowance))
return FALSE;
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_SOURCE) &&
(a->priv->profile_source != b->priv->profile_source))
return FALSE;
return TRUE;
}
@@ -561,6 +566,44 @@ mm_3gpp_profile_get_roaming_allowance (MM3gppProfile *self)
/*****************************************************************************/
/**
* mm_3gpp_profile_set_profile_source:
* @self: a #MM3gppProfile.
* @profile_source: a #MMBearerProfileSource.
*
* Sets profile source.
*
* Since: 1.20
*/
void
mm_3gpp_profile_set_profile_source (MM3gppProfile *self,
MMBearerProfileSource profile_source)
{
g_return_if_fail (MM_IS_3GPP_PROFILE (self));
self->priv->profile_source = profile_source;
}
/**
* mm_3gpp_profile_get_profile_source:
* @self: a #MM3gppProfile.
*
* Gets the profile source.
*
* Returns: a #MMBearerProfileSource.
*
* Since: 1.20
*/
MMBearerProfileSource
mm_3gpp_profile_get_profile_source (MM3gppProfile *self)
{
g_return_val_if_fail (MM_IS_3GPP_PROFILE (self), MM_BEARER_PROFILE_SOURCE_UNKNOWN);
return self->priv->profile_source;
}
/*****************************************************************************/
/**
* mm_3gpp_profile_get_dictionary: (skip)
*/
@@ -717,6 +760,16 @@ mm_3gpp_profile_consume_string (MM3gppProfile *self,
return FALSE;
}
mm_3gpp_profile_set_enabled (self, profile_enabled);
} else if (g_str_equal (key, PROPERTY_SOURCE)) {
GError *inner_error = NULL;
MMBearerProfileSource profile_source;
profile_source = mm_common_get_profile_source_from_string (value, &inner_error);
if (inner_error) {
g_propagate_error (error, inner_error);
return FALSE;
}
mm_3gpp_profile_set_profile_source (self, profile_source);
} else {
g_set_error (error,
MM_CORE_ERROR,
@@ -821,6 +874,10 @@ mm_3gpp_profile_consume_variant (MM3gppProfile *self,
mm_3gpp_profile_set_enabled (
self,
g_variant_get_boolean (value));
else if (g_str_equal (key, PROPERTY_SOURCE))
mm_3gpp_profile_set_profile_source (
self,
g_variant_get_uint32 (value));
else {
/* Set error */
g_set_error (error,
@@ -909,6 +966,7 @@ mm_3gpp_profile_init (MM3gppProfile *self)
self->priv->access_type_preference = MM_BEARER_ACCESS_TYPE_PREFERENCE_NONE;
self->priv->enabled = TRUE;
self->priv->roaming_allowance = MM_BEARER_ROAMING_ALLOWANCE_NONE;
self->priv->profile_source = MM_BEARER_PROFILE_SOURCE_UNKNOWN;
}
static void

View File

@@ -96,6 +96,8 @@ void mm_3gpp_profile_set_enabled (MM3gppProfile *s
gboolean enabled);
void mm_3gpp_profile_set_roaming_allowance (MM3gppProfile *self,
MMBearerRoamingAllowance roaming_allowance);
void mm_3gpp_profile_set_profile_source (MM3gppProfile *self,
MMBearerProfileSource profile_source);
gint mm_3gpp_profile_get_profile_id (MM3gppProfile *self);
const gchar *mm_3gpp_profile_get_profile_name (MM3gppProfile *self);
@@ -108,6 +110,7 @@ MMBearerApnType mm_3gpp_profile_get_apn_type (MM3gpp
MMBearerAccessTypePreference mm_3gpp_profile_get_access_type_preference (MM3gppProfile *self);
gboolean mm_3gpp_profile_get_enabled (MM3gppProfile *self);
MMBearerRoamingAllowance mm_3gpp_profile_get_roaming_allowance (MM3gppProfile *self);
MMBearerProfileSource mm_3gpp_profile_get_profile_source (MM3gppProfile *self);
/*****************************************************************************/
/* ModemManager/libmm-glib/mmcli specific methods */
@@ -140,6 +143,7 @@ typedef enum {
MM_3GPP_PROFILE_CMP_FLAGS_NO_ACCESS_TYPE_PREFERENCE = 1 << 6,
MM_3GPP_PROFILE_CMP_FLAGS_NO_ENABLED = 1 << 7,
MM_3GPP_PROFILE_CMP_FLAGS_NO_ROAMING_ALLOWANCE = 1 << 8,
MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_SOURCE = 1 << 9,
} MM3gppProfileCmpFlags;
gboolean mm_3gpp_profile_cmp (MM3gppProfile *a,

View File

@@ -716,6 +716,16 @@ mm_common_get_access_type_preference_from_string (const gchar *str,
error);
}
MMBearerProfileSource
mm_common_get_profile_source_from_string (const gchar *str,
GError **error)
{
return _enum_from_string (MM_TYPE_BEARER_PROFILE_SOURCE,
str,
MM_BEARER_PROFILE_SOURCE_UNKNOWN,
error);
}
/******************************************************************************/
/* MMModemPortInfo array management */

View File

@@ -100,6 +100,8 @@ MMModem3gppDrxCycle mm_common_get_3gpp_drx_cycle_from_string
GError **error);
MMBearerAccessTypePreference mm_common_get_access_type_preference_from_string (const gchar *str,
GError **error);
MMBearerProfileSource mm_common_get_profile_source_from_string (const gchar *str,
GError **error);
/******************************************************************************/