[gnome-software: 8/9] packagekit: Remove redundant calls to pk_client_set_background()




commit e531204d8c5ab64ed884a4d37eb2c01f10a029a8
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Jun 1 12:00:17 2022 +0100

    packagekit: Remove redundant calls to pk_client_set_background()
    
    `pk_client_set_background()` and `pk_client_set_interactive()` are
    called by `gs_packagekit_task_setup()`, so calling them just before
    calling it is redundant.
    
    This introduces no functional changes for most of these call sites
    *apart from* `gs_plugin_app_upgrade_download()`, `_download_only()` and
    `gs_plugin_packagekit_refresh_metadata_async()`.
    
    At those sites, the intention of the code seemed to be to
    unconditionally set `background=TRUE`, but the subsequent call to
    `gs_packagekit_task_setup()` was undoing that work. Following the logic
    of the comment in `gs_packagekit_task_setup()`, it seems more consistent
    and still correct to set `background=!interactive` as with all the other
    call sites.
    
    The use of `background=TRUE` in these call sites may have dated from
    before the interactive state was properly exposed to those bits of code,
    and hence the background/interactive state passed to PackageKit had to
    be hard-coded.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 plugins/packagekit/gs-plugin-packagekit.c | 17 -----------------
 1 file changed, 17 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 3ee471c84..5c9860cc7 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -267,7 +267,6 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
                                         -1);
 
        task_related = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_related), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_related), GS_PLUGIN_ACTION_GET_SOURCES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_get_packages (PK_CLIENT (task_related),
@@ -333,7 +332,6 @@ gs_plugin_add_sources (GsPlugin *plugin,
                                         -1);
 
        task_sources = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_sources), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_sources), GS_PLUGIN_ACTION_GET_SOURCES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_get_repo_list (PK_CLIENT (task_sources),
@@ -465,7 +463,6 @@ gs_plugin_app_install (GsPlugin *plugin,
 
        /* Set up a #PkTask to handle the D-Bus calls to packagekitd. */
        task_install = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_install), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_install), GS_PLUGIN_ACTION_INSTALL, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        if (gs_app_get_state (app) == GS_APP_STATE_UNAVAILABLE) {
@@ -689,7 +686,6 @@ gs_plugin_app_remove (GsPlugin *plugin,
        gs_packagekit_helper_add_app (helper, app);
 
        task_remove = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_remove), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_remove), GS_PLUGIN_ACTION_REMOVE, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_task_remove_packages_sync (task_remove,
@@ -766,7 +762,6 @@ gs_plugin_packagekit_add_updates (GsPlugin *plugin,
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
 
        task_updates = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_updates), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_updates), GS_PLUGIN_ACTION_GET_UPDATES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_get_updates (PK_CLIENT (task_updates),
@@ -845,7 +840,6 @@ gs_plugin_packagekit_list_apps_async (GsPlugin              *plugin,
        gs_packagekit_helper_set_progress_app (helper, app_dl);
 
        task_list_apps = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_list_apps), interactive);
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_list_apps), GS_PLUGIN_ACTION_UNKNOWN, interactive);
 
        if (gs_app_query_get_provides_files (query) != NULL) {
@@ -913,7 +907,6 @@ gs_plugin_add_search_what_provides (GsPlugin *plugin,
                                         -1);
 
        task_search = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_search), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_search), GS_PLUGIN_ACTION_SEARCH_PROVIDES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_what_provides (PK_CLIENT (task_search),
@@ -2577,7 +2570,6 @@ gs_plugin_packagekit_refresh_guess_app_id (GsPluginPackagekit  *self,
        gs_packagekit_helper_add_app (helper, app);
 
        task_local = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_local), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_local), GS_PLUGIN_ACTION_FILE_TO_APP, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_get_files_local (PK_CLIENT (task_local),
@@ -2715,7 +2707,6 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        files = g_strsplit (filename, "\t", -1);
 
        task_local = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_local), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        pk_client_set_cache_age (PK_CLIENT (task_local), G_MAXUINT);
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_local), GS_PLUGIN_ACTION_FILE_TO_APP, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
@@ -3384,9 +3375,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
 
        task_upgrade = gs_packagekit_task_new (plugin);
        pk_task_set_only_download (task_upgrade, TRUE);
-       pk_client_set_background (PK_CLIENT (task_upgrade), TRUE);
        pk_client_set_cache_age (PK_CLIENT (task_upgrade), 60 * 60 * 24);
-       pk_client_set_interactive (PK_CLIENT (task_upgrade), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_upgrade), GS_PLUGIN_ACTION_UPGRADE_DOWNLOAD, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_task_upgrade_system_sync (task_upgrade,
@@ -3452,7 +3441,6 @@ gs_plugin_enable_repo (GsPlugin *plugin,
        gs_packagekit_helper_add_app (helper, repo);
 
        task_enable_repo = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_enable_repo), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_enable_repo), GS_PLUGIN_ACTION_ENABLE_REPO, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_repo_enable (PK_CLIENT (task_enable_repo),
@@ -3525,7 +3513,6 @@ gs_plugin_disable_repo (GsPlugin *plugin,
        gs_packagekit_helper_add_app (helper, repo);
 
        task_disable_repo = gs_packagekit_task_new (plugin);
-       pk_client_set_interactive (PK_CLIENT (task_disable_repo), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_disable_repo), GS_PLUGIN_ACTION_DISABLE_REPO, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_repo_enable (PK_CLIENT (task_disable_repo),
@@ -3577,8 +3564,6 @@ _download_only (GsPluginPackagekit  *self,
         * shown to the user */
        task_refresh = gs_packagekit_task_new (plugin);
        pk_task_set_only_download (task_refresh, TRUE);
-       pk_client_set_background (PK_CLIENT (task_refresh), TRUE);
-       pk_client_set_interactive (PK_CLIENT (task_refresh), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_refresh), GS_PLUGIN_ACTION_DOWNLOAD, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
 
        results = pk_client_get_updates (PK_CLIENT (task_refresh),
@@ -3716,8 +3701,6 @@ gs_plugin_packagekit_refresh_metadata_async (GsPlugin                     *plugi
 
        task_refresh = gs_packagekit_task_new (plugin);
        pk_task_set_only_download (task_refresh, TRUE);
-       pk_client_set_background (PK_CLIENT (task_refresh), TRUE);
-       pk_client_set_interactive (PK_CLIENT (task_refresh), interactive);
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (task_refresh), GS_PLUGIN_ACTION_UNKNOWN, interactive);
        pk_client_set_cache_age (PK_CLIENT (task_refresh), cache_age_secs);
 


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