diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-02-17 21:57:34 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-02-18 15:41:26 +0100 |
commit | b6402a4e2158adf28dad2cd6b2dcf8b4966be2d0 (patch) | |
tree | 8461d8913191ac1c031cd8d5f454f1fdb7e25ecc /plugins/option | |
parent | 15d34d56fd3277b23c5f477d9aab257cb0bc10a7 (diff) |
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.
Diffstat (limited to 'plugins/option')
-rw-r--r-- | plugins/option/mm-broadband-bearer-hso.c | 125 |
1 files changed, 55 insertions, 70 deletions
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); } /*****************************************************************************/ |