bearer,3gpp: dial operation specifies which data port to use
Instead of deciding in advance which data port to use, we let the dialling operation gather it. For the generic dialling logic, ATD-based, always an 'AT' port will be used as data port, even if we grabbed a 'net' port. Those plugins that can work with 'net' ports will grab the specific 'net' port themselves.
This commit is contained in:
@@ -329,7 +329,6 @@ connect_3gpp (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMAtSerialPort *secondary,
|
||||
MMPort *data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@@ -343,7 +342,6 @@ connect_3gpp (MMBroadbandBearer *self,
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->data = g_object_ref (data);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -354,6 +352,19 @@ connect_3gpp (MMBroadbandBearer *self,
|
||||
g_assert (ctx->self->priv->connect_pending == NULL);
|
||||
g_assert (ctx->self->priv->disconnect_pending == NULL);
|
||||
|
||||
/* We need a net data port */
|
||||
ctx->data = mm_base_modem_get_best_data_port (MM_BASE_MODEM (modem),
|
||||
MM_PORT_TYPE_NET);
|
||||
if (!ctx->data) {
|
||||
g_simple_async_result_set_error (
|
||||
ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_NOT_FOUND,
|
||||
"No valid data port found to launch connection");
|
||||
connect_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Run! */
|
||||
connect_3gpp_context_step (ctx);
|
||||
}
|
||||
|
||||
@@ -1368,7 +1368,7 @@ huawei_modem_create_bearer (MMIfaceModem *self,
|
||||
user_data,
|
||||
huawei_modem_create_bearer);
|
||||
|
||||
if (mm_port_get_port_type (mm_base_modem_peek_best_data_port (MM_BASE_MODEM (self))) == MM_PORT_TYPE_NET) {
|
||||
if (mm_base_modem_peek_best_data_port (MM_BASE_MODEM (self), MM_PORT_TYPE_NET)) {
|
||||
/* If we get a 'net' port, check if driver is 'cdc_ether' or 'cdc_ncm' */
|
||||
const gchar **drivers;
|
||||
guint i;
|
||||
|
||||
@@ -504,44 +504,23 @@ typedef struct {
|
||||
guint cid;
|
||||
GCancellable *cancellable;
|
||||
GSimpleAsyncResult *result;
|
||||
MMPort *data;
|
||||
guint authentication_retries;
|
||||
GError *saved_error;
|
||||
} Dial3gppContext;
|
||||
|
||||
static Dial3gppContext *
|
||||
dial_3gpp_context_new (MMBroadbandBearerIcera *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
ctx = g_new0 (Dial3gppContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
dial_3gpp_context_new);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
if (ctx->data)
|
||||
g_object_unref (ctx->data);
|
||||
g_object_unref (ctx->cancellable);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
g_slice_free (Dial3gppContext, ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -571,12 +550,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static MMPort *
|
||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
return MM_PORT (g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -764,7 +746,9 @@ report_connect_status (MMBroadbandBearerIcera *self,
|
||||
return;
|
||||
}
|
||||
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||
g_object_ref (ctx->data),
|
||||
(GDestroyNotify)g_object_unref);
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
|
||||
@@ -1039,21 +1023,39 @@ static void
|
||||
dial_3gpp (MMBroadbandBearer *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMPort *data, /* unused by us */
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
authenticate (dial_3gpp_context_new (MM_BROADBAND_BEARER_ICERA (self),
|
||||
modem,
|
||||
primary,
|
||||
cid,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data));
|
||||
ctx = g_slice_new0 (Dial3gppContext);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
dial_3gpp);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
|
||||
/* We need a net data port */
|
||||
ctx->data = mm_base_modem_get_best_data_port (modem, MM_PORT_TYPE_NET);
|
||||
if (!ctx->data) {
|
||||
g_simple_async_result_set_error (
|
||||
ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_NOT_FOUND,
|
||||
"No valid data port found to launch connection");
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
authenticate (ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -732,25 +732,6 @@ broadband_bearer_icera_new_ready (GObject *source,
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
static void
|
||||
broadband_bearer_new_ready (GObject *source,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
{
|
||||
MMBearer *bearer = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
bearer = mm_broadband_bearer_new_finish (res, &error);
|
||||
if (!bearer)
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
else
|
||||
g_simple_async_result_set_op_res_gpointer (simple,
|
||||
bearer,
|
||||
(GDestroyNotify)g_object_unref);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_create_bearer (MMIfaceModem *self,
|
||||
MMBearerProperties *properties,
|
||||
@@ -764,17 +745,6 @@ modem_create_bearer (MMIfaceModem *self,
|
||||
user_data,
|
||||
modem_create_bearer);
|
||||
|
||||
/* If data port is AT create a generic bearer */
|
||||
if (MM_IS_AT_SERIAL_PORT (mm_base_modem_peek_best_data_port (MM_BASE_MODEM (self)))) {
|
||||
mm_broadband_bearer_new (
|
||||
MM_BROADBAND_MODEM (self),
|
||||
properties,
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)broadband_bearer_new_ready,
|
||||
result);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Otherwise create a Icera bearer */
|
||||
mm_broadband_bearer_icera_new (
|
||||
MM_BROADBAND_MODEM (self),
|
||||
|
||||
@@ -57,46 +57,23 @@ typedef struct {
|
||||
MMAtSerialPort *primary;
|
||||
guint cid;
|
||||
GCancellable *cancellable;
|
||||
MMPort *data;
|
||||
GSimpleAsyncResult *result;
|
||||
guint poll_count;
|
||||
} Dial3gppContext;
|
||||
|
||||
static Dial3gppContext *
|
||||
dial_3gpp_context_new (MMBroadbandBearerMbm *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
ctx = g_new0 (Dial3gppContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
dial_3gpp_context_new);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
ctx->poll_count = 0;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete (ctx->result);
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
if (ctx->data)
|
||||
g_object_unref (ctx->data);
|
||||
g_object_unref (ctx->cancellable);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
g_slice_free (Dial3gppContext, ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -126,12 +103,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static MMPort *
|
||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
return MM_PORT (g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -164,7 +144,9 @@ mm_broadband_bearer_mbm_report_connection_status (MMBroadbandBearerMbm *self,
|
||||
if (!ctx)
|
||||
break;
|
||||
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||
g_object_ref (ctx->data),
|
||||
(GDestroyNotify)g_object_unref);
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
|
||||
@@ -433,21 +415,40 @@ static void
|
||||
dial_3gpp (MMBroadbandBearer *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMPort *data, /* unused by us */
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
authenticate (dial_3gpp_context_new (MM_BROADBAND_BEARER_MBM (self),
|
||||
modem,
|
||||
primary,
|
||||
cid,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data));
|
||||
ctx = g_slice_new0 (Dial3gppContext);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
dial_3gpp);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
ctx->poll_count = 0;
|
||||
|
||||
/* We need a net data port */
|
||||
ctx->data = mm_base_modem_get_best_data_port (modem, MM_PORT_TYPE_NET);
|
||||
if (!ctx->data) {
|
||||
g_simple_async_result_set_error (
|
||||
ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_NOT_FOUND,
|
||||
"No valid data port found to launch connection");
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
authenticate (ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -55,45 +55,18 @@ typedef struct {
|
||||
gint retries;
|
||||
} DetailedConnectContext;
|
||||
|
||||
static DetailedConnectContext *
|
||||
detailed_connect_context_new (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMPort *data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
DetailedConnectContext *ctx;
|
||||
|
||||
ctx = g_new0 (DetailedConnectContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->data = g_object_ref (data);
|
||||
/* NOTE:
|
||||
* We don't currently support cancelling AT commands, so we'll just check
|
||||
* whether the operation is to be cancelled at each step. */
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
detailed_connect_context_new);
|
||||
ctx->retries = 4;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->cancellable);
|
||||
g_object_unref (ctx->data);
|
||||
if (ctx->data)
|
||||
g_object_unref (ctx->data);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
g_slice_free (DetailedConnectContext, ctx);
|
||||
}
|
||||
|
||||
static MMBearerConnectResult *
|
||||
@@ -264,28 +237,12 @@ connect_3gpp_qmiconnect_ready (MMBaseModem *modem,
|
||||
}
|
||||
|
||||
static void
|
||||
connect_3gpp (MMBroadbandBearer *bearer,
|
||||
MMBroadbandModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMAtSerialPort *secondary,
|
||||
MMPort *data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
connect_3gpp_authenticate (DetailedConnectContext *ctx)
|
||||
{
|
||||
DetailedConnectContext *ctx;
|
||||
gchar *command, *apn, *user, *password;
|
||||
MMBearerProperties *config;
|
||||
gchar *command, *apn, *user, *password;
|
||||
|
||||
ctx = detailed_connect_context_new (bearer,
|
||||
modem,
|
||||
primary,
|
||||
data,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
|
||||
config = mm_bearer_peek_config (MM_BEARER (bearer));
|
||||
config = mm_bearer_peek_config (MM_BEARER (ctx->self));
|
||||
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));
|
||||
@@ -304,6 +261,44 @@ connect_3gpp (MMBroadbandBearer *bearer,
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_3gpp (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMAtSerialPort *secondary,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
DetailedConnectContext *ctx;
|
||||
|
||||
ctx = g_slice_new0 (DetailedConnectContext);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
connect_3gpp);
|
||||
ctx->retries = 4;
|
||||
|
||||
/* Get a 'net' data port */
|
||||
ctx->data = mm_base_modem_peek_best_data_port (MM_BASE_MODEM (modem),
|
||||
MM_PORT_TYPE_NET);
|
||||
if (!ctx->data) {
|
||||
g_simple_async_result_set_error (
|
||||
ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_CONNECTED,
|
||||
"Couldn't connect: no available net port available");
|
||||
detailed_connect_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
connect_3gpp_authenticate (ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 3GPP Disonnection sequence */
|
||||
|
||||
|
||||
@@ -54,28 +54,6 @@ typedef struct {
|
||||
GSimpleAsyncResult *result;
|
||||
} GetIpConfig3gppContext;
|
||||
|
||||
static GetIpConfig3gppContext *
|
||||
get_ip_config_3gpp_context_new (MMBroadbandBearerHso *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
guint cid,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GetIpConfig3gppContext *ctx;
|
||||
|
||||
ctx = g_new0 (GetIpConfig3gppContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
get_ip_config_3gpp_context_new);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
get_ip_config_context_complete_and_free (GetIpConfig3gppContext *ctx)
|
||||
{
|
||||
@@ -84,7 +62,7 @@ get_ip_config_context_complete_and_free (GetIpConfig3gppContext *ctx)
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
g_slice_free (GetIpConfig3gppContext, ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -210,8 +188,19 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GetIpConfig3gppContext *ctx;
|
||||
gchar *command;
|
||||
|
||||
ctx = g_slice_new0 (GetIpConfig3gppContext);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
get_ip_config_3gpp);
|
||||
|
||||
command = g_strdup_printf ("AT_OWANDATA=%d", cid);
|
||||
mm_base_modem_at_command_full (
|
||||
MM_BASE_MODEM (modem),
|
||||
@@ -222,12 +211,7 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
|
||||
FALSE, /* raw */
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)ip_config_ready,
|
||||
get_ip_config_3gpp_context_new (MM_BROADBAND_BEARER_HSO (self),
|
||||
MM_BASE_MODEM (modem),
|
||||
primary,
|
||||
cid,
|
||||
callback,
|
||||
user_data));
|
||||
ctx);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
@@ -241,49 +225,23 @@ typedef struct {
|
||||
guint cid;
|
||||
GCancellable *cancellable;
|
||||
GSimpleAsyncResult *result;
|
||||
MMPort *data;
|
||||
guint auth_idx;
|
||||
GError *saved_error;
|
||||
} Dial3gppContext;
|
||||
|
||||
static Dial3gppContext *
|
||||
dial_3gpp_context_new (MMBroadbandBearerHso *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
ctx = g_new0 (Dial3gppContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
dial_3gpp_context_new);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
|
||||
/* Always start with the index that worked last time
|
||||
* (will be 0 the first time)*/
|
||||
ctx->auth_idx = self->priv->auth_idx;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
if (ctx->data)
|
||||
g_object_unref (ctx->data);
|
||||
g_object_unref (ctx->cancellable);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
g_slice_free (Dial3gppContext, ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -313,12 +271,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static MMPort *
|
||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
return MM_PORT (g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -400,7 +361,9 @@ mm_broadband_bearer_hso_report_connection_status (MMBroadbandBearerHso *self,
|
||||
return;
|
||||
}
|
||||
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||
g_object_ref (ctx->data),
|
||||
(GDestroyNotify)g_object_unref);
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
|
||||
@@ -713,21 +676,43 @@ static void
|
||||
dial_3gpp (MMBroadbandBearer *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMPort *data, /* unused by us */
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
authenticate (dial_3gpp_context_new (MM_BROADBAND_BEARER_HSO (self),
|
||||
modem,
|
||||
primary,
|
||||
cid,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data));
|
||||
ctx = g_slice_new0 (Dial3gppContext);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
dial_3gpp);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
|
||||
/* Always start with the index that worked last time
|
||||
* (will be 0 the first time)*/
|
||||
ctx->auth_idx = ctx->self->priv->auth_idx;
|
||||
|
||||
/* We need a net data port */
|
||||
ctx->data = mm_base_modem_get_best_data_port (modem, MM_PORT_TYPE_NET);
|
||||
if (!ctx->data) {
|
||||
g_simple_async_result_set_error (
|
||||
ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_NOT_FOUND,
|
||||
"No valid data port found to launch connection");
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
authenticate (ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -69,12 +69,15 @@ dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
||||
g_slice_free (Dial3gppContext, ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static MMPort *
|
||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
return MM_PORT (g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))));
|
||||
}
|
||||
|
||||
static void dial_3gpp_context_step (Dial3gppContext *ctx);
|
||||
@@ -86,7 +89,8 @@ parent_dial_3gpp_ready (MMBroadbandBearer *self,
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_sierra_parent_class)->dial_3gpp_finish (self, res, &error)) {
|
||||
ctx->data = MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_sierra_parent_class)->dial_3gpp_finish (self, res, &error);
|
||||
if (!ctx->data) {
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
@@ -251,7 +255,9 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
|
||||
ctx->step++;
|
||||
|
||||
case DIAL_3GPP_STEP_CONNECT:
|
||||
if (!MM_IS_AT_SERIAL_PORT (ctx->data)) {
|
||||
/* We need a net or AT data port */
|
||||
ctx->data = mm_base_modem_get_best_data_port (ctx->modem, MM_PORT_TYPE_NET);
|
||||
if (ctx->data) {
|
||||
gchar *command;
|
||||
|
||||
command = g_strdup_printf ("!SCACT=1,%d", ctx->cid);
|
||||
@@ -273,7 +279,6 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
|
||||
MM_BROADBAND_BEARER (ctx->self),
|
||||
ctx->modem,
|
||||
ctx->primary,
|
||||
ctx->data,
|
||||
ctx->cid,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)parent_dial_3gpp_ready,
|
||||
@@ -281,7 +286,9 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
|
||||
return;
|
||||
|
||||
case DIAL_3GPP_STEP_LAST:
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||
g_object_ref (ctx->data),
|
||||
(GDestroyNotify)g_object_unref);
|
||||
dial_3gpp_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
@@ -291,7 +298,6 @@ static void
|
||||
dial_3gpp (MMBroadbandBearer *self,
|
||||
MMBaseModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMPort *data,
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
@@ -311,7 +317,6 @@ dial_3gpp (MMBroadbandBearer *self,
|
||||
user_data,
|
||||
dial_3gpp);
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
ctx->data = g_object_ref (data);
|
||||
ctx->step = DIAL_3GPP_STEP_FIRST;
|
||||
|
||||
dial_3gpp_context_step (ctx);
|
||||
|
||||
Reference in New Issue
Block a user