[gnome-software/1268-appstream-urls-not-properly-supported: 5/5] flatpak: Implement gs_plugin_url_to_app()




commit 3350985c30da1225da59724bedc5a2b42becb95d
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jul 29 14:06:08 2021 +0200

    flatpak: Implement gs_plugin_url_to_app()
    
    This can work for the appstream:// URI-s, due to handling its
    own appstream silo.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1268

 plugins/flatpak/gs-flatpak.c        | 23 +++++++++++++++++++++++
 plugins/flatpak/gs-flatpak.h        |  5 +++++
 plugins/flatpak/gs-plugin-flatpak.c | 16 ++++++++++++++++
 3 files changed, 44 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 7e9c571f8..d56f87cb1 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -3708,6 +3708,29 @@ gs_flatpak_add_recent (GsFlatpak *self,
        return TRUE;
 }
 
+gboolean
+gs_flatpak_url_to_app (GsFlatpak *self,
+                      GsAppList *list,
+                      const gchar *url,
+                      GCancellable *cancellable,
+                      GError **error)
+{
+       g_autoptr(GsAppList) list_tmp = gs_app_list_new ();
+       g_autoptr(GRWLockReaderLocker) locker = NULL;
+
+       if (!gs_flatpak_rescan_app_data (self, cancellable, error))
+               return FALSE;
+
+       locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+       if (!gs_appstream_url_to_app (self->plugin, self->silo, list_tmp, url, cancellable, error))
+               return FALSE;
+
+       gs_flatpak_claim_app_list (self, list_tmp);
+       gs_app_list_add_list (list, list_tmp);
+
+       return TRUE;
+}
+
 const gchar *
 gs_flatpak_get_id (GsFlatpak *self)
 {
diff --git a/plugins/flatpak/gs-flatpak.h b/plugins/flatpak/gs-flatpak.h
index 26a16e6f2..1bd7be2ec 100644
--- a/plugins/flatpak/gs-flatpak.h
+++ b/plugins/flatpak/gs-flatpak.h
@@ -128,6 +128,11 @@ gboolean   gs_flatpak_add_recent           (GsFlatpak              *self,
                                                 guint64                 age,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
+gboolean       gs_flatpak_url_to_app           (GsFlatpak              *self,
+                                                GsAppList              *list,
+                                                const gchar            *url,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
 void           gs_flatpak_set_busy             (GsFlatpak              *self,
                                                 gboolean                busy);
 gboolean       gs_flatpak_get_busy             (GsFlatpak              *self);
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 1cd2b9d6a..3f19c40ef 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1584,3 +1584,19 @@ gs_plugin_add_recent (GsPlugin *plugin,
        }
        return TRUE;
 }
+
+gboolean
+gs_plugin_url_to_app (GsPlugin *plugin,
+                     GsAppList *list,
+                     const gchar *url,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       GsPluginData *priv = gs_plugin_get_data (plugin);
+       for (guint i = 0; i < priv->flatpaks->len; i++) {
+               GsFlatpak *flatpak = g_ptr_array_index (priv->flatpaks, i);
+               if (!gs_flatpak_url_to_app (flatpak, list, url, cancellable, error))
+                       return FALSE;
+       }
+       return TRUE;
+}


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