diff options
author | Ben Chan <benchan@chromium.org> | 2017-09-12 08:46:22 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-09-13 16:36:49 +0200 |
commit | c13746dad76ad8a99352251f51c09428e3639b1c (patch) | |
tree | f66830fdf1fb9ea2fc1f3625653933304cab225c | |
parent | 43c4a49bc762910697c0a9a576d66e9438de4b78 (diff) |
novatel-lte: port scan_networks to use GTask
-rw-r--r-- | plugins/novatel/mm-broadband-modem-novatel-lte.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/plugins/novatel/mm-broadband-modem-novatel-lte.c b/plugins/novatel/mm-broadband-modem-novatel-lte.c index 4f43adcc..38f7e7e7 100644 --- a/plugins/novatel/mm-broadband-modem-novatel-lte.c +++ b/plugins/novatel/mm-broadband-modem-novatel-lte.c @@ -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, - scan_result, - NULL); - g_simple_async_result_complete (operation_result); - g_object_unref (operation_result); + g_task_return_pointer (task, + scan_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, - 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_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_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); } /*****************************************************************************/ |