[gnome-software/wip/hughsie/vnd.flatpak.ref: 6/7] Do not rely on the AppStream plugin to handle searching in flatpak



commit 3558546b82da9b92da44bc04477535ff57840819
Author: Richard Hughes <richard hughsie com>
Date:   Tue Sep 13 16:52:39 2016 +0100

    Do not rely on the AppStream plugin to handle searching in flatpak
    
    This removes the flatpak symlink cache which turned out to be an inflexible
    workaround as we couldn't force a specific remote to be refreshed syncronously.

 configure.ac                           |    2 +-
 src/gs-self-test.c                     |    1 +
 src/plugins/gs-flatpak-symlinks.c      |  185 +++------------------------
 src/plugins/gs-flatpak-symlinks.h      |    2 +-
 src/plugins/gs-flatpak.c               |  219 ++++++++++++++++++++++++++++++--
 src/plugins/gs-flatpak.h               |   19 +++
 src/plugins/gs-plugin-appstream.c      |   16 +--
 src/plugins/gs-plugin-flatpak-system.c |   59 +++++++++
 src/plugins/gs-plugin-flatpak-user.c   |   59 +++++++++
 9 files changed, 368 insertions(+), 194 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4e1a6e6..0a7c49f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,7 +84,7 @@ dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
 PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.20.0 gio-unix-2.0)
-PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.6.1)
+PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.6.4)
 PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0 >= 2.31.5)
 PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= 1.1.1)
 PKG_CHECK_MODULES(SQLITE, sqlite3)
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 4b00b8d..e844920 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -1047,6 +1047,7 @@ gs_plugin_loader_flatpak_func (GsPluginLoader *plugin_loader)
        g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
        g_assert_cmpint ((gint64) gs_app_get_kudos (app), ==,
                         GS_APP_KUDO_HAS_KEYWORDS |
+                        GS_APP_KUDO_HI_DPI_ICON |
                         GS_APP_KUDO_SANDBOXED_SECURE |
                         GS_APP_KUDO_SANDBOXED);
        g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "");
diff --git a/src/plugins/gs-flatpak-symlinks.c b/src/plugins/gs-flatpak-symlinks.c
index cff6c5a..cf15ac8 100644
--- a/src/plugins/gs-flatpak-symlinks.c
+++ b/src/plugins/gs-flatpak-symlinks.c
@@ -27,117 +27,11 @@
 #include "gs-flatpak-symlinks.h"
 
 static gboolean
