diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-09-13 22:40:58 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-10-06 09:46:57 +0200 |
commit | 0c8842695ffd0dea5ae1213bc0bf2c73473bcb19 (patch) | |
tree | aabbf6b5e3ef82d7692e6ffa60400ce5030fd01c | |
parent | d1436ac0c6ad594e25803f96e522c81d043d7e1d (diff) |
via: port cdma_setup_registration_checks to GTask
-rw-r--r-- | plugins/via/mm-broadband-modem-via.c | 88 |
1 files changed, 41 insertions, 47 deletions
diff --git a/plugins/via/mm-broadband-modem-via.c b/plugins/via/mm-broadband-modem-via.c index 1c5f9e22..f013fb80 100644 --- a/plugins/via/mm-broadband-modem-via.c +++ b/plugins/via/mm-broadband-modem-via.c @@ -67,80 +67,74 @@ typedef struct { } SetupRegistrationChecksResults; static gboolean -setup_registration_checks_finish (MMIfaceModemCdma *self, - GAsyncResult *res, - gboolean *skip_qcdm_call_manager_step, - gboolean *skip_qcdm_hdr_step, - gboolean *skip_at_cdma_service_status_step, - gboolean *skip_at_cdma1x_serving_system_step, - gboolean *skip_detailed_registration_state, - GError **error) +setup_registration_checks_finish (MMIfaceModemCdma *self, + GAsyncResult *res, + gboolean *skip_qcdm_call_manager_step, + gboolean *skip_qcdm_hdr_step, + gboolean *skip_at_cdma_service_status_step, + gboolean *skip_at_cdma1x_serving_system_step, + gboolean *skip_detailed_registration_state, + GError **error) { SetupRegistrationChecksResults *results; - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + results = g_task_propagate_pointer (G_TASK (res), error); + if (!results) return FALSE; - results = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); - *skip_qcdm_call_manager_step = results->skip_qcdm_call_manager_step; - *skip_qcdm_hdr_step = results->skip_qcdm_hdr_step; - *skip_at_cdma_service_status_step = results->skip_at_cdma_service_status_step; + *skip_qcdm_call_manager_step = results->skip_qcdm_call_manager_step; + *skip_qcdm_hdr_step = results->skip_qcdm_hdr_step; + *skip_at_cdma_service_status_step = results->skip_at_cdma_service_status_step; *skip_at_cdma1x_serving_system_step = results->skip_at_cdma1x_serving_system_step; - *skip_detailed_registration_state = results->skip_detailed_registration_state; + *skip_detailed_registration_state = results->skip_detailed_registration_state; + + g_free (results); + return TRUE; } static void parent_setup_registration_checks_ready (MMIfaceModemCdma *self, - GAsyncResult *res, - GSimpleAsyncResult *simple) + GAsyncResult *res, + GTask *task) { - GError *error = NULL; - SetupRegistrationChecksResults results = { 0 }; + GError *error = NULL; + SetupRegistrationChecksResults *results; + + results = g_new0 (SetupRegistrationChecksResults, 1); if (!iface_modem_cdma_parent->setup_registration_checks_finish (self, res, - &results.skip_qcdm_call_manager_step, - &results.skip_qcdm_hdr_step, - &results.skip_at_cdma_service_status_step, - &results.skip_at_cdma1x_serving_system_step, - &results.skip_detailed_registration_state, + &results->skip_qcdm_call_manager_step, + &results->skip_qcdm_hdr_step, + &results->skip_at_cdma_service_status_step, + &results->skip_at_cdma1x_serving_system_step, + &results->skip_detailed_registration_state, &error)) { - g_simple_async_result_take_error (simple, error); + g_task_return_error (task, error); } else { /* Skip +CSS */ - results.skip_at_cdma1x_serving_system_step = TRUE; + results->skip_at_cdma1x_serving_system_step = TRUE; /* Skip +CAD */ - results.skip_at_cdma_service_status_step = TRUE; - + results->skip_at_cdma_service_status_step = TRUE; /* Force to always use the detailed registration checks, as we have * ^SYSINFO for that */ - results.skip_detailed_registration_state = FALSE; - - g_simple_async_result_set_op_res_gpointer (simple, &results, NULL); + results->skip_detailed_registration_state = FALSE; + g_task_return_pointer (task, results, g_free); } - - /* All done. NOTE: complete NOT in idle! */ - g_simple_async_result_complete (simple); - g_object_unref (simple); + g_object_unref (task); } static void -setup_registration_checks (MMIfaceModemCdma *self, - GAsyncReadyCallback callback, - gpointer user_data) +setup_registration_checks (MMIfaceModemCdma *self, + GAsyncReadyCallback callback, + gpointer user_data) { - GSimpleAsyncResult *result; - - result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - setup_registration_checks); - /* Run parent's checks first */ - iface_modem_cdma_parent->setup_registration_checks (self, - (GAsyncReadyCallback)parent_setup_registration_checks_ready, - result); + iface_modem_cdma_parent->setup_registration_checks ( + self, + (GAsyncReadyCallback)parent_setup_registration_checks_ready, + g_task_new (self, NULL, callback, user_data)); } /*****************************************************************************/ |