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:

committed by
Aleksander Morgado

parent
fd1a1839ae
commit
50f3f41c3a
@@ -69,7 +69,6 @@ connect_3gpp_context_complete_and_free (Connect3gppContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
g_object_unref (ctx->result);
|
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->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
@@ -377,14 +376,28 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
Connect3gppContext *ctx;
|
Connect3gppContext *ctx;
|
||||||
|
MMPort *data;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
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 */
|
/* Setup connection context */
|
||||||
ctx = g_slice_new0 (Connect3gppContext);
|
ctx = g_slice_new0 (Connect3gppContext);
|
||||||
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,
|
||||||
@@ -395,19 +408,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user