[PATCH] port-serial-qcdm: port mm_port_serial_qcdm_command to use GTask
Ben Chan
benchan at chromium.org
Sat Jul 1 12:10:19 UTC 2017
---
src/mm-port-serial-qcdm.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/mm-port-serial-qcdm.c b/src/mm-port-serial-qcdm.c
index e997bb06..4d26e398 100644
--- a/src/mm-port-serial-qcdm.c
+++ b/src/mm-port-serial-qcdm.c
@@ -153,27 +153,24 @@ mm_port_serial_qcdm_command_finish (MMPortSerialQcdm *self,
GAsyncResult *res,
GError **error)
{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
- return NULL;
-
- return g_byte_array_ref ((GByteArray *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+ return g_task_propagate_pointer (G_TASK (res), error);
}
static void
serial_command_ready (MMPortSerial *port,
GAsyncResult *res,
- GSimpleAsyncResult *simple)
+ GTask *task)
{
GByteArray *response;
GError *error = NULL;
response = mm_port_serial_command_finish (port, res, &error);
if (!response)
- g_simple_async_result_take_error (simple, error);
+ g_task_return_error (task, error);
else
- g_simple_async_result_set_op_res_gpointer (simple, response, (GDestroyNotify)g_byte_array_unref);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
+ g_task_return_pointer (task, response, (GDestroyNotify)g_byte_array_unref);
+
+ g_object_unref (task);
}
void
@@ -184,15 +181,12 @@ mm_port_serial_qcdm_command (MMPortSerialQcdm *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *simple;
+ GTask *task;
g_return_if_fail (MM_IS_PORT_SERIAL_QCDM (self));
g_return_if_fail (command != NULL);
- simple = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_port_serial_qcdm_command);
+ task = g_task_new (self, cancellable, callback, user_data);
/* 'command' is expected to be already CRC-ed and escaped */
mm_port_serial_command (MM_PORT_SERIAL (self),
@@ -201,7 +195,7 @@ mm_port_serial_qcdm_command (MMPortSerialQcdm *self,
FALSE, /* never cached */
cancellable,
(GAsyncReadyCallback)serial_command_ready,
- simple);
+ task);
}
static void
--
2.13.2
More information about the ModemManager-devel
mailing list