api,core: new 'allow-roaming' property to be set when creating a bearer
This new boolean property, applicable to 3GPP bearers, will specify whether 3GPP bearers are allowed to get connected when registered in a roaming network.
This commit is contained in:
@@ -233,7 +233,7 @@
|
||||
|
||||
List of properties used when creating the bearer.
|
||||
-->
|
||||
<property name="Properties" type="a{ss}" access="read" />
|
||||
<property name="Properties" type="a{sv}" access="read" />
|
||||
|
||||
</interface>
|
||||
</node>
|
||||
|
||||
@@ -60,15 +60,17 @@
|
||||
Allowed properties are:
|
||||
<variablelist>
|
||||
<varlistentry><term><literal>"apn"</literal></term>
|
||||
<listitem><para>Access Point Name. Required in 3GPP.</para></listitem></varlistentry>
|
||||
<listitem><para>Access Point Name, given as a string value (signature <literal>"s"</literal>). Required in 3GPP.</para></listitem></varlistentry>
|
||||
<varlistentry><term><literal>"ip-type"</literal></term>
|
||||
<listitem><para>Addressing type, one of <literal>"IPV4"</literal>, <literal>"IPV4V6"</literal>, or <literal>"IPV6"</literal>. Optional in 3GPP and CDMA.</para></listitem></varlistentry>
|
||||
<listitem><para>Addressing type, given as a string value (signature <literal>"s"</literal>). One of <literal>"IPV4"</literal>, <literal>"IPV4V6"</literal>, or <literal>"IPV6"</literal>. Optional in 3GPP and CDMA.</para></listitem></varlistentry>
|
||||
<varlistentry><term><literal>"user"</literal></term>
|
||||
<listitem><para>User name (if any) required by the network. Optional in 3GPP.</para></listitem></varlistentry>
|
||||
<listitem><para>User name (if any) required by the network, given as a string value (signature <literal>"s"</literal>). Optional in 3GPP.</para></listitem></varlistentry>
|
||||
<varlistentry><term><literal>"password"</literal></term>
|
||||
<listitem><para>Password (if any) required by the network. Optional in 3GPP.</para></listitem></varlistentry>
|
||||
<listitem><para>Password (if any) required by the network, given as a string value (signature <literal>"s"</literal>). Optional in 3GPP.</para></listitem></varlistentry>
|
||||
<varlistentry><term><literal>"allow-roaming"</literal></term>
|
||||
<listitem><para>Flag to tell whether connection is allowed during roaming, given as a boolean value (signature <literal>"b"</literal>). Optional in 3GPP.</para></listitem></varlistentry>
|
||||
<varlistentry><term><literal>"number"</literal></term>
|
||||
<listitem><para>Telephone number to dial. Required in POTS.</para></listitem></varlistentry>
|
||||
<listitem><para>Telephone number to dial, given as a string value (signature <literal>"s"</literal>). Required in POTS.</para></listitem></varlistentry>
|
||||
</variablelist>
|
||||
|
||||
Some properties are only applicable to a bearer of certain access
|
||||
@@ -76,7 +78,7 @@
|
||||
applicable to CDMA2000 Packet Data Session bearers.
|
||||
-->
|
||||
<method name="CreateBearer">
|
||||
<arg name="properties" type="a{ss}" direction="in" />
|
||||
<arg name="properties" type="a{sv}" direction="in" />
|
||||
<arg name="path" type="o" direction="out" />
|
||||
</method>
|
||||
|
||||
|
||||
+46
-13
@@ -37,6 +37,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_APN,
|
||||
PROP_IP_TYPE,
|
||||
PROP_ALLOW_ROAMING,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@@ -47,6 +48,8 @@ struct _MMBearer3gppPrivate {
|
||||
gchar *apn;
|
||||
/* IP type of the PDP context */
|
||||
gchar *ip_type;
|
||||
/* Flag to allow/forbid connections while roaming */
|
||||
gboolean allow_roaming;
|
||||
|
||||
/* Data port used when modem is connected */
|
||||
MMPort *port;
|
||||
@@ -769,24 +772,35 @@ mm_bearer_3gpp_new_from_properties (MMBaseModem *modem,
|
||||
{
|
||||
GVariantIter iter;
|
||||
const gchar *key;
|
||||
const gchar *value;
|
||||
GVariant *value;
|
||||
gchar *apn = NULL;
|
||||
gchar *ip_type = NULL;
|
||||
gboolean allow_roaming = FALSE;
|
||||
gboolean allow_roaming_found = FALSE;
|
||||
|
||||
mm_dbg ("Creating 3GPP bearer with properties...");
|
||||
g_variant_iter_init (&iter, properties);
|
||||
while (g_variant_iter_loop (&iter, "{ss}", &key, &value)) {
|
||||
mm_dbg (" Property '%s', value '%s'", key, value);
|
||||
while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
|
||||
if (g_str_equal (key, "apn")) {
|
||||
if (apn)
|
||||
mm_warn ("Duplicate 'apn' property found, ignoring value '%s'", value);
|
||||
mm_warn ("Duplicate 'apn' property found, ignoring value '%s'",
|
||||
g_variant_get_string (value, NULL));
|
||||
else
|
||||
apn = g_strdup (value);
|
||||
apn = g_variant_dup_string (value, NULL);
|
||||
} else if (g_str_equal (key, "ip-type")) {
|
||||
if (ip_type)
|
||||
mm_warn ("Duplicate 'ip-type' property found, ignoring value '%s'", value);
|
||||
mm_warn ("Duplicate 'ip-type' property found, ignoring value '%s'",
|
||||
g_variant_get_string (value, NULL));
|
||||
else
|
||||
ip_type = g_strdup (value);
|
||||
ip_type = g_variant_dup_string (value, NULL);
|
||||
} else if (g_str_equal (key, "allow-roaming")) {
|
||||
if (allow_roaming_found)
|
||||
mm_warn ("Duplicate 'allow-roaming' property found, ignoring value '%s'",
|
||||
g_variant_get_string (value, NULL));
|
||||
else {
|
||||
allow_roaming_found = TRUE;
|
||||
allow_roaming = g_variant_get_boolean (value);
|
||||
}
|
||||
}
|
||||
else
|
||||
mm_dbg ("Ignoring property '%s' in 3GPP bearer", key);
|
||||
@@ -804,13 +818,15 @@ mm_bearer_3gpp_new_from_properties (MMBaseModem *modem,
|
||||
|
||||
return mm_bearer_3gpp_new (modem,
|
||||
apn,
|
||||
ip_type);
|
||||
ip_type,
|
||||
allow_roaming);
|
||||
}
|
||||
|
||||
MMBearer *
|
||||
mm_bearer_3gpp_new (MMBaseModem *modem,
|
||||
const gchar *apn,
|
||||
const gchar *ip_type)
|
||||
const gchar *ip_type,
|
||||
gboolean allow_roaming)
|
||||
{
|
||||
static guint id = 0;
|
||||
MMBearer3gpp *bearer;
|
||||
@@ -818,14 +834,16 @@ mm_bearer_3gpp_new (MMBaseModem *modem,
|
||||
|
||||
/* Create the object */
|
||||
bearer = g_object_new (MM_TYPE_BEARER_3GPP,
|
||||
MM_BEARER_3GPP_APN, apn,
|
||||
MM_BEARER_3GPP_IP_TYPE, ip_type,
|
||||
MM_BEARER_3GPP_APN, apn,
|
||||
MM_BEARER_3GPP_IP_TYPE, ip_type,
|
||||
MM_BEARER_3GPP_ALLOW_ROAMING, allow_roaming,
|
||||
NULL);
|
||||
|
||||
/* Build dict with all properties */
|
||||
mm_bearer_expose_properties (MM_BEARER (bearer),
|
||||
"apn", apn,
|
||||
"ip-type", ip_type,
|
||||
"apn", apn,
|
||||
"ip-type", ip_type,
|
||||
"allow-roaming", allow_roaming,
|
||||
NULL);
|
||||
|
||||
/* Set modem and path ONLY after having checked input properties, so that
|
||||
@@ -857,6 +875,9 @@ set_property (GObject *object,
|
||||
g_free (self->priv->ip_type);
|
||||
self->priv->ip_type = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_ALLOW_ROAMING:
|
||||
self->priv->allow_roaming = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -878,6 +899,9 @@ get_property (GObject *object,
|
||||
case PROP_IP_TYPE:
|
||||
g_value_set_string (value, self->priv->ip_type);
|
||||
break;
|
||||
case PROP_ALLOW_ROAMING:
|
||||
g_value_set_boolean (value, self->priv->allow_roaming);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -891,6 +915,7 @@ mm_bearer_3gpp_init (MMBearer3gpp *self)
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
|
||||
MM_TYPE_BEARER_3GPP,
|
||||
MMBearer3gppPrivate);
|
||||
self->priv->allow_roaming = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -936,4 +961,12 @@ mm_bearer_3gpp_class_init (MMBearer3gppClass *klass)
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_IP_TYPE, properties[PROP_IP_TYPE]);
|
||||
|
||||
properties[PROP_ALLOW_ROAMING] =
|
||||
g_param_spec_boolean (MM_BEARER_3GPP_ALLOW_ROAMING,
|
||||
"Allow roaming",
|
||||
"Whether connections are allowed when roaming",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_ALLOW_ROAMING, properties[PROP_ALLOW_ROAMING]);
|
||||
}
|
||||
|
||||
@@ -31,9 +31,10 @@
|
||||
#define MM_IS_BEARER_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_3GPP))
|
||||
#define MM_BEARER_3GPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_3GPP, MMBearer3gppClass))
|
||||
|
||||
#define MM_BEARER_3GPP_CID "bearer-3gpp-cid"
|
||||
#define MM_BEARER_3GPP_APN "bearer-3gpp-apn"
|
||||
#define MM_BEARER_3GPP_IP_TYPE "bearer-3gpp-ip-type"
|
||||
#define MM_BEARER_3GPP_CID "bearer-3gpp-cid"
|
||||
#define MM_BEARER_3GPP_APN "bearer-3gpp-apn"
|
||||
#define MM_BEARER_3GPP_IP_TYPE "bearer-3gpp-ip-type"
|
||||
#define MM_BEARER_3GPP_ALLOW_ROAMING "bearer-3gpp-allow-roaming"
|
||||
|
||||
/* Prefix for all 3GPP bearer object paths */
|
||||
#define MM_DBUS_BEARER_3GPP_PREFIX MM_DBUS_BEARER_PREFIX "/3GPP"
|
||||
@@ -55,7 +56,8 @@ GType mm_bearer_3gpp_get_type (void);
|
||||
|
||||
MMBearer *mm_bearer_3gpp_new (MMBaseModem *modem,
|
||||
const gchar *apn,
|
||||
const gchar *ip_type);
|
||||
const gchar *ip_type,
|
||||
gboolean allow_roaming);
|
||||
MMBearer *mm_bearer_3gpp_new_from_properties (MMBaseModem *modem,
|
||||
GVariant *properties,
|
||||
GError **error);
|
||||
|
||||
+13
-6
@@ -472,15 +472,22 @@ mm_bearer_expose_properties (MMBearer *bearer,
|
||||
|
||||
va_start (va_args, first_property_name);
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
key = first_property_name;
|
||||
while (key) {
|
||||
const gchar *value;
|
||||
if (g_str_equal (key, "allow-roaming")) {
|
||||
gboolean value;
|
||||
|
||||
/* If a key with NULL value is given, just ignore it. */
|
||||
value = va_arg (va_args, gchar *);
|
||||
if (value)
|
||||
g_variant_builder_add (&builder, "{ss}", key, value);
|
||||
value = va_arg (va_args, gboolean);
|
||||
g_variant_builder_add (&builder, "{sv}", key, g_variant_new_boolean (value));
|
||||
} else {
|
||||
const gchar *value;
|
||||
|
||||
/* If a key with NULL value is given, just ignore it. */
|
||||
value = va_arg (va_args, gchar *);
|
||||
if (value)
|
||||
g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (value));
|
||||
}
|
||||
|
||||
key = va_arg (va_args, gchar *);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user