[gnome-software/mwleeds/hardcoded-pwa-list] make things better
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/mwleeds/hardcoded-pwa-list] make things better
- Date: Thu, 24 Mar 2022 02:28:22 +0000 (UTC)
commit 7b4b06a0af3e3af987a1f8061ad5af25f0c9e47d
Author: Phaedrus Leeds <mwleeds protonmail com>
Date: Wed Mar 23 19:28:13 2022 -0700
make things better
plugins/epiphany/gs-plugin-epiphany.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index adc468ca5..3b67204bc 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -538,6 +538,8 @@ list_installed_apps_thread_cb (GTask *task,
const gchar *name;
const gchar *url = NULL;
g_autofree char *icon_path = NULL;
+ g_autofree char *url_hash = NULL;
+ g_autofree char *metainfo_app_id = NULL;
const gchar *exec;
int argc;
g_auto(GStrv) argv = NULL;
@@ -598,9 +600,18 @@ list_installed_apps_thread_cb (GTask *task,
g_hash_table_insert (self->url_id_map, g_strdup (url),
g_strdup (desktop_file_id));
- g_debug ("Creating GsApp for webapp with URL %s using app ID from Epiphany: %s",
- url, desktop_file_id);
- app = gs_epiphany_create_app (self, desktop_file_id);
+ /* Generate the app ID used in the AppStream data using the
+ * same method as pwa-metainfo-generator.py in
+ * https://gitlab.gnome.org/mwleeds/gnome-pwa-list
+ * Using this app ID rather than the one provided by Epiphany
+ * makes it possible for the appstream plugin to refine the
+ * GsApp we create.
+ */
+ url_hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1, url, -1);
+ metainfo_app_id = g_strconcat ("org.gnome.Software.WebApp_", url_hash, ".desktop", NULL);
+ g_debug ("Creating GsApp for webapp with URL %s using app ID %s (desktop file id: %s)",
+ url, metainfo_app_id, desktop_file_id);
+ app = gs_epiphany_create_app (self, metainfo_app_id);
gs_app_set_state (app, GS_APP_STATE_INSTALLED);
gs_app_set_name (app, GS_APP_QUALITY_NORMAL, name);
@@ -657,6 +668,7 @@ list_installed_apps_thread_cb (GTask *task,
for (guint i = 0; i < gs_app_list_length (installed_cache); i++) {
GsApp *app = gs_app_list_index (installed_cache, i);
const char *installed_app_id;
+ const char *appstream_source;
installed_app_id = gs_app_get_launchable (app, AS_LAUNCHABLE_KIND_DESKTOP_ID);
if (installed_app_id == NULL) {
@@ -668,7 +680,12 @@ list_installed_apps_thread_cb (GTask *task,
continue;
/* The app may not be available if it was installed via Epiphany */
- gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
+ appstream_source = gs_app_get_metadata_item (app, "appstream::source-file");
+ if (appstream_source)
+ gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+ else
+ gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
+
gs_plugin_cache_remove (GS_PLUGIN (self), gs_app_get_id (app));
}
@@ -933,6 +950,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
GsPluginEpiphany *self = GS_PLUGIN_EPIPHANY (plugin);
const char *installed_app_id;
const char *url;
+ const char *appstream_source;
if (!gs_app_has_management_plugin (app, plugin))
return TRUE;
@@ -962,7 +980,11 @@ gs_plugin_app_remove (GsPlugin *plugin,
g_hash_table_remove (self->url_id_map, url);
/* The app may not be available if it was installed via Epiphany */
- gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
+ appstream_source = gs_app_get_metadata_item (app, "appstream::source-file");
+ if (appstream_source)
+ gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+ else
+ gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]