diff options
author | Ben Chan <benchan@chromium.org> | 2017-09-12 04:35:01 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-09-13 16:36:49 +0200 |
commit | 979730247eee09e79450a5f8997c2dfd019952f5 (patch) | |
tree | ab72c17a2915687c8ceadd02e45c6fd54699c8d9 | |
parent | 7000039c8c469d4c786ab13753becdbe313297d6 (diff) |
novatel: port set_current_modes to use GTask
-rw-r--r-- | plugins/novatel/mm-broadband-modem-novatel.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/plugins/novatel/mm-broadband-modem-novatel.c b/plugins/novatel/mm-broadband-modem-novatel.c index ffd38efb..6fd0c478 100644 --- a/plugins/novatel/mm-broadband-modem-novatel.c +++ b/plugins/novatel/mm-broadband-modem-novatel.c @@ -289,24 +289,23 @@ set_current_modes_finish (MMIfaceModem *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 allowed_mode_update_ready (MMBroadbandModemNovatel *self, GAsyncResult *res, - GSimpleAsyncResult *operation_result) + GTask *task) { GError *error = NULL; mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); if (error) /* Let the error be critical. */ - g_simple_async_result_take_error (operation_result, error); + g_task_return_error (task, error); else - g_simple_async_result_set_op_res_gboolean (operation_result, TRUE); - g_simple_async_result_complete (operation_result); - g_object_unref (operation_result); + g_task_return_boolean (task, TRUE); + g_object_unref (task); } static void @@ -316,25 +315,21 @@ set_current_modes (MMIfaceModem *self, GAsyncReadyCallback callback, gpointer user_data) { - GSimpleAsyncResult *result; + GTask *task; gchar *command; gint a = -1; gint b = -1; - result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - set_current_modes); + task = g_task_new (self, NULL, callback, user_data); /* Setting allowed modes only in 3GPP modems */ if (!mm_iface_modem_is_3gpp (self)) { - g_simple_async_result_set_error ( - result, + g_task_return_new_error ( + task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Setting allowed modes not supported in CDMA-only modems"); - g_simple_async_result_complete_in_idle (result); - g_object_unref (result); + g_object_unref (task); return; } @@ -364,18 +359,16 @@ set_current_modes (MMIfaceModem *self, allowed_str = mm_modem_mode_build_string_from_mask (allowed); preferred_str = mm_modem_mode_build_string_from_mask (preferred); - g_simple_async_result_set_error (result, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Requested mode (allowed: '%s', preferred: '%s') not " - "supported by the modem.", - allowed_str, - preferred_str); + g_task_return_new_error (task, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Requested mode (allowed: '%s', preferred: '%s') not " + "supported by the modem.", + allowed_str, + preferred_str); + g_object_unref (task); g_free (allowed_str); g_free (preferred_str); - - g_simple_async_result_complete_in_idle (result); - g_object_unref (result); return; } @@ -386,7 +379,7 @@ set_current_modes (MMIfaceModem *self, 3, FALSE, (GAsyncReadyCallback)allowed_mode_update_ready, - result); + task); g_free (command); } |