[gcr/wip/nielsdg/initial-gtask: 82/86] 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: 82/86] gcr-console-interaction: Port to GTask
- Date: Tue, 31 Mar 2020 07:28:59 +0000 (UTC)
commit 21688b9806e0322c1b2dfc37cc1adb2618cb74e0
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 | 55 +++++++++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/gcr/console-interaction.c b/gcr/console-interaction.c
index bc3b7dc..47c2cb4 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 *task,
+ gpointer src_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
GTlsPassword *password;
GError *error = NULL;
- password = g_simple_async_result_get_op_res_gpointer (res);
- console_interaction_ask_password (G_TLS_INTERACTION (object), password,
- cancellable, &error);
- if (error != NULL)
- g_simple_async_result_take_error (res, error);
+ password = g_task_get_task_data (task);
+ console_interaction_ask_password (G_TLS_INTERACTION (src_object), password,
+ 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 (task, g_object_ref (password), g_object_unref);
+
+ g_task_run_in_thread (task, 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 (G_TASK (result), 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]