[PATCH] base-modem: port mm_base_modem_authorize to use GTask
Aleksander Morgado
aleksander at aleksander.es
Thu Apr 6 18:29:02 UTC 2017
On 04/04/17 08:37, Ben Chan wrote:
> ---
> src/mm-base-modem.c | 25 ++++++++++---------------
> 1 file changed, 10 insertions(+), 15 deletions(-)
>
Pushed to git master, thanks!
> diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
> index 430ce59d..76286f6b 100644
> --- a/src/mm-base-modem.c
> +++ b/src/mm-base-modem.c
> @@ -1172,23 +1172,22 @@ mm_base_modem_authorize_finish (MMBaseModem *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
> authorize_ready (MMAuthProvider *authp,
> GAsyncResult *res,
> - GSimpleAsyncResult *simple)
> + GTask *task)
> {
> GError *error = NULL;
>
> if (!mm_auth_provider_authorize_finish (authp, res, &error))
> - g_simple_async_result_take_error (simple, error);
> + g_task_return_error (task, error);
> else
> - g_simple_async_result_set_op_res_gboolean (simple, TRUE);
> + g_task_return_boolean (task, TRUE);
>
> - g_simple_async_result_complete (simple);
> - g_object_unref (simple);
> + g_object_unref (task);
> }
>
> void
> @@ -1198,18 +1197,14 @@ mm_base_modem_authorize (MMBaseModem *self,
> GAsyncReadyCallback callback,
> gpointer user_data)
> {
> - GSimpleAsyncResult *result;
> + GTask *task;
>
> - result = g_simple_async_result_new (G_OBJECT (self),
> - callback,
> - user_data,
> - mm_base_modem_authorize);
> + task = g_task_new (self, self->priv->authp_cancellable, callback, user_data);
>
> /* When running in the session bus for tests, default to always allow */
> if (mm_context_get_test_session ()) {
> - g_simple_async_result_set_op_res_gboolean (result, TRUE);
> - g_simple_async_result_complete_in_idle (result);
> - g_object_unref (result);
> + g_task_return_boolean (task, TRUE);
> + g_object_unref (task);
> return;
> }
>
> @@ -1218,7 +1213,7 @@ mm_base_modem_authorize (MMBaseModem *self,
> authorization,
> self->priv->authp_cancellable,
> (GAsyncReadyCallback)authorize_ready,
> - result);
> + task);
> }
>
> /*****************************************************************************/
>
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list