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,
|
MMBroadbandModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMAtSerialPort *secondary,
|
MMAtSerialPort *secondary,
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -343,7 +342,6 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->modem = g_object_ref (modem);
|
ctx->modem = g_object_ref (modem);
|
||||||
ctx->primary = g_object_ref (primary);
|
ctx->primary = g_object_ref (primary);
|
||||||
ctx->data = g_object_ref (data);
|
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
@@ -354,6 +352,19 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
g_assert (ctx->self->priv->connect_pending == NULL);
|
g_assert (ctx->self->priv->connect_pending == NULL);
|
||||||
g_assert (ctx->self->priv->disconnect_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! */
|
/* Run! */
|
||||||
connect_3gpp_context_step (ctx);
|
connect_3gpp_context_step (ctx);
|
||||||
}
|
}
|
||||||
|
@@ -1368,7 +1368,7 @@ huawei_modem_create_bearer (MMIfaceModem *self,
|
|||||||
user_data,
|
user_data,
|
||||||
huawei_modem_create_bearer);
|
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' */
|
/* If we get a 'net' port, check if driver is 'cdc_ether' or 'cdc_ncm' */
|
||||||
const gchar **drivers;
|
const gchar **drivers;
|
||||||
guint i;
|
guint i;
|
||||||
|
@@ -504,44 +504,23 @@ typedef struct {
|
|||||||
guint cid;
|
guint cid;
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
|
MMPort *data;
|
||||||
guint authentication_retries;
|
guint authentication_retries;
|
||||||
GError *saved_error;
|
GError *saved_error;
|
||||||
} Dial3gppContext;
|
} 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
|
static void
|
||||||
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (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->cancellable);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_free (ctx);
|
g_slice_free (Dial3gppContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -571,12 +550,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static MMPort *
|
||||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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
|
static void
|
||||||
@@ -764,7 +746,9 @@ report_connect_status (MMBroadbandBearerIcera *self,
|
|||||||
return;
|
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);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1039,21 +1023,39 @@ static void
|
|||||||
dial_3gpp (MMBroadbandBearer *self,
|
dial_3gpp (MMBroadbandBearer *self,
|
||||||
MMBaseModem *modem,
|
MMBaseModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMPort *data, /* unused by us */
|
|
||||||
guint cid,
|
guint cid,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
Dial3gppContext *ctx;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
g_assert (primary != NULL);
|
||||||
|
|
||||||
authenticate (dial_3gpp_context_new (MM_BROADBAND_BEARER_ICERA (self),
|
ctx = g_slice_new0 (Dial3gppContext);
|
||||||
modem,
|
ctx->self = g_object_ref (self);
|
||||||
primary,
|
ctx->modem = g_object_ref (modem);
|
||||||
cid,
|
ctx->primary = g_object_ref (primary);
|
||||||
cancellable,
|
ctx->cid = cid;
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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);
|
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
|
static void
|
||||||
modem_create_bearer (MMIfaceModem *self,
|
modem_create_bearer (MMIfaceModem *self,
|
||||||
MMBearerProperties *properties,
|
MMBearerProperties *properties,
|
||||||
@@ -764,17 +745,6 @@ modem_create_bearer (MMIfaceModem *self,
|
|||||||
user_data,
|
user_data,
|
||||||
modem_create_bearer);
|
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 */
|
/* Otherwise create a Icera bearer */
|
||||||
mm_broadband_bearer_icera_new (
|
mm_broadband_bearer_icera_new (
|
||||||
MM_BROADBAND_MODEM (self),
|
MM_BROADBAND_MODEM (self),
|
||||||
|
@@ -57,46 +57,23 @@ typedef struct {
|
|||||||
MMAtSerialPort *primary;
|
MMAtSerialPort *primary;
|
||||||
guint cid;
|
guint cid;
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
|
MMPort *data;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
guint poll_count;
|
guint poll_count;
|
||||||
} Dial3gppContext;
|
} 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
|
static void
|
||||||
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
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->cancellable);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_free (ctx);
|
g_slice_free (Dial3gppContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -126,12 +103,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static MMPort *
|
||||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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
|
void
|
||||||
@@ -164,7 +144,9 @@ mm_broadband_bearer_mbm_report_connection_status (MMBroadbandBearerMbm *self,
|
|||||||
if (!ctx)
|
if (!ctx)
|
||||||
break;
|
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);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -433,21 +415,40 @@ static void
|
|||||||
dial_3gpp (MMBroadbandBearer *self,
|
dial_3gpp (MMBroadbandBearer *self,
|
||||||
MMBaseModem *modem,
|
MMBaseModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMPort *data, /* unused by us */
|
|
||||||
guint cid,
|
guint cid,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
Dial3gppContext *ctx;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
g_assert (primary != NULL);
|
||||||
|
|
||||||
authenticate (dial_3gpp_context_new (MM_BROADBAND_BEARER_MBM (self),
|
ctx = g_slice_new0 (Dial3gppContext);
|
||||||
modem,
|
ctx->self = g_object_ref (self);
|
||||||
primary,
|
ctx->modem = g_object_ref (modem);
|
||||||
cid,
|
ctx->primary = g_object_ref (primary);
|
||||||
cancellable,
|
ctx->cid = cid;
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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;
|
gint retries;
|
||||||
} DetailedConnectContext;
|
} 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
|
static void
|
||||||
detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
|
detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
|
if (ctx->data)
|
||||||
g_object_unref (ctx->data);
|
g_object_unref (ctx->data);
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_free (ctx);
|
g_slice_free (DetailedConnectContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MMBearerConnectResult *
|
static MMBearerConnectResult *
|
||||||
@@ -264,28 +237,12 @@ connect_3gpp_qmiconnect_ready (MMBaseModem *modem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_3gpp (MMBroadbandBearer *bearer,
|
connect_3gpp_authenticate (DetailedConnectContext *ctx)
|
||||||
MMBroadbandModem *modem,
|
|
||||||
MMAtSerialPort *primary,
|
|
||||||
MMAtSerialPort *secondary,
|
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GAsyncReadyCallback callback,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
DetailedConnectContext *ctx;
|
|
||||||
gchar *command, *apn, *user, *password;
|
|
||||||
MMBearerProperties *config;
|
MMBearerProperties *config;
|
||||||
|
gchar *command, *apn, *user, *password;
|
||||||
|
|
||||||
ctx = detailed_connect_context_new (bearer,
|
config = mm_bearer_peek_config (MM_BEARER (ctx->self));
|
||||||
modem,
|
|
||||||
primary,
|
|
||||||
data,
|
|
||||||
cancellable,
|
|
||||||
callback,
|
|
||||||
user_data);
|
|
||||||
|
|
||||||
config = mm_bearer_peek_config (MM_BEARER (bearer));
|
|
||||||
apn = mm_at_serial_port_quote_string (mm_bearer_properties_get_apn (config));
|
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));
|
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));
|
password = mm_at_serial_port_quote_string (mm_bearer_properties_get_password (config));
|
||||||
@@ -304,6 +261,44 @@ connect_3gpp (MMBroadbandBearer *bearer,
|
|||||||
g_free (command);
|
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 */
|
/* 3GPP Disonnection sequence */
|
||||||
|
|
||||||
|
@@ -54,28 +54,6 @@ typedef struct {
|
|||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
} GetIpConfig3gppContext;
|
} 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
|
static void
|
||||||
get_ip_config_context_complete_and_free (GetIpConfig3gppContext *ctx)
|
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->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_free (ctx);
|
g_slice_free (GetIpConfig3gppContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -210,8 +188,19 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GetIpConfig3gppContext *ctx;
|
||||||
gchar *command;
|
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);
|
command = g_strdup_printf ("AT_OWANDATA=%d", cid);
|
||||||
mm_base_modem_at_command_full (
|
mm_base_modem_at_command_full (
|
||||||
MM_BASE_MODEM (modem),
|
MM_BASE_MODEM (modem),
|
||||||
@@ -222,12 +211,7 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
|
|||||||
FALSE, /* raw */
|
FALSE, /* raw */
|
||||||
NULL, /* cancellable */
|
NULL, /* cancellable */
|
||||||
(GAsyncReadyCallback)ip_config_ready,
|
(GAsyncReadyCallback)ip_config_ready,
|
||||||
get_ip_config_3gpp_context_new (MM_BROADBAND_BEARER_HSO (self),
|
ctx);
|
||||||
MM_BASE_MODEM (modem),
|
|
||||||
primary,
|
|
||||||
cid,
|
|
||||||
callback,
|
|
||||||
user_data));
|
|
||||||
g_free (command);
|
g_free (command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,49 +225,23 @@ typedef struct {
|
|||||||
guint cid;
|
guint cid;
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
|
MMPort *data;
|
||||||
guint auth_idx;
|
guint auth_idx;
|
||||||
GError *saved_error;
|
GError *saved_error;
|
||||||
} Dial3gppContext;
|
} 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
|
static void
|
||||||
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (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->cancellable);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_free (ctx);
|
g_slice_free (Dial3gppContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -313,12 +271,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static MMPort *
|
||||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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
|
static void
|
||||||
@@ -400,7 +361,9 @@ mm_broadband_bearer_hso_report_connection_status (MMBroadbandBearerHso *self,
|
|||||||
return;
|
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);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -713,21 +676,43 @@ static void
|
|||||||
dial_3gpp (MMBroadbandBearer *self,
|
dial_3gpp (MMBroadbandBearer *self,
|
||||||
MMBaseModem *modem,
|
MMBaseModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMPort *data, /* unused by us */
|
|
||||||
guint cid,
|
guint cid,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
Dial3gppContext *ctx;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
g_assert (primary != NULL);
|
||||||
|
|
||||||
authenticate (dial_3gpp_context_new (MM_BROADBAND_BEARER_HSO (self),
|
ctx = g_slice_new0 (Dial3gppContext);
|
||||||
modem,
|
ctx->self = g_object_ref (self);
|
||||||
primary,
|
ctx->modem = g_object_ref (modem);
|
||||||
cid,
|
ctx->primary = g_object_ref (primary);
|
||||||
cancellable,
|
ctx->cid = cid;
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
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);
|
g_slice_free (Dial3gppContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static MMPort *
|
||||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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);
|
static void dial_3gpp_context_step (Dial3gppContext *ctx);
|
||||||
@@ -86,7 +89,8 @@ parent_dial_3gpp_ready (MMBroadbandBearer *self,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
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);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
dial_3gpp_context_complete_and_free (ctx);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
@@ -251,7 +255,9 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
|
|||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
case DIAL_3GPP_STEP_CONNECT:
|
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;
|
gchar *command;
|
||||||
|
|
||||||
command = g_strdup_printf ("!SCACT=1,%d", ctx->cid);
|
command = g_strdup_printf ("!SCACT=1,%d", ctx->cid);
|
||||||
@@ -273,7 +279,6 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
|
|||||||
MM_BROADBAND_BEARER (ctx->self),
|
MM_BROADBAND_BEARER (ctx->self),
|
||||||
ctx->modem,
|
ctx->modem,
|
||||||
ctx->primary,
|
ctx->primary,
|
||||||
ctx->data,
|
|
||||||
ctx->cid,
|
ctx->cid,
|
||||||
ctx->cancellable,
|
ctx->cancellable,
|
||||||
(GAsyncReadyCallback)parent_dial_3gpp_ready,
|
(GAsyncReadyCallback)parent_dial_3gpp_ready,
|
||||||
@@ -281,7 +286,9 @@ dial_3gpp_context_step (Dial3gppContext *ctx)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case DIAL_3GPP_STEP_LAST:
|
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);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -291,7 +298,6 @@ static void
|
|||||||
dial_3gpp (MMBroadbandBearer *self,
|
dial_3gpp (MMBroadbandBearer *self,
|
||||||
MMBaseModem *modem,
|
MMBaseModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMPort *data,
|
|
||||||
guint cid,
|
guint cid,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
@@ -311,7 +317,6 @@ dial_3gpp (MMBroadbandBearer *self,
|
|||||||
user_data,
|
user_data,
|
||||||
dial_3gpp);
|
dial_3gpp);
|
||||||
ctx->cancellable = g_object_ref (cancellable);
|
ctx->cancellable = g_object_ref (cancellable);
|
||||||
ctx->data = g_object_ref (data);
|
|
||||||
ctx->step = DIAL_3GPP_STEP_FIRST;
|
ctx->step = DIAL_3GPP_STEP_FIRST;
|
||||||
|
|
||||||
dial_3gpp_context_step (ctx);
|
dial_3gpp_context_step (ctx);
|
||||||
|
@@ -699,16 +699,18 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self,
|
|||||||
#endif /* WITH_QMI */
|
#endif /* WITH_QMI */
|
||||||
|
|
||||||
MMPort *
|
MMPort *
|
||||||
mm_base_modem_get_best_data_port (MMBaseModem *self)
|
mm_base_modem_get_best_data_port (MMBaseModem *self,
|
||||||
|
MMPortType type)
|
||||||
{
|
{
|
||||||
MMPort *port;
|
MMPort *port;
|
||||||
|
|
||||||
port = mm_base_modem_peek_best_data_port (self);
|
port = mm_base_modem_peek_best_data_port (self, type);
|
||||||
return (port ? g_object_ref (port) : NULL);
|
return (port ? g_object_ref (port) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPort *
|
MMPort *
|
||||||
mm_base_modem_peek_best_data_port (MMBaseModem *self)
|
mm_base_modem_peek_best_data_port (MMBaseModem *self,
|
||||||
|
MMPortType type)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
@@ -716,9 +718,12 @@ mm_base_modem_peek_best_data_port (MMBaseModem *self)
|
|||||||
|
|
||||||
/* Return first not-connected data port */
|
/* Return first not-connected data port */
|
||||||
for (l = self->priv->data; l; l = g_list_next (l)) {
|
for (l = self->priv->data; l; l = g_list_next (l)) {
|
||||||
if (!mm_port_get_connected ((MMPort *)l->data))
|
if (!mm_port_get_connected ((MMPort *)l->data) &&
|
||||||
|
(mm_port_get_port_type ((MMPort *)l->data) == type ||
|
||||||
|
type == MM_PORT_TYPE_UNKNOWN)) {
|
||||||
return (MMPort *)l->data;
|
return (MMPort *)l->data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -127,7 +127,7 @@ MMQmiPort *mm_base_modem_peek_port_qmi (MMBaseModem *self);
|
|||||||
MMQmiPort *mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error);
|
MMQmiPort *mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error);
|
||||||
#endif
|
#endif
|
||||||
MMAtSerialPort *mm_base_modem_peek_best_at_port (MMBaseModem *self, GError **error);
|
MMAtSerialPort *mm_base_modem_peek_best_at_port (MMBaseModem *self, GError **error);
|
||||||
MMPort *mm_base_modem_peek_best_data_port (MMBaseModem *self);
|
MMPort *mm_base_modem_peek_best_data_port (MMBaseModem *self, MMPortType type);
|
||||||
GList *mm_base_modem_peek_data_ports (MMBaseModem *self);
|
GList *mm_base_modem_peek_data_ports (MMBaseModem *self);
|
||||||
|
|
||||||
MMAtSerialPort *mm_base_modem_get_port_primary (MMBaseModem *self);
|
MMAtSerialPort *mm_base_modem_get_port_primary (MMBaseModem *self);
|
||||||
@@ -140,7 +140,7 @@ MMQmiPort *mm_base_modem_get_port_qmi (MMBaseModem *self);
|
|||||||
MMQmiPort *mm_base_modem_get_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error);
|
MMQmiPort *mm_base_modem_get_port_qmi_for_data (MMBaseModem *self, MMPort *data, GError **error);
|
||||||
#endif
|
#endif
|
||||||
MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self, GError **error);
|
MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self, GError **error);
|
||||||
MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self);
|
MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self, MMPortType type);
|
||||||
GList *mm_base_modem_get_data_ports (MMBaseModem *self);
|
GList *mm_base_modem_get_data_ports (MMBaseModem *self);
|
||||||
|
|
||||||
void mm_base_modem_set_hotplugged (MMBaseModem *self,
|
void mm_base_modem_set_hotplugged (MMBaseModem *self,
|
||||||
|
@@ -791,7 +791,7 @@ _connect (MMBearer *self,
|
|||||||
g_assert (modem);
|
g_assert (modem);
|
||||||
|
|
||||||
/* Grab a data port */
|
/* Grab a data port */
|
||||||
data = mm_base_modem_get_best_data_port (modem);
|
data = mm_base_modem_get_best_data_port (modem, MM_PORT_TYPE_NET);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
g_simple_async_report_error_in_idle (
|
g_simple_async_report_error_in_idle (
|
||||||
G_OBJECT (self),
|
G_OBJECT (self),
|
||||||
|
@@ -76,10 +76,12 @@ typedef struct {
|
|||||||
MMBaseModem *modem;
|
MMBaseModem *modem;
|
||||||
MMAtSerialPort *primary;
|
MMAtSerialPort *primary;
|
||||||
MMAtSerialPort *secondary;
|
MMAtSerialPort *secondary;
|
||||||
MMPort *data;
|
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
MMPort *data;
|
||||||
|
gboolean close_data_on_exit;
|
||||||
|
|
||||||
/* 3GPP-specific */
|
/* 3GPP-specific */
|
||||||
guint cid;
|
guint cid;
|
||||||
guint max_cid;
|
guint max_cid;
|
||||||
@@ -102,10 +104,14 @@ detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
g_object_unref (ctx->data);
|
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
if (ctx->secondary)
|
if (ctx->secondary)
|
||||||
g_object_unref (ctx->secondary);
|
g_object_unref (ctx->secondary);
|
||||||
|
if (ctx->data) {
|
||||||
|
if (ctx->close_data_on_exit)
|
||||||
|
mm_serial_port_close (MM_SERIAL_PORT (ctx->data));
|
||||||
|
g_object_unref (ctx->data);
|
||||||
|
}
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_slice_free (DetailedConnectContext, ctx);
|
g_slice_free (DetailedConnectContext, ctx);
|
||||||
@@ -143,7 +149,6 @@ detailed_connect_context_new (MMBroadbandBearer *self,
|
|||||||
MMBroadbandModem *modem,
|
MMBroadbandModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMAtSerialPort *secondary,
|
MMAtSerialPort *secondary,
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -155,7 +160,6 @@ detailed_connect_context_new (MMBroadbandBearer *self,
|
|||||||
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
||||||
ctx->primary = g_object_ref (primary);
|
ctx->primary = g_object_ref (primary);
|
||||||
ctx->secondary = (secondary ? g_object_ref (secondary) : NULL);
|
ctx->secondary = (secondary ? g_object_ref (secondary) : NULL);
|
||||||
ctx->data = g_object_ref (data);
|
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
@@ -167,6 +171,37 @@ detailed_connect_context_new (MMBroadbandBearer *self,
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Generic implementations (both 3GPP and CDMA) are always AT-port based */
|
||||||
|
|
||||||
|
static MMAtSerialPort *
|
||||||
|
common_get_at_data_port (MMBaseModem *modem,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MMPort *data;
|
||||||
|
|
||||||
|
/* Look for best data port, NULL if none available. */
|
||||||
|
data = mm_base_modem_peek_best_data_port (modem, MM_PORT_TYPE_AT);
|
||||||
|
if (!data) {
|
||||||
|
g_set_error (error,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_CONNECTED,
|
||||||
|
"Couldn't connect: no port available");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert (MM_IS_AT_SERIAL_PORT (data));
|
||||||
|
|
||||||
|
if (!mm_serial_port_open (MM_SERIAL_PORT (data), error)) {
|
||||||
|
g_prefix_error (error, "Couldn't connect: cannot keep data port open.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_dbg ("Connection through a plain serial AT port (%s)", mm_port_get_device (data));
|
||||||
|
|
||||||
|
return MM_AT_SERIAL_PORT (g_object_ref (data));
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* CDMA CONNECT
|
/* CDMA CONNECT
|
||||||
*
|
*
|
||||||
@@ -199,6 +234,9 @@ dial_cdma_ready (MMBaseModem *modem,
|
|||||||
|
|
||||||
/* else... Yuhu! */
|
/* else... Yuhu! */
|
||||||
|
|
||||||
|
/* Keep port open during connection */
|
||||||
|
ctx->close_data_on_exit = FALSE;
|
||||||
|
|
||||||
/* Generic CDMA connections are done over PPP always */
|
/* Generic CDMA connections are done over PPP always */
|
||||||
g_assert (MM_IS_AT_SERIAL_PORT (ctx->data));
|
g_assert (MM_IS_AT_SERIAL_PORT (ctx->data));
|
||||||
config = mm_bearer_ip_config_new ();
|
config = mm_bearer_ip_config_new ();
|
||||||
@@ -231,7 +269,7 @@ cdma_connect_context_dial (DetailedConnectContext *ctx)
|
|||||||
command = g_strdup ("DT#777");
|
command = g_strdup ("DT#777");
|
||||||
|
|
||||||
mm_base_modem_at_command_full (ctx->modem,
|
mm_base_modem_at_command_full (ctx->modem,
|
||||||
ctx->primary,
|
MM_AT_SERIAL_PORT (ctx->data),
|
||||||
command,
|
command,
|
||||||
90,
|
90,
|
||||||
FALSE,
|
FALSE,
|
||||||
@@ -339,32 +377,33 @@ connect_cdma (MMBroadbandBearer *self,
|
|||||||
MMBroadbandModem *modem,
|
MMBroadbandModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMAtSerialPort *secondary, /* unused by us */
|
MMAtSerialPort *secondary, /* unused by us */
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
DetailedConnectContext *ctx;
|
DetailedConnectContext *ctx;
|
||||||
MMPort *real_data;
|
GError *error = NULL;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
g_assert (primary != NULL);
|
||||||
|
|
||||||
if (MM_IS_AT_SERIAL_PORT (data))
|
|
||||||
real_data = data;
|
|
||||||
else {
|
|
||||||
mm_dbg ("Ignoring 'net' interface in CDMA connection");
|
|
||||||
real_data = MM_PORT (primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx = detailed_connect_context_new (self,
|
ctx = detailed_connect_context_new (self,
|
||||||
modem,
|
modem,
|
||||||
primary,
|
primary,
|
||||||
NULL,
|
NULL,
|
||||||
real_data,
|
|
||||||
cancellable,
|
cancellable,
|
||||||
callback,
|
callback,
|
||||||
user_data);
|
user_data);
|
||||||
|
|
||||||
|
/* Grab dial port. This gets a reference to the dial port and OPENs it.
|
||||||
|
* If we fail, we'll need to close it ourselves. */
|
||||||
|
ctx->data = (MMPort *)common_get_at_data_port (ctx->modem, &error);
|
||||||
|
if (!ctx->data) {
|
||||||
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
detailed_connect_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->close_data_on_exit = TRUE;
|
||||||
|
|
||||||
if (mm_bearer_properties_get_rm_protocol (
|
if (mm_bearer_properties_get_rm_protocol (
|
||||||
mm_bearer_peek_config (MM_BEARER (self))) !=
|
mm_bearer_peek_config (MM_BEARER (self))) !=
|
||||||
MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
|
MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
|
||||||
@@ -393,10 +432,12 @@ typedef struct {
|
|||||||
MMBroadbandBearer *self;
|
MMBroadbandBearer *self;
|
||||||
MMBaseModem *modem;
|
MMBaseModem *modem;
|
||||||
MMAtSerialPort *primary;
|
MMAtSerialPort *primary;
|
||||||
MMAtSerialPort *dial_port;
|
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
GError *saved_error;
|
GError *saved_error;
|
||||||
|
|
||||||
|
MMAtSerialPort *dial_port;
|
||||||
|
gboolean close_dial_port_on_exit;
|
||||||
} Dial3gppContext;
|
} Dial3gppContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -404,10 +445,11 @@ dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
|
|||||||
{
|
{
|
||||||
if (ctx->saved_error)
|
if (ctx->saved_error)
|
||||||
g_error_free (ctx->saved_error);
|
g_error_free (ctx->saved_error);
|
||||||
|
if (ctx->dial_port)
|
||||||
|
g_object_unref (ctx->dial_port);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
g_simple_async_result_complete (ctx->result);
|
g_simple_async_result_complete (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->dial_port);
|
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
@@ -441,12 +483,15 @@ dial_3gpp_context_complete_and_free_if_cancelled (Dial3gppContext *ctx)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static MMPort *
|
||||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
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
|
static void
|
||||||
@@ -475,6 +520,9 @@ extended_error_ready (MMBaseModem *modem,
|
|||||||
|
|
||||||
ctx->saved_error = NULL;
|
ctx->saved_error = NULL;
|
||||||
|
|
||||||
|
/* Close the dialling port as we got an error */
|
||||||
|
mm_serial_port_close (MM_SERIAL_PORT (ctx->dial_port));
|
||||||
|
|
||||||
/* Done with errors */
|
/* Done with errors */
|
||||||
dial_3gpp_context_complete_and_free (ctx);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -503,7 +551,9 @@ atd_ready (MMBaseModem *modem,
|
|||||||
return;
|
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->dial_port),
|
||||||
|
(GDestroyNotify)g_object_unref);
|
||||||
dial_3gpp_context_complete_and_free (ctx);
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +561,6 @@ static void
|
|||||||
dial_3gpp (MMBroadbandBearer *self,
|
dial_3gpp (MMBroadbandBearer *self,
|
||||||
MMBaseModem *modem,
|
MMBaseModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMPort *data,
|
|
||||||
guint cid,
|
guint cid,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
@@ -519,23 +568,29 @@ dial_3gpp (MMBroadbandBearer *self,
|
|||||||
{
|
{
|
||||||
gchar *command;
|
gchar *command;
|
||||||
Dial3gppContext *ctx;
|
Dial3gppContext *ctx;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
g_assert (primary != NULL);
|
||||||
|
|
||||||
ctx = g_slice_new0 (Dial3gppContext);
|
ctx = g_slice_new0 (Dial3gppContext);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->modem = g_object_ref (modem);
|
ctx->modem = g_object_ref (modem);
|
||||||
/* Dial port might not be the primary port */
|
|
||||||
ctx->primary = g_object_ref (primary);
|
ctx->primary = g_object_ref (primary);
|
||||||
ctx->dial_port = (data && MM_IS_AT_SERIAL_PORT (data) ?
|
|
||||||
g_object_ref (data) :
|
|
||||||
g_object_ref (primary));
|
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
dial_3gpp);
|
dial_3gpp);
|
||||||
ctx->cancellable = g_object_ref (cancellable);
|
ctx->cancellable = g_object_ref (cancellable);
|
||||||
|
|
||||||
|
/* Grab dial port. This gets a reference to the dial port and OPENs it.
|
||||||
|
* If we fail, we'll need to close it ourselves. */
|
||||||
|
ctx->dial_port = common_get_at_data_port (ctx->modem, &error);
|
||||||
|
if (!ctx->dial_port) {
|
||||||
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
dial_3gpp_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use default *99 to connect */
|
/* Use default *99 to connect */
|
||||||
command = g_strdup_printf ("ATD*99***%d#", cid);
|
command = g_strdup_printf ("ATD*99***%d#", cid);
|
||||||
mm_base_modem_at_command_full (ctx->modem,
|
mm_base_modem_at_command_full (ctx->modem,
|
||||||
@@ -584,6 +639,10 @@ get_ip_config_3gpp_ready (MMBroadbandModem *modem,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keep port open during connection */
|
||||||
|
if (MM_IS_AT_SERIAL_PORT (ctx->data))
|
||||||
|
ctx->close_data_on_exit = FALSE;
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (
|
g_simple_async_result_set_op_res_gpointer (
|
||||||
ctx->result,
|
ctx->result,
|
||||||
mm_bearer_connect_result_new (ctx->data, ipv4_config, ipv6_config),
|
mm_bearer_connect_result_new (ctx->data, ipv4_config, ipv6_config),
|
||||||
@@ -604,9 +663,8 @@ dial_3gpp_ready (MMBroadbandModem *modem,
|
|||||||
MMBearerIpConfig *config;
|
MMBearerIpConfig *config;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->dial_3gpp_finish (ctx->self,
|
ctx->data = MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->dial_3gpp_finish (ctx->self, res, &error);
|
||||||
res,
|
if (!ctx->data) {
|
||||||
&error)) {
|
|
||||||
/* Clear CID when it failed to connect. */
|
/* Clear CID when it failed to connect. */
|
||||||
ctx->self->priv->cid = 0;
|
ctx->self->priv->cid = 0;
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
@@ -614,6 +672,11 @@ dial_3gpp_ready (MMBroadbandModem *modem,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the dialling operation used an AT port, it is assumed to have an extra
|
||||||
|
* open() count. */
|
||||||
|
if (MM_IS_AT_SERIAL_PORT (ctx->data))
|
||||||
|
ctx->close_data_on_exit = TRUE;
|
||||||
|
|
||||||
if (MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->get_ip_config_3gpp &&
|
if (MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->get_ip_config_3gpp &&
|
||||||
MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->get_ip_config_3gpp_finish) {
|
MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->get_ip_config_3gpp_finish) {
|
||||||
/* Launch specific IP config retrieval */
|
/* Launch specific IP config retrieval */
|
||||||
@@ -631,6 +694,10 @@ dial_3gpp_ready (MMBroadbandModem *modem,
|
|||||||
|
|
||||||
/* Yuhu! */
|
/* Yuhu! */
|
||||||
|
|
||||||
|
/* Keep port open during connection */
|
||||||
|
if (MM_IS_AT_SERIAL_PORT (ctx->data))
|
||||||
|
ctx->close_data_on_exit = FALSE;
|
||||||
|
|
||||||
/* If no specific IP retrieval requested, set the default implementation
|
/* If no specific IP retrieval requested, set the default implementation
|
||||||
* (PPP if data port is AT, DHCP otherwise) */
|
* (PPP if data port is AT, DHCP otherwise) */
|
||||||
config = mm_bearer_ip_config_new ();
|
config = mm_bearer_ip_config_new ();
|
||||||
@@ -674,7 +741,6 @@ initialize_pdp_context_ready (MMBaseModem *modem,
|
|||||||
MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->dial_3gpp (ctx->self,
|
MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->dial_3gpp (ctx->self,
|
||||||
ctx->modem,
|
ctx->modem,
|
||||||
ctx->primary,
|
ctx->primary,
|
||||||
ctx->data,
|
|
||||||
ctx->cid,
|
ctx->cid,
|
||||||
ctx->cancellable,
|
ctx->cancellable,
|
||||||
(GAsyncReadyCallback)dial_3gpp_ready,
|
(GAsyncReadyCallback)dial_3gpp_ready,
|
||||||
@@ -920,7 +986,6 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
MMBroadbandModem *modem,
|
MMBroadbandModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMAtSerialPort *secondary,
|
MMAtSerialPort *secondary,
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -933,7 +998,6 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
modem,
|
modem,
|
||||||
primary,
|
primary,
|
||||||
secondary,
|
secondary,
|
||||||
data,
|
|
||||||
cancellable,
|
cancellable,
|
||||||
callback,
|
callback,
|
||||||
user_data);
|
user_data);
|
||||||
@@ -955,7 +1019,6 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
MMBroadbandBearer *self;
|
MMBroadbandBearer *self;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
MMPort *suggested_data;
|
|
||||||
} ConnectContext;
|
} ConnectContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -963,7 +1026,6 @@ connect_context_complete_and_free (ConnectContext *ctx)
|
|||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->suggested_data);
|
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_slice_free (ConnectContext, ctx);
|
g_slice_free (ConnectContext, ctx);
|
||||||
}
|
}
|
||||||
@@ -1044,7 +1106,6 @@ connect (MMBearer *self,
|
|||||||
{
|
{
|
||||||
MMBaseModem *modem = NULL;
|
MMBaseModem *modem = NULL;
|
||||||
MMAtSerialPort *primary;
|
MMAtSerialPort *primary;
|
||||||
MMPort *suggested_data;
|
|
||||||
ConnectContext *ctx;
|
ConnectContext *ctx;
|
||||||
|
|
||||||
/* Don't try to connect if already connected */
|
/* Don't try to connect if already connected */
|
||||||
@@ -1092,44 +1153,9 @@ connect (MMBearer *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for best data port, NULL if none available. */
|
|
||||||
suggested_data = mm_base_modem_peek_best_data_port (modem);
|
|
||||||
if (!suggested_data) {
|
|
||||||
g_simple_async_report_error_in_idle (
|
|
||||||
G_OBJECT (self),
|
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_CONNECTED,
|
|
||||||
"Couldn't connect: all available data ports already connected");
|
|
||||||
g_object_unref (modem);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If data port is AT, we need to ensure it's open during the whole
|
|
||||||
* connection. For the case where the primary port is used as data port,
|
|
||||||
* which is actually always right now, this is already ensured because the
|
|
||||||
* primary port is kept open as long as the modem is enabled, but anyway
|
|
||||||
* there's no real problem in keeping an open count here as well. */
|
|
||||||
if (MM_IS_AT_SERIAL_PORT (suggested_data)) {
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (!mm_serial_port_open (MM_SERIAL_PORT (suggested_data), &error)) {
|
|
||||||
g_prefix_error (&error, "Couldn't connect: cannot keep data port open.");
|
|
||||||
g_simple_async_report_take_gerror_in_idle (
|
|
||||||
G_OBJECT (self),
|
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
error);
|
|
||||||
g_object_unref (modem);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In this context, we only keep the stuff we'll need later */
|
/* In this context, we only keep the stuff we'll need later */
|
||||||
ctx = g_slice_new0 (ConnectContext);
|
ctx = g_slice_new0 (ConnectContext);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->suggested_data = g_object_ref (suggested_data);
|
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
@@ -1142,7 +1168,6 @@ connect (MMBearer *self,
|
|||||||
MM_BROADBAND_MODEM (modem),
|
MM_BROADBAND_MODEM (modem),
|
||||||
primary,
|
primary,
|
||||||
mm_base_modem_peek_port_secondary (modem),
|
mm_base_modem_peek_port_secondary (modem),
|
||||||
suggested_data,
|
|
||||||
cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback) connect_3gpp_ready,
|
(GAsyncReadyCallback) connect_3gpp_ready,
|
||||||
ctx);
|
ctx);
|
||||||
@@ -1157,7 +1182,6 @@ connect (MMBearer *self,
|
|||||||
MM_BROADBAND_MODEM (modem),
|
MM_BROADBAND_MODEM (modem),
|
||||||
primary,
|
primary,
|
||||||
mm_base_modem_peek_port_secondary (modem),
|
mm_base_modem_peek_port_secondary (modem),
|
||||||
suggested_data,
|
|
||||||
cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback) connect_cdma_ready,
|
(GAsyncReadyCallback) connect_cdma_ready,
|
||||||
ctx);
|
ctx);
|
||||||
|
@@ -52,7 +52,6 @@ struct _MMBroadbandBearerClass {
|
|||||||
MMBroadbandModem *modem,
|
MMBroadbandModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMAtSerialPort *secondary,
|
MMAtSerialPort *secondary,
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -64,12 +63,11 @@ struct _MMBroadbandBearerClass {
|
|||||||
void (* dial_3gpp) (MMBroadbandBearer *self,
|
void (* dial_3gpp) (MMBroadbandBearer *self,
|
||||||
MMBaseModem *modem,
|
MMBaseModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMPort *data,
|
|
||||||
guint cid,
|
guint cid,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
gboolean (* dial_3gpp_finish) (MMBroadbandBearer *self,
|
MMPort * (* dial_3gpp_finish) (MMBroadbandBearer *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@@ -107,7 +105,6 @@ struct _MMBroadbandBearerClass {
|
|||||||
MMBroadbandModem *modem,
|
MMBroadbandModem *modem,
|
||||||
MMAtSerialPort *primary,
|
MMAtSerialPort *primary,
|
||||||
MMAtSerialPort *secondary,
|
MMAtSerialPort *secondary,
|
||||||
MMPort *data,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
Reference in New Issue
Block a user