aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/huawei/mm-broadband-bearer-huawei.c15
-rw-r--r--plugins/huawei/mm-broadband-modem-huawei.c2
-rw-r--r--plugins/icera/mm-broadband-bearer-icera.c74
-rw-r--r--plugins/icera/mm-broadband-modem-icera.c30
-rw-r--r--plugins/mbm/mm-broadband-bearer-mbm.c79
-rw-r--r--plugins/novatel/mm-broadband-bearer-novatel-lte.c93
-rw-r--r--plugins/option/mm-broadband-bearer-hso.c125
-rw-r--r--plugins/sierra/mm-broadband-bearer-sierra.c21
8 files changed, 204 insertions, 235 deletions
diff --git a/plugins/huawei/mm-broadband-bearer-huawei.c b/plugins/huawei/mm-broadband-bearer-huawei.c
index 804d1659..364760fd 100644
--- a/plugins/huawei/mm-broadband-bearer-huawei.c
+++ b/plugins/huawei/mm-broadband-bearer-huawei.c
@@ -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);
}
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
index b5ce8973..c1a29b3e 100644
--- a/plugins/huawei/mm-broadband-modem-huawei.c
+++ b/plugins/huawei/mm-broadband-modem-huawei.c
@@ -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;
diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c
index 589bdc4e..b7ea8df0 100644
--- a/plugins/icera/mm-broadband-bearer-icera.c
+++ b/plugins/icera/mm-broadband-bearer-icera.c
@@ -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);
}
/*****************************************************************************/
diff --git a/plugins/icera/mm-broadband-modem-icera.c b/plugins/icera/mm-broadband-modem-icera.c
index ca292fd7..5446fe68 100644
--- a/plugins/icera/mm-broadband-modem-icera.c
+++ b/plugins/icera/mm-broadband-modem-icera.c
@@ -733,25 +733,6 @@ broadband_bearer_icera_new_ready (GObject *source,
}
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,
GAsyncReadyCallback callback,
@@ -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),
diff --git a/plugins/mbm/mm-broadband-bearer-mbm.c b/plugins/mbm/mm-broadband-bearer-mbm.c
index ee9399db..264d084b 100644
--- a/plugins/mbm/mm-broadband-bearer-mbm.c
+++ b/plugins/mbm/mm-broadband-bearer-mbm.c
@@ -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);
}
/*****************************************************************************/
diff --git a/plugins/novatel/mm-broadband-bearer-novatel-lte.c b/plugins/novatel/mm-broadband-bearer-novatel-lte.c
index 88d46cc7..a12e5984 100644
--- a/plugins/novatel/mm-broadband-bearer-novatel-lte.c
+++ b/plugins/novatel/mm-broadband-bearer-novatel-lte.c
@@ -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 */
diff --git a/plugins/option/mm-broadband-bearer-hso.c b/plugins/option/mm-broadband-bearer-hso.c
index 194f1a89..1830bb2f 100644
--- a/plugins/option/mm-broadband-bearer-hso.c
+++ b/plugins/option/mm-broadband-bearer-hso.c
@@ -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);
}
/*****************************************************************************/
diff --git a/plugins/sierra/mm-broadband-bearer-sierra.c b/plugins/sierra/mm-broadband-bearer-sierra.c
index 17473d12..7a07b609 100644
--- a/plugins/sierra/mm-broadband-bearer-sierra.c
+++ b/plugins/sierra/mm-broadband-bearer-sierra.c
@@ -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);