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,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
return g_task_propagate_pointer (G_TASK (res), error);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cops_query_ready (MMBroadbandModemNovatelLte *self,
|
cops_query_ready (MMBroadbandModemNovatelLte *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *operation_result)
|
GTask *task)
|
||||||
{
|
{
|
||||||
const gchar *response;
|
const gchar *response;
|
||||||
GError *error = NULL;
|
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);
|
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_simple_async_result_take_error (operation_result, error);
|
g_task_return_error (task, error);
|
||||||
g_simple_async_result_complete (operation_result);
|
g_object_unref (task);
|
||||||
g_object_unref (operation_result);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_result = mm_3gpp_parse_cops_test_response (response, &error);
|
scan_result = mm_3gpp_parse_cops_test_response (response, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_simple_async_result_take_error (operation_result, error);
|
g_task_return_error (task, error);
|
||||||
g_simple_async_result_complete (operation_result);
|
g_object_unref (task);
|
||||||
g_object_unref (operation_result);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (operation_result,
|
g_task_return_pointer (task,
|
||||||
scan_result,
|
scan_result,
|
||||||
NULL);
|
(GDestroyNotify)mm_3gpp_network_info_list_free);
|
||||||
g_simple_async_result_complete (operation_result);
|
g_object_unref (task);
|
||||||
g_object_unref (operation_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -547,15 +541,12 @@ scan_networks (MMIfaceModem3gpp *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *result;
|
GTask *task;
|
||||||
MMModemAccessTechnology access_tech;
|
MMModemAccessTechnology access_tech;
|
||||||
|
|
||||||
mm_dbg ("scanning for networks (Novatel LTE)...");
|
mm_dbg ("scanning for networks (Novatel LTE)...");
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (self),
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
scan_networks);
|
|
||||||
|
|
||||||
access_tech = mm_iface_modem_get_access_technologies (MM_IFACE_MODEM (self));
|
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.
|
/* 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);
|
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);
|
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,
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
"Couldn't scan for networks with access technologies: %s",
|
"Couldn't scan for networks with access technologies: %s",
|
||||||
access_tech_string);
|
access_tech_string);
|
||||||
g_simple_async_result_complete_in_idle (result);
|
g_object_unref (task);
|
||||||
g_object_unref (result);
|
|
||||||
g_free (access_tech_string);
|
g_free (access_tech_string);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -583,7 +573,7 @@ scan_networks (MMIfaceModem3gpp *self,
|
|||||||
300,
|
300,
|
||||||
FALSE,
|
FALSE,
|
||||||
(GAsyncReadyCallback)cops_query_ready,
|
(GAsyncReadyCallback)cops_query_ready,
|
||||||
result);
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user