[gnome-software/mwleeds/pwa-plugin] WIP



commit c206a29a10db40af067ffc6c48c14e256d6111c4
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Fri Dec 10 22:43:40 2021 -0800

    WIP

 plugins/epiphany/gs-plugin-epiphany.c | 71 ++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 68c840def..6ae1d9273 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -111,7 +111,7 @@ gs_plugin_epiphany_setup_async (GsPlugin            *plugin,
         */
        gs_ephy_web_app_provider_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                                    G_DBUS_PROXY_FLAGS_NONE,
-                                                   "org.gnome.Epiphany.WebAppProvider",
+                                                   "org.gnome.Epiphany.Devel.WebAppProvider",
                                                    "/org/gnome/Epiphany/WebAppProvider",
                                                    cancellable,
                                                    proxy_new_cb,
@@ -156,6 +156,75 @@ gs_plugin_adopt_app (GsPlugin *plugin,
        }
 }
 
+gboolean
+gs_plugin_add_installed (GsPlugin      *plugin,
+                        GsAppList     *list,
+                        GCancellable  *cancellable,
+                        GError       **error)
+{
+       GsPluginEpiphany *self = GS_PLUGIN_EPIPHANY (plugin);
+       g_autoptr(GVariant) webapps_v = NULL;
+       gsize n_webapps;
+
+       //TODO use a worker thread?
+       if (!gs_ephy_web_app_provider_call_get_installed_web_apps_sync (self->epiphany_proxy,
+                                                                       &webapps_v,
+                                                                       cancellable,
+                                                                       error)) {
+               gs_epiphany_error_convert (error);
+               return FALSE;
+       }
+
+       g_assert (g_variant_is_of_type (webapps_v, G_VARIANT_TYPE ("aa{sv}")));
+       n_webapps = g_variant_n_children (webapps_v);
+       g_debug ("%s: epiphany-webapp-provider returned %" G_GSIZE_FORMAT " installed web apps", G_STRFUNC, 
n_webapps);
+       for (gsize i = 0; i < n_webapps; i++) {
+               g_autoptr(GVariant) webapp_v = g_variant_get_child_value (webapps_v, i);
+               GVariantDict dict;
+               const gchar *desktop_path;
+               const gchar *name;
+               const gchar *url;
+               const gchar *icon_path = NULL;
+               guint64 install_date = 0;
+               g_autofree char *app_id = NULL;
+               g_autoptr(GsApp) app = NULL;
+
+               g_variant_dict_init (&dict, webapp_v);
+               if (!g_variant_dict_lookup (&dict, "desktop-path", "&s", &desktop_path)) {
+                       g_warning ("%s: webapp missing desktop-path", G_STRFUNC);
+                       continue;
+               }
+               if (!g_variant_dict_lookup (&dict, "name", "&s", &name)) {
+                       g_warning ("%s: webapp missing name", G_STRFUNC);
+                       continue;
+               }
+               if (!g_variant_dict_lookup (&dict, "url", "&s", &url)) {
+                       g_warning ("%s: webapp missing url", G_STRFUNC);
+                       continue;
+               }
+               g_variant_dict_lookup (&dict, "icon-path", "&s", &icon_path);
+               g_variant_dict_lookup (&dict, "install-date", "t", &install_date);
+
+               app_id = g_path_get_basename (desktop_path);
+               app = gs_app_new (app_id);
+               gs_app_set_management_plugin (app, plugin);
+               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);
+               if (icon_path) {
+                       g_autoptr(GFile) icon_file = g_file_new_for_path (icon_path);
+                       g_autoptr(GIcon) icon = g_file_icon_new (icon_file);
+                       gs_app_add_icon (app, icon);
+               }
+               if (install_date) {
+                       gs_app_set_install_date (app, install_date);
+               }
+               gs_app_list_add (list, app);
+       }
+
+       return TRUE;
+}
+
 gboolean
 gs_plugin_app_install (GsPlugin      *plugin,
                       GsApp         *app,


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