[gnome-software/gnome-3-26] packagekit: Implement repository enabling



commit 989fdc5bfb268b40c21484b5d5aa06a823389061
Author: Kalev Lember <klember redhat com>
Date:   Thu Dec 7 11:38:01 2017 +0100

    packagekit: Implement repository enabling
    
    This fixes enabling repositories after clicking 'Enable' in the Enable
    Proprietary Software Sources notification which up until now was
    untested and just errored out.

 plugins/packagekit/gs-plugin-packagekit.c |   37 ++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 4f758af..7f78a1c 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -261,6 +261,35 @@ gs_plugin_app_source_enable (GsPlugin *plugin,
        return TRUE;
 }
 
+static gboolean
+gs_plugin_repo_enable (GsPlugin *plugin,
+                       GsApp *repo,
+                       GCancellable *cancellable,
+                       GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       ProgressData data;
+       g_autoptr(PkResults) results = NULL;
+
+       data.app = repo;
+       data.plugin = plugin;
+       data.ptask = NULL;
+
+       /* do sync call */
+       gs_plugin_status_update (plugin, repo, GS_PLUGIN_STATUS_WAITING);
+       results = pk_client_repo_enable (PK_CLIENT (priv->task),
+                                        gs_app_get_id (repo),
+                                        TRUE,
+                                        cancellable,
+                                        gs_plugin_packagekit_progress_cb, &data,
+                                        error);
+       if (!gs_plugin_packagekit_results_valid (results, error)) {
+               gs_utils_error_add_unique_id (error, repo);
+               return FALSE;
+       }
+       return TRUE;
+}
+
 gboolean
 gs_plugin_app_install (GsPlugin *plugin,
                       GsApp *app,
@@ -287,7 +316,13 @@ gs_plugin_app_install (GsPlugin *plugin,
                       gs_plugin_get_name (plugin)) != 0)
                return TRUE;
 
-       /* we enable the repo */
+       /* enable repo */
+       if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE) {
+               return gs_plugin_repo_enable (plugin, app,
+                                             cancellable, error);
+       }
+
+       /* enable the repo where the unavailable app is coming from */
        if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE) {
 
                /* get everything up front we need */


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