[gnome-software/wip/hughsie/vnd.flatpak.ref] Allow processing wildcards from the flatpak plugin
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/vnd.flatpak.ref] Allow processing wildcards from the flatpak plugin
- Date: Fri, 16 Sep 2016 09:02:37 +0000 (UTC)
commit 3a870019458305ab30f9ad5f4d6f201b7d2a349f
Author: Richard Hughes <richard hughsie com>
Date: Fri Sep 16 09:58:34 2016 +0100
Allow processing wildcards from the flatpak plugin
src/plugins/gs-flatpak.c | 43 ++++++++++++++++++++++++++++++++
src/plugins/gs-flatpak.h | 5 +++
src/plugins/gs-plugin-flatpak-system.c | 18 +++++++++++++
src/plugins/gs-plugin-flatpak-user.c | 18 +++++++++++++
4 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index f1290da..5ff0304 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -1612,6 +1612,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,
diff --git a/src/plugins/gs-flatpak.h b/src/plugins/gs-flatpak.h
index a3d4bb0..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,
diff --git a/src/plugins/gs-plugin-flatpak-system.c b/src/plugins/gs-plugin-flatpak-system.c
index 959d22f..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,
diff --git a/src/plugins/gs-plugin-flatpak-user.c b/src/plugins/gs-plugin-flatpak-user.c
index a055f65..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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]