hso: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask

This commit is contained in:
Ben Chan
2017-09-19 03:22:16 -07:00
committed by Aleksander Morgado
parent 0131f9b006
commit 616cfa9959

View File

@@ -261,18 +261,18 @@ modem_3gpp_setup_cleanup_unsolicited_events_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
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
parent_setup_unsolicited_events_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GSimpleAsyncResult *simple)
GTask *task)
{
GError *error = NULL;
if (!iface_modem_3gpp_parent->setup_unsolicited_events_finish (self, res, &error))
g_simple_async_result_take_error (simple, error);
g_task_return_error (task, error);
else {
/* Our own setup now */
mm_port_serial_at_add_unsolicited_msg_handler (
@@ -282,11 +282,9 @@ parent_setup_unsolicited_events_ready (MMIfaceModem3gpp *self,
self,
NULL);
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
g_task_return_boolean (task, TRUE);
}
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_object_unref (task);
}
static void
@@ -294,33 +292,26 @@ modem_3gpp_setup_unsolicited_events (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
modem_3gpp_setup_unsolicited_events);
/* Chain up parent's setup */
iface_modem_3gpp_parent->setup_unsolicited_events (
self,
(GAsyncReadyCallback)parent_setup_unsolicited_events_ready,
result);
g_task_new (self, NULL, callback, user_data));
}
static void
parent_cleanup_unsolicited_events_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GSimpleAsyncResult *simple)
GTask *task)
{
GError *error = NULL;
if (!iface_modem_3gpp_parent->cleanup_unsolicited_events_finish (self, res, &error))
g_simple_async_result_take_error (simple, error);
g_task_return_error (task, error);
else
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
@@ -328,13 +319,6 @@ modem_3gpp_cleanup_unsolicited_events (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
modem_3gpp_cleanup_unsolicited_events);
/* Our own cleanup first */
mm_port_serial_at_add_unsolicited_msg_handler (
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
@@ -345,7 +329,7 @@ modem_3gpp_cleanup_unsolicited_events (MMIfaceModem3gpp *self,
iface_modem_3gpp_parent->cleanup_unsolicited_events (
self,
(GAsyncReadyCallback)parent_cleanup_unsolicited_events_ready,
result);
g_task_new (self, NULL, callback, user_data));
}
/*****************************************************************************/