[libsecret/wip/dueno/f34: 1/2] Fix deprecated-declarations warnings




commit f157dfa1d4ab67ef35d120aef6096681727d8912
Author: Dhanuka Warusadura <csx tuta io>
Date:   Mon Aug 16 11:09:01 2021 +0530

    Fix deprecated-declarations warnings
    
    These changes try to fix the existing deprecated-declarations
    warnings.
    
    Related to: https://gitlab.gnome.org/GNOME/libsecret/-/merge_requests/43

 libsecret/secret-private.h |  3 --
 libsecret/secret-prompt.c  | 98 ++++++++++++++++++++++------------------------
 libsecret/secret-util.c    | 11 ------
 3 files changed, 47 insertions(+), 65 deletions(-)
---
diff --git a/libsecret/secret-private.h b/libsecret/secret-private.h
index 16f78ec..87633f6 100644
--- a/libsecret/secret-private.h
+++ b/libsecret/secret-private.h
@@ -67,9 +67,6 @@ SecretPrompt *       _secret_prompt_instance                  (SecretService *se
 
 void                 _secret_util_strip_remote_error          (GError **error);
 
-gboolean             _secret_util_propagate_error             (GSimpleAsyncResult *async,
-                                                               GError **error);
-
 gchar *              _secret_util_parent_path                 (const gchar *path);
 
 gboolean             _secret_util_empty_path                  (const gchar *path);
diff --git a/libsecret/secret-prompt.c b/libsecret/secret-prompt.c
index e8d8409..f151162 100644
--- a/libsecret/secret-prompt.c
+++ b/libsecret/secret-prompt.c
@@ -232,7 +232,6 @@ secret_prompt_perform_sync (SecretPrompt *self,
 typedef struct {
        GDBusConnection *connection;
        GCancellable *call_cancellable;
-       GCancellable *async_cancellable;
        gulong cancelled_sig;
        gboolean prompting;
        gboolean dismissed;
@@ -249,7 +248,6 @@ perform_closure_free (gpointer data)
 {
        PerformClosure *closure = data;
        g_object_unref (closure->call_cancellable);
-       g_clear_object (&closure->async_cancellable);
        g_object_unref (closure->connection);
        if (closure->result)
                g_variant_unref (closure->result);
@@ -261,11 +259,11 @@ perform_closure_free (gpointer data)
 }
 
 static void
-perform_prompt_complete (GSimpleAsyncResult *res,
+perform_prompt_complete (GTask *task,
                          gboolean dismissed)
 {
-       PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
-
+       PerformClosure *closure = g_task_get_task_data (task);
+       GCancellable *async_cancellable = g_task_get_cancellable (task);
        closure->dismissed = dismissed;
        if (closure->completed)
                return;
@@ -280,10 +278,10 @@ perform_prompt_complete (GSimpleAsyncResult *res,
        closure->watch = 0;
 
        if (closure->cancelled_sig)
-               g_signal_handler_disconnect (closure->async_cancellable, closure->cancelled_sig);
+               g_signal_handler_disconnect (async_cancellable, closure->cancelled_sig);
        closure->cancelled_sig = 0;
 
-       g_simple_async_result_complete (res);
+       g_task_return_boolean (task, TRUE);
 }
 
 static void
@@ -295,9 +293,8 @@ on_prompt_completed (GDBusConnection *connection,
                      GVariant *parameters,
                      gpointer user_data)
 {
-       GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
-       SecretPrompt *self = SECRET_PROMPT (g_async_result_get_source_object (user_data));
-       PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
+       GTask *task = G_TASK (user_data);
+       PerformClosure *closure = g_task_get_task_data (task);
        gboolean dismissed;
 
        closure->prompting = FALSE;
@@ -305,14 +302,12 @@ on_prompt_completed (GDBusConnection *connection,
        if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(bv)"))) {
                g_warning ("SecretPrompt received invalid %s signal of type %s",
                           signal_name, g_variant_get_type_string (parameters));
-               perform_prompt_complete (res, TRUE);
+               perform_prompt_complete (task, TRUE);
 
        } else {
                g_variant_get (parameters, "(bv)", &dismissed, &closure->result);
-               perform_prompt_complete (res, dismissed);
+               perform_prompt_complete (task, dismissed);
        }
-
-       g_object_unref (self);
 }
 
 static void
@@ -320,8 +315,8 @@ on_prompt_prompted (GObject *source,
                     GAsyncResult *result,
                     gpointer user_data)
 {
-       GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
-       PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
+       GTask *task = G_TASK (user_data);
+       PerformClosure *closure = g_task_get_task_data (task);
        SecretPrompt *self = SECRET_PROMPT (source);
        GError *error = NULL;
        GVariant *retval;
@@ -334,8 +329,8 @@ on_prompt_prompted (GObject *source,
                g_clear_error (&error);
 
        if (error != NULL) {
-               g_simple_async_result_take_error (res, error);
-               perform_prompt_complete (res, TRUE);
+               g_task_return_error (task, g_steal_pointer (&error));
+               perform_prompt_complete (task, TRUE);
 
        } else {
                closure->prompting = TRUE;
@@ -344,7 +339,7 @@ on_prompt_prompted (GObject *source,
                /* And now we wait for the signal */
        }
 
-       g_object_unref (res);
+       g_clear_object (&task);
 }
 
 static void
@@ -352,11 +347,11 @@ on_prompt_vanished (GDBusConnection *connection,
                     const gchar *name,
                     gpointer user_data)
 {
-       GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
-       PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
+       GTask *task = G_TASK (user_data);
+       PerformClosure *closure = g_task_get_task_data (task);
        closure->vanished = TRUE;
        g_cancellable_cancel (closure->call_cancellable);
-       perform_prompt_complete (res, TRUE);
+       perform_prompt_complete (task, TRUE);
 }
 
 static void
@@ -364,8 +359,8 @@ on_prompt_dismissed (GObject *source,
                      GAsyncResult *result,
                      gpointer user_data)
 {
-       GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
-       PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
+       GTask *task = G_TASK (user_data);
+       PerformClosure *closure = g_task_get_task_data (task);
        SecretPrompt *self = SECRET_PROMPT (source);
        GError *error = NULL;
        GVariant *retval;
@@ -380,29 +375,29 @@ on_prompt_dismissed (GObject *source,
                g_clear_error (&error);
 
        if (error != NULL) {
-               g_simple_async_result_take_error (res, error);
-               perform_prompt_complete (res, TRUE);
+               g_task_return_error (task, error);
+               perform_prompt_complete (task, TRUE);
        }
 
-       g_object_unref (res);
+       g_clear_object (&task);
 }
 
 static void
 on_prompt_cancelled (GCancellable *cancellable,
                      gpointer user_data)
 {
-       GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
-       PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
-       SecretPrompt *self = SECRET_PROMPT (g_async_result_get_source_object (user_data));
+       GTask *task = G_TASK (user_data);
+       SecretPrompt *self = SECRET_PROMPT (g_task_get_source_object (task));
+       PerformClosure *closure = g_task_get_task_data (task);
 
        /* Instead of cancelling our dbus calls, we cancel the prompt itself via this dbus call */
 
        g_dbus_proxy_call (G_DBUS_PROXY (self), "Dismiss", g_variant_new ("()"),
                           G_DBUS_CALL_FLAGS_NO_AUTO_START, -1,
                           closure->call_cancellable,
-                          on_prompt_dismissed, g_object_ref (res));
+                          on_prompt_dismissed, g_object_ref (task));
 
-       g_object_unref (self);
+       g_clear_object (&task);
 }
 
 /**
@@ -433,8 +428,9 @@ secret_prompt_perform (SecretPrompt *self,
                        GAsyncReadyCallback callback,
                        gpointer user_data)
 {
-       GSimpleAsyncResult *res;
+       GTask *task;
        PerformClosure *closure;
+       GCancellable *async_cancellable;
        gchar *owner_name;
        const gchar *object_path;
        gboolean prompted;
@@ -451,14 +447,15 @@ secret_prompt_perform (SecretPrompt *self,
 
        proxy = G_DBUS_PROXY (self);
 
-       res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
-                                        secret_prompt_perform);
+       task = g_task_new (self, cancellable, callback, user_data);
+       async_cancellable = g_task_get_cancellable (task);
+       g_task_set_source_tag (task, secret_prompt_perform);
        closure = g_slice_new0 (PerformClosure);
        closure->connection = g_object_ref (g_dbus_proxy_get_connection (proxy));
        closure->call_cancellable = g_cancellable_new ();
-       closure->async_cancellable = cancellable ? g_object_ref (cancellable) : NULL;
+       async_cancellable = cancellable ? g_object_ref (cancellable) : NULL;
        closure->return_type = return_type ? g_variant_type_copy (return_type) : NULL;
-       g_simple_async_result_set_op_res_gpointer (res, closure, perform_closure_free);
+       g_task_set_task_data (task, closure, perform_closure_free);
 
        if (window_id == NULL)
                window_id = "";
@@ -472,26 +469,26 @@ secret_prompt_perform (SecretPrompt *self,
                                                              object_path, NULL,
                                                              G_DBUS_SIGNAL_FLAGS_NONE,
                                                              on_prompt_completed,
-                                                             g_object_ref (res),
+                                                             g_object_ref (task),
                                                              g_object_unref);
 
        closure->watch = g_bus_watch_name_on_connection (closure->connection, owner_name,
                                                         G_BUS_NAME_WATCHER_FLAGS_NONE, NULL,
                                                         on_prompt_vanished,
-                                                        g_object_ref (res),
+                                                        g_object_ref (task),
                                                         g_object_unref);
 
-       if (closure->async_cancellable) {
-               closure->cancelled_sig = g_cancellable_connect (closure->async_cancellable,
+       if (async_cancellable) {
+               closure->cancelled_sig = g_cancellable_connect (async_cancellable,
                                                                G_CALLBACK (on_prompt_cancelled),
-                                                               res, NULL);
+                                                               g_object_ref (task), g_object_unref);
        }
 
        g_dbus_proxy_call (proxy, "Prompt", g_variant_new ("(s)", window_id),
                           G_DBUS_CALL_FLAGS_NO_AUTO_START, -1,
-                          closure->call_cancellable, on_prompt_prompted, g_object_ref (res));
+                          closure->call_cancellable, on_prompt_prompted, g_object_ref (task));
 
-       g_object_unref (res);
+       g_clear_object (&task);
        g_free (owner_name);
 }
 
@@ -516,20 +513,19 @@ secret_prompt_perform_finish (SecretPrompt *self,
                               GError **error)
 {
        PerformClosure *closure;
-       GSimpleAsyncResult *res;
        gchar *string;
 
        g_return_val_if_fail (SECRET_IS_PROMPT (self), NULL);
        g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-       g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
-                                                             secret_prompt_perform), NULL);
-
-       res = G_SIMPLE_ASYNC_RESULT (result);
+       g_return_val_if_fail (g_task_is_valid (result, self), NULL);
+       g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == secret_prompt_perform, NULL);
 
-       if (_secret_util_propagate_error (res, error))
+       if (!g_task_propagate_boolean (G_TASK (result), error)) {
+               _secret_util_strip_remote_error (error);
                return NULL;
+       }
 
-       closure = g_simple_async_result_get_op_res_gpointer (res);
+       closure = g_task_get_task_data (G_TASK (result));
        if (closure->result == NULL)
                return NULL;
        if (closure->return_type != NULL && !g_variant_is_of_type (closure->result, closure->return_type)) {
diff --git a/libsecret/secret-util.c b/libsecret/secret-util.c
index c145a44..f011728 100644
--- a/libsecret/secret-util.c
+++ b/libsecret/secret-util.c
@@ -103,17 +103,6 @@ secret_error_get_quark (void)
        return quark;
 }
 
-gboolean
-_secret_util_propagate_error (GSimpleAsyncResult *async,
-                              GError **error)
-{
-       if (!g_simple_async_result_propagate_error (async, error))
-               return FALSE;
-
-       _secret_util_strip_remote_error (error);
-       return TRUE;
-}
-
 void
 _secret_util_strip_remote_error (GError **error)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]