[gnome-software/wip/kalev/3rd-party-software] packagekit: Implement repository enabling



commit 69f093770996aba5fecd29a20e0184bb63680403
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 |   36 ++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 26ec0da..c9249b6 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -202,6 +202,34 @@ 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 = { 0 };
+       g_autoptr(PkResults) results = NULL;
+
+       data.app = repo;
+       data.plugin = plugin;
+
+       /* 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,
@@ -227,7 +255,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]