[gnome-software] core: Use GS_APP_QUIRK_HIDE_EVERYWHERE instead of Blacklisted category



commit 0b07a8511514ea416572e2ece503fd5dd405950d
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Nov 29 12:13:55 2019 +0000

    core: Use GS_APP_QUIRK_HIDE_EVERYWHERE instead of Blacklisted category
    
    Hide things based on the new quirk rather than the category. Put some
    conversions in place in the `gs-appstream` plugin to apply the quirk if
    the category is present (for backwards compatibility). Add a new
    metadata key to apply the quirk.
    
    Applications will now be blacklisted if they contain this in their
    appdata:
    ```
    <metadata>
      <value key="GnomeSoftware::quirks::hide-everywhere">true</value>
    </metadata>
    ```
    
    And they will also be blacklisted if they contain this, which is now
    deprecated:
    ```
    <categories>
      <category>Blacklisted</category>
    </categories>
    ```
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Fixes: #696

 lib/gs-plugin-loader.c                       |  2 +-
 plugins/core/gs-appstream.c                  | 18 ++++++++++++++++++
 plugins/core/gs-plugin-hardcoded-blacklist.c |  2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 4fb02d80..fece927c 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1197,7 +1197,7 @@ gs_plugin_loader_app_is_valid (GsApp *app, gpointer user_data)
        }
 
        /* don't show blacklisted apps */
-       if (gs_app_has_category (app, "Blacklisted")) {
+       if (gs_app_has_quirk (app, GS_APP_QUIRK_HIDE_EVERYWHERE)) {
                g_debug ("app invalid as blacklisted %s",
                         gs_plugin_loader_get_app_str (app));
                return FALSE;
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index c91584a0..fcba7053 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -726,6 +726,14 @@ gs_appstream_refine_app (GsPlugin *plugin,
                        gs_app_remove_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE);
        }
 
+       tmp = gs_app_get_metadata_item (app, "GnomeSoftware::quirks::hide-everywhere");
+       if (tmp != NULL) {
+               if (g_strcmp0 (tmp, "true") == 0)
+                       gs_app_add_quirk (app, GS_APP_QUIRK_HIDE_EVERYWHERE);
+               else if (g_strcmp0 (tmp, "false") == 0)
+                       gs_app_remove_quirk (app, GS_APP_QUIRK_HIDE_EVERYWHERE);
+       }
+
        /* set id */
        tmp = xb_node_query_text (component, "id", NULL);
        if (tmp != NULL && gs_app_get_id (app) == NULL)
@@ -830,6 +838,16 @@ gs_appstream_refine_app (GsPlugin *plugin,
                        for (guint i = 0; i < categories->len; i++) {
                                XbNode *category = g_ptr_array_index (categories, i);
                                gs_app_add_category (app, xb_node_get_text (category));
+
+                               /* Special case: We used to use the `Blacklisted`
+                                * category to hide apps from their .desktop
+                                * file or appdata. We now use a quirk for that.
+                                * This special case can be removed when all
+                                * appstream files no longer use the `Blacklisted`
+                                * category (including external-appstream files
+                                * put together by distributions). */
+                               if (g_strcmp0 (xb_node_get_text (category), "Blacklisted") == 0)
+                                       gs_app_add_quirk (app, GS_APP_QUIRK_HIDE_EVERYWHERE);
                        }
                }
        }
diff --git a/plugins/core/gs-plugin-hardcoded-blacklist.c b/plugins/core/gs-plugin-hardcoded-blacklist.c
index b041b314..5034090f 100644
--- a/plugins/core/gs-plugin-hardcoded-blacklist.c
+++ b/plugins/core/gs-plugin-hardcoded-blacklist.c
@@ -52,7 +52,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
        /* search */
        for (i = 0; app_globs[i] != NULL; i++) {
                if (fnmatch (app_globs[i], gs_app_get_id (app), 0) == 0) {
-                       gs_app_add_category (app, "Blacklisted");
+                       gs_app_add_quirk (app, GS_APP_QUIRK_HIDE_EVERYWHERE);
                        break;
                }
        }


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