broadband-modem-qmi: port power_cycle to use GTask

This commit is contained in:
Ben Chan
2018-04-26 18:07:26 -07:00
committed by Aleksander Morgado
parent f52264d78a
commit 71d21cba02

View File

@@ -215,13 +215,13 @@ power_cycle_finish (MMBroadbandModemQmi *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
power_cycle_set_operating_mode_reset_ready (QmiClientDms *client,
GAsyncResult *res,
GSimpleAsyncResult *simple)
GTask *task)
{
QmiMessageDmsSetOperatingModeOutput *output;
GError *error = NULL;
@@ -229,23 +229,22 @@ power_cycle_set_operating_mode_reset_ready (QmiClientDms *client,
output = qmi_client_dms_set_operating_mode_finish (client, res, &error);
if (!output ||
!qmi_message_dms_set_operating_mode_output_get_result (output, &error)) {
g_simple_async_result_take_error (simple, error);
g_task_return_error (task, error);
} else {
mm_info ("Modem is being rebooted now");
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
g_task_return_boolean (task, TRUE);
}
if (output)
qmi_message_dms_set_operating_mode_output_unref (output);
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_object_unref (task);
}
static void
power_cycle_set_operating_mode_offline_ready (QmiClientDms *client,
GAsyncResult *res,
GSimpleAsyncResult *simple)
GTask *task)
{
QmiMessageDmsSetOperatingModeInput *input;
QmiMessageDmsSetOperatingModeOutput *output;
@@ -253,16 +252,14 @@ power_cycle_set_operating_mode_offline_ready (QmiClientDms *client,
output = qmi_client_dms_set_operating_mode_finish (client, res, &error);
if (!output) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
if (!qmi_message_dms_set_operating_mode_output_get_result (output, &error)) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
g_task_return_error (task, error);
g_object_unref (task);
qmi_message_dms_set_operating_mode_output_unref (output);
return;
}
@@ -278,7 +275,7 @@ power_cycle_set_operating_mode_offline_ready (QmiClientDms *client,
20,
NULL,
(GAsyncReadyCallback)power_cycle_set_operating_mode_reset_ready,
simple);
task);
qmi_message_dms_set_operating_mode_input_unref (input);
}
@@ -288,18 +285,15 @@ power_cycle (MMBroadbandModemQmi *self,
gpointer user_data)
{
QmiMessageDmsSetOperatingModeInput *input;
GSimpleAsyncResult *simple;
GTask *task;
QmiClient *client;
if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
if (!assure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
QMI_SERVICE_DMS, &client,
callback, user_data))
return;
simple = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
power_cycle);
task = g_task_new (self, NULL, callback, user_data);
/* Now, go into offline mode */
input = qmi_message_dms_set_operating_mode_input_new ();
@@ -309,7 +303,7 @@ power_cycle (MMBroadbandModemQmi *self,
20,
NULL,
(GAsyncReadyCallback)power_cycle_set_operating_mode_offline_ready,
simple);
task);
qmi_message_dms_set_operating_mode_input_unref (input);
}