[gnome-software/mwleeds/pwa-plugin] fixup! Revive webapp support



commit f885e592077d9b3617f99ee0f4903a78cc671f07
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Thu Feb 24 13:24:06 2022 -0800

    fixup! Revive webapp support

 plugins/epiphany/gs-plugin-epiphany.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 277e24f78..574f3d92d 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -253,6 +253,9 @@ gs_plugin_epiphany_init (GsPluginEpiphany *self)
 
        /* need help from appstream */
        gs_plugin_add_rule (GS_PLUGIN (self), GS_PLUGIN_RULE_RUN_AFTER, "appstream");
+
+       /* prioritize over packages */
+       gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_BETTER_THAN, "packagekit");
 }
 
 static void
@@ -302,6 +305,31 @@ gs_plugin_epiphany_list_installed_apps_async (GsPlugin            *plugin,
                                list_installed_apps_thread_cb, g_steal_pointer (&task));
 }
 
+/* Run in @worker */
+static GsApp *
+gs_epiphany_create_app (GsPluginEpiphany *self,
+                       const char       *id)
+{
+       g_autoptr(GsApp) app_cached = NULL;
+       g_autoptr(GsApp) tmp_app = NULL;
+
+       assert_in_worker (self);
+
+       tmp_app = gs_app_new (id);
+       gs_app_set_management_plugin (tmp_app, GS_PLUGIN (self));
+       gs_app_set_origin (tmp_app, "gnome-web");
+       gs_app_set_origin_ui (tmp_app, _("GNOME Web"));
+       gs_app_set_kind (tmp_app, AS_COMPONENT_KIND_WEB_APP);
+       gs_app_set_scope (tmp_app, AS_COMPONENT_SCOPE_USER);
+
+       app_cached = gs_plugin_cache_lookup (self->plugin, gs_app_get_unique_id (tmp_app));
+       if (app_cached != NULL)
+               return g_steal_pointer (&app_cached);
+
+       gs_plugin_cache_add (self->plugin, NULL, app_tmp);
+       return g_steal_pointer (&tmp_app);
+}
+
 /* Run in @worker */
 static void
 list_installed_apps_thread_cb (GTask        *task,
@@ -378,11 +406,8 @@ list_installed_apps_thread_cb (GTask        *task,
                file_info = g_file_query_info (desktop_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
                install_date = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
-               //TODO do we need to check a cache here, see if a GsApp already exists?
-               app = gs_app_new (desktop_file_id);
-               gs_app_set_management_plugin (app, GS_PLUGIN (self));
+               app = gs_epiphany_create_app (self, desktop_file_id);
                gs_app_set_state (app, GS_APP_STATE_INSTALLED);
-               gs_app_set_kind (app, AS_COMPONENT_KIND_WEB_APP);
                gs_app_set_name (app, GS_APP_QUALITY_NORMAL, name);
                gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);
 


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