bearer: simplify handling of the bearer configuration
The base MMBearer object will receive the MMBearerProperties configuration, which contains every generic and plugin-specific set up. Not every configuration parameter will be used by every implementation (e.g. not every bearer needs user/password). The Bearer object will expose every configuration parameter received in its `Properties' property in the interface, even if it's not really used.
This commit is contained in:
@@ -440,6 +440,22 @@ mm_bearer_properties_dup (MMBearerProperties *orig)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
mm_bearer_properties_cmp (MMBearerProperties *a,
|
||||
MMBearerProperties *b)
|
||||
{
|
||||
return ((!g_strcmp0 (a->priv->apn, b->priv->apn)) &&
|
||||
(!g_strcmp0 (a->priv->ip_type, b->priv->ip_type)) &&
|
||||
(!g_strcmp0 (a->priv->number, b->priv->number)) &&
|
||||
(!g_strcmp0 (a->priv->user, b->priv->user)) &&
|
||||
(!g_strcmp0 (a->priv->password, b->priv->password)) &&
|
||||
(a->priv->allow_roaming == b->priv->allow_roaming) &&
|
||||
(a->priv->allow_roaming_set == b->priv->allow_roaming_set) &&
|
||||
(a->priv->rm_protocol == b->priv->rm_protocol));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBearerProperties *
|
||||
mm_bearer_properties_new (void)
|
||||
{
|
||||
|
||||
@@ -86,6 +86,9 @@ gboolean mm_bearer_properties_consume_variant (MMBearerProperties *self,
|
||||
|
||||
GVariant *mm_bearer_properties_get_dictionary (MMBearerProperties *self);
|
||||
|
||||
gboolean mm_bearer_properties_cmp (MMBearerProperties *a,
|
||||
MMBearerProperties *b);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* MM_BEARER_PROPERTIES_H */
|
||||
|
||||
@@ -385,21 +385,9 @@ disconnect (MMBearer *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
cmp_properties (MMBearer *self,
|
||||
MMBearerProperties *properties)
|
||||
{
|
||||
return (mm_bearer_properties_get_apn (properties) == NULL &&
|
||||
mm_bearer_properties_get_ip_type (properties) == NULL &&
|
||||
mm_bearer_properties_get_number (properties) == NULL &&
|
||||
mm_bearer_properties_get_rm_protocol (properties) == MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN &&
|
||||
mm_bearer_properties_get_allow_roaming (properties));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBearer *
|
||||
mm_bearer_iridium_new (MMBroadbandModemIridium *modem)
|
||||
mm_bearer_iridium_new (MMBroadbandModemIridium *modem,
|
||||
MMBearerProperties *config)
|
||||
{
|
||||
MMBearer *bearer;
|
||||
|
||||
@@ -408,6 +396,7 @@ mm_bearer_iridium_new (MMBroadbandModemIridium *modem)
|
||||
* g_object_get() here */
|
||||
bearer = g_object_new (MM_TYPE_BEARER_IRIDIUM,
|
||||
MM_BEARER_MODEM, modem,
|
||||
MM_BEARER_CONFIG, config,
|
||||
"ip-timeout", MM_BEARER_IRIDIUM_IP_TIMEOUT_DEFAULT,
|
||||
NULL);
|
||||
|
||||
@@ -428,7 +417,6 @@ mm_bearer_iridium_class_init (MMBearerIridiumClass *klass)
|
||||
MMBearerClass *bearer_class = MM_BEARER_CLASS (klass);
|
||||
|
||||
/* Virtual methods */
|
||||
bearer_class->cmp_properties = cmp_properties;
|
||||
bearer_class->connect = connect;
|
||||
bearer_class->connect_finish = connect_finish;
|
||||
bearer_class->disconnect = disconnect;
|
||||
|
||||
@@ -48,6 +48,7 @@ GType mm_bearer_iridium_get_type (void);
|
||||
|
||||
/* Iridium bearer creation implementation.
|
||||
* NOTE it is *not* a broadband bearer, so not async-initable */
|
||||
MMBearer *mm_bearer_iridium_new (MMBroadbandModemIridium *modem);
|
||||
MMBearer *mm_bearer_iridium_new (MMBroadbandModemIridium *modem,
|
||||
MMBearerProperties *config);
|
||||
|
||||
#endif /* MM_BEARER_IRIDIUM_H */
|
||||
|
||||
@@ -360,10 +360,9 @@ create_bearer (MMIfaceModem *self,
|
||||
callback,
|
||||
user_data,
|
||||
create_bearer);
|
||||
/* We just create a MMBearerIridium
|
||||
* Note that we do not need to use properties here */
|
||||
mm_dbg ("Creating Iridium bearer...");
|
||||
bearer = mm_bearer_iridium_new (MM_BROADBAND_MODEM_IRIDIUM (self));
|
||||
bearer = mm_bearer_iridium_new (MM_BROADBAND_MODEM_IRIDIUM (self),
|
||||
properties);
|
||||
g_simple_async_result_set_op_res_gpointer (result,
|
||||
bearer,
|
||||
(GDestroyNotify)g_object_unref);
|
||||
|
||||
@@ -36,26 +36,11 @@
|
||||
|
||||
G_DEFINE_TYPE (MMBroadbandBearerNovatel, mm_broadband_bearer_novatel, MM_TYPE_BROADBAND_BEARER);
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_USER,
|
||||
PROP_PASSWORD,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static GParamSpec *properties[PROP_LAST];
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
struct _MMBroadbandBearerNovatelPrivate {
|
||||
/* timeout id for checking whether we're still connected */
|
||||
guint connection_poller;
|
||||
/* Username for authenticating to APN */
|
||||
gchar *user;
|
||||
/* Password for authenticating to APN */
|
||||
gchar *password;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -255,7 +240,7 @@ connect_3gpp_qmiconnect_ready (MMBaseModem *modem,
|
||||
* happened. Instead, we need to poll the modem to see if it's
|
||||
* ready.
|
||||
*/
|
||||
g_timeout_add_seconds(1, (GSourceFunc)connect_3gpp_qmistatus, ctx);
|
||||
g_timeout_add_seconds (1, (GSourceFunc)connect_3gpp_qmistatus, ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -268,9 +253,9 @@ connect_3gpp (MMBroadbandBearer *bearer,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandBearerNovatel *self = MM_BROADBAND_BEARER_NOVATEL (bearer);
|
||||
DetailedConnectContext *ctx;
|
||||
gchar *command, *apn, *user, *password;
|
||||
MMBearerProperties *config;
|
||||
|
||||
ctx = detailed_connect_context_new (bearer,
|
||||
modem,
|
||||
@@ -280,9 +265,10 @@ connect_3gpp (MMBroadbandBearer *bearer,
|
||||
callback,
|
||||
user_data);
|
||||
|
||||
apn = mm_at_serial_port_quote_string (mm_broadband_bearer_get_3gpp_apn (bearer));
|
||||
user = mm_at_serial_port_quote_string (self->priv->user);
|
||||
password = mm_at_serial_port_quote_string (self->priv->password);
|
||||
config = mm_bearer_peek_config (MM_BEARER (bearer));
|
||||
apn = mm_at_serial_port_quote_string (mm_bearer_properties_get_apn (config));
|
||||
user = mm_at_serial_port_quote_string (mm_bearer_properties_get_user (config));
|
||||
password = mm_at_serial_port_quote_string (mm_bearer_properties_get_password (config));
|
||||
command = g_strdup_printf ("$NWQMICONNECT=,,,,,,%s,,,%s,%s",
|
||||
apn, user, password);
|
||||
g_free (apn);
|
||||
@@ -298,7 +284,6 @@ connect_3gpp (MMBroadbandBearer *bearer,
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
MMBroadbandBearer *self;
|
||||
MMBaseModem *modem;
|
||||
@@ -308,7 +293,6 @@ typedef struct {
|
||||
GSimpleAsyncResult *result;
|
||||
} DetailedDisconnectContext;
|
||||
|
||||
|
||||
static DetailedDisconnectContext *
|
||||
detailed_disconnect_context_new (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
@@ -374,13 +358,12 @@ disconnect_3gpp_status_complete (MMBaseModem *modem,
|
||||
}
|
||||
|
||||
result = mm_strip_tag (result, "$NWQMISTATUS:");
|
||||
if (g_strrstr(result, "QMI State: DISCONNECTED"))
|
||||
if (g_strrstr (result, "QMI State: DISCONNECTED"))
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
|
||||
detailed_disconnect_context_complete_and_free (ctx);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
disconnect_3gpp_check_status (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
@@ -435,100 +418,17 @@ disconnect_3gpp (MMBroadbandBearer *self,
|
||||
ctx); /* user_data */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
MMBroadbandBearerNovatel *self = MM_BROADBAND_BEARER_NOVATEL (object);
|
||||
|
||||
g_free (self->priv->user);
|
||||
g_free (self->priv->password);
|
||||
if (self->priv->connection_poller)
|
||||
g_source_remove (self->priv->connection_poller);
|
||||
|
||||
G_OBJECT_CLASS (mm_broadband_bearer_novatel_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBroadbandBearerNovatel *self = MM_BROADBAND_BEARER_NOVATEL (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_USER:
|
||||
g_free (self->priv->user);
|
||||
self->priv->user = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_free (self->priv->password);
|
||||
self->priv->password = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBroadbandBearerNovatel *self = MM_BROADBAND_BEARER_NOVATEL (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_USER:
|
||||
g_value_set_string (value, self->priv->user);
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_value_set_string (value, self->priv->password);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
cmp_properties (MMBearer *bearer,
|
||||
MMBearerProperties *properties)
|
||||
{
|
||||
MMBroadbandBearerNovatel *self = MM_BROADBAND_BEARER_NOVATEL (bearer);
|
||||
|
||||
return ((mm_broadband_bearer_get_allow_roaming (MM_BROADBAND_BEARER (self)) ==
|
||||
mm_bearer_properties_get_allow_roaming (properties)) &&
|
||||
(!g_strcmp0 (mm_broadband_bearer_get_ip_type (MM_BROADBAND_BEARER (self)),
|
||||
mm_bearer_properties_get_ip_type (properties))) &&
|
||||
(!g_strcmp0 (mm_broadband_bearer_get_3gpp_apn (MM_BROADBAND_BEARER (self)),
|
||||
mm_bearer_properties_get_apn (properties))) &&
|
||||
(!g_strcmp0 (self->priv->user,
|
||||
mm_bearer_properties_get_user (properties))) &&
|
||||
(!g_strcmp0 (self->priv->password,
|
||||
mm_bearer_properties_get_password (properties))));
|
||||
}
|
||||
|
||||
static MMBearerProperties *
|
||||
expose_properties (MMBearer *bearer)
|
||||
{
|
||||
MMBroadbandBearerNovatel *self = MM_BROADBAND_BEARER_NOVATEL (bearer);
|
||||
MMBearerProperties *properties;
|
||||
|
||||
properties = mm_bearer_properties_new ();
|
||||
mm_bearer_properties_set_apn (properties,
|
||||
mm_broadband_bearer_get_3gpp_apn (MM_BROADBAND_BEARER (self)));
|
||||
mm_bearer_properties_set_ip_type (properties,
|
||||
mm_broadband_bearer_get_ip_type (MM_BROADBAND_BEARER (self)));
|
||||
mm_bearer_properties_set_allow_roaming (properties,
|
||||
mm_broadband_bearer_get_allow_roaming (MM_BROADBAND_BEARER (self)));
|
||||
mm_bearer_properties_set_user (properties, self->priv->user);
|
||||
mm_bearer_properties_set_password (properties, self->priv->user);
|
||||
return properties;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_bearer_novatel_init (MMBroadbandBearerNovatel *self)
|
||||
{
|
||||
@@ -536,8 +436,6 @@ mm_broadband_bearer_novatel_init (MMBroadbandBearerNovatel *self)
|
||||
MM_TYPE_BROADBAND_BEARER_NOVATEL,
|
||||
MMBroadbandBearerNovatelPrivate);
|
||||
|
||||
self->priv->user = NULL;
|
||||
self->priv->password = NULL;
|
||||
self->priv->connection_poller = 0;
|
||||
}
|
||||
|
||||
@@ -545,38 +443,16 @@ static void
|
||||
mm_broadband_bearer_novatel_class_init (MMBroadbandBearerNovatelClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MMBearerClass *bearer_class = MM_BEARER_CLASS (klass);
|
||||
MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (MMBroadbandBearerNovatelPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
bearer_class->cmp_properties = cmp_properties;
|
||||
bearer_class->expose_properties = expose_properties;
|
||||
|
||||
broadband_bearer_class->connect_3gpp = connect_3gpp;
|
||||
broadband_bearer_class->connect_3gpp_finish = connect_3gpp_finish;
|
||||
broadband_bearer_class->disconnect_3gpp = disconnect_3gpp;
|
||||
broadband_bearer_class->disconnect_3gpp_finish = disconnect_3gpp_finish;
|
||||
|
||||
properties[PROP_USER] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_NOVATEL_USER,
|
||||
"User",
|
||||
"Username to authenticate to APN",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_USER, properties[PROP_USER]);
|
||||
|
||||
properties[PROP_PASSWORD] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_NOVATEL_PASSWORD,
|
||||
"Password",
|
||||
"Password to authenticate to APN",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_PASSWORD, properties[PROP_PASSWORD]);
|
||||
}
|
||||
|
||||
MMBearer *
|
||||
@@ -599,11 +475,12 @@ mm_broadband_bearer_novatel_new_finish (GAsyncResult *res,
|
||||
return MM_BEARER (bearer);
|
||||
}
|
||||
|
||||
void mm_broadband_bearer_novatel_new (MMBroadbandModemNovatel *modem,
|
||||
MMBearerProperties *properties,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
void
|
||||
mm_broadband_bearer_novatel_new (MMBroadbandModemNovatel *modem,
|
||||
MMBearerProperties *config,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_async_initable_new_async (
|
||||
MM_TYPE_BROADBAND_BEARER_NOVATEL,
|
||||
@@ -612,10 +489,6 @@ void mm_broadband_bearer_novatel_new (MMBroadbandModemNovatel *modem,
|
||||
callback,
|
||||
user_data,
|
||||
MM_BEARER_MODEM, modem,
|
||||
MM_BROADBAND_BEARER_3GPP_APN, mm_bearer_properties_get_apn (properties),
|
||||
MM_BROADBAND_BEARER_IP_TYPE, mm_bearer_properties_get_ip_type (properties),
|
||||
MM_BROADBAND_BEARER_ALLOW_ROAMING, mm_bearer_properties_get_allow_roaming (properties),
|
||||
MM_BROADBAND_BEARER_NOVATEL_USER, mm_bearer_properties_get_user (properties),
|
||||
MM_BROADBAND_BEARER_NOVATEL_PASSWORD, mm_bearer_properties_get_password (properties),
|
||||
MM_BEARER_CONFIG, config,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -36,20 +36,8 @@
|
||||
|
||||
G_DEFINE_TYPE (MMBroadbandBearerHso, mm_broadband_bearer_hso, MM_TYPE_BROADBAND_BEARER);
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_USER,
|
||||
PROP_PASSWORD,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static GParamSpec *properties[PROP_LAST];
|
||||
|
||||
struct _MMBroadbandBearerHsoPrivate {
|
||||
gchar *user;
|
||||
gchar *password;
|
||||
guint auth_idx;
|
||||
|
||||
gpointer connect_pending;
|
||||
guint connect_pending_id;
|
||||
gulong connect_cancellable_id;
|
||||
@@ -544,6 +532,8 @@ static void
|
||||
authenticate (Dial3gppContext *ctx)
|
||||
{
|
||||
gchar *command;
|
||||
const gchar *user;
|
||||
const gchar *password;
|
||||
|
||||
if (!auth_commands[ctx->auth_idx]) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
@@ -554,8 +544,11 @@ authenticate (Dial3gppContext *ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
user = mm_bearer_properties_get_user (mm_bearer_peek_config (MM_BEARER (ctx->self)));
|
||||
password = mm_bearer_properties_get_password (mm_bearer_peek_config (MM_BEARER (ctx->self)));
|
||||
|
||||
/* Both user and password are required; otherwise firmware returns an error */
|
||||
if (!ctx->self->priv->user || !ctx->self->priv->password)
|
||||
if (!user || !password)
|
||||
command = g_strdup_printf ("%s=%d,0",
|
||||
auth_commands[ctx->auth_idx],
|
||||
ctx->cid);
|
||||
@@ -563,8 +556,8 @@ authenticate (Dial3gppContext *ctx)
|
||||
command = g_strdup_printf ("%s=%d,1,\"%s\",\"%s\"",
|
||||
auth_commands[ctx->auth_idx],
|
||||
ctx->cid,
|
||||
ctx->self->priv->password,
|
||||
ctx->self->priv->user);
|
||||
password,
|
||||
user);
|
||||
|
||||
mm_base_modem_at_command_full (ctx->modem,
|
||||
ctx->primary,
|
||||
@@ -683,44 +676,6 @@ disconnect_3gpp (MMBroadbandBearer *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
cmp_properties (MMBearer *self,
|
||||
MMBearerProperties *properties)
|
||||
{
|
||||
MMBroadbandBearerHso *hso = MM_BROADBAND_BEARER_HSO (self);
|
||||
|
||||
return ((mm_broadband_bearer_get_allow_roaming (MM_BROADBAND_BEARER (self)) ==
|
||||
mm_bearer_properties_get_allow_roaming (properties)) &&
|
||||
(!g_strcmp0 (mm_broadband_bearer_get_ip_type (MM_BROADBAND_BEARER (self)),
|
||||
mm_bearer_properties_get_ip_type (properties))) &&
|
||||
(!g_strcmp0 (mm_broadband_bearer_get_3gpp_apn (MM_BROADBAND_BEARER (self)),
|
||||
mm_bearer_properties_get_apn (properties))) &&
|
||||
(!g_strcmp0 (hso->priv->user,
|
||||
mm_bearer_properties_get_user (properties))) &&
|
||||
(!g_strcmp0 (hso->priv->password,
|
||||
mm_bearer_properties_get_password (properties))));
|
||||
}
|
||||
|
||||
static MMBearerProperties *
|
||||
expose_properties (MMBearer *self)
|
||||
{
|
||||
MMBroadbandBearerHso *hso = MM_BROADBAND_BEARER_HSO (self);
|
||||
MMBearerProperties *properties;
|
||||
|
||||
properties = mm_bearer_properties_new ();
|
||||
mm_bearer_properties_set_apn (properties,
|
||||
mm_broadband_bearer_get_3gpp_apn (MM_BROADBAND_BEARER (self)));
|
||||
mm_bearer_properties_set_ip_type (properties,
|
||||
mm_broadband_bearer_get_ip_type (MM_BROADBAND_BEARER (self)));
|
||||
mm_bearer_properties_set_allow_roaming (properties,
|
||||
mm_broadband_bearer_get_allow_roaming (MM_BROADBAND_BEARER (self)));
|
||||
mm_bearer_properties_set_user (properties, hso->priv->user);
|
||||
mm_bearer_properties_set_password (properties, hso->priv->user);
|
||||
return properties;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBearer *
|
||||
mm_broadband_bearer_hso_new_finish (GAsyncResult *res,
|
||||
GError **error)
|
||||
@@ -743,7 +698,7 @@ mm_broadband_bearer_hso_new_finish (GAsyncResult *res,
|
||||
|
||||
void
|
||||
mm_broadband_bearer_hso_new (MMBroadbandModemHso *modem,
|
||||
MMBearerProperties *properties,
|
||||
MMBearerProperties *config,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@@ -755,58 +710,10 @@ mm_broadband_bearer_hso_new (MMBroadbandModemHso *modem,
|
||||
callback,
|
||||
user_data,
|
||||
MM_BEARER_MODEM, modem,
|
||||
MM_BROADBAND_BEARER_3GPP_APN, mm_bearer_properties_get_apn (properties),
|
||||
MM_BROADBAND_BEARER_IP_TYPE, mm_bearer_properties_get_ip_type (properties),
|
||||
MM_BROADBAND_BEARER_ALLOW_ROAMING, mm_bearer_properties_get_allow_roaming (properties),
|
||||
MM_BROADBAND_BEARER_HSO_USER, mm_bearer_properties_get_user (properties),
|
||||
MM_BROADBAND_BEARER_HSO_PASSWORD, mm_bearer_properties_get_password (properties),
|
||||
MM_BEARER_CONFIG, config,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBroadbandBearerHso *self = MM_BROADBAND_BEARER_HSO (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_USER:
|
||||
g_free (self->priv->user);
|
||||
self->priv->user = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_free (self->priv->password);
|
||||
self->priv->password = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBroadbandBearerHso *self = MM_BROADBAND_BEARER_HSO (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_USER:
|
||||
g_value_set_string (value, self->priv->user);
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_value_set_string (value, self->priv->password);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_bearer_hso_init (MMBroadbandBearerHso *self)
|
||||
{
|
||||
@@ -816,53 +723,18 @@ mm_broadband_bearer_hso_init (MMBroadbandBearerHso *self)
|
||||
MMBroadbandBearerHsoPrivate);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
MMBroadbandBearerHso *self = MM_BROADBAND_BEARER_HSO (object);
|
||||
|
||||
g_free (self->priv->user);
|
||||
g_free (self->priv->password);
|
||||
|
||||
G_OBJECT_CLASS (mm_broadband_bearer_hso_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_bearer_hso_class_init (MMBroadbandBearerHsoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MMBearerClass *bearer_class = MM_BEARER_CLASS (klass);
|
||||
MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (MMBroadbandBearerHsoPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
bearer_class->cmp_properties = cmp_properties;
|
||||
bearer_class->expose_properties = expose_properties;
|
||||
|
||||
broadband_bearer_class->dial_3gpp = dial_3gpp;
|
||||
broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
|
||||
broadband_bearer_class->get_ip_config_3gpp = get_ip_config_3gpp;
|
||||
broadband_bearer_class->get_ip_config_3gpp_finish = get_ip_config_3gpp_finish;
|
||||
broadband_bearer_class->disconnect_3gpp = disconnect_3gpp;
|
||||
broadband_bearer_class->disconnect_3gpp_finish = disconnect_3gpp_finish;
|
||||
|
||||
properties[PROP_USER] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_HSO_USER,
|
||||
"User",
|
||||
"Username to use to authenticate the connection",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_USER, properties[PROP_USER]);
|
||||
|
||||
properties[PROP_PASSWORD] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_HSO_PASSWORD,
|
||||
"Password",
|
||||
"Password to use to authenticate the connection",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_PASSWORD, properties[PROP_PASSWORD]);
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
#define MM_IS_BROADBAND_BEARER_HSO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_HSO))
|
||||
#define MM_BROADBAND_BEARER_HSO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_HSO, MMBroadbandBearerHsoClass))
|
||||
|
||||
#define MM_BROADBAND_BEARER_HSO_USER "broadband-bearer-hso-user"
|
||||
#define MM_BROADBAND_BEARER_HSO_PASSWORD "broadband-bearer-hso-password"
|
||||
|
||||
typedef enum {
|
||||
MM_BROADBAND_BEARER_HSO_CONNECTION_STATUS_UNKNOWN,
|
||||
MM_BROADBAND_BEARER_HSO_CONNECTION_STATUS_CONNECTED,
|
||||
@@ -58,7 +55,7 @@ GType mm_broadband_bearer_hso_get_type (void);
|
||||
|
||||
/* Default 3GPP bearer creation implementation */
|
||||
void mm_broadband_bearer_hso_new (MMBroadbandModemHso *modem,
|
||||
MMBearerProperties *properties,
|
||||
MMBearerProperties *config,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
@@ -170,7 +170,7 @@ mm_bearer_list_find (MMBearerList *self,
|
||||
GList *l;
|
||||
|
||||
for (l = self->priv->bearers; l; l = g_list_next (l)) {
|
||||
if (mm_bearer_cmp_properties (MM_BEARER (l->data), properties))
|
||||
if (mm_bearer_properties_cmp (mm_bearer_peek_config (MM_BEARER (l->data)), properties))
|
||||
return g_object_ref (l->data);
|
||||
}
|
||||
|
||||
|
||||
+42
-29
@@ -45,6 +45,7 @@ enum {
|
||||
PROP_CONNECTION,
|
||||
PROP_MODEM,
|
||||
PROP_STATUS,
|
||||
PROP_CONFIG,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@@ -59,6 +60,8 @@ struct _MMBearerPrivate {
|
||||
gchar *path;
|
||||
/* Status of this bearer */
|
||||
MMBearerStatus status;
|
||||
/* Configuration of the bearer */
|
||||
MMBearerProperties *config;
|
||||
|
||||
/* Cancellable for connect() */
|
||||
GCancellable *connect_cancellable;
|
||||
@@ -68,28 +71,12 @@ struct _MMBearerPrivate {
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
bearer_expose_properties (MMBearer *self)
|
||||
{
|
||||
MMBearerProperties *properties;
|
||||
GVariant *dictionary;
|
||||
|
||||
properties = MM_BEARER_GET_CLASS (self)->expose_properties (self);
|
||||
dictionary = mm_bearer_properties_get_dictionary (properties);
|
||||
mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (self), dictionary);
|
||||
g_variant_unref (dictionary);
|
||||
g_object_unref (properties);
|
||||
}
|
||||
|
||||
void
|
||||
mm_bearer_export (MMBearer *self)
|
||||
{
|
||||
static guint id = 0;
|
||||
gchar *path;
|
||||
|
||||
/* Expose properties before exporting */
|
||||
bearer_expose_properties (self);
|
||||
|
||||
path = g_strdup_printf (MM_DBUS_BEARER_PREFIX "/%d", id++);
|
||||
g_object_set (self,
|
||||
MM_BEARER_PATH, path,
|
||||
@@ -625,6 +612,20 @@ mm_bearer_get_path (MMBearer *self)
|
||||
return self->priv->path;
|
||||
}
|
||||
|
||||
MMBearerProperties *
|
||||
mm_bearer_peek_config (MMBearer *self)
|
||||
{
|
||||
return self->priv->config;
|
||||
}
|
||||
|
||||
MMBearerProperties *
|
||||
mm_bearer_get_config (MMBearer *self)
|
||||
{
|
||||
return (self->priv->config ?
|
||||
g_object_ref (self->priv->config) :
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
@@ -685,17 +686,6 @@ mm_bearer_report_disconnection (MMBearer *self)
|
||||
return MM_BEARER_GET_CLASS (self)->report_disconnection (self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
mm_bearer_cmp_properties (MMBearer *self,
|
||||
MMBearerProperties *properties)
|
||||
{
|
||||
return MM_BEARER_GET_CLASS (self)->cmp_properties (self, properties);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -738,6 +728,18 @@ set_property (GObject *object,
|
||||
/* We don't allow g_object_set()-ing the status property */
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
case PROP_CONFIG: {
|
||||
GVariant *dictionary;
|
||||
|
||||
g_clear_object (&self->priv->config);
|
||||
self->priv->config = g_value_dup_object (value);
|
||||
/* Also expose the properties */
|
||||
dictionary = mm_bearer_properties_get_dictionary (self->priv->config);
|
||||
mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (self), dictionary);
|
||||
if (dictionary)
|
||||
g_variant_unref (dictionary);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -765,6 +767,9 @@ get_property (GObject *object,
|
||||
case PROP_STATUS:
|
||||
g_value_set_enum (value, self->priv->status);
|
||||
break;
|
||||
case PROP_CONFIG:
|
||||
g_value_set_object (value, self->priv->config);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -812,8 +817,8 @@ dispose (GObject *object)
|
||||
g_clear_object (&self->priv->connection);
|
||||
}
|
||||
|
||||
if (self->priv->modem)
|
||||
g_clear_object (&self->priv->modem);
|
||||
g_clear_object (&self->priv->modem);
|
||||
g_clear_object (&self->priv->config);
|
||||
|
||||
G_OBJECT_CLASS (mm_bearer_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -865,4 +870,12 @@ mm_bearer_class_init (MMBearerClass *klass)
|
||||
MM_BEARER_STATUS_DISCONNECTED,
|
||||
G_PARAM_READABLE);
|
||||
g_object_class_install_property (object_class, PROP_STATUS, properties[PROP_STATUS]);
|
||||
|
||||
properties[PROP_CONFIG] =
|
||||
g_param_spec_object (MM_BEARER_CONFIG,
|
||||
"Bearer configuration",
|
||||
"List of user provided properties",
|
||||
MM_TYPE_BEARER_PROPERTIES,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_CONFIG, properties[PROP_CONFIG]);
|
||||
}
|
||||
|
||||
+5
-15
@@ -40,6 +40,7 @@ typedef struct _MMBearerPrivate MMBearerPrivate;
|
||||
#define MM_BEARER_CONNECTION "bearer-connection"
|
||||
#define MM_BEARER_MODEM "bearer-modem"
|
||||
#define MM_BEARER_STATUS "bearer-status"
|
||||
#define MM_BEARER_CONFIG "bearer-config"
|
||||
|
||||
typedef enum { /*< underscore_name=mm_bearer_status >*/
|
||||
MM_BEARER_STATUS_DISCONNECTED,
|
||||
@@ -78,25 +79,17 @@ struct _MMBearerClass {
|
||||
|
||||
/* Report disconnection */
|
||||
void (* report_disconnection) (MMBearer *bearer);
|
||||
|
||||
/* Check if the bearer has the exact same properties */
|
||||
gboolean (* cmp_properties) (MMBearer *self,
|
||||
MMBearerProperties *properties);
|
||||
|
||||
/* Builder of the properties to be exposed in DBus. Bearers should expose only
|
||||
* the input properties they actually ended up using */
|
||||
MMBearerProperties * (* expose_properties) (MMBearer *self);
|
||||
};
|
||||
|
||||
GType mm_bearer_get_type (void);
|
||||
|
||||
void mm_bearer_export (MMBearer *self);
|
||||
const gchar *mm_bearer_get_path (MMBearer *bearer);
|
||||
|
||||
void mm_bearer_expose_properties (MMBearer *bearer,
|
||||
MMBearerProperties *properties);
|
||||
const gchar *mm_bearer_get_path (MMBearer *bearer);
|
||||
MMBearerStatus mm_bearer_get_status (MMBearer *bearer);
|
||||
MMBearerProperties *mm_bearer_peek_config (MMBearer *self);
|
||||
MMBearerProperties *mm_bearer_get_config (MMBearer *self);
|
||||
|
||||
MMBearerStatus mm_bearer_get_status (MMBearer *bearer);
|
||||
|
||||
void mm_bearer_connect (MMBearer *self,
|
||||
GAsyncReadyCallback callback,
|
||||
@@ -116,7 +109,4 @@ void mm_bearer_disconnect_force (MMBearer *self);
|
||||
|
||||
void mm_bearer_report_disconnection (MMBearer *self);
|
||||
|
||||
gboolean mm_bearer_cmp_properties (MMBearer *self,
|
||||
MMBearerProperties *properties);
|
||||
|
||||
#endif /* MM_BEARER_H */
|
||||
|
||||
+42
-244
@@ -53,24 +53,8 @@ typedef enum {
|
||||
CONNECTION_TYPE_CDMA,
|
||||
} ConnectionType;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_3GPP_APN,
|
||||
PROP_CDMA_NUMBER,
|
||||
PROP_CDMA_RM_PROTOCOL,
|
||||
PROP_IP_TYPE,
|
||||
PROP_ALLOW_ROAMING,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static GParamSpec *properties[PROP_LAST];
|
||||
|
||||
struct _MMBroadbandBearerPrivate {
|
||||
/*-- Common stuff --*/
|
||||
/* IP type */
|
||||
gchar *ip_type;
|
||||
/* Flag to allow/forbid connections while roaming */
|
||||
gboolean allow_roaming;
|
||||
/* Data port used when modem is connected */
|
||||
MMPort *port;
|
||||
/* Current connection type */
|
||||
@@ -81,8 +65,6 @@ struct _MMBroadbandBearerPrivate {
|
||||
ConnectionForbiddenReason reason_3gpp;
|
||||
/* Handler ID for the registration state change signals */
|
||||
guint id_3gpp_registration_change;
|
||||
/* APN of the PDP context */
|
||||
gchar *apn;
|
||||
/* CID of the PDP context */
|
||||
guint cid;
|
||||
|
||||
@@ -92,10 +74,6 @@ struct _MMBroadbandBearerPrivate {
|
||||
/* Handler IDs for the registration state change signals */
|
||||
guint id_cdma1x_registration_change;
|
||||
guint id_evdo_registration_change;
|
||||
/* (Optional) Number to dial */
|
||||
gchar *number;
|
||||
/* Protocol of the Rm interface */
|
||||
MMModemCdmaRmProtocol rm_protocol;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -106,38 +84,6 @@ static const gchar *connection_forbidden_reason_str [CONNECTION_FORBIDDEN_REASON
|
||||
"Registered in roaming network, and roaming not allowed"
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const gchar *
|
||||
mm_broadband_bearer_get_3gpp_apn (MMBroadbandBearer *self)
|
||||
{
|
||||
return self->priv->apn;
|
||||
}
|
||||
|
||||
MMModemCdmaRmProtocol
|
||||
mm_broadband_bearer_get_cdma_rm_protocol (MMBroadbandBearer *self)
|
||||
{
|
||||
return self->priv->rm_protocol;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
mm_broadband_bearer_get_ip_type (MMBroadbandBearer *self)
|
||||
{
|
||||
return self->priv->ip_type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_broadband_bearer_get_allow_roaming (MMBroadbandBearer *self)
|
||||
{
|
||||
return self->priv->allow_roaming;
|
||||
}
|
||||
|
||||
guint
|
||||
mm_broadband_bearer_get_3gpp_cid (MMBroadbandBearer *self)
|
||||
{
|
||||
return self->priv->cid;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Detailed connect result, used in both CDMA and 3GPP sequences */
|
||||
typedef struct {
|
||||
@@ -328,12 +274,15 @@ static void
|
||||
cdma_connect_context_dial (DetailedConnectContext *ctx)
|
||||
{
|
||||
gchar *command;
|
||||
const gchar *number;
|
||||
|
||||
number = mm_bearer_properties_get_number (mm_bearer_peek_config (MM_BEARER (ctx->self)));
|
||||
|
||||
/* If a number was given when creating the bearer, use that one.
|
||||
* Otherwise, use the default one, #777
|
||||
*/
|
||||
if (ctx->self->priv->number)
|
||||
command = g_strconcat ("DT", ctx->self->priv->number, NULL);
|
||||
if (number)
|
||||
command = g_strconcat ("DT", number, NULL);
|
||||
else
|
||||
command = g_strdup ("DT#777");
|
||||
|
||||
@@ -405,14 +354,14 @@ current_rm_protocol_ready (MMBaseModem *self,
|
||||
return;
|
||||
}
|
||||
|
||||
if (current_rm != ctx->self->priv->rm_protocol) {
|
||||
if (current_rm != mm_bearer_properties_get_rm_protocol (mm_bearer_peek_config (MM_BEARER (self)))) {
|
||||
guint new_index;
|
||||
gchar *command;
|
||||
|
||||
mm_dbg ("Setting requested RM protocol...");
|
||||
|
||||
new_index = (mm_cdma_get_index_from_rm_protocol (
|
||||
ctx->self->priv->rm_protocol,
|
||||
mm_bearer_properties_get_rm_protocol (mm_bearer_peek_config (MM_BEARER (self))),
|
||||
&error));
|
||||
if (error) {
|
||||
mm_warn ("Cannot set RM protocol: '%s'",
|
||||
@@ -462,7 +411,9 @@ connect_cdma (MMBroadbandBearer *self,
|
||||
callback,
|
||||
user_data);
|
||||
|
||||
if (self->priv->rm_protocol != MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
|
||||
if (mm_bearer_properties_get_rm_protocol (
|
||||
mm_bearer_peek_config (MM_BEARER (self))) !=
|
||||
MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
|
||||
/* Need to query current RM protocol */
|
||||
mm_dbg ("Querying current RM protocol set...");
|
||||
mm_base_modem_at_command_full (ctx->modem,
|
||||
@@ -754,7 +705,7 @@ dial_3gpp_ready (MMBroadbandModem *modem,
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_pdp_context_ready (MMBaseModem *self,
|
||||
initialize_pdp_context_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
DetailedConnectContext *ctx)
|
||||
{
|
||||
@@ -764,7 +715,7 @@ initialize_pdp_context_ready (MMBaseModem *self,
|
||||
if (detailed_connect_context_complete_and_free_if_cancelled (ctx))
|
||||
return;
|
||||
|
||||
mm_base_modem_at_command_full_finish (self, res, &error);
|
||||
mm_base_modem_at_command_full_finish (modem, res, &error);
|
||||
if (error) {
|
||||
mm_warn ("Couldn't initialize PDP context with our APN: '%s'",
|
||||
error->message);
|
||||
@@ -783,7 +734,7 @@ initialize_pdp_context_ready (MMBaseModem *self,
|
||||
}
|
||||
|
||||
static void
|
||||
find_cid_ready (MMBaseModem *self,
|
||||
find_cid_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
DetailedConnectContext *ctx)
|
||||
{
|
||||
@@ -791,7 +742,7 @@ find_cid_ready (MMBaseModem *self,
|
||||
gchar *command;
|
||||
GError *error = NULL;
|
||||
|
||||
result = mm_base_modem_at_sequence_full_finish (self, res, NULL, &error);
|
||||
result = mm_base_modem_at_sequence_full_finish (modem, res, NULL, &error);
|
||||
if (!result) {
|
||||
mm_warn ("Couldn't find best CID to use: '%s'", error->message);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
@@ -809,7 +760,7 @@ find_cid_ready (MMBaseModem *self,
|
||||
ctx->cid = g_variant_get_uint32 (result);
|
||||
command = g_strdup_printf ("+CGDCONT=%u,\"IP\",\"%s\"",
|
||||
ctx->cid,
|
||||
ctx->self->priv->apn);
|
||||
mm_bearer_properties_get_apn (mm_bearer_peek_config (MM_BEARER (ctx->self))));
|
||||
mm_base_modem_at_command_full (ctx->modem,
|
||||
ctx->primary,
|
||||
command,
|
||||
@@ -822,7 +773,7 @@ find_cid_ready (MMBaseModem *self,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_cid_range (MMBaseModem *self,
|
||||
parse_cid_range (MMBaseModem *modem,
|
||||
DetailedConnectContext *ctx,
|
||||
const gchar *command,
|
||||
const gchar *response,
|
||||
@@ -907,7 +858,7 @@ parse_cid_range (MMBaseModem *self,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_pdp_list (MMBaseModem *self,
|
||||
parse_pdp_list (MMBaseModem *modem,
|
||||
DetailedConnectContext *ctx,
|
||||
const gchar *command,
|
||||
const gchar *response,
|
||||
@@ -960,14 +911,19 @@ parse_pdp_list (MMBaseModem *self,
|
||||
mm_dbg ("Found PDP context with CID %u and no APN",
|
||||
pdp->cid);
|
||||
cid = pdp->cid;
|
||||
} else if (ctx->self->priv->apn &&
|
||||
g_str_equal (pdp->apn, ctx->self->priv->apn)) {
|
||||
/* Found a PDP context with the same CID, we'll use it. */
|
||||
mm_dbg ("Found PDP context with CID %u for APN '%s'",
|
||||
pdp->cid, pdp->apn);
|
||||
cid = pdp->cid;
|
||||
/* In this case, stop searching */
|
||||
break;
|
||||
} else {
|
||||
const gchar *apn;
|
||||
|
||||
apn = mm_bearer_properties_get_apn (mm_bearer_peek_config (MM_BEARER (ctx->self)));
|
||||
if (apn &&
|
||||
g_str_equal (pdp->apn, apn)) {
|
||||
/* Found a PDP context with the same CID, we'll use it. */
|
||||
mm_dbg ("Found PDP context with CID %u for APN '%s'",
|
||||
pdp->cid, pdp->apn);
|
||||
cid = pdp->cid;
|
||||
/* In this case, stop searching */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1767,41 +1723,6 @@ report_disconnection (MMBearer *self)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
cmp_properties (MMBearer *self,
|
||||
MMBearerProperties *properties)
|
||||
{
|
||||
MMBroadbandBearer *broadband = MM_BROADBAND_BEARER (self);
|
||||
|
||||
return ((!g_strcmp0 (broadband->priv->apn,
|
||||
mm_bearer_properties_get_apn (properties))) &&
|
||||
(!g_strcmp0 (broadband->priv->ip_type,
|
||||
mm_bearer_properties_get_ip_type (properties))) &&
|
||||
(broadband->priv->allow_roaming ==
|
||||
mm_bearer_properties_get_allow_roaming (properties)) &&
|
||||
(!g_strcmp0 (broadband->priv->number,
|
||||
mm_bearer_properties_get_number (properties))) &&
|
||||
(broadband->priv->rm_protocol ==
|
||||
mm_bearer_properties_get_rm_protocol (properties)));
|
||||
}
|
||||
|
||||
static MMBearerProperties *
|
||||
expose_properties (MMBearer *self)
|
||||
{
|
||||
MMBroadbandBearer *broadband = MM_BROADBAND_BEARER (self);
|
||||
MMBearerProperties *properties;
|
||||
|
||||
properties = mm_bearer_properties_new ();
|
||||
mm_bearer_properties_set_apn (properties, broadband->priv->apn);
|
||||
mm_bearer_properties_set_number (properties, broadband->priv->number);
|
||||
mm_bearer_properties_set_rm_protocol (properties, broadband->priv->rm_protocol);
|
||||
mm_bearer_properties_set_ip_type (properties, broadband->priv->ip_type);
|
||||
mm_bearer_properties_set_allow_roaming (properties, broadband->priv->allow_roaming);
|
||||
return properties;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _InitAsyncContext InitAsyncContext;
|
||||
static void interface_initialization_step (InitAsyncContext *ctx);
|
||||
|
||||
@@ -1885,9 +1806,12 @@ crm_range_ready (MMBaseModem *modem,
|
||||
if (mm_cdma_parse_crm_test_response (response,
|
||||
&min, &max,
|
||||
&error)) {
|
||||
MMModemCdmaRmProtocol current;
|
||||
|
||||
current = mm_bearer_properties_get_rm_protocol (mm_bearer_peek_config (MM_BEARER (ctx->self)));
|
||||
/* Check if value within the range */
|
||||
if (ctx->self->priv->rm_protocol >= min &&
|
||||
ctx->self->priv->rm_protocol <= max) {
|
||||
if (current >= min &&
|
||||
current <= max) {
|
||||
/* Fine, go on with next step */
|
||||
ctx->step++;
|
||||
interface_initialization_step (ctx);
|
||||
@@ -1897,8 +1821,7 @@ crm_range_ready (MMBaseModem *modem,
|
||||
error = g_error_new (MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Requested RM protocol '%s' is not supported",
|
||||
mm_modem_cdma_rm_protocol_get_string (
|
||||
ctx->self->priv->rm_protocol));
|
||||
mm_modem_cdma_rm_protocol_get_string (current));
|
||||
}
|
||||
|
||||
/* Failed, set as fatal as well */
|
||||
@@ -1933,7 +1856,7 @@ modem_3gpp_registration_state_changed (MMBroadbandModem *modem,
|
||||
self->priv->reason_3gpp = CONNECTION_FORBIDDEN_REASON_NONE;
|
||||
break;
|
||||
case MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING:
|
||||
if (self->priv->allow_roaming) {
|
||||
if (mm_bearer_properties_get_allow_roaming (mm_bearer_peek_config (MM_BEARER (self)))) {
|
||||
mm_dbg ("Bearer allowed to connect, registered in roaming network");
|
||||
self->priv->reason_3gpp = CONNECTION_FORBIDDEN_REASON_NONE;
|
||||
} else {
|
||||
@@ -1964,7 +1887,7 @@ modem_cdma_registration_state_changed (MMBroadbandModem *modem,
|
||||
|
||||
if (cdma1x_state == MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING ||
|
||||
evdo_state == MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING) {
|
||||
if (self->priv->allow_roaming) {
|
||||
if (mm_bearer_properties_get_allow_roaming (mm_bearer_peek_config (MM_BEARER (self)))) {
|
||||
mm_dbg ("Bearer allowed to connect, registered in roaming network");
|
||||
self->priv->reason_cdma = CONNECTION_FORBIDDEN_REASON_NONE;
|
||||
} else {
|
||||
@@ -1998,7 +1921,8 @@ interface_initialization_step (InitAsyncContext *ctx)
|
||||
/* If a specific RM protocol is given, we need to check whether it is
|
||||
* supported. */
|
||||
if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (ctx->modem)) &&
|
||||
ctx->self->priv->rm_protocol != MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
|
||||
mm_bearer_properties_get_rm_protocol (
|
||||
mm_bearer_peek_config (MM_BEARER (ctx->self))) != MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
|
||||
mm_base_modem_at_command_full (ctx->modem,
|
||||
ctx->port,
|
||||
"+CRM=?",
|
||||
@@ -2106,78 +2030,11 @@ mm_broadband_bearer_new (MMBroadbandModem *modem,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data,
|
||||
MM_BEARER_MODEM, modem,
|
||||
MM_BROADBAND_BEARER_3GPP_APN, mm_bearer_properties_get_apn (properties),
|
||||
MM_BROADBAND_BEARER_CDMA_NUMBER, mm_bearer_properties_get_number (properties),
|
||||
MM_BROADBAND_BEARER_CDMA_RM_PROTOCOL, mm_bearer_properties_get_rm_protocol (properties),
|
||||
MM_BROADBAND_BEARER_IP_TYPE, mm_bearer_properties_get_ip_type (properties),
|
||||
MM_BROADBAND_BEARER_ALLOW_ROAMING, mm_bearer_properties_get_allow_roaming (properties),
|
||||
MM_BEARER_MODEM, modem,
|
||||
MM_BEARER_CONFIG, properties,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBroadbandBearer *self = MM_BROADBAND_BEARER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_3GPP_APN:
|
||||
g_free (self->priv->apn);
|
||||
self->priv->apn = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CDMA_NUMBER:
|
||||
g_free (self->priv->number);
|
||||
self->priv->number = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CDMA_RM_PROTOCOL:
|
||||
self->priv->rm_protocol = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_IP_TYPE:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBroadbandBearer *self = MM_BROADBAND_BEARER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_3GPP_APN:
|
||||
g_value_set_string (value, self->priv->apn);
|
||||
break;
|
||||
case PROP_CDMA_NUMBER:
|
||||
g_value_set_string (value, self->priv->number);
|
||||
break;
|
||||
case PROP_CDMA_RM_PROTOCOL:
|
||||
g_value_set_enum (value, self->priv->rm_protocol);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_bearer_init (MMBroadbandBearer *self)
|
||||
{
|
||||
@@ -2188,8 +2045,6 @@ mm_broadband_bearer_init (MMBroadbandBearer *self)
|
||||
|
||||
/* Set defaults */
|
||||
self->priv->connection_type = CONNECTION_TYPE_NONE;
|
||||
self->priv->allow_roaming = TRUE;
|
||||
self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN;
|
||||
self->priv->reason_3gpp = CONNECTION_FORBIDDEN_REASON_NONE;
|
||||
self->priv->reason_cdma = CONNECTION_FORBIDDEN_REASON_NONE;
|
||||
}
|
||||
@@ -2224,17 +2079,6 @@ dispose (GObject *object)
|
||||
G_OBJECT_CLASS (mm_broadband_bearer_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
MMBroadbandBearer *self = MM_BROADBAND_BEARER (object);
|
||||
|
||||
g_free (self->priv->apn);
|
||||
g_free (self->priv->ip_type);
|
||||
|
||||
G_OBJECT_CLASS (mm_broadband_bearer_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
async_initable_iface_init (GAsyncInitableIface *iface)
|
||||
{
|
||||
@@ -2251,13 +2095,8 @@ mm_broadband_bearer_class_init (MMBroadbandBearerClass *klass)
|
||||
g_type_class_add_private (object_class, sizeof (MMBroadbandBearerPrivate));
|
||||
|
||||
/* Virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->dispose = dispose;
|
||||
|
||||
bearer_class->cmp_properties = cmp_properties;
|
||||
bearer_class->expose_properties = expose_properties;
|
||||
bearer_class->connect = connect;
|
||||
bearer_class->connect_finish = connect_finish;
|
||||
bearer_class->disconnect = disconnect;
|
||||
@@ -2276,45 +2115,4 @@ mm_broadband_bearer_class_init (MMBroadbandBearerClass *klass)
|
||||
klass->disconnect_3gpp_finish = detailed_disconnect_finish;
|
||||
klass->disconnect_cdma = disconnect_cdma;
|
||||
klass->disconnect_cdma_finish = detailed_disconnect_finish;
|
||||
|
||||
properties[PROP_3GPP_APN] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_3GPP_APN,
|
||||
"3GPP APN",
|
||||
"Access Point Name to use in the connection",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_3GPP_APN, properties[PROP_3GPP_APN]);
|
||||
|
||||
properties[PROP_CDMA_NUMBER] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_CDMA_NUMBER,
|
||||
"Number to dial",
|
||||
"Number to dial when launching the CDMA connection",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_CDMA_NUMBER, properties[PROP_CDMA_NUMBER]);
|
||||
|
||||
properties[PROP_CDMA_RM_PROTOCOL] =
|
||||
g_param_spec_enum (MM_BROADBAND_BEARER_CDMA_RM_PROTOCOL,
|
||||
"Rm Protocol",
|
||||
"Protocol to use in the CDMA Rm interface",
|
||||
MM_TYPE_MODEM_CDMA_RM_PROTOCOL,
|
||||
MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_CDMA_RM_PROTOCOL, properties[PROP_CDMA_RM_PROTOCOL]);
|
||||
|
||||
properties[PROP_IP_TYPE] =
|
||||
g_param_spec_string (MM_BROADBAND_BEARER_IP_TYPE,
|
||||
"IP type",
|
||||
"IP setup to use in the connection",
|
||||
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_BROADBAND_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]);
|
||||
}
|
||||
|
||||
@@ -146,11 +146,6 @@ void mm_broadband_bearer_new (MMBroadbandModem *modem,
|
||||
MMBearer *mm_broadband_bearer_new_finish (GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
const gchar *mm_broadband_bearer_get_3gpp_apn (MMBroadbandBearer *self);
|
||||
guint mm_broadband_bearer_get_cdma_rm_protocol (MMBroadbandBearer *self);
|
||||
const gchar *mm_broadband_bearer_get_ip_type (MMBroadbandBearer *self);
|
||||
gboolean mm_broadband_bearer_get_allow_roaming (MMBroadbandBearer *self);
|
||||
|
||||
guint mm_broadband_bearer_get_3gpp_cid (MMBroadbandBearer *self);
|
||||
|
||||
#endif /* MM_BROADBAND_BEARER_H */
|
||||
|
||||
Reference in New Issue
Block a user