bearer: set allow-roaming as property at generic bearer object level
This commit is contained in:
+1
-25
@@ -37,7 +37,6 @@ enum {
|
||||
PROP_0,
|
||||
PROP_APN,
|
||||
PROP_IP_TYPE,
|
||||
PROP_ALLOW_ROAMING,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@@ -48,8 +47,6 @@ 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;
|
||||
@@ -71,12 +68,6 @@ mm_bearer_3gpp_get_ip_type (MMBearer3gpp *self)
|
||||
return self->priv->ip_type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_bearer_3gpp_get_allow_roaming (MMBearer3gpp *self)
|
||||
{
|
||||
return self->priv->allow_roaming;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* CONNECT
|
||||
*
|
||||
@@ -807,7 +798,7 @@ mm_bearer_3gpp_new (MMBaseModem *modem,
|
||||
bearer = g_object_new (MM_TYPE_BEARER_3GPP,
|
||||
MM_BEARER_3GPP_APN, mm_common_bearer_properties_get_apn (properties),
|
||||
MM_BEARER_3GPP_IP_TYPE, mm_common_bearer_properties_get_ip_type (properties),
|
||||
MM_BEARER_3GPP_ALLOW_ROAMING, mm_common_bearer_properties_get_allow_roaming (properties),
|
||||
MM_BEARER_ALLOW_ROAMING, mm_common_bearer_properties_get_allow_roaming (properties),
|
||||
NULL);
|
||||
|
||||
/* Set modem and path ONLY after having checked input properties, so that
|
||||
@@ -839,9 +830,6 @@ 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;
|
||||
@@ -863,9 +851,6 @@ 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;
|
||||
@@ -879,7 +864,6 @@ 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
|
||||
@@ -925,12 +909,4 @@ 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]);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#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"
|
||||
@@ -61,6 +60,5 @@ MMBearer *mm_bearer_3gpp_new (MMBaseModem *modem,
|
||||
|
||||
const gchar *mm_bearer_3gpp_get_apn (MMBearer3gpp *self);
|
||||
const gchar *mm_bearer_3gpp_get_ip_type (MMBearer3gpp *self);
|
||||
gboolean mm_bearer_3gpp_get_allow_roaming (MMBearer3gpp *self);
|
||||
|
||||
#endif /* MM_BEARER_3GPP_H */
|
||||
|
||||
@@ -43,6 +43,7 @@ enum {
|
||||
PROP_MODEM,
|
||||
PROP_CONNECTION_FORBIDDEN_REASON,
|
||||
PROP_STATUS,
|
||||
PROP_ALLOW_ROAMING,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@@ -59,6 +60,8 @@ struct _MMBearerPrivate {
|
||||
MMBearerConnectionForbiddenReason connection_forbidden_reason;
|
||||
/* Status of this bearer */
|
||||
MMBearerStatus status;
|
||||
/* Flag to allow/forbid connections while roaming */
|
||||
gboolean allow_roaming;
|
||||
|
||||
/* Cancellable for connect() */
|
||||
GCancellable *connect_cancellable;
|
||||
@@ -454,6 +457,12 @@ mm_bearer_get_status (MMBearer *self)
|
||||
return self->priv->status;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_bearer_get_allow_roaming (MMBearer *self)
|
||||
{
|
||||
return self->priv->allow_roaming;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
mm_bearer_get_path (MMBearer *self)
|
||||
{
|
||||
@@ -583,6 +592,9 @@ set_property (GObject *object,
|
||||
case PROP_STATUS:
|
||||
self->priv->status = g_value_get_enum (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;
|
||||
@@ -613,6 +625,9 @@ get_property (GObject *object,
|
||||
case PROP_STATUS:
|
||||
g_value_set_enum (value, self->priv->status);
|
||||
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;
|
||||
@@ -627,6 +642,7 @@ mm_bearer_init (MMBearer *self)
|
||||
MM_TYPE_BEARER,
|
||||
MMBearerPrivate);
|
||||
self->priv->status = MM_BEARER_STATUS_DISCONNECTED;
|
||||
self->priv->allow_roaming = TRUE;
|
||||
self->priv->connection_forbidden_reason = MM_BEARER_CONNECTION_FORBIDDEN_REASON_UNREGISTERED;
|
||||
|
||||
/* Set defaults */
|
||||
@@ -718,4 +734,12 @@ mm_bearer_class_init (MMBearerClass *klass)
|
||||
MM_BEARER_STATUS_DISCONNECTED,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_STATUS, properties[PROP_STATUS]);
|
||||
|
||||
properties[PROP_ALLOW_ROAMING] =
|
||||
g_param_spec_boolean (MM_BEARER_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]);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ typedef struct _MMBearerPrivate MMBearerPrivate;
|
||||
#define MM_BEARER_MODEM "bearer-modem"
|
||||
#define MM_BEARER_CONNECTION_FORBIDDEN_REASON "bearer-connection-forbidden-reason"
|
||||
#define MM_BEARER_STATUS "bearer-status"
|
||||
#define MM_BEARER_ALLOW_ROAMING "bearer-allow-roaming"
|
||||
|
||||
/* Prefix for all bearer object paths */
|
||||
#define MM_DBUS_BEARER_PREFIX MM_DBUS_PATH "/Bearers"
|
||||
@@ -98,6 +99,8 @@ void mm_bearer_set_connection_forbidden (MMBearer *bearer,
|
||||
|
||||
MMBearerStatus mm_bearer_get_status (MMBearer *bearer);
|
||||
|
||||
gboolean mm_bearer_get_allow_roaming (MMBearer *self);
|
||||
|
||||
void mm_bearer_connect (MMBearer *self,
|
||||
const gchar *number,
|
||||
GAsyncReadyCallback callback,
|
||||
|
||||
@@ -388,7 +388,7 @@ mm_iface_modem_3gpp_create_bearer (MMIfaceModem3gpp *self,
|
||||
if (current_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME)
|
||||
mm_bearer_set_connection_allowed (bearer);
|
||||
else if (current_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING) {
|
||||
if (mm_bearer_3gpp_get_allow_roaming (MM_BEARER_3GPP (bearer)))
|
||||
if (mm_bearer_get_allow_roaming (bearer))
|
||||
mm_bearer_set_connection_allowed (bearer);
|
||||
else
|
||||
mm_bearer_set_connection_forbidden (
|
||||
@@ -559,7 +559,7 @@ set_bearer_3gpp_connection_allowed (MMBearer *bearer,
|
||||
/* Don't allow bearer to get connected if roaming forbidden */
|
||||
if (MM_IS_BEARER_3GPP (bearer)) {
|
||||
if (!*roaming_network ||
|
||||
mm_bearer_3gpp_get_allow_roaming (MM_BEARER_3GPP (bearer)))
|
||||
mm_bearer_get_allow_roaming (bearer))
|
||||
mm_bearer_set_connection_allowed (bearer);
|
||||
else
|
||||
mm_bearer_set_connection_forbidden (bearer,
|
||||
|
||||
Reference in New Issue
Block a user