libmm-glib: new 'access-type-preference' in 3GPP profile and bearer properties

This commit is contained in:
Aleksander Morgado
2021-12-24 14:03:13 +01:00
parent fc6bc84d22
commit e61fd7ca58
7 changed files with 215 additions and 86 deletions
@@ -1296,6 +1296,8 @@ mm_bearer_properties_get_rm_protocol
mm_bearer_properties_set_rm_protocol
mm_bearer_properties_get_multiplex
mm_bearer_properties_set_multiplex
mm_bearer_properties_get_access_type_preference
mm_bearer_properties_set_access_type_preference
<SUBSECTION Private>
mm_bearer_properties_new_from_dictionary
mm_bearer_properties_new_from_string
@@ -1645,6 +1647,8 @@ mm_3gpp_profile_get_profile_id
mm_3gpp_profile_set_profile_id
mm_3gpp_profile_get_profile_name
mm_3gpp_profile_set_profile_name
mm_3gpp_profile_get_access_type_preference
mm_3gpp_profile_set_access_type_preference
<SUBSECTION Private>
mm_3gpp_profile_new_from_dictionary
mm_3gpp_profile_new_from_string
+77 -13
View File
@@ -37,21 +37,23 @@
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"
#define PROPERTY_PASSWORD "password"
#define PROPERTY_IP_TYPE "ip-type"
#define PROPERTY_APN_TYPE "apn-type"
#define PROPERTY_ID "profile-id"
#define PROPERTY_NAME "profile-name"
#define PROPERTY_APN "apn"
#define PROPERTY_ALLOWED_AUTH "allowed-auth"
#define PROPERTY_USER "user"
#define PROPERTY_PASSWORD "password"
#define PROPERTY_IP_TYPE "ip-type"
#define PROPERTY_APN_TYPE "apn-type"
#define PROPERTY_ACCESS_TYPE_PREFERENCE "access-type-preference"
struct _MM3gppProfilePrivate {
gint profile_id;
gchar *profile_name;
gchar *apn;
MMBearerIpFamily ip_type;
MMBearerApnType apn_type;
gint profile_id;
gchar *profile_name;
gchar *apn;
MMBearerIpFamily ip_type;
MMBearerApnType apn_type;
MMBearerAccessTypePreference access_type_preference;
/* Optional authentication settings */
MMBearerAllowedAuth allowed_auth;
@@ -107,6 +109,9 @@ mm_3gpp_profile_cmp (MM3gppProfile *a,
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_PROFILE_NAME) &&
(a->priv->profile_name != b->priv->profile_name))
return FALSE;
if (!(flags & MM_3GPP_PROFILE_CMP_FLAGS_NO_ACCESS_TYPE_PREFERENCE) &&
(a->priv->access_type_preference != b->priv->access_type_preference))
return FALSE;
return TRUE;
}
@@ -430,6 +435,44 @@ mm_3gpp_profile_get_apn_type (MM3gppProfile *self)
/*****************************************************************************/
/**
* mm_3gpp_profile_set_access_type_preference:
* @self: a #MM3gppProfile.
* @access_type_preference: a #MMBearerAccessTypePreference.
*
* Sets the 5G network access type preference.
*
* Since: 1.20
*/
void
mm_3gpp_profile_set_access_type_preference (MM3gppProfile *self,
MMBearerAccessTypePreference access_type_preference)
{
g_return_if_fail (MM_IS_3GPP_PROFILE (self));
self->priv->access_type_preference = access_type_preference;
}
/**
* mm_3gpp_profile_get_access_type_preference:
* @self: a #MM3gppProfile.
*
* Gets 5G network access type preference.
*
* Returns: a #MMBearerAccessTypePreference.
*
* Since: 1.20
*/
MMBearerAccessTypePreference
mm_3gpp_profile_get_access_type_preference (MM3gppProfile *self)
{
g_return_val_if_fail (MM_IS_3GPP_PROFILE (self), MM_BEARER_ACCESS_TYPE_PREFERENCE_NONE);
return self->priv->access_type_preference;
}
/*****************************************************************************/
/**
* mm_3gpp_profile_get_dictionary: (skip)
*/
@@ -493,6 +536,12 @@ mm_3gpp_profile_get_dictionary (MM3gppProfile *self)
PROPERTY_APN_TYPE,
g_variant_new_uint32 (self->priv->apn_type));
if (self->priv->access_type_preference != MM_BEARER_ACCESS_TYPE_PREFERENCE_NONE)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_ACCESS_TYPE_PREFERENCE,
g_variant_new_uint32 (self->priv->access_type_preference));
return g_variant_ref_sink (g_variant_builder_end (&builder));
}
@@ -553,6 +602,16 @@ mm_3gpp_profile_consume_string (MM3gppProfile *self,
return FALSE;
}
mm_3gpp_profile_set_apn_type (self, apn_type);
} else if (g_str_equal (key, PROPERTY_ACCESS_TYPE_PREFERENCE)) {
GError *inner_error = NULL;
MMBearerAccessTypePreference access_type_preference;
access_type_preference = mm_common_get_access_type_preference_from_string (value, &inner_error);
if (inner_error) {
g_propagate_error (error, inner_error);
return FALSE;
}
mm_3gpp_profile_set_access_type_preference (self, access_type_preference);
} else {
g_set_error (error,
MM_CORE_ERROR,
@@ -649,6 +708,10 @@ mm_3gpp_profile_consume_variant (MM3gppProfile *self,
mm_3gpp_profile_set_apn_type (
self,
g_variant_get_uint32 (value));
else if (g_str_equal (key, PROPERTY_ACCESS_TYPE_PREFERENCE))
mm_3gpp_profile_set_access_type_preference (
self,
g_variant_get_uint32 (value));
else {
/* Set error */
g_set_error (error,
@@ -734,6 +797,7 @@ mm_3gpp_profile_init (MM3gppProfile *self)
self->priv->allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN;
self->priv->ip_type = MM_BEARER_IP_FAMILY_NONE;
self->priv->apn_type = MM_BEARER_APN_TYPE_NONE;
self->priv->access_type_preference = MM_BEARER_ACCESS_TYPE_PREFERENCE_NONE;
}
static void
+34 -30
View File
@@ -74,31 +74,34 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MM3gppProfile, g_object_unref)
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,
MMBearerAllowedAuth allowed_auth);
void mm_3gpp_profile_set_user (MM3gppProfile *self,
const gchar *user);
void mm_3gpp_profile_set_password (MM3gppProfile *self,
const gchar *password);
void mm_3gpp_profile_set_ip_type (MM3gppProfile *self,
MMBearerIpFamily ip_type);
void mm_3gpp_profile_set_apn_type (MM3gppProfile *self,
MMBearerApnType apn_type);
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,
MMBearerAllowedAuth allowed_auth);
void mm_3gpp_profile_set_user (MM3gppProfile *self,
const gchar *user);
void mm_3gpp_profile_set_password (MM3gppProfile *self,
const gchar *password);
void mm_3gpp_profile_set_ip_type (MM3gppProfile *self,
MMBearerIpFamily ip_type);
void mm_3gpp_profile_set_apn_type (MM3gppProfile *self,
MMBearerApnType apn_type);
void mm_3gpp_profile_set_access_type_preference (MM3gppProfile *self,
MMBearerAccessTypePreference access_type_preference);
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);
const gchar *mm_3gpp_profile_get_password (MM3gppProfile *self);
MMBearerIpFamily mm_3gpp_profile_get_ip_type (MM3gppProfile *self);
MMBearerApnType mm_3gpp_profile_get_apn_type (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);
MMBearerAllowedAuth mm_3gpp_profile_get_allowed_auth (MM3gppProfile *self);
const gchar *mm_3gpp_profile_get_user (MM3gppProfile *self);
const gchar *mm_3gpp_profile_get_password (MM3gppProfile *self);
MMBearerIpFamily mm_3gpp_profile_get_ip_type (MM3gppProfile *self);
MMBearerApnType mm_3gpp_profile_get_apn_type (MM3gppProfile *self);
MMBearerAccessTypePreference mm_3gpp_profile_get_access_type_preference (MM3gppProfile *self);
/*****************************************************************************/
/* ModemManager/libmm-glib/mmcli specific methods */
@@ -122,12 +125,13 @@ 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_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,
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,
MM_3GPP_PROFILE_CMP_FLAGS_NO_ACCESS_TYPE_PREFERENCE = 1 << 6,
} MM3gppProfileCmpFlags;
gboolean mm_3gpp_profile_cmp (MM3gppProfile *a,
+42 -1
View File
@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org>
* Copyright (C) 2011-2021 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <string.h>
@@ -372,6 +372,44 @@ mm_bearer_properties_get_profile_id (MMBearerProperties *self)
/*****************************************************************************/
/**
* mm_bearer_properties_set_access_type_preference:
* @self: a #MMBearerProperties.
* @access_type_preference: a #MMBearerAccessTypePreference value.
*
* Sets the 5G network access type preference.
*
* Since: 1.20
*/
void
mm_bearer_properties_set_access_type_preference (MMBearerProperties *self,
MMBearerAccessTypePreference access_type_preference)
{
g_return_if_fail (MM_IS_BEARER_PROPERTIES (self));
mm_3gpp_profile_set_access_type_preference (self->priv->profile, access_type_preference);
}
/**
* mm_bearer_properties_get_access_type_preference:
* @self: a #MMBearerProperties.
*
* Gets the 5G network access type preference.
*
* Returns: a #MMBearerAccessTypePreference value.
*
* Since: 1.20
*/
MMBearerAccessTypePreference
mm_bearer_properties_get_access_type_preference (MMBearerProperties *self)
{
g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_BEARER_ACCESS_TYPE_PREFERENCE_NONE);
return mm_3gpp_profile_get_access_type_preference (self->priv->profile);
}
/*****************************************************************************/
/**
* mm_bearer_properties_set_allow_roaming:
* @self: a #MMBearerProperties.
@@ -832,6 +870,9 @@ mm_bearer_properties_cmp (MMBearerProperties *a,
if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PROFILE_NAME) &&
!cmp_str (mm_3gpp_profile_get_profile_name (a->priv->profile), mm_3gpp_profile_get_profile_name (b->priv->profile), flags))
return FALSE;
if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_ACCESS_TYPE_PREFERENCE) &&
(mm_3gpp_profile_get_access_type_preference (a->priv->profile) != mm_3gpp_profile_get_access_type_preference (b->priv->profile)))
return FALSE;
if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_ALLOW_ROAMING)) {
if (a->priv->allow_roaming != b->priv->allow_roaming)
return FALSE;
+46 -42
View File
@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.o
*
* Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org>
* Copyright (C) 2011-2021 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_BEARER_PROPERTIES_H
@@ -66,40 +66,43 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBearerProperties, g_object_unref)
MMBearerProperties *mm_bearer_properties_new (void);
void mm_bearer_properties_set_apn (MMBearerProperties *self,
const gchar *apn);
void mm_bearer_properties_set_allowed_auth (MMBearerProperties *self,
MMBearerAllowedAuth allowed_auth);
void mm_bearer_properties_set_user (MMBearerProperties *self,
const gchar *user);
void mm_bearer_properties_set_password (MMBearerProperties *self,
const gchar *password);
void mm_bearer_properties_set_ip_type (MMBearerProperties *self,
MMBearerIpFamily ip_type);
void mm_bearer_properties_set_apn_type (MMBearerProperties *self,
MMBearerApnType apn_type);
void mm_bearer_properties_set_profile_id (MMBearerProperties *self,
gint profile_id);
void mm_bearer_properties_set_profile_name (MMBearerProperties *self,
const gchar *profile_name);
void mm_bearer_properties_set_allow_roaming (MMBearerProperties *self,
gboolean allow_roaming);
void mm_bearer_properties_set_rm_protocol (MMBearerProperties *self,
MMModemCdmaRmProtocol protocol);
void mm_bearer_properties_set_multiplex (MMBearerProperties *self,
MMBearerMultiplexSupport multiplex);
void mm_bearer_properties_set_apn (MMBearerProperties *self,
const gchar *apn);
void mm_bearer_properties_set_allowed_auth (MMBearerProperties *self,
MMBearerAllowedAuth allowed_auth);
void mm_bearer_properties_set_user (MMBearerProperties *self,
const gchar *user);
void mm_bearer_properties_set_password (MMBearerProperties *self,
const gchar *password);
void mm_bearer_properties_set_ip_type (MMBearerProperties *self,
MMBearerIpFamily ip_type);
void mm_bearer_properties_set_apn_type (MMBearerProperties *self,
MMBearerApnType apn_type);
void mm_bearer_properties_set_profile_id (MMBearerProperties *self,
gint profile_id);
void mm_bearer_properties_set_profile_name (MMBearerProperties *self,
const gchar *profile_name);
void mm_bearer_properties_set_allow_roaming (MMBearerProperties *self,
gboolean allow_roaming);
void mm_bearer_properties_set_rm_protocol (MMBearerProperties *self,
MMModemCdmaRmProtocol protocol);
void mm_bearer_properties_set_multiplex (MMBearerProperties *self,
MMBearerMultiplexSupport multiplex);
void mm_bearer_properties_set_access_type_preference (MMBearerProperties *self,
MMBearerAccessTypePreference access_type_preference);
const gchar *mm_bearer_properties_get_apn (MMBearerProperties *self);
MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_user (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_password (MMBearerProperties *self);
MMBearerIpFamily mm_bearer_properties_get_ip_type (MMBearerProperties *self);
MMBearerApnType mm_bearer_properties_get_apn_type (MMBearerProperties *self);
gint mm_bearer_properties_get_profile_id (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_profile_name (MMBearerProperties *self);
gboolean mm_bearer_properties_get_allow_roaming (MMBearerProperties *self);
MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MMBearerProperties *self);
MMBearerMultiplexSupport mm_bearer_properties_get_multiplex (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_apn (MMBearerProperties *self);
MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_user (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_password (MMBearerProperties *self);
MMBearerIpFamily mm_bearer_properties_get_ip_type (MMBearerProperties *self);
MMBearerApnType mm_bearer_properties_get_apn_type (MMBearerProperties *self);
gint mm_bearer_properties_get_profile_id (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_profile_name (MMBearerProperties *self);
gboolean mm_bearer_properties_get_allow_roaming (MMBearerProperties *self);
MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MMBearerProperties *self);
MMBearerMultiplexSupport mm_bearer_properties_get_multiplex (MMBearerProperties *self);
MMBearerAccessTypePreference mm_bearer_properties_get_access_type_preference (MMBearerProperties *self);
/*****************************************************************************/
/* ModemManager/libmm-glib/mmcli specific methods */
@@ -129,14 +132,15 @@ GVariant *mm_bearer_properties_get_dictionary (MMBearerProperties *self)
MM3gppProfile *mm_bearer_properties_peek_3gpp_profile (MMBearerProperties *self);
typedef enum {
MM_BEARER_PROPERTIES_CMP_FLAGS_NONE = 0,
MM_BEARER_PROPERTIES_CMP_FLAGS_LOOSE = 1 << 0,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PASSWORD = 1 << 1,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_ALLOW_ROAMING = 1 << 2,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_RM_PROTOCOL = 1 << 3,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_APN_TYPE = 1 << 4,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PROFILE_ID = 1 << 5,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PROFILE_NAME = 1 << 6,
MM_BEARER_PROPERTIES_CMP_FLAGS_NONE = 0,
MM_BEARER_PROPERTIES_CMP_FLAGS_LOOSE = 1 << 0,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PASSWORD = 1 << 1,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_ALLOW_ROAMING = 1 << 2,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_RM_PROTOCOL = 1 << 3,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_APN_TYPE = 1 << 4,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PROFILE_ID = 1 << 5,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PROFILE_NAME = 1 << 6,
MM_BEARER_PROPERTIES_CMP_FLAGS_NO_ACCESS_TYPE_PREFERENCE = 1 << 7,
} MMBearerPropertiesCmpFlags;
gboolean mm_bearer_properties_cmp (MMBearerProperties *a,
+10
View File
@@ -706,6 +706,16 @@ mm_common_get_3gpp_drx_cycle_from_string (const gchar *str,
error);
}
MMBearerAccessTypePreference
mm_common_get_access_type_preference_from_string (const gchar *str,
GError **error)
{
return _enum_from_string (MM_TYPE_BEARER_ACCESS_TYPE_PREFERENCE,
str,
MM_BEARER_ACCESS_TYPE_PREFERENCE_NONE,
error);
}
/******************************************************************************/
/* MMModemPortInfo array management */
+2
View File
@@ -98,6 +98,8 @@ MMModem3gppMicoMode mm_common_get_3gpp_mico_mode_from_string
GError **error);
MMModem3gppDrxCycle mm_common_get_3gpp_drx_cycle_from_string (const gchar *str,
GError **error);
MMBearerAccessTypePreference mm_common_get_access_type_preference_from_string (const gchar *str,
GError **error);
/******************************************************************************/