[gnome-software] Add a refine flag to be able to refine the related applications



commit ac4726635c8fb7704dcf2d39267b38d7286ee5b2
Author: Richard Hughes <richard hughsie com>
Date:   Mon Feb 17 13:00:23 2014 +0000

    Add a refine flag to be able to refine the related applications

 src/gs-cmd.c           |    2 ++
 src/gs-plugin-loader.c |   30 ++++++++++++++++++++++++++++++
 src/gs-plugin.h        |    1 +
 src/gs-shell.c         |    3 ++-
 4 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 6fad84f..b31ea36 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -135,6 +135,8 @@ gs_cmd_refine_flag_from_string (const gchar *flag, GError **error)
                return GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS;
        if (g_strcmp0 (flag, "origin") == 0)
                return GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN;
+       if (g_strcmp0 (flag, "related") == 0)
+               return GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED;
        g_set_error (error,
                     GS_PLUGIN_ERROR,
                     GS_PLUGIN_ERROR_NOT_SUPPORTED,
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 560bcee..a65b463 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -227,6 +227,9 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                             GError **error)
 {
        GList *l;
+       GList *related_list = NULL;
+       GPtrArray *related;
+       GsApp *app;
        GsPlugin *plugin;
        gboolean ret = TRUE;
        guint i;
@@ -253,6 +256,32 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                        goto out;
        }
 
+       /* also do related packages one layer deep */
+       if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED) > 0) {
+               flags &= ~GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED;
+               for (l = *list; l != NULL; l = l->next) {
+                       app = GS_APP (l->data);
+                       related = gs_app_get_related (app);
+                       for (i = 0; i < related->len; i++) {
+                               app = g_ptr_array_index (related, i);
+                               g_debug ("refining related: %s[%s]",
+                                        gs_app_get_id (app),
+                                        gs_app_get_source_default (app));
+                               gs_plugin_add_app (&related_list, app);
+                       }
+               }
+               if (related_list != NULL) {
+                       ret = gs_plugin_loader_run_refine (plugin_loader,
+                                                          function_name_parent,
+                                                          &related_list,
+                                                          flags,
+                                                          cancellable,
+                                                          error);
+                       if (!ret)
+                               goto out;
+               }
+       }
+
        /* now emit all the changed signals */
        for (l = freeze_list; l != NULL; l = l->next)
                g_object_thaw_notify (G_OBJECT (l->data));
@@ -260,6 +289,7 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
        /* dedupe applications we already know about */
        gs_plugin_loader_list_dedupe (plugin_loader, *list);
 out:
+       gs_plugin_list_free (related_list);
        gs_plugin_list_free (freeze_list);
        return ret;
 }
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 9c23ac7..58b0d0b 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -93,6 +93,7 @@ typedef enum {
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION     = 1 << 8,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS   = 1 << 9,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN           = 1 << 10,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED          = 1 << 11,
        GS_PLUGIN_REFINE_FLAGS_LAST
 } GsPluginRefineFlags;
 
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 53c4dad..f5852c9 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -952,7 +952,8 @@ gs_shell_show_sources (GsShell *shell)
 
        /* get the list of non-core software sources */
        gs_plugin_loader_get_sources_async (priv->plugin_loader,
-                                           GS_PLUGIN_REFINE_FLAGS_DEFAULT,
+                                           GS_PLUGIN_REFINE_FLAGS_DEFAULT |
+                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED,
                                            priv->cancellable,
                                            (GAsyncReadyCallback) gs_shell_sources_get_sources_cb,
                                            shell);


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