novatel-lte: port scan_networks to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
43c4a49bc7
commit
c13746dad7
@@ -504,16 +504,13 @@ scan_networks_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
return g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
cops_query_ready (MMBroadbandModemNovatelLte *self,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *operation_result)
|
||||
GTask *task)
|
||||
{
|
||||
const gchar *response;
|
||||
GError *error = NULL;
|
||||
@@ -521,25 +518,22 @@ cops_query_ready (MMBroadbandModemNovatelLte *self,
|
||||
|
||||
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_take_error (operation_result, error);
|
||||
g_simple_async_result_complete (operation_result);
|
||||
g_object_unref (operation_result);
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
scan_result = mm_3gpp_parse_cops_test_response (response, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_take_error (operation_result, error);
|
||||
g_simple_async_result_complete (operation_result);
|
||||
g_object_unref (operation_result);
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
g_simple_async_result_set_op_res_gpointer (operation_result,
|
||||
g_task_return_pointer (task,
|
||||
scan_result,
|
||||
NULL);
|
||||
g_simple_async_result_complete (operation_result);
|
||||
g_object_unref (operation_result);
|
||||
(GDestroyNotify)mm_3gpp_network_info_list_free);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -547,15 +541,12 @@ scan_networks (MMIfaceModem3gpp *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *result;
|
||||
GTask *task;
|
||||
MMModemAccessTechnology access_tech;
|
||||
|
||||
mm_dbg ("scanning for networks (Novatel LTE)...");
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
scan_networks);
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
access_tech = mm_iface_modem_get_access_technologies (MM_IFACE_MODEM (self));
|
||||
/* The Novatel LTE modem does not properly support AT+COPS=? in LTE mode.
|
||||
@@ -567,13 +558,12 @@ scan_networks (MMIfaceModem3gpp *self,
|
||||
|
||||
access_tech_string = mm_modem_access_technology_build_string_from_mask (access_tech);
|
||||
mm_warn ("Couldn't scan for networks with access technologies: %s", access_tech_string);
|
||||
g_simple_async_result_set_error (result,
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Couldn't scan for networks with access technologies: %s",
|
||||
access_tech_string);
|
||||
g_simple_async_result_complete_in_idle (result);
|
||||
g_object_unref (result);
|
||||
g_object_unref (task);
|
||||
g_free (access_tech_string);
|
||||
return;
|
||||
}
|
||||
@@ -583,7 +573,7 @@ scan_networks (MMIfaceModem3gpp *self,
|
||||
300,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback)cops_query_ready,
|
||||
result);
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
Reference in New Issue
Block a user