Projects
openEuler:24.03:SP1:Everything
PackageKit
_service:tar_scm:Revert-PkClient-Replace-the-GS...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:Revert-PkClient-Replace-the-GSimpleAsyncResult-with-.patch of Package PackageKit
From 9756228d02e05661c15e0fc4b9a230d0d2b02d1b Mon Sep 17 00:00:00 2001 From: lingsheng <lingsheng1@h-partners.com> Date: Fri, 23 Aug 2024 10:53:29 +0000 Subject: [PATCH] Revert PkClient: Replace the GSimpleAsyncResult with the GTask API Reverted patch:https://github.com/PackageKit/Packagekit/commit/b068646d2fbb246c590a47531688c69df2699fa6 --- lib/packagekit-glib2/pk-client.c | 164 ++++++++++++++++--------------- 1 file changed, 86 insertions(+), 78 deletions(-) diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c index c3eadc2..8792dd3 100644 --- a/lib/packagekit-glib2/pk-client.c +++ b/lib/packagekit-glib2/pk-client.c @@ -163,7 +163,7 @@ struct _PkClientState GDBusProxy *proxy_props; GCancellable *cancellable; GCancellable *cancellable_client; - GTask *res; + GSimpleAsyncResult *res; PkBitfield filters; PkClient *client; PkProgress *progress; @@ -210,15 +210,11 @@ pk_client_state_remove (PkClient *client, PkClientState *state) } } -/* - * pk_client_state_finish: - * @state: (transfer full): the #PkClientState - * @error: (transfer full): the #GError - **/ static void -pk_client_state_finish (PkClientState *state, GError *error) +pk_client_state_finish (PkClientState *state, const GError *error) { gboolean ret; + g_autoptr(GError) error_local = NULL; if (state->res == NULL) return; @@ -240,17 +236,15 @@ pk_client_state_finish (PkClientState *state, GError *error) g_object_unref (G_OBJECT (state->proxy_props)); if (state->ret) { - g_task_return_pointer (state->res, - g_object_ref (state->results), - g_object_unref); + g_simple_async_result_set_op_res_gpointer (state->res, + g_object_ref (state->results), + g_object_unref); } else { - g_task_return_error (state->res, error); + g_simple_async_result_set_from_error (state->res, error); } /* remove any socket file */ if (state->client_helper != NULL) { - g_autoptr(GError) error_local = NULL; - if (!pk_client_helper_stop (state->client_helper, &error_local)) g_warning ("failed to stop the client helper: %s", error_local->message); g_object_unref (state->client_helper); @@ -259,6 +253,9 @@ pk_client_state_finish (PkClientState *state, GError *error) /* remove from list */ pk_client_state_remove (state->client, state); + /* complete */ + g_simple_async_result_complete_in_idle (state->res); + /* mark the state as finished */ g_clear_object (&state->res); } @@ -343,7 +340,7 @@ pk_client_cancel_cb (GObject *source_object, g_debug ("failed to cancel: %s", error->message); if (state) - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); } } @@ -370,7 +367,7 @@ pk_client_cancellable_cancel_cb (GCancellable *cancellable, g_debug ("Cancelled, but no proxy, not sure what to do here"); local_error = g_error_new_literal (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "PackageKit transaction disappeared"); - pk_client_state_finish (state, g_steal_pointer (&local_error)); + pk_client_state_finish (state, local_error); return; } @@ -396,10 +393,9 @@ pk_client_state_new (PkClient *client, state = g_object_new (PK_TYPE_CLIENT_STATE, NULL); state->role = role; - state->cancellable = g_cancellable_new (); - state->res = g_task_new (client, state->cancellable, callback_ready, user_data); + state->res = g_simple_async_result_new (G_OBJECT (client), callback_ready, user_data, source_tag); state->client = g_object_ref (client); - g_task_set_source_tag (state->res, source_tag); + state->cancellable = g_cancellable_new (); if (cancellable != NULL) { state->cancellable_client = g_object_ref (cancellable); @@ -1007,7 +1003,7 @@ pk_client_copy_downloaded_finished_cb (GFile *file, GAsyncResult *res, PkClientS /* get the result */ if (!g_file_copy_finish (file, res, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -1076,7 +1072,7 @@ pk_client_copy_downloaded_file (PkClientState *state, const gchar *package_id, c PK_CLIENT_ERROR, PK_ERROR_ENUM_FILE_CONFLICTS, "file %s already exists", path); - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } g_file_copy_async (source, destination, G_FILE_COPY_OVERWRITE, @@ -1182,7 +1178,7 @@ pk_client_signal_finished (PkClientState *state, "Failed: %s", pk_exit_enum_to_string (exit_enum)); } - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -1617,7 +1613,7 @@ pk_client_signal_cb (GDBusProxy *proxy, local_error = g_error_new_literal (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "PackageKit transaction disappeared"); - pk_client_state_finish (state, g_steal_pointer (&local_error)); + pk_client_state_finish (state, local_error); return; } } @@ -1638,7 +1634,7 @@ pk_client_notify_name_owner_cb (GObject *obj, local_error = g_error_new_literal (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "PackageKit daemon disappeared"); - pk_client_state_finish (state, g_steal_pointer (&local_error)); + pk_client_state_finish (state, local_error); } else { pk_client_state_unset_proxy (state); g_cancellable_cancel (state->cancellable); @@ -1695,7 +1691,7 @@ pk_client_method_cb (GObject *source_object, if (value == NULL) { /* fix up the D-Bus error */ pk_client_fixup_dbus_error (error); - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -1740,7 +1736,7 @@ pk_client_set_hints_cb (GObject *source_object, if (value == NULL) { /* fix up the D-Bus error */ pk_client_fixup_dbus_error (error); - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2352,7 +2348,7 @@ pk_client_get_tid_cb (GObject *object, GAsyncResult *res, gpointer user_data) state->tid = pk_control_get_tid_finish (control, res, &error); if (state->tid == NULL) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2385,11 +2381,17 @@ pk_client_get_tid_cb (GObject *object, GAsyncResult *res, gpointer user_data) PkResults * pk_client_generic_finish (PkClient *client, GAsyncResult *res, GError **error) { + GSimpleAsyncResult *simple; + g_return_val_if_fail (PK_IS_CLIENT (client), NULL); - g_return_val_if_fail (G_IS_TASK (res), NULL); + g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (res), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); - return g_task_propagate_pointer (G_TASK (res), error); + simple = G_SIMPLE_ASYNC_RESULT (res); + if (g_simple_async_result_propagate_error (simple, error)) + return NULL; + + return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); } /** @@ -2432,7 +2434,7 @@ pk_client_resolve_async (PkClient *client, PkBitfield filters, gchar **packages, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2485,7 +2487,7 @@ pk_client_search_names_async (PkClient *client, PkBitfield filters, gchar **valu /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2539,7 +2541,7 @@ pk_client_search_details_async (PkClient *client, PkBitfield filters, gchar **va /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2591,7 +2593,7 @@ pk_client_search_groups_async (PkClient *client, PkBitfield filters, gchar **val /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2643,7 +2645,7 @@ pk_client_search_files_async (PkClient *client, PkBitfield filters, gchar **valu /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2695,7 +2697,7 @@ pk_client_get_details_async (PkClient *client, gchar **package_ids, GCancellable /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2744,14 +2746,14 @@ pk_client_get_details_local_async (PkClient *client, gchar **files, GCancellable state->progress = pk_progress_new (); state->files = pk_client_convert_real_paths (files, &error); if (state->files == NULL) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2800,14 +2802,14 @@ pk_client_get_files_local_async (PkClient *client, gchar **files, GCancellable * state->progress = pk_progress_new (); state->files = pk_client_convert_real_paths (files, &error); if (state->files == NULL) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2859,7 +2861,7 @@ pk_client_get_update_detail_async (PkClient *client, gchar **package_ids, GCance /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2912,7 +2914,7 @@ pk_client_download_packages_async (PkClient *client, gchar **package_ids, const /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -2962,7 +2964,7 @@ pk_client_get_updates_async (PkClient *client, PkBitfield filters, GCancellable /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3012,7 +3014,7 @@ pk_client_get_old_transactions_async (PkClient *client, guint number, GCancellab /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3067,7 +3069,7 @@ pk_client_depends_on_async (PkClient *client, PkBitfield filters, gchar **packag /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3117,7 +3119,7 @@ pk_client_get_packages_async (PkClient *client, PkBitfield filters, GCancellable /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3172,7 +3174,7 @@ pk_client_required_by_async (PkClient *client, PkBitfield filters, gchar **packa /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3229,7 +3231,7 @@ pk_client_what_provides_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3278,7 +3280,7 @@ pk_client_get_distro_upgrades_async (PkClient *client, GCancellable *cancellable /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3329,7 +3331,7 @@ pk_client_get_files_async (PkClient *client, gchar **package_ids, GCancellable * /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3377,7 +3379,7 @@ pk_client_get_categories_async (PkClient *client, GCancellable *cancellable, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3443,7 +3445,7 @@ pk_client_remove_packages_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3496,7 +3498,7 @@ pk_client_refresh_cache_async (PkClient *client, gboolean force, GCancellable *c /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3549,7 +3551,7 @@ pk_client_install_packages_async (PkClient *client, PkBitfield transaction_flags /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3603,7 +3605,7 @@ pk_client_install_signature_async (PkClient *client, PkSigTypeEnum type, const g /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3661,7 +3663,7 @@ pk_client_update_packages_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3686,7 +3688,7 @@ pk_client_copy_native_finished_cb (GFile *file, GAsyncResult *res, gpointer user /* get the result */ if (!g_file_copy_finish (file, res, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3797,7 +3799,7 @@ pk_client_install_files_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3807,7 +3809,7 @@ pk_client_install_files_async (PkClient *client, /* check files are valid */ state->files = pk_client_convert_real_paths (files, &error); if (state->files == NULL) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3869,7 +3871,7 @@ pk_client_accept_eula_async (PkClient *client, const gchar *eula_id, GCancellabl /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3919,7 +3921,7 @@ pk_client_get_repo_list_async (PkClient *client, PkBitfield filters, GCancellabl /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -3971,7 +3973,7 @@ pk_client_repo_enable_async (PkClient *client, const gchar *repo_id, gboolean en /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4026,7 +4028,7 @@ pk_client_repo_set_data_async (PkClient *client, const gchar *repo_id, const gch /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4086,7 +4088,7 @@ pk_client_repo_remove_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4147,7 +4149,7 @@ pk_client_upgrade_system_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4205,7 +4207,7 @@ pk_client_repair_system_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4234,7 +4236,7 @@ pk_client_adopt_get_proxy_cb (GObject *object, state->proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (state->proxy == NULL) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4287,7 +4289,7 @@ pk_client_adopt_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } @@ -4327,25 +4329,28 @@ pk_client_adopt_async (PkClient *client, PkProgress * pk_client_get_progress_finish (PkClient *client, GAsyncResult *res, GError **error) { + GSimpleAsyncResult *simple; + g_return_val_if_fail (PK_IS_CLIENT (client), NULL); - g_return_val_if_fail (G_IS_TASK (res), NULL); + g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (res), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); - return g_task_propagate_pointer (G_TASK (res), error); + simple = G_SIMPLE_ASYNC_RESULT (res); + if (g_simple_async_result_propagate_error (simple, error)) + return NULL; + + return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); } /* * pk_client_get_progress_state_finish: - * @state: a #PkClientState - * @error: (transfer full) **/ static void -pk_client_get_progress_state_finish (PkClientState *state, GError *error) +pk_client_get_progress_state_finish (PkClientState *state, const GError *error) { if (state->cancellable_id > 0) { g_cancellable_disconnect (state->cancellable_client, state->cancellable_id); - state->cancellable_id = 0; } g_clear_object (&state->cancellable); g_clear_object (&state->cancellable_client); @@ -4356,15 +4361,18 @@ pk_client_get_progress_state_finish (PkClientState *state, GError *error) g_object_unref (G_OBJECT (state->proxy_props)); if (state->ret) { - g_task_return_pointer (state->res, - g_object_ref (state->progress), - g_object_unref); + g_simple_async_result_set_op_res_gpointer (state->res, + g_object_ref (state->progress), + g_object_unref); } else { - g_task_return_error (state->res, g_steal_pointer (&error)); + g_simple_async_result_set_from_error (state->res, error); } /* remove from list */ pk_client_state_remove (state->client, state); + + /* complete */ + g_simple_async_result_complete_in_idle (state->res); } /* @@ -4380,7 +4388,7 @@ pk_client_get_progress_cb (GObject *source_object, state->proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (state->proxy == NULL) { - pk_client_get_progress_state_finish (state, g_steal_pointer (&error)); + pk_client_get_progress_state_finish (state, error); return; } @@ -4425,7 +4433,7 @@ pk_client_get_progress_async (PkClient *client, /* check not already cancelled */ if (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, &error)) { - pk_client_state_finish (state, g_steal_pointer (&error)); + pk_client_state_finish (state, error); return; } -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2