[gnome-software/wip/hughsie/more-refine-requires] trivial: Be more specific when requesting information from plugins



commit 0b8463b5c5ff78257b8fef5280a79ca1668d5986
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 5 20:11:24 2018 +0100

    trivial: Be more specific when requesting information from plugins
    
    The AppStream plugin happily shares all the information it knows for pretty
    much any resolve operation. Future plugins will query the data as required,
    and although they are fast, it won't be zero time.
    
    Be explicit and request the things we need in the right places.

 lib/gs-cmd.c                            | 8 ++++++++
 lib/gs-plugin-loader.c                  | 5 +++++
 lib/gs-plugin-types.h                   | 8 ++++++++
 lib/gs-plugin.c                         | 8 ++++++++
 plugins/dummy/gs-self-test.c            | 1 +
 plugins/modalias/gs-self-test.c         | 2 +-
 plugins/shell-extensions/gs-self-test.c | 4 +++-
 src/gs-details-page.c                   | 9 +++++++++
 src/gs-installed-page.c                 | 1 +
 src/gs-overview-page.c                  | 1 +
 10 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-cmd.c b/lib/gs-cmd.c
index d95c4a72..e16487e1 100644
--- a/lib/gs-cmd.c
+++ b/lib/gs-cmd.c
@@ -140,6 +140,14 @@ gs_cmd_refine_flag_from_string (const gchar *flag, GError **error)
                return GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI;
        if (g_strcmp0 (flag, "runtime") == 0)
                return GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME;
+       if (g_strcmp0 (flag, "categories") == 0)
+               return GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES;
+       if (g_strcmp0 (flag, "project-group") == 0)
+               return GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP;
+       if (g_strcmp0 (flag, "developer-name") == 0)
+               return GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME;
+       if (g_strcmp0 (flag, "kudos") == 0)
+               return GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS;
        g_set_error (error,
                     GS_PLUGIN_ERROR,
                     GS_PLUGIN_ERROR_NOT_SUPPORTED,
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 1acf29b6..1c325ff2 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3481,6 +3481,11 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
                gs_plugin_job_add_refine_flags (plugin_job,
                                                GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN);
        }
+       if (gs_plugin_job_has_refine_flags (plugin_job,
+                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH)) {
+               gs_plugin_job_add_refine_flags (plugin_job,
+                                               GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES);
+       }
        if (gs_plugin_job_has_refine_flags (plugin_job,
                                            GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME)) {
                gs_plugin_job_add_refine_flags (plugin_job,
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index 1576d34a..ffa5d8f4 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -153,6 +153,10 @@ typedef enum {
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI:          Require the origin for UI
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME:            Require the runtime
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS:                Require screenshot information
+ * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES:         Require categories
+ * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP:      Require project group
+ * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME:     Require developer name
+ * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS:              Require kudos
  *
  * The refine flags.
  **/
@@ -184,6 +188,10 @@ typedef enum {
 #define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI       ((guint64) 1 << 24)
 #define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME         ((guint64) 1 << 25)
 #define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS     ((guint64) 1 << 26)
+#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES      ((guint64) 1 << 27)
+#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP   ((guint64) 1 << 28)
+#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME  ((guint64) 1 << 29)
+#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS           ((guint64) 1 << 30)
 typedef guint64 GsPluginRefineFlags;
 
 /**
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index a9f5585d..a0a8eb60 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -2042,6 +2042,14 @@ gs_plugin_refine_flags_to_string (GsPluginRefineFlags refine_flags)
                g_ptr_array_add (cstrs, "require-runtime");
        if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS)
                g_ptr_array_add (cstrs, "require-screenshots");
+       if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES)
+               g_ptr_array_add (cstrs, "require-categories");
+       if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP)
+               g_ptr_array_add (cstrs, "require-project-group");
+       if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME)
+               g_ptr_array_add (cstrs, "require-developer-name");
+       if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS)
+               g_ptr_array_add (cstrs, "require-kudos");
        if (cstrs->len == 0)
                return g_strdup ("none");
        g_ptr_array_add (cstrs, NULL);
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 513e43b8..feb4f0f2 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -365,6 +365,7 @@ gs_plugins_dummy_installed_func (GsPluginLoader *plugin_loader)
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE,
                                         NULL);
        list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
diff --git a/plugins/modalias/gs-self-test.c b/plugins/modalias/gs-self-test.c
index 0816b97a..dbe628a7 100644
--- a/plugins/modalias/gs-self-test.c
+++ b/plugins/modalias/gs-self-test.c
@@ -37,7 +37,7 @@ gs_plugins_modalias_func (GsPluginLoader *plugin_loader)
        /* get search result based on addon keyword */
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
                                         "search", "colorhug2",
-                                        "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
+                                        "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES,
                                         NULL);
        list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
        gs_test_flush_main_context ();
diff --git a/plugins/shell-extensions/gs-self-test.c b/plugins/shell-extensions/gs-self-test.c
index 9d333877..b0fb993d 100644
--- a/plugins/shell-extensions/gs-self-test.c
+++ b/plugins/shell-extensions/gs-self-test.c
@@ -42,7 +42,9 @@ gs_plugins_shell_extensions_installed_func (GsPluginLoader *plugin_loader)
        }
 
        /* get installed packages */
-       plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_INSTALLED, NULL);
+       plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_INSTALLED,
+                                        "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES,
+                                        NULL);
        list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
        gs_test_flush_main_context ();
        g_assert_no_error (error);
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index da0b3109..bbe6943b 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1813,6 +1813,9 @@ gs_details_page_set_local_file (GsDetailsPage *self, GFile *file)
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS,
                                         NULL);
        gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
@@ -1841,6 +1844,9 @@ gs_details_page_set_url (GsDetailsPage *self, const gchar *url)
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS |
                                                         GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES,
                                         NULL);
@@ -1869,6 +1875,9 @@ gs_details_page_load (GsDetailsPage *self)
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROJECT_GROUP |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_DEVELOPER_NAME |
+                                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_KUDOS |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS,
                                         NULL);
        gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index 1a2a0037..38b2e9bd 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -271,6 +271,7 @@ gs_installed_page_load (GsInstalledPage *self)
                GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE |
                GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION |
                GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE |
+               GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES |
                GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING;
 
        if (should_show_installed_size (self))
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 24d74f61..5598713f 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -785,6 +785,7 @@ gs_overview_page_load (GsOverviewPage *self)
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_POPULAR,
                                                 "max-results", 20,
                                                 "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
+                                                                GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES |
                                                                 GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
                                                 "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
                                                                 GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,


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