[gcr/wip/nielsdg/initial-gtask: 12/16] gcr-console-interaction: Port to GTask
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcr/wip/nielsdg/initial-gtask: 12/16] gcr-console-interaction: Port to GTask
- Date: Mon, 23 Dec 2019 09:07:52 +0000 (UTC)
commit 4b26faa83434375ce05b348324b68bb1c5dea89b
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Dec 22 11:12:59 2019 +0100
gcr-console-interaction: Port to GTask
gcr/console-interaction.c | 53 +++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 25 deletions(-)
---
diff --git a/gcr/console-interaction.c b/gcr/console-interaction.c
index bc3b7dc..b36ff55 100644
--- a/gcr/console-interaction.c
+++ b/gcr/console-interaction.c
@@ -108,46 +108,49 @@ console_interaction_ask_password (GTlsInteraction *interaction,
}
static void
-ask_password_with_getpass (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
+ask_password_with_getpass (GTask *res,
+ gpointer src_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
GTlsPassword *password;
GError *error = NULL;
- password = g_simple_async_result_get_op_res_gpointer (res);
+ password = g_task_get_task_data (task);
console_interaction_ask_password (G_TLS_INTERACTION (object), password,
- cancellable, &error);
- if (error != NULL)
- g_simple_async_result_take_error (res, error);
+ cancellable, &error);
+ if (error == NULL)
+ g_task_return_boolean (task, TRUE);
+ else
+ g_task_return_error (task, g_steal_pointer (&error));
}
static void
console_interaction_ask_password_async (GTlsInteraction *interaction,
- GTlsPassword *password,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ GTlsPassword *password,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (interaction), callback, user_data,
- console_interaction_ask_password);
- g_simple_async_result_set_op_res_gpointer (res, g_object_ref (password), g_object_unref);
- g_simple_async_result_run_in_thread (res, ask_password_with_getpass,
- G_PRIORITY_DEFAULT, cancellable);
- g_object_unref (res);
+ GTask *task;
+
+ task = g_task_new (interaction, cancellable, callback, user_data);
+ g_task_set_source_tag (task, console_interaction_ask_password);
+ g_task_set_task_data (res, g_object_ref (password), g_object_unref);
+
+ g_task_run_in_thread (res, ask_password_with_getpass);
+ g_clear_object (&task);
}
static GTlsInteractionResult
-console_interaction_ask_password_finish (GTlsInteraction *interaction,
- GAsyncResult *result,
- GError **error)
+console_interaction_ask_password_finish (GTlsInteraction *interaction,
+ GAsyncResult *result,
+ GError **error)
{
- g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (interaction),
- console_interaction_ask_password), G_TLS_INTERACTION_FAILED);
+ g_return_val_if_fail (g_task_is_valid (result, interaction),
+ G_TLS_INTERACTION_FAILED);
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
+ if (!g_task_propagate_boolean (task, error))
return G_TLS_INTERACTION_FAILED;
return G_TLS_INTERACTION_HANDLED;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]