-gs_flatpak_symlinks_remote_valid (FlatpakRemote *xremote)
-{
-       if (xremote == NULL)
-               return FALSE;
-       if (flatpak_remote_get_disabled (xremote))
-               return FALSE;
-       if (flatpak_remote_get_noenumerate (xremote))
-               return FALSE;
-       return TRUE;
-}
-
-/* encode the symlink name with ${scope}:${name}[.xml.gz] */
-static gboolean
-gs_flatpak_symlinks_check_exist (FlatpakRemote *xremote,
-                                const gchar *cache_dir,
-                                const gchar *prefix,
-                                const gchar *kind,
-                                GError **error)
-{
-       g_autofree gchar *appstream_dir_fn = NULL;
-       g_autofree gchar *flatpak_remote_fn = NULL;
-       g_autofree gchar *subdir = NULL;
-       g_autofree gchar *symlink_source = NULL;
-       g_autofree gchar *symlink_target = NULL;
-       g_autofree gchar *xml_dir = NULL;
-       g_autoptr(GFile) appstream_dir = NULL;
-
-       /* get the AppStream data location */
-       appstream_dir = flatpak_remote_get_appstream_dir (xremote, NULL);
-       if (appstream_dir == NULL) {
-               g_debug ("no appstream dir for %s, skipping",
-                        flatpak_remote_get_name (xremote));
-               return TRUE;
-       }
-
-       /* ensure all the remotes have an XML symlink */
-       appstream_dir_fn = g_file_get_path (appstream_dir);
-       subdir = g_build_filename (cache_dir, kind, NULL);
-       if (g_strcmp0 (kind, "xmls") == 0) {
-               flatpak_remote_fn = g_strdup_printf ("%s:%s.xml.gz",
-                                                    prefix,
-                                                    flatpak_remote_get_name (xremote));
-               symlink_target = g_build_filename (appstream_dir_fn,
-                                                  "appstream.xml.gz",
-                                                  NULL);
-       } else {
-               flatpak_remote_fn = g_strdup_printf ("%s:%s",
-                                                    prefix,
-                                                    flatpak_remote_get_name (xremote));
-               symlink_target = g_build_filename (appstream_dir_fn,
-                                                  "icons",
-                                                  NULL);
-       }
-       symlink_source = g_build_filename (subdir,
-                                          flatpak_remote_fn,
-                                          NULL);
-       if (!gs_mkdir_parent (symlink_source, error))
-               return FALSE;
-
-       /* check XML symbolic link is correct */
-       if (g_file_test (symlink_source, G_FILE_TEST_IS_SYMLINK)) {
-               g_autofree gchar *symlink_target_actual = NULL;
-
-               /* target does not exist */
-               symlink_target_actual = g_file_read_link (symlink_source, NULL);
-               if (!g_file_test (symlink_target_actual, G_FILE_TEST_EXISTS)) {
-                       g_debug ("symlink %s is dangling (no %s), deleting",
-                                 symlink_source, symlink_target_actual);
-                       return gs_utils_unlink (symlink_source, error);
-               }
-
-               /* same */
-               if (g_strcmp0 (symlink_target_actual, symlink_target) == 0) {
-                       g_debug ("symlink %s already points to %s",
-                                symlink_source, symlink_target);
-                       return TRUE;
-               }
-               g_warning ("symlink incorrect expected %s target to "
-                          "be %s, got %s, deleting",
-                          symlink_source,
-                          symlink_target,
-                          symlink_target_actual);
-               if (!gs_utils_unlink (symlink_source, error))
-                       return FALSE;
-       }
-
-       /* create it if required, but only if the destination exists */
-       if (!g_file_test (symlink_source, G_FILE_TEST_EXISTS)) {
-               if (g_file_test (symlink_target, G_FILE_TEST_EXISTS)) {
-                       g_debug ("creating missing symbolic link from %s to %s",
-                                symlink_source, symlink_target);
-                       if (!gs_utils_symlink (symlink_target, symlink_source, error))
-                               return FALSE;
-               } else {
-                       g_debug ("not creating missing symbolic link from "
-                                "%s to %s as target does not yet exist",
-                                symlink_source, symlink_target);
-               }
-       }
-
-       return TRUE;
-}
-
-/* encode the symlink name with ${scope}:${name}, i.e. the origin */
-static gboolean
-gs_flatpak_symlinks_check_valid (FlatpakInstallation *installation,
-                                const gchar *cache_dir,
-                                const gchar *prefix,
-                                const gchar *kind,
-                                GCancellable *cancellable,
-                                GError **error)
+gs_flatpak_symlinks_cleanup_kind (const gchar *cache_dir,
+                                 const gchar *prefix,
+                                 const gchar *kind,
+                                 GCancellable *cancellable,
+                                 GError **error)
 {
        const gchar *tmp;
        g_autofree gchar *subdir = NULL;
@@ -164,21 +58,7 @@ gs_flatpak_symlinks_check_valid (FlatpakInstallation *installation,
                fn = g_build_filename (subdir, tmp, NULL);
                if (!g_file_test (fn, G_FILE_TEST_IS_SYMLINK))
                        continue;
-
-               /* can we find a valid remote for this file */
-               origin = g_strdup (tmp + strlen (prefix_colon));
-               str = g_strrstr (origin, ".xml.gz");
-               if (str != NULL)
-                       *str = '\0';
-               xremote = flatpak_installation_get_remote_by_name (installation,
-                                                                  origin,
-                                                                  cancellable,
-                                                                  NULL);
-               if (gs_flatpak_symlinks_remote_valid (xremote)) {
-                       g_debug ("%s remote symlink is valid", origin);
-                       continue;
-               }
-               g_debug ("deleting %s symlink as no longer valid", fn);
+               g_debug ("deleting %s as symlinks no longer required", fn);
                if (!gs_utils_unlink (fn, error))
                        return FALSE;
        }
@@ -186,14 +66,12 @@ gs_flatpak_symlinks_check_valid (FlatpakInstallation *installation,
 }
 
 gboolean
-gs_flatpak_symlinks_rebuild (FlatpakInstallation *installation,
+gs_flatpak_symlinks_cleanup (FlatpakInstallation *installation,
                             GCancellable *cancellable,
                             GError **error)
 {
        const gchar *prefix = "flatpak";
-       guint i;
        g_autofree gchar *cache_dir = NULL;
-       g_autoptr(GPtrArray) xremotes = NULL;
 
        /* use the correct symlink target */
        cache_dir = g_build_filename (g_get_user_data_dir (),
@@ -202,47 +80,18 @@ gs_flatpak_symlinks_rebuild (FlatpakInstallation *installation,
        if (flatpak_installation_get_is_user (installation))
                prefix = "user-flatpak";
 
-       /* go through each remote checking the symlink is in place */
-       xremotes = flatpak_installation_list_remotes (installation,
-                                                     cancellable,
-                                                     error);
-       if (xremotes == NULL)
-               return FALSE;
-       for (i = 0; i < xremotes->len; i++) {
-               FlatpakRemote *xremote = g_ptr_array_index (xremotes, i);
-               if (!gs_flatpak_symlinks_remote_valid (xremote))
-                       continue;
-               g_debug ("found remote %s:%s",
-                        prefix,
-                        flatpak_remote_get_name (xremote));
-               if (!gs_flatpak_symlinks_check_exist (xremote,
-                                                     cache_dir,
-                                                     prefix,
-                                                     "icons",
-                                                     error))
-                       return FALSE;
-               if (!gs_flatpak_symlinks_check_exist (xremote,
-                                                     cache_dir,
-                                                     prefix,
-                                                     "xmls",
-                                                     error))
-                       return FALSE;
-       }
-
        /* go through each symlink and check the remote still valid */
-       if (!gs_flatpak_symlinks_check_valid (installation,
-                                             cache_dir,
-                                             prefix,
-                                             "icons",
-                                             cancellable,
-                                             error))
+       if (!gs_flatpak_symlinks_cleanup_kind (cache_dir,
+                                              prefix,
+                                              "icons",
+                                              cancellable,
+                                              error))
                return FALSE;
-       if (!gs_flatpak_symlinks_check_valid (installation,
-                                             cache_dir,
-                                             prefix,
-                                             "xmls",
-                                             cancellable,
-                                             error))
+       if (!gs_flatpak_symlinks_cleanup_kind (cache_dir,
+                                              prefix,
+                                              "xmls",
+                                              cancellable,
+                                              error))
                return FALSE;
 
        /* success */
diff --git a/src/plugins/gs-flatpak-symlinks.h b/src/plugins/gs-flatpak-symlinks.h
index aeda415..e8f9dc6 100644
--- a/src/plugins/gs-flatpak-symlinks.h
+++ b/src/plugins/gs-flatpak-symlinks.h
@@ -26,7 +26,7 @@
 
 G_BEGIN_DECLS
 
-gboolean        gs_flatpak_symlinks_rebuild    (FlatpakInstallation    *installation,
+gboolean        gs_flatpak_symlinks_cleanup    (FlatpakInstallation    *installation,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
 
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 6f9fc4d..d1b03f3 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -42,6 +42,7 @@ struct _GsFlatpak {
        GFileMonitor            *monitor;
        AsAppScope               scope;
        GsPlugin                *plugin;
+       AsStore                 *store;
 };
 
 G_DEFINE_TYPE (GsFlatpak, gs_flatpak, G_TYPE_OBJECT)
@@ -104,10 +105,104 @@ gs_plugin_flatpak_changed_cb (GFileMonitor *monitor,
                g_warning ("failed to get initial available data: %s",
                           error_md->message);
        }
+}
+
+static gboolean
+gs_flatpak_add_apps_from_xremote (GsFlatpak *self,
+                                 FlatpakRemote *xremote,
+                                 GCancellable *cancellable,
+                                 GError **error)
+{
+       GPtrArray *apps;
+       guint i;
+       g_autofree gchar *appstream_dir_fn = NULL;
+       g_autofree gchar *appstream_fn = NULL;
+       g_autofree gchar *only_app_id = NULL;
+       g_autoptr(AsStore) store = NULL;
+       g_autoptr(GFile) appstream_dir = NULL;
+       g_autoptr(GFile) file = NULL;
+
+       /* get the AppStream data location */
+       appstream_dir = flatpak_remote_get_appstream_dir (xremote, NULL);
+       if (appstream_dir == NULL) {
+               g_debug ("no appstream dir for %s, skipping",
+                        flatpak_remote_get_name (xremote));
+               return TRUE;
+       }
+
+       /* load the file into a temp store */
+       appstream_dir_fn = g_file_get_path (appstream_dir);
+       appstream_fn = g_build_filename (appstream_dir_fn,
+                                        "appstream.xml.gz", NULL);
+       file = g_file_new_for_path (appstream_fn);
+       store = as_store_new ();
+       as_store_set_add_flags (store, AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
+       if (!as_store_from_file (store, file, NULL, cancellable, error)) {
+               gs_utils_error_convert_appstream (error);
+               return FALSE;
+       }
 
-       /* ensure the AppStream symlink cache is up to date */
-       if (!gs_flatpak_symlinks_rebuild (self->installation, NULL, &error))
-               g_warning ("failed to check symlinks: %s", error->message);
+       /* only add the specific app for noenumerate=true */
+       if (flatpak_remote_get_noenumerate (xremote)) {
+               g_autofree gchar *tmp = NULL;
+               tmp = g_strdup (flatpak_remote_get_name (xremote));
+               g_strdelimit (tmp, "-", '\0');
+               only_app_id = g_strdup_printf ("%s.desktop", tmp);
+       }
+
+       /* get all the apps and fix them up */
+       apps = as_store_get_apps (store);
+       for (i = 0; i < apps->len; i++) {
+               AsApp *app = g_ptr_array_index (apps, i);
+
+               /* filter to app */
+               if (only_app_id != NULL &&
+                   g_strcmp0 (as_app_get_id (app), only_app_id) != 0) {
+                       as_app_set_kind (app, AS_APP_KIND_UNKNOWN);
+                       continue;
+               }
+
+               /* add */
+               as_app_set_scope (app, self->scope);
+               as_app_set_origin (app, flatpak_remote_get_name (xremote));
+               as_app_add_keyword (app, NULL, "flatpak");
+               g_debug ("adding %s", as_app_get_unique_id (app));
+       }
+
+       /* add them to the main store */
+       as_store_add_apps (self->store, apps);
+       return TRUE;
+}
+
+static gboolean
+gs_flatpak_rescan_appstream_store (GsFlatpak *self,
+                                  GCancellable *cancellable,
+                                  GError **error)
+{
+       guint i;
+       g_autoptr(GPtrArray) xremotes = NULL;
+
+       /* remove all components */
+       as_store_remove_all (self->store);
+
+       /* go through each remote adding metadata */
+       xremotes = flatpak_installation_list_remotes (self->installation,
+                                                     cancellable,
+                                                     error);
+       if (xremotes == NULL) {
+               gs_plugin_flatpak_error_convert (error);
+               return FALSE;
+       }
+       for (i = 0; i < xremotes->len; i++) {
+               FlatpakRemote *xremote = g_ptr_array_index (xremotes, i);
+               if (flatpak_remote_get_disabled (xremote))
+                       continue;
+               g_debug ("found remote %s",
+                        flatpak_remote_get_name (xremote));
+               if (!gs_flatpak_add_apps_from_xremote (self, xremote, cancellable, error))
+                       return FALSE;
+       }
+       return TRUE;
 }
 
 gboolean
@@ -153,8 +248,12 @@ gs_flatpak_setup (GsFlatpak *self, GCancellable *cancellable, GError **error)
        g_signal_connect (self->monitor, "changed",
                          G_CALLBACK (gs_plugin_flatpak_changed_cb), self);
 
-       /* ensure the AppStream symlink cache is up to date */
-       if (!gs_flatpak_symlinks_rebuild (self->installation, cancellable, error))
+       /* ensure the legacy AppStream symlink cache is deleted */
+       if (!gs_flatpak_symlinks_cleanup (self->installation, cancellable, error))
+               return FALSE;
+
+       /* ensure the AppStream store is up to date */
+       if (!gs_flatpak_rescan_appstream_store (self, cancellable, error))
                return FALSE;
 
        /* success */
@@ -244,11 +343,9 @@ gs_flatpak_refresh_appstream (GsFlatpak *self, guint cache_age,
                something_changed = TRUE;
        }
 
-       /* ensure the AppStream symlink cache is up to date */
+       /* ensure the AppStream store is up to date */
        if (something_changed) {
-               if (!gs_flatpak_symlinks_rebuild (self->installation,
-                                                 cancellable,
-                                                 error))
+               if (!gs_flatpak_rescan_appstream_store (self, cancellable, error))
                        return FALSE;
        }
 
@@ -620,6 +717,10 @@ gs_flatpak_app_install_source (GsFlatpak *self, GsApp *app,
                return FALSE;
        }
 
+       /* refresh the AppStream data manually */
+       if (!gs_flatpak_add_apps_from_xremote (self, xremote, cancellable, error))
+               return FALSE;
+
        /* success */
        gs_app_set_state (app, AS_APP_STATE_INSTALLED);
        return TRUE;
@@ -1397,6 +1498,21 @@ gs_plugin_refine_item_size (GsFlatpak *self,
        return TRUE;
 }
 
+static gboolean
+gs_flatpak_refine_appstream (GsFlatpak *self, GsApp *app, GError **error)
+{
+       AsApp *item;
+       const gchar *unique_id = gs_app_get_unique_id (app);
+       if (unique_id == NULL)
+               return TRUE;
+       item = as_store_get_app_by_unique_id (self->store,
+                                             unique_id,
+                                             AS_STORE_SEARCH_FLAG_USE_WILDCARDS);
+       if (item == NULL)
+               return TRUE;
+       return gs_appstream_refine_app (self->plugin, app, item, error);
+}
+
 gboolean
 gs_flatpak_refine_app (GsFlatpak *self,
                       GsApp *app,
@@ -1417,6 +1533,10 @@ gs_flatpak_refine_app (GsFlatpak *self,
                                  gs_app_get_id (app));
        g_assert (ptask != NULL);
 
+       /* always do AppStream properties */
+       if (!gs_flatpak_refine_appstream (self, app, error))
+               return FALSE;
+
        /* flatpak apps can always be removed */
        gs_app_remove_quirk (app, AS_APP_QUIRK_COMPULSORY);
 
@@ -1485,6 +1605,49 @@ gs_flatpak_refine_app (GsFlatpak *self,
 }
 
 gboolean
+gs_flatpak_refine_wildcard (GsFlatpak *self, GsAppList *list, GsApp *app,
+                           GCancellable *cancellable, GError **error)
+{
+       const gchar *id;
+       guint i;
+       g_autoptr(GPtrArray) items = NULL;
+
+       /* not a wildcard */
+       if (!gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX))
+               return TRUE;
+
+       /* not valid */
+       id = gs_app_get_id (app);
+       if (id == NULL)
+               return TRUE;
+
+       /* find all apps when matching any prefixes */
+       items = as_store_get_apps_by_id (self->store, id);
+       for (i = 0; i < items->len; i++) {
+               AsApp *item = NULL;
+               g_autoptr(GsApp) new = NULL;
+
+               /* does the app have an installation method */
+               item = g_ptr_array_index (items, i);
+               if (as_app_get_bundle_default (item) == NULL) {
+                       g_debug ("not using %s for wildcard as no bundle",
+                                as_app_get_id (item));
+                       continue;
+               }
+
+               /* new app */
+               g_debug ("found %s for wildcard %s",
+                        as_app_get_unique_id (item), id);
+               new = gs_appstream_create_app (self->plugin, item);
+               gs_app_set_scope (new, self->scope);
+               if (!gs_flatpak_refine_app (self, new, 0, cancellable, error))
+                       return FALSE;
+               gs_app_list_add (list, new);
+       }
+       return TRUE;
+}
+
+gboolean
 gs_flatpak_launch (GsFlatpak *self,
                   GsApp *app,
                   GCancellable *cancellable,
@@ -2050,6 +2213,40 @@ gs_flatpak_file_to_app (GsFlatpak *self,
        return TRUE;
 }
 
+gboolean
+gs_flatpak_search (GsFlatpak *self,
+                  gchar **values,
+                  GsAppList *list,
+                  GCancellable *cancellable,
+                  GError **error)
+{
+       return gs_appstream_store_search (self->plugin, self->store,
+                                         values, list,
+                                         cancellable, error);
+}
+
+gboolean
+gs_flatpak_add_category_apps (GsFlatpak *self,
+                             GsCategory *category,
+                             GsAppList *list,
+                             GCancellable *cancellable,
+                             GError **error)
+{
+       return gs_appstream_store_add_category_apps (self->plugin, self->store,
+                                                    category, list,
+                                                    cancellable, error);
+}
+
+gboolean
+gs_flatpak_add_categories (GsFlatpak *self,
+                          GPtrArray *list,
+                          GCancellable *cancellable,
+                          GError **error)
+{
+       return gs_appstream_store_add_categories (self->plugin, self->store,
+                                                 list, cancellable, error);
+}
+
 static void
 gs_flatpak_finalize (GObject *object)
 {
@@ -2058,6 +2255,7 @@ gs_flatpak_finalize (GObject *object)
        self = GS_FLATPAK (object);
 
        g_object_unref (self->plugin);
+       g_object_unref (self->store);
        g_hash_table_unref (self->broken_remotes);
 
        G_OBJECT_CLASS (gs_flatpak_parent_class)->finalize (object);
@@ -2075,6 +2273,9 @@ gs_flatpak_init (GsFlatpak *self)
 {
        self->broken_remotes = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                      g_free, NULL);
+       self->store = as_store_new ();
+       as_store_set_add_flags (self->store, AS_STORE_ADD_FLAG_USE_UNIQUE_ID);
+       as_store_set_watch_flags (self->store, AS_STORE_WATCH_FLAG_REMOVED);
 }
 
 GsFlatpak *
diff --git a/src/plugins/gs-flatpak.h b/src/plugins/gs-flatpak.h
index 980270b..edcf438 100644
--- a/src/plugins/gs-flatpak.h
+++ b/src/plugins/gs-flatpak.h
@@ -69,6 +69,11 @@ gboolean     gs_flatpak_refine_app           (GsFlatpak              *self,
                                                 GsPluginRefineFlags    flags,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
+gboolean       gs_flatpak_refine_wildcard      (GsFlatpak              *self,
+                                                GsAppList              *list,
+                                                GsApp                  *app,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
 gboolean       gs_flatpak_launch               (GsFlatpak              *self,
                                                 GsApp                  *app,
                                                 GCancellable           *cancellable,
@@ -90,6 +95,20 @@ gboolean     gs_flatpak_file_to_app          (GsFlatpak              *self,
                                                 GFile                  *file,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
+gboolean       gs_flatpak_search               (GsFlatpak              *self,
+                                                gchar                  **values,
+                                                GsAppList              *list,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
+gboolean       gs_flatpak_add_categories       (GsFlatpak              *self,
+                                                GPtrArray              *list,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
+gboolean       gs_flatpak_add_category_apps    (GsFlatpak              *self,
+                                                GsCategory             *category,
+                                                GsAppList              *list,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
 
 G_END_DECLS
 
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 1e9dbab..63d9e94 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -282,20 +282,6 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                }
        }
 
-       /* add keyword for non-package sources */
-       for (i = 0; i < items->len; i++) {
-               AsBundle *bundle;
-               app = g_ptr_array_index (items, i);
-               bundle = as_app_get_bundle_default (app);
-               if (bundle == NULL)
-                       continue;
-               g_debug ("Adding keyword '%s' to %s",
-                        as_bundle_kind_to_string (as_bundle_get_kind (bundle)),
-                        as_app_get_unique_id (app));
-               as_app_add_keyword (app, NULL,
-                                   as_bundle_kind_to_string (as_bundle_get_kind (bundle)));
-       }
-
        /* fix up these */
        for (i = 0; i < items->len; i++) {
                app = g_ptr_array_index (items, i);
@@ -354,7 +340,7 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
        if (item == NULL) {
                guint i;
                GPtrArray *apps;
-               g_debug ("no app with ID %s found in appstream", unique_id);
+               g_debug ("no app with ID %s found in system appstream", unique_id);
                apps = as_store_get_apps (priv->store);
                for (i = 0; i < apps->len; i++) {
                        item = g_ptr_array_index (apps, i);
diff --git a/src/plugins/gs-plugin-flatpak-system.c b/src/plugins/gs-plugin-flatpak-system.c
index 2f1ea84..18b06c5 100644
--- a/src/plugins/gs-plugin-flatpak-system.c
+++ b/src/plugins/gs-plugin-flatpak-system.c
@@ -135,6 +135,24 @@ gs_plugin_refine_app (GsPlugin *plugin,
 }
 
 gboolean
+gs_plugin_refine (GsPlugin *plugin,
+                 GsAppList *list,
+                 GsPluginRefineFlags flags,
+                 GCancellable *cancellable,
+                 GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       guint i;
+       for (i = 0; i < gs_app_list_length (list); i++) {
+               GsApp *app = gs_app_list_index (list, i);
+               if (!gs_flatpak_refine_wildcard (priv->flatpak, list, app,
+                                                cancellable, error))
+                       return FALSE;
+       }
+       return TRUE;
+}
+
+gboolean
 gs_plugin_launch (GsPlugin *plugin,
                  GsApp *app,
                  GCancellable *cancellable,
@@ -193,3 +211,44 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        return gs_flatpak_file_to_app (priv->flatpak, list, file,
                                       cancellable, error);
 }
+
+gboolean
+gs_plugin_add_search (GsPlugin *plugin,
+                     gchar **values,
+                     GsAppList *list,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       return gs_flatpak_search (priv->flatpak,
+                                 values,
+                                 list,
+                                 cancellable,
+                                 error);
+}
+
+gboolean
+gs_plugin_add_categories (GsPlugin *plugin,
+                         GPtrArray *list,
+                         GCancellable *cancellable,
+                         GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       return gs_flatpak_add_categories (priv->flatpak, list,
+                                         cancellable, error);
+}
+
+gboolean
+gs_plugin_add_category_apps (GsPlugin *plugin,
+                            GsCategory *category,
+                            GsAppList *list,
+                            GCancellable *cancellable,
+                            GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       return gs_flatpak_add_category_apps (priv->flatpak,
+                                            category,
+                                            list,
+                                            cancellable,
+                                            error);
+}
diff --git a/src/plugins/gs-plugin-flatpak-user.c b/src/plugins/gs-plugin-flatpak-user.c
index 3ad59a6..f7f72cf 100644
--- a/src/plugins/gs-plugin-flatpak-user.c
+++ b/src/plugins/gs-plugin-flatpak-user.c
@@ -135,6 +135,24 @@ gs_plugin_refine_app (GsPlugin *plugin,
 }
 
 gboolean
+gs_plugin_refine (GsPlugin *plugin,
+                 GsAppList *list,
+                 GsPluginRefineFlags flags,
+                 GCancellable *cancellable,
+                 GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       guint i;
+       for (i = 0; i < gs_app_list_length (list); i++) {
+               GsApp *app = gs_app_list_index (list, i);
+               if (!gs_flatpak_refine_wildcard (priv->flatpak, list, app,
+                                                cancellable, error))
+                       return FALSE;
+       }
+       return TRUE;
+}
+
+gboolean
 gs_plugin_launch (GsPlugin *plugin,
                  GsApp *app,
                  GCancellable *cancellable,
@@ -195,3 +213,44 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        return gs_flatpak_file_to_app (priv->flatpak, list, file,
                                       cancellable, error);
 }
+
+gboolean
+gs_plugin_add_search (GsPlugin *plugin,
+                     gchar **values,
+                     GsAppList *list,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       return gs_flatpak_search (priv->flatpak,
+                                 values,
+                                 list,
+                                 cancellable,
+                                 error);
+}
+
+gboolean
+gs_plugin_add_categories (GsPlugin *plugin,
+                         GPtrArray *list,
+                         GCancellable *cancellable,
+                         GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       return gs_flatpak_add_categories (priv->flatpak, list,
+                                         cancellable, error);
+}
+
+gboolean
+gs_plugin_add_category_apps (GsPlugin *plugin,
+                            GsCategory *category,
+                            GsAppList *list,
+                            GCancellable *cancellable,
+                            GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       return gs_flatpak_add_category_apps (priv->flatpak,
+                                            category,
+                                            list,
+                                            cancellable,
+                                            error);
+}


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