huawei: avoid creating Connect3gppContext when no data port is available

This patch modifies MMBroadbandBearerHuawei such that connect_3gpp
simply reports an error via g_simple_async_report_error_in_idle, without
creating a Connect3gppContext, if no data port is available.
This commit is contained in:
Ben Chan
2014-01-08 16:10:06 -08:00
committed by Aleksander Morgado
parent fd1a1839ae
commit 50f3f41c3a

View File

@@ -69,8 +69,7 @@ connect_3gpp_context_complete_and_free (Connect3gppContext *ctx)
g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->cancellable);
g_object_unref (ctx->result);
if (ctx->data)
g_object_unref (ctx->data);
g_object_unref (ctx->data);
g_object_unref (ctx->primary);
g_object_unref (ctx->modem);
g_object_unref (ctx->self);
@@ -377,14 +376,28 @@ connect_3gpp (MMBroadbandBearer *self,
gpointer user_data)
{
Connect3gppContext *ctx;
MMPort *data;
g_assert (primary != NULL);
/* We need a net data port */
data = mm_base_modem_peek_best_data_port (MM_BASE_MODEM (modem), MM_PORT_TYPE_NET);
if (!data) {
g_simple_async_report_error_in_idle (G_OBJECT (self),
callback,
user_data,
MM_CORE_ERROR,
MM_CORE_ERROR_NOT_FOUND,
"No valid data port found to launch connection");
return;
}
/* Setup connection context */
ctx = g_slice_new0 (Connect3gppContext);
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,
@@ -395,19 +408,6 @@ 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);
}