aboutsummaryrefslogtreecommitdiff
path: root/libmm-common/mm-common-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-22 09:35:15 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-22 09:38:21 +0200
commit1ac18a06bb37d8745480a9af4fd6bc2f762bf265 (patch)
tree2074fb1f3cb16e483779dcd4f19db3d6c1c936c1 /libmm-common/mm-common-helpers.c
parentc15525a1b3c2006e614f75a372f374176f576c23 (diff)
api,dbus: 'ip-type' property now given as a MMBearerIpFamily (u)
Instead of using a predefined set of string values for 'ip-type' in Modem.CreateBearer() and Simple.Connect(), we'll use an enumeration. The implementation will then need to convert the requested IP family type to e.g. the correct PDP type in 3GPP modems. This change also consolidates the use of enums in dictionary properties when possible to do so, as with the Rm Protocol.
Diffstat (limited to 'libmm-common/mm-common-helpers.c')
-rw-r--r--libmm-common/mm-common-helpers.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libmm-common/mm-common-helpers.c b/libmm-common/mm-common-helpers.c
index ca96d752..488c771e 100644
--- a/libmm-common/mm-common-helpers.c
+++ b/libmm-common/mm-common-helpers.c
@@ -334,6 +334,28 @@ mm_common_get_rm_protocol_from_string (const gchar *str,
return MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN;
}
+MMBearerIpFamily
+mm_common_get_ip_type_from_string (const gchar *str,
+ GError **error)
+{
+ GEnumClass *enum_class;
+ guint i;
+
+ enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_BEARER_IP_FAMILY));
+
+ for (i = 0; enum_class->values[i].value_nick; i++) {
+ if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick))
+ return enum_class->values[i].value;
+ }
+
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_INVALID_ARGS,
+ "Couldn't match '%s' with a valid MMBearerIpFamily value",
+ str);
+ return MM_BEARER_IP_FAMILY_UNKNOWN;
+}
+
GVariant *
mm_common_build_bands_unknown (void)
{