broadband-modem-qmi: port modem_3gpp_register_in_network to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
a3123cadd8
commit
b6de1ad22e
@@ -4294,13 +4294,13 @@ modem_3gpp_register_in_network_finish (MMIfaceModem3gpp *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
|
||||||
initiate_network_register_ready (QmiClientNas *client,
|
initiate_network_register_ready (QmiClientNas *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
QmiMessageNasInitiateNetworkRegisterOutput *output;
|
QmiMessageNasInitiateNetworkRegisterOutput *output;
|
||||||
@@ -4308,25 +4308,25 @@ initiate_network_register_ready (QmiClientNas *client,
|
|||||||
output = qmi_client_nas_initiate_network_register_finish (client, res, &error);
|
output = qmi_client_nas_initiate_network_register_finish (client, res, &error);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
g_prefix_error (&error, "QMI operation failed: ");
|
g_prefix_error (&error, "QMI operation failed: ");
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_task_return_error (task, error);
|
||||||
} else if (!qmi_message_nas_initiate_network_register_output_get_result (output, &error)) {
|
} else if (!qmi_message_nas_initiate_network_register_output_get_result (output, &error)) {
|
||||||
/* NOFX is not an error, they actually play pretty well */
|
/* NOFX is not an error, they actually play pretty well */
|
||||||
if (g_error_matches (error,
|
if (g_error_matches (error,
|
||||||
QMI_PROTOCOL_ERROR,
|
QMI_PROTOCOL_ERROR,
|
||||||
QMI_PROTOCOL_ERROR_NO_EFFECT)) {
|
QMI_PROTOCOL_ERROR_NO_EFFECT)) {
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
} else {
|
} else {
|
||||||
g_prefix_error (&error, "Couldn't initiate network register: ");
|
g_prefix_error (&error, "Couldn't initiate network register: ");
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_task_return_error (task, error);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
|
|
||||||
|
g_object_unref (task);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
qmi_message_nas_initiate_network_register_output_unref (output);
|
qmi_message_nas_initiate_network_register_output_unref (output);
|
||||||
g_simple_async_result_complete (simple);
|
|
||||||
g_object_unref (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4345,15 +4345,16 @@ modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
|
|||||||
/* Parse input MCC/MNC */
|
/* Parse input MCC/MNC */
|
||||||
if (operator_id && !mm_3gpp_parse_operator_id (operator_id, &mcc, &mnc, &error)) {
|
if (operator_id && !mm_3gpp_parse_operator_id (operator_id, &mcc, &mnc, &error)) {
|
||||||
g_assert (error != NULL);
|
g_assert (error != NULL);
|
||||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
g_task_report_error (self,
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
modem_3gpp_register_in_network,
|
||||||
|
error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get NAS client */
|
/* Get NAS client */
|
||||||
if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
if (!assure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
||||||
QMI_SERVICE_NAS, &client,
|
QMI_SERVICE_NAS, &client,
|
||||||
callback, user_data))
|
callback, user_data))
|
||||||
return;
|
return;
|
||||||
@@ -4386,10 +4387,7 @@ modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
|
|||||||
120,
|
120,
|
||||||
cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)initiate_network_register_ready,
|
(GAsyncReadyCallback)initiate_network_register_ready,
|
||||||
g_simple_async_result_new (G_OBJECT (self),
|
g_task_new (self, NULL, callback, user_data));
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
modem_3gpp_register_in_network));
|
|
||||||
|
|
||||||
qmi_message_nas_initiate_network_register_input_unref (input);
|
qmi_message_nas_initiate_network_register_input_unref (input);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user