aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libmm-glib')
-rw-r--r--libmm-glib/mm-bearer-properties.c84
-rw-r--r--libmm-glib/mm-bearer-properties.h4
-rw-r--r--libmm-glib/mm-common-helpers.c10
-rw-r--r--libmm-glib/mm-common-helpers.h3
-rw-r--r--libmm-glib/mm-simple-connect-properties.c38
-rw-r--r--libmm-glib/mm-simple-connect-properties.h3
6 files changed, 141 insertions, 1 deletions
diff --git a/libmm-glib/mm-bearer-properties.c b/libmm-glib/mm-bearer-properties.c
index 37c65a00..40489624 100644
--- a/libmm-glib/mm-bearer-properties.c
+++ b/libmm-glib/mm-bearer-properties.c
@@ -38,6 +38,7 @@ G_DEFINE_TYPE (MMBearerProperties, mm_bearer_properties, G_TYPE_OBJECT);
#define PROPERTY_USER "user"
#define PROPERTY_PASSWORD "password"
#define PROPERTY_IP_TYPE "ip-type"
+#define PROPERTY_APN_TYPE "apn-type"
#define PROPERTY_ALLOW_ROAMING "allow-roaming"
#define PROPERTY_RM_PROTOCOL "rm-protocol"
#define PROPERTY_MULTIPLEX "multiplex"
@@ -50,6 +51,8 @@ struct _MMBearerPropertiesPrivate {
gchar *apn;
/* IP type */
MMBearerIpFamily ip_type;
+ /* APN type */
+ MMBearerApnType apn_type;
/* Allowed auth */
MMBearerAllowedAuth allowed_auth;
/* User */
@@ -267,6 +270,44 @@ mm_bearer_properties_get_ip_type (MMBearerProperties *self)
/*****************************************************************************/
/**
+ * mm_bearer_properties_set_apn_type:
+ * @self: a #MMBearerProperties.
+ * @apn_type: a mask of #MMBearerApnType values.
+ *
+ * Sets the APN types to use.
+ *
+ * Since: 1.18
+ */
+void
+mm_bearer_properties_set_apn_type (MMBearerProperties *self,
+ MMBearerApnType apn_type)
+{
+ g_return_if_fail (MM_IS_BEARER_PROPERTIES (self));
+
+ self->priv->apn_type = apn_type;
+}
+
+/**
+ * mm_bearer_properties_get_apn_type:
+ * @self: a #MMBearerProperties.
+ *
+ * Gets the APN types to use.
+ *
+ * Returns: a mask of #MMBearerApnType values.
+ *
+ * Since: 1.18
+ */
+MMBearerApnType
+mm_bearer_properties_get_apn_type (MMBearerProperties *self)
+{
+ g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_BEARER_APN_TYPE_NONE);
+
+ return self->priv->apn_type;
+}
+
+/*****************************************************************************/
+
+/**
* mm_bearer_properties_set_allow_roaming:
* @self: a #MMBearerProperties.
* @allow_roaming: boolean value.
@@ -476,6 +517,12 @@ mm_bearer_properties_get_dictionary (MMBearerProperties *self)
PROPERTY_IP_TYPE,
g_variant_new_uint32 (self->priv->ip_type));
+ if (self->priv->apn_type != MM_BEARER_APN_TYPE_NONE)
+ g_variant_builder_add (&builder,
+ "{sv}",
+ PROPERTY_APN_TYPE,
+ g_variant_new_uint32 (self->priv->apn_type));
+
if (self->priv->allow_roaming_set)
g_variant_builder_add (&builder,
"{sv}",
@@ -536,6 +583,16 @@ mm_bearer_properties_consume_string (MMBearerProperties *self,
return FALSE;
}
mm_bearer_properties_set_ip_type (self, ip_type);
+ } else if (g_str_equal (key, PROPERTY_APN_TYPE)) {
+ GError *inner_error = NULL;
+ MMBearerApnType apn_type;
+
+ apn_type = mm_common_get_apn_type_from_string (value, &inner_error);
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
+ return FALSE;
+ }
+ mm_bearer_properties_set_apn_type (self, apn_type);
} else if (g_str_equal (key, PROPERTY_ALLOW_ROAMING)) {
GError *inner_error = NULL;
gboolean allow_roaming;
@@ -655,6 +712,10 @@ mm_bearer_properties_consume_variant (MMBearerProperties *properties,
mm_bearer_properties_set_ip_type (
properties,
g_variant_get_uint32 (value));
+ else if (g_str_equal (key, PROPERTY_APN_TYPE))
+ mm_bearer_properties_set_apn_type (
+ properties,
+ g_variant_get_uint32 (value));
else if (g_str_equal (key, PROPERTY_ALLOW_ROAMING))
mm_bearer_properties_set_allow_roaming (
properties,
@@ -763,6 +824,23 @@ cmp_ip_type (MMBearerIpFamily a,
}
static gboolean
+cmp_apn_type (MMBearerApnType a,
+ MMBearerApnType b,
+ MMBearerPropertiesCmpFlags flags)
+{
+ /* Strict match */
+ if (a == b)
+ return TRUE;
+ /* Additional loose match NONE == DEFAULT */
+ if (flags & MM_BEARER_PROPERTIES_CMP_FLAGS_LOOSE) {
+ if ((a == MM_BEARER_APN_TYPE_NONE && b == MM_BEARER_APN_TYPE_DEFAULT) ||
+ (b == MM_BEARER_APN_TYPE_NONE && a == MM_BEARER_APN_TYPE_DEFAULT))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
cmp_allowed_auth (MMBearerAllowedAuth a,
MMBearerAllowedAuth b,
MMBearerPropertiesCmpFlags flags)
@@ -813,8 +891,11 @@ mm_bearer_properties_cmp (MMBearerProperties *a,
if (!cmp_allowed_auth (a->priv->allowed_auth, b->priv->allowed_auth, flags))
return FALSE;
if (!cmp_str (a->priv->user, b->priv->user, flags))
+ if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_APN_TYPE) &&
+ !cmp_apn_type (a->priv->apn_type, b->priv->apn_type, flags))
return FALSE;
- if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PASSWORD) && !cmp_str (a->priv->password, b->priv->password, flags))
+ if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_PASSWORD) &&
+ !cmp_str (a->priv->password, b->priv->password, flags))
return FALSE;
if (!(flags & MM_BEARER_PROPERTIES_CMP_FLAGS_NO_ALLOW_ROAMING)) {
if (a->priv->allow_roaming != b->priv->allow_roaming)
@@ -861,6 +942,7 @@ mm_bearer_properties_init (MMBearerProperties *self)
self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN;
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->multiplex = MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN;
}
diff --git a/libmm-glib/mm-bearer-properties.h b/libmm-glib/mm-bearer-properties.h
index 062d01c5..f0307db3 100644
--- a/libmm-glib/mm-bearer-properties.h
+++ b/libmm-glib/mm-bearer-properties.h
@@ -68,6 +68,8 @@ 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_allow_roaming (MMBearerProperties *self,
gboolean allow_roaming);
void mm_bearer_properties_set_rm_protocol (MMBearerProperties *self,
@@ -80,6 +82,7 @@ MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProper
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);
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);
@@ -122,6 +125,7 @@ typedef enum {
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,
} MMBearerPropertiesCmpFlags;
gboolean mm_bearer_properties_cmp (MMBearerProperties *a,
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c
index a505421c..8bfaa567 100644
--- a/libmm-glib/mm-common-helpers.c
+++ b/libmm-glib/mm-common-helpers.c
@@ -867,6 +867,16 @@ mm_common_get_multiplex_support_from_string (const gchar *str,
error);
}
+MMBearerApnType
+mm_common_get_apn_type_from_string (const gchar *str,
+ GError **error)
+{
+ return _flags_from_string (MM_TYPE_BEARER_APN_TYPE,
+ str,
+ MM_BEARER_APN_TYPE_NONE,
+ error);
+}
+
GArray *
mm_common_oma_pending_network_initiated_sessions_variant_to_garray (GVariant *variant)
{
diff --git a/libmm-glib/mm-common-helpers.h b/libmm-glib/mm-common-helpers.h
index b8a75dfb..86843b67 100644
--- a/libmm-glib/mm-common-helpers.h
+++ b/libmm-glib/mm-common-helpers.h
@@ -85,6 +85,9 @@ MMModemAccessTechnology mm_common_get_access_technology_from_string (const gchar
MMBearerMultiplexSupport mm_common_get_multiplex_support_from_string (const gchar *str,
GError **error);
+MMBearerApnType mm_common_get_apn_type_from_string (const gchar *str,
+ GError **error);
+
GArray *mm_common_ports_variant_to_garray (GVariant *variant);
MMModemPortInfo *mm_common_ports_variant_to_array (GVariant *variant,
guint *n_ports);
diff --git a/libmm-glib/mm-simple-connect-properties.c b/libmm-glib/mm-simple-connect-properties.c
index 93006fc4..d1a83592 100644
--- a/libmm-glib/mm-simple-connect-properties.c
+++ b/libmm-glib/mm-simple-connect-properties.c
@@ -327,6 +327,44 @@ mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self)
/*****************************************************************************/
/**
+ * mm_simple_connect_properties_set_apn_type:
+ * @self: a #MMSimpleConnectProperties.
+ * @apn_type: a mask of #MMBearerApnType values.
+ *
+ * Sets the APN types to use.
+ *
+ * Since: 1.18
+ */
+void
+mm_simple_connect_properties_set_apn_type (MMSimpleConnectProperties *self,
+ MMBearerApnType apn_type)
+{
+ g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
+
+ mm_bearer_properties_set_apn_type (self->priv->bearer_properties, apn_type);
+}
+
+/**
+ * mm_simple_connect_properties_get_apn_type:
+ * @self: a #MMSimpleConnectProperties.
+ *
+ * Gets the APN types to use.
+ *
+ * Returns: a mask of #MMBearerApnType values.
+ *
+ * Since: 1.18
+ */
+MMBearerApnType
+mm_simple_connect_properties_get_apn_type (MMSimpleConnectProperties *self)
+{
+ g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), MM_BEARER_APN_TYPE_NONE);
+
+ return mm_bearer_properties_get_apn_type (self->priv->bearer_properties);
+}
+
+/*****************************************************************************/
+
+/**
* mm_simple_connect_properties_set_allow_roaming:
* @self: a #MMSimpleConnectProperties.
* @allow_roaming: boolean value.
diff --git a/libmm-glib/mm-simple-connect-properties.h b/libmm-glib/mm-simple-connect-properties.h
index 207ebaae..77ab93ba 100644
--- a/libmm-glib/mm-simple-connect-properties.h
+++ b/libmm-glib/mm-simple-connect-properties.h
@@ -74,6 +74,8 @@ void mm_simple_connect_properties_set_password (MMSimpleConnectProperties *
const gchar *password);
void mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *self,
MMBearerIpFamily ip_type);
+void mm_simple_connect_properties_set_apn_type (MMSimpleConnectProperties *self,
+ MMBearerApnType apn_type);
void mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *self,
gboolean allow_roaming);
void mm_simple_connect_properties_set_rm_protocol (MMSimpleConnectProperties *self,
@@ -88,6 +90,7 @@ MMBearerAllowedAuth mm_simple_connect_properties_get_allowed_auth (MMSimp
const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self);
MMBearerIpFamily mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self);
+MMBearerApnType mm_simple_connect_properties_get_apn_type (MMSimpleConnectProperties *self);
gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *self);
MMModemCdmaRmProtocol mm_simple_connect_properties_get_rm_protocol (MMSimpleConnectProperties *self);
MMBearerMultiplexSupport mm_simple_connect_properties_get_multiplex (MMSimpleConnectProperties *self);