diff options
Diffstat (limited to 'plugins/icera')
-rw-r--r-- | plugins/icera/mm-broadband-bearer-icera.c | 74 | ||||
-rw-r--r-- | plugins/icera/mm-broadband-modem-icera.c | 30 |
2 files changed, 38 insertions, 66 deletions
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), |