hso: port disconnect_3gpp to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
ee80e1f660
commit
795ecad0e6
@@ -698,19 +698,14 @@ dial_3gpp (MMBroadbandBearer *self,
|
|||||||
/* 3GPP disconnect */
|
/* 3GPP disconnect */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MMBroadbandBearerHso *self;
|
|
||||||
MMBaseModem *modem;
|
MMBaseModem *modem;
|
||||||
MMPortSerialAt *primary;
|
MMPortSerialAt *primary;
|
||||||
GSimpleAsyncResult *result;
|
|
||||||
} DisconnectContext;
|
} DisconnectContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_context_complete_and_free (DisconnectContext *ctx)
|
disconnect_context_free (DisconnectContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete (ctx->result);
|
|
||||||
g_object_unref (ctx->result);
|
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->self);
|
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
@@ -720,13 +715,13 @@ disconnect_3gpp_finish (MMBroadbandBearer *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
return g_task_propagate_boolean (G_TASK (res), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_owancall_ready (MMBaseModem *modem,
|
disconnect_owancall_ready (MMBaseModem *modem,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DisconnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
@@ -737,8 +732,8 @@ disconnect_owancall_ready (MMBaseModem *modem,
|
|||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
disconnect_context_complete_and_free (ctx);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -753,17 +748,16 @@ disconnect_3gpp (MMBroadbandBearer *self,
|
|||||||
{
|
{
|
||||||
gchar *command;
|
gchar *command;
|
||||||
DisconnectContext *ctx;
|
DisconnectContext *ctx;
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
g_assert (primary != NULL);
|
g_assert (primary != NULL);
|
||||||
|
|
||||||
ctx = g_new0 (DisconnectContext, 1);
|
ctx = g_new0 (DisconnectContext, 1);
|
||||||
ctx->self = g_object_ref (self);
|
|
||||||
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
||||||
ctx->primary = g_object_ref (primary);
|
ctx->primary = g_object_ref (primary);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
|
||||||
callback,
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
user_data,
|
g_task_set_task_data (task, ctx, (GDestroyNotify)disconnect_context_free);
|
||||||
disconnect_3gpp);
|
|
||||||
|
|
||||||
/* Use specific CID */
|
/* Use specific CID */
|
||||||
command = g_strdup_printf ("AT_OWANCALL=%d,0,0", cid);
|
command = g_strdup_printf ("AT_OWANCALL=%d,0,0", cid);
|
||||||
@@ -775,7 +769,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
|
|||||||
FALSE, /* raw */
|
FALSE, /* raw */
|
||||||
NULL, /* cancellable */
|
NULL, /* cancellable */
|
||||||
(GAsyncReadyCallback)disconnect_owancall_ready,
|
(GAsyncReadyCallback)disconnect_owancall_ready,
|
||||||
ctx);
|
task);
|
||||||
g_free (command);
|
g_free (command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user