Blame SOURCES/add-back-shell-extensions-support.patch

698863
From 82a85d6bbacb148e355680446c4bbd6a091ad2eb Mon Sep 17 00:00:00 2001
698863
From: Kalev Lember <klember@redhat.com>
698863
Date: Wed, 3 Jun 2020 15:50:41 +0200
698863
Subject: [PATCH 1/2] Revert "Remove support for Shell extensions"
698863
698863
This reverts commit 77bdc3855c26de0edc2ce5d73bb6be861721c37b.
698863
---
698863
 contrib/gnome-software.spec.in                |    1 +
698863
 meson_options.txt                             |    1 +
698863
 plugins/core/gs-appstream.c                   |   14 +-
698863
 plugins/core/gs-desktop-common.c              |    3 +
698863
 plugins/meson.build                           |    3 +
698863
 plugins/packagekit/gs-plugin-packagekit.c     |    3 +
698863
 plugins/shell-extensions/gs-appstream.c       |    1 +
698863
 plugins/shell-extensions/gs-appstream.h       |    1 +
698863
 .../gs-plugin-shell-extensions.c              | 1159 +++++++++++++++++
698863
 plugins/shell-extensions/gs-self-test.c       |  156 +++
698863
 plugins/shell-extensions/meson.build          |   47 +
698863
 src/gs-category-page.c                        |   25 +
698863
 src/gs-category-page.ui                       |   45 +
698863
 src/gs-details-page.c                         |   14 +-
698863
 src/gs-repo-row.c                             |    3 +-
698863
 src/gs-repos-dialog.c                         |    3 +-
698863
 src/gs-summary-tile.c                         |   15 +-
698863
 17 files changed, 1478 insertions(+), 16 deletions(-)
698863
 create mode 120000 plugins/shell-extensions/gs-appstream.c
698863
 create mode 120000 plugins/shell-extensions/gs-appstream.h
698863
 create mode 100644 plugins/shell-extensions/gs-plugin-shell-extensions.c
698863
 create mode 100644 plugins/shell-extensions/gs-self-test.c
698863
 create mode 100644 plugins/shell-extensions/meson.build
698863
698863
diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in
698863
index 587a72e6..7f415f51 100644
698863
--- a/contrib/gnome-software.spec.in
698863
+++ b/contrib/gnome-software.spec.in
698863
@@ -183,6 +183,7 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
698863
 %{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_provenance.so
698863
 %{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_repos.so
698863
 %{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_rewrite-resource.so
698863
+%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_shell-extensions.so
698863
 %{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_systemd-updates.so
698863
 %{_sysconfdir}/xdg/autostart/gnome-software-service.desktop
698863
 %{_datadir}/app-info/xmls/org.gnome.Software.Featured.xml
698863
diff --git a/meson_options.txt b/meson_options.txt
698863
index f6068ba5..eba69ea2 100644
698863
--- a/meson_options.txt
698863
+++ b/meson_options.txt
698863
@@ -10,6 +10,7 @@ option('fwupd', type : 'boolean', value : true, description : 'enable fwupd supp
698863
 option('flatpak', type : 'boolean', value : true, description : 'enable Flatpak support')
698863
 option('malcontent', type : 'boolean', value : true, description : 'enable parental controls support using libmalcontent')
698863
 option('rpm_ostree', type : 'boolean', value : false, description : 'enable rpm-ostree support')
698863
+option('shell_extensions', type : 'boolean', value : true, description : 'enable shell extensions support')
698863
 option('odrs', type : 'boolean', value : true, description : 'enable ODRS support')
698863
 option('gudev', type : 'boolean', value : true, description : 'enable GUdev support')
698863
 option('snap', type : 'boolean', value : false, description : 'enable Snap support')
698863
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
698863
index a387f2e0..e507ac0f 100644
698863
--- a/plugins/core/gs-appstream.c
698863
+++ b/plugins/core/gs-appstream.c
698863
@@ -30,15 +30,6 @@ gs_appstream_create_app (GsPlugin *plugin, XbSilo *silo, XbNode *component, GErr
698863
 	if (gs_app_has_quirk (app_new, GS_APP_QUIRK_IS_WILDCARD))
698863
 		return g_steal_pointer (&app_new);
698863
 
698863
-	/* no longer supported */
698863
-	if (gs_app_get_kind (app_new) == AS_APP_KIND_SHELL_EXTENSION) {
698863
-		g_set_error (error,
698863
-			     GS_PLUGIN_ERROR,
698863
-			     GS_PLUGIN_ERROR_NOT_SUPPORTED,
698863
-			     "shell extensions no longer supported");
698863
-		return NULL;
698863
-	}
698863
-
698863
 	/* look for existing object */
698863
 	app = gs_plugin_cache_lookup (plugin, gs_app_get_unique_id (app_new));
698863
 	if (app != NULL)
698863
@@ -1548,6 +1539,11 @@ gs_appstream_component_add_extra_info (GsPlugin *plugin, XbBuilderNode *componen
698863
 		gs_appstream_component_add_category (component, "Addon");
698863
 		gs_appstream_component_add_category (component, "Font");
698863
 		break;
698863
+	case AS_APP_KIND_SHELL_EXTENSION:
698863
+		gs_appstream_component_add_category (component, "Addon");
698863
+		gs_appstream_component_add_category (component, "ShellExtension");
698863
+		gs_appstream_component_add_icon (component, "application-x-addon-symbolic");
698863
+		break;
698863
 	case AS_APP_KIND_DRIVER:
698863
 		gs_appstream_component_add_category (component, "Addon");
698863
 		gs_appstream_component_add_category (component, "Driver");
698863
diff --git a/plugins/core/gs-desktop-common.c b/plugins/core/gs-desktop-common.c
698863
index 33ae3fa2..17ed029d 100644
698863
--- a/plugins/core/gs-desktop-common.c
698863
+++ b/plugins/core/gs-desktop-common.c
698863
@@ -203,6 +203,9 @@ static const GsDesktopMap map_addons[] = {
698863
 	{ "language-packs",	NC_("Menu of Add-ons", "Language Packs"),
698863
 					{ "Addon::LanguagePack",
698863
 					  NULL} },
698863
+	{ "shell-extensions",	NC_("Menu of Add-ons", "Shell Extensions"),
698863
+					{ "Addon::ShellExtension",
698863
+					  NULL} },
698863
 	{ "localization",	NC_("Menu of Add-ons", "Localization"),
698863
 					{ "Addon::Localization",
698863
 					  NULL} },
698863
diff --git a/plugins/meson.build b/plugins/meson.build
698863
index d749b3df..d30f14d4 100644
698863
--- a/plugins/meson.build
698863
+++ b/plugins/meson.build
698863
@@ -39,6 +39,9 @@ subdir('repos')
698863
 if get_option('rpm_ostree')
698863
   subdir('rpm-ostree')
698863
 endif
698863
+if get_option('shell_extensions')
698863
+  subdir('shell-extensions')
698863
+endif
698863
 if get_option('snap')
698863
   subdir('snap')
698863
 endif
698863
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
698863
index d0bdabae..2c4e1644 100644
698863
--- a/plugins/packagekit/gs-plugin-packagekit.c
698863
+++ b/plugins/packagekit/gs-plugin-packagekit.c
698863
@@ -688,5 +688,8 @@ gs_plugin_launch (GsPlugin *plugin,
698863
 	if (g_strcmp0 (gs_app_get_management_plugin (app),
698863
 		       gs_plugin_get_name (plugin)) != 0)
698863
 		return TRUE;
698863
+	/* these are handled by the shell extensions plugin */
698863
+	if (gs_app_get_kind (app) == AS_APP_KIND_SHELL_EXTENSION)
698863
+		return TRUE;
698863
 	return gs_plugin_app_launch (plugin, app, error);
698863
 }
698863
diff --git a/plugins/shell-extensions/gs-appstream.c b/plugins/shell-extensions/gs-appstream.c
698863
new file mode 120000
698863
index 00000000..96326ab0
698863
--- /dev/null
698863
+++ b/plugins/shell-extensions/gs-appstream.c
698863
@@ -0,0 +1 @@
698863
+../core/gs-appstream.c
698863
\ No newline at end of file
698863
diff --git a/plugins/shell-extensions/gs-appstream.h b/plugins/shell-extensions/gs-appstream.h
698863
new file mode 120000
698863
index 00000000..4eabcb3c
698863
--- /dev/null
698863
+++ b/plugins/shell-extensions/gs-appstream.h
698863
@@ -0,0 +1 @@
698863
+../core/gs-appstream.h
698863
\ No newline at end of file
698863
diff --git a/plugins/shell-extensions/gs-plugin-shell-extensions.c b/plugins/shell-extensions/gs-plugin-shell-extensions.c
698863
new file mode 100644
698863
index 00000000..80a5d0eb
698863
--- /dev/null
698863
+++ b/plugins/shell-extensions/gs-plugin-shell-extensions.c
698863
@@ -0,0 +1,1159 @@
698863
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
698863
+ *
698863
+ * Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
698863
+ * Copyright (C) 2018 Kalev Lember <klember@redhat.com>
698863
+ *
698863
+ * SPDX-License-Identifier: GPL-2.0+
698863
+ */
698863
+
698863
+#include <config.h>
698863
+
698863
+#include <errno.h>
698863
+#include <glib/gi18n.h>
698863
+#include <json-glib/json-glib.h>
698863
+#include <xmlb.h>
698863
+
698863
+#include <gnome-software.h>
698863
+
698863
+#include "gs-appstream.h"
698863
+
698863
+#define SHELL_EXTENSIONS_API_URI 		"https://extensions.gnome.org/"
698863
+
698863
+/*
698863
+ * Things we want from the API:
698863
+ *
698863
+ *  - Size on disk/download
698863
+ *  - Existing review data for each extension?
698863
+ *  - A local icon for an installed shell extension
698863
+ *
698863
+ * See https://git.gnome.org/browse/extensions-web/tree/sweettooth/extensions/views.py
698863
+ * for the source to the web application.
698863
+ */
698863
+
698863
+struct GsPluginData {
698863
+	GDBusProxy	*proxy;
698863
+	gchar		*shell_version;
698863
+	GsApp		*cached_origin;
698863
+	GSettings	*settings;
698863
+	XbSilo		*silo;
698863
+	GRWLock		 silo_lock;
698863
+};
698863
+
698863
+typedef enum {
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_ENABLED		= 1,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_DISABLED	= 2,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_ERROR		= 3,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_OUT_OF_DATE	= 4,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_DOWNLOADING	= 5,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_INITIALIZED	= 6,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_UNINSTALLED	= 99,
698863
+	GS_PLUGIN_SHELL_EXTENSION_STATE_LAST
698863
+} GsPluginShellExtensionState;
698863
+
698863
+typedef enum {
698863
+	GS_PLUGIN_SHELL_EXTENSION_KIND_SYSTEM		= 1,
698863
+	GS_PLUGIN_SHELL_EXTENSION_KIND_PER_USER		= 2,
698863
+	GS_PLUGIN_SHELL_EXTENSION_KIND_LAST
698863
+} GsPluginShellExtensionKind;
698863
+
698863
+static gboolean _check_silo (GsPlugin *plugin, GCancellable *cancellable, GError **error);
698863
+
698863
+void
698863
+gs_plugin_initialize (GsPlugin *plugin)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
698863
+
698863
+	/* XbSilo needs external locking as we destroy the silo and build a new
698863
+	 * one when something changes */
698863
+	g_rw_lock_init (&priv->silo_lock);
698863
+
698863
+	/* add source */
698863
+	priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin));
698863
+	gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE);
698863
+	gs_app_set_origin_hostname (priv->cached_origin, SHELL_EXTENSIONS_API_URI);
698863
+	gs_app_set_origin (priv->cached_origin, _("GNOME"));
698863
+
698863
+	priv->settings = g_settings_new ("org.gnome.software");
698863
+
698863
+	/* add the source to the plugin cache which allows us to match the
698863
+	 * unique ID to a GsApp when creating an event */
698863
+	gs_plugin_cache_add (plugin,
698863
+			     gs_app_get_unique_id (priv->cached_origin),
698863
+			     priv->cached_origin);
698863
+}
698863
+
698863
+void
698863
+gs_plugin_destroy (GsPlugin *plugin)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_free (priv->shell_version);
698863
+	if (priv->proxy != NULL)
698863
+		g_object_unref (priv->proxy);
698863
+	if (priv->silo != NULL)
698863
+		g_object_unref (priv->silo);
698863
+	g_object_unref (priv->cached_origin);
698863
+	g_object_unref (priv->settings);
698863
+	g_rw_lock_clear (&priv->silo_lock);
698863
+}
698863
+
698863
+void
698863
+gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
698863
+{
698863
+	if (gs_app_get_kind (app) == AS_APP_KIND_SHELL_EXTENSION &&
698863
+	    gs_app_get_scope (app) == AS_APP_SCOPE_USER) {
698863
+		gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
698863
+	}
698863
+}
698863
+
698863
+static AsAppState
698863
+gs_plugin_shell_extensions_convert_state (guint value)
698863
+{
698863
+	switch (value) {
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_DISABLED:
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_DOWNLOADING:
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_ENABLED:
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_ERROR:
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_INITIALIZED:
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_OUT_OF_DATE:
698863
+		return AS_APP_STATE_INSTALLED;
698863
+	case GS_PLUGIN_SHELL_EXTENSION_STATE_UNINSTALLED:
698863
+		return AS_APP_STATE_AVAILABLE;
698863
+	default:
698863
+		g_warning ("unknown state %u", value);
698863
+	}
698863
+	return AS_APP_STATE_UNKNOWN;
698863
+}
698863
+
698863
+static GsApp *
698863
+gs_plugin_shell_extensions_parse_installed (GsPlugin *plugin,
698863
+                                            const gchar *uuid,
698863
+                                            GVariantIter *iter,
698863
+                                            GError **error)
698863
+{
698863
+	const gchar *tmp;
698863
+	gchar *str;
698863
+	GVariant *val;
698863
+	g_autofree gchar *id = NULL;
698863
+	g_autoptr(AsIcon) ic = NULL;
698863
+	g_autoptr(GsApp) app = NULL;
698863
+
698863
+	id = as_utils_appstream_id_build (uuid);
698863
+	app = gs_app_new (id);
698863
+	gs_app_set_metadata (app, "GnomeSoftware::Creator",
698863
+			     gs_plugin_get_name (plugin));
698863
+	gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
698863
+	gs_app_set_metadata (app, "shell-extensions::uuid", uuid);
698863
+	gs_app_set_kind (app, AS_APP_KIND_SHELL_EXTENSION);
698863
+	gs_app_set_license (app, GS_APP_QUALITY_NORMAL, "GPL-2.0+");
698863
+	gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "GNOME Shell Extension");
698863
+	gs_app_set_origin_hostname (app, SHELL_EXTENSIONS_API_URI);
698863
+	gs_app_set_origin (app, _("GNOME"));
698863
+	while (g_variant_iter_loop (iter, "{sv}", &str, &val)) {
698863
+		if (g_strcmp0 (str, "description") == 0) {
698863
+			g_autofree gchar *tmp1 = NULL;
698863
+			g_autofree gchar *tmp2 = NULL;
698863
+			tmp1 = as_markup_import (g_variant_get_string (val, NULL),
698863
+						 AS_MARKUP_CONVERT_FORMAT_SIMPLE,
698863
+						 NULL);
698863
+			tmp2 = as_markup_convert_simple (tmp1, error);
698863
+			if (tmp2 == NULL) {
698863
+				gs_utils_error_convert_appstream (error);
698863
+				return NULL;
698863
+			}
698863
+			gs_app_set_description (app, GS_APP_QUALITY_NORMAL, tmp2);
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "name") == 0) {
698863
+			gs_app_set_name (app, GS_APP_QUALITY_NORMAL,
698863
+					 g_variant_get_string (val, NULL));
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "version") == 0) {
698863
+			guint val_int = (guint) g_variant_get_double (val);
698863
+			g_autofree gchar *version = g_strdup_printf ("%u", val_int);
698863
+			gs_app_set_version (app, version);
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "url") == 0) {
698863
+			gs_app_set_url (app, AS_URL_KIND_HOMEPAGE,
698863
+					g_variant_get_string (val, NULL));
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "type") == 0) {
698863
+			guint val_int = (guint) g_variant_get_double (val);
698863
+			switch (val_int) {
698863
+			case GS_PLUGIN_SHELL_EXTENSION_KIND_SYSTEM:
698863
+				gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
698863
+				break;
698863
+			case GS_PLUGIN_SHELL_EXTENSION_KIND_PER_USER:
698863
+				gs_app_set_scope (app, AS_APP_SCOPE_USER);
698863
+				break;
698863
+			default:
698863
+				g_warning ("%s unknown type %u", uuid, val_int);
698863
+				break;
698863
+			}
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "state") == 0) {
698863
+			AsAppState st;
698863
+			guint val_int = (guint) g_variant_get_double (val);
698863
+			st = gs_plugin_shell_extensions_convert_state (val_int);
698863
+			gs_app_set_state (app, st);
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "error") == 0) {
698863
+			tmp = g_variant_get_string (val, NULL);
698863
+			if (tmp != NULL && tmp[0] != '\0') {
698863
+				g_warning ("unhandled shell error: %s", tmp);
698863
+			}
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "hasPrefs") == 0) {
698863
+			if (g_variant_get_boolean (val))
698863
+				gs_app_set_metadata (app, "shell-extensions::has-prefs", "");
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "extension-id") == 0) {
698863
+			tmp = g_variant_get_string (val, NULL);
698863
+			gs_app_set_metadata (app, "shell-extensions::extension-id", tmp);
698863
+			continue;
698863
+		}
698863
+		if (g_strcmp0 (str, "path") == 0) {
698863
+			tmp = g_variant_get_string (val, NULL);
698863
+			gs_app_set_metadata (app, "shell-extensions::path", tmp);
698863
+			continue;
698863
+		}
698863
+	}
698863
+
698863
+	/* hardcode icon */
698863
+	ic = as_icon_new ();
698863
+	as_icon_set_kind (ic, AS_ICON_KIND_STOCK);
698863
+	as_icon_set_name (ic, "application-x-addon-symbolic");
698863
+	gs_app_add_icon (app, ic);
698863
+
698863
+	/* add categories */
698863
+	gs_app_add_category (app, "Addon");
698863
+	gs_app_add_category (app, "ShellExtension");
698863
+
698863
+	return g_steal_pointer (&app);
698863
+}
698863
+
698863
+static void
698863
+gs_plugin_shell_extensions_changed_cb (GDBusProxy *proxy,
698863
+				       const gchar *sender_name,
698863
+				       const gchar *signal_name,
698863
+				       GVariant *parameters,
698863
+				       GsPlugin *plugin)
698863
+{
698863
+	if (g_strcmp0 (signal_name, "ExtensionStatusChanged") == 0) {
698863
+		AsAppState st;
698863
+		GsApp *app;
698863
+		const gchar *error_str;
698863
+		const gchar *uuid;
698863
+		guint state;
698863
+
698863
+		/* get what changed */
698863
+		g_variant_get (parameters, "(&si&s)",
698863
+			       &uuid, &state, &error_str);
698863
+
698863
+		/* find it in the cache; do we care? */
698863
+		app = gs_plugin_cache_lookup (plugin, uuid);
698863
+		if (app == NULL) {
698863
+			g_debug ("no app for changed %s", uuid);
698863
+			return;
698863
+		}
698863
+
698863
+		/* set the new state in the UI */
698863
+		st = gs_plugin_shell_extensions_convert_state (state);
698863
+		gs_app_set_state (app, st);
698863
+
698863
+		/* not sure what to do here */
698863
+		if (error_str != NULL && error_str[0] != '\0') {
698863
+			g_warning ("%s has error: %s",
698863
+				   gs_app_get_id (app),
698863
+				   error_str);
698863
+		}
698863
+	}
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autofree gchar *name_owner = NULL;
698863
+	g_autoptr(GVariant) version = NULL;
698863
+
698863
+	if (priv->proxy != NULL)
698863
+		return TRUE;
698863
+	priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
698863
+						     G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION,
698863
+						     NULL,
698863
+						     "org.gnome.Shell",
698863
+						     "/org/gnome/Shell",
698863
+						     "org.gnome.Shell.Extensions",
698863
+						     cancellable,
698863
+						     error);
698863
+	if (priv->proxy == NULL) {
698863
+		gs_utils_error_convert_gio (error);
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	/* not running under Shell */
698863
+	name_owner = g_dbus_proxy_get_name_owner (priv->proxy);
698863
+	if (name_owner == NULL) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_NOT_SUPPORTED,
698863
+				     "gnome-shell is not running");
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	g_signal_connect (priv->proxy, "g-signal",
698863
+			  G_CALLBACK (gs_plugin_shell_extensions_changed_cb), plugin);
698863
+
698863
+	/* get the GNOME Shell version */
698863
+	version = g_dbus_proxy_get_cached_property (priv->proxy,
698863
+						    "ShellVersion");
698863
+	if (version == NULL) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_NOT_SUPPORTED,
698863
+				     "unable to get shell version");
698863
+		return FALSE;
698863
+	}
698863
+	priv->shell_version = g_variant_dup_string (version, NULL);
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_add_installed (GsPlugin *plugin,
698863
+			 GsAppList *list,
698863
+			 GCancellable *cancellable,
698863
+			 GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	GVariantIter *ext_iter;
698863
+	gchar *ext_uuid;
698863
+	g_autoptr(GVariantIter) iter = NULL;
698863
+	g_autoptr(GVariant) retval = NULL;
698863
+
698863
+	/* installed */
698863
+	retval = g_dbus_proxy_call_sync (priv->proxy,
698863
+					 "ListExtensions",
698863
+					 NULL,
698863
+					 G_DBUS_CALL_FLAGS_NONE,
698863
+					 -1,
698863
+					 cancellable,
698863
+					 error);
698863
+	if (retval == NULL) {
698863
+		gs_utils_error_convert_gdbus (error);
698863
+		gs_utils_error_convert_gio (error);
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	/* parse each installed extension */
698863
+	g_variant_get (retval, "(a{sa{sv}})", &iter);
698863
+	while (g_variant_iter_loop (iter, "{sa{sv}}", &ext_uuid, &ext_iter)) {
698863
+		g_autoptr(GsApp) app = NULL;
698863
+
698863
+		/* search in the cache */
698863
+		app = gs_plugin_cache_lookup (plugin, ext_uuid);
698863
+		if (app != NULL) {
698863
+			gs_app_list_add (list, app);
698863
+			continue;
698863
+		}
698863
+
698863
+		/* parse the data into an GsApp */
698863
+		app = gs_plugin_shell_extensions_parse_installed (plugin,
698863
+		                                                  ext_uuid,
698863
+		                                                  ext_iter,
698863
+		                                                  error);
698863
+		if (app == NULL)
698863
+			return FALSE;
698863
+
698863
+		/* ignore system installed */
698863
+		if (gs_app_get_scope (app) == AS_APP_SCOPE_SYSTEM)
698863
+			continue;
698863
+
698863
+		/* save in the cache */
698863
+		gs_plugin_cache_add (plugin, ext_uuid, app);
698863
+
698863
+		/* add to results */
698863
+		gs_app_list_add (list, app);
698863
+	}
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_add_sources (GsPlugin *plugin,
698863
+                       GsAppList *list,
698863
+                       GCancellable *cancellable,
698863
+                       GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autoptr(GsApp) app = NULL;
698863
+
698863
+	/* create something that we can use to enable/disable */
698863
+	app = gs_app_new ("org.gnome.extensions");
698863
+	gs_app_set_kind (app, AS_APP_KIND_SOURCE);
698863
+	gs_app_set_scope (app, AS_APP_SCOPE_USER);
698863
+	if (g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		gs_app_set_state (app, AS_APP_STATE_INSTALLED);
698863
+	else
698863
+		gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
698863
+	gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE);
698863
+	gs_app_set_name (app, GS_APP_QUALITY_LOWEST,
698863
+	                 _("GNOME Shell Extensions Repository"));
698863
+	gs_app_set_url (app, AS_URL_KIND_HOMEPAGE,
698863
+	                SHELL_EXTENSIONS_API_URI);
698863
+	gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
698863
+	gs_app_list_add (list, app);
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_refine_app (GsPlugin *plugin,
698863
+		      GsApp *app,
698863
+		      GsPluginRefineFlags flags,
698863
+		      GCancellable *cancellable,
698863
+		      GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	const gchar *uuid;
698863
+	g_autofree gchar *xpath = NULL;
698863
+	g_autoptr(GError) error_local = NULL;
698863
+	g_autoptr(GRWLockReaderLocker) locker = NULL;
698863
+	g_autoptr(XbNode) component = NULL;
698863
+
698863
+	/* repo not enabled */
698863
+	if (!g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		return TRUE;
698863
+
698863
+	/* only process this app if was created by this plugin */
698863
+	if (g_strcmp0 (gs_app_get_management_plugin (app),
698863
+		       gs_plugin_get_name (plugin)) != 0)
698863
+		return TRUE;
698863
+
698863
+	/* can we get the AppStream-created app state using the cache */
698863
+	uuid = gs_app_get_metadata_item (app, "shell-extensions::uuid");
698863
+	if (uuid != NULL && gs_app_get_state (app) == AS_APP_STATE_UNKNOWN) {
698863
+		GsApp *app_cache = gs_plugin_cache_lookup (plugin, uuid);
698863
+		if (app_cache != NULL) {
698863
+			g_debug ("copy cached state for %s",
698863
+				 gs_app_get_id (app));
698863
+			gs_app_set_state (app, gs_app_get_state (app_cache));
698863
+		}
698863
+	}
698863
+
698863
+	/* assume apps are available if they exist in AppStream metadata */
698863
+	if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
698863
+		gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
698863
+
698863
+	/* FIXME: assume these are small */
698863
+	if (gs_app_get_size_installed (app) == 0)
698863
+		gs_app_set_size_installed (app, 1024 * 50);
698863
+	if (gs_app_get_size_download (app) == 0)
698863
+		gs_app_set_size_download (app, GS_APP_SIZE_UNKNOWABLE);
698863
+
698863
+
698863
+	/* check silo is valid */
698863
+	if (!_check_silo (plugin, cancellable, error))
698863
+		return FALSE;
698863
+
698863
+	locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
698863
+
698863
+	/* find the component using the UUID */
698863
+	if (uuid == NULL)
698863
+		return TRUE;
698863
+
698863
+	xpath = g_strdup_printf ("components/component/custom/"
698863
+				 "value[@key='shell-extensions::uuid'][text()='%s']/../..",
698863
+				 uuid);
698863
+	component = xb_silo_query_first (priv->silo, xpath, &error_local);
698863
+	if (component == NULL) {
698863
+		if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
698863
+			return TRUE;
698863
+		if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
698863
+			return TRUE;
698863
+		g_propagate_error (error, g_steal_pointer (&error_local));
698863
+		return FALSE;
698863
+	}
698863
+	return gs_appstream_refine_app (plugin, app, priv->silo, component, flags, error);
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_refine_wildcard (GsPlugin *plugin,
698863
+			   GsApp *app,
698863
+			   GsAppList *list,
698863
+			   GsPluginRefineFlags refine_flags,
698863
+			   GCancellable *cancellable,
698863
+			   GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	const gchar *id;
698863
+	g_autofree gchar *xpath = NULL;
698863
+	g_autoptr(GError) error_local = NULL;
698863
+	g_autoptr(GPtrArray) components = NULL;
698863
+	g_autoptr(GRWLockReaderLocker) locker = NULL;
698863
+
698863
+	/* repo not enabled */
698863
+	if (!g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		return TRUE;
698863
+
698863
+	/* check silo is valid */
698863
+	if (!_check_silo (plugin, cancellable, error))
698863
+		return FALSE;
698863
+
698863
+	/* not enough info to find */
698863
+	id = gs_app_get_id (app);
698863
+	if (id == NULL)
698863
+		return TRUE;
698863
+
698863
+	locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
698863
+
698863
+	/* find all apps */
698863
+	xpath = g_strdup_printf ("components/component/id[text()='%s']/..", id);
698863
+	components = xb_silo_query (priv->silo, xpath, 0, &error_local);
698863
+	if (components == NULL) {
698863
+		if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
698863
+			return TRUE;
698863
+		if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT))
698863
+			return TRUE;
698863
+		g_propagate_error (error, g_steal_pointer (&error_local));
698863
+		return FALSE;
698863
+	}
698863
+	for (guint i = 0; i < components->len; i++) {
698863
+		XbNode *component = g_ptr_array_index (components, i);
698863
+		g_autoptr(GsApp) new = NULL;
698863
+		new = gs_appstream_create_app (plugin, priv->silo, component, error);
698863
+		if (new == NULL)
698863
+			return FALSE;
698863
+		gs_app_subsume_metadata (new, app);
698863
+		if (!gs_appstream_refine_app (plugin, new, priv->silo, component,
698863
+					      refine_flags, error))
698863
+			return FALSE;
698863
+		gs_app_list_add (list, new);
698863
+	}
698863
+
698863
+	/* success */
698863
+	return TRUE;
698863
+}
698863
+
698863
+static gboolean
698863
+gs_plugin_shell_extensions_parse_version (GsPlugin *plugin,
698863
+					  const gchar *component_id,
698863
+					  XbBuilderNode *app,
698863
+					  JsonObject *ver_map,
698863
+					  GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	JsonObject *json_ver = NULL;
698863
+	gint64 version;
698863
+	g_autofree gchar *shell_version = NULL;
698863
+
698863
+	/* look for version, major.minor.micro */
698863
+	if (json_object_has_member (ver_map, priv->shell_version)) {
698863
+		json_ver = json_object_get_object_member (ver_map,
698863
+							  priv->shell_version);
698863
+	}
698863
+
698863
+	/* look for version, major.minor */
698863
+	if (json_ver == NULL) {
698863
+		g_auto(GStrv) ver_majmin = NULL;
698863
+		ver_majmin = g_strsplit (priv->shell_version, ".", -1);
698863
+		if (g_strv_length (ver_majmin) >= 2) {
698863
+			g_autofree gchar *tmp = NULL;
698863
+			tmp = g_strdup_printf ("%s.%s", ver_majmin[0], ver_majmin[1]);
698863
+			if (json_object_has_member (ver_map, tmp))
698863
+				json_ver = json_object_get_object_member (ver_map, tmp);
698863
+		}
698863
+	}
698863
+
698863
+	/* FIXME: mark as incompatible? */
698863
+	if (json_ver == NULL)
698863
+		return TRUE;
698863
+
698863
+	/* parse the version */
698863
+	version = json_object_get_int_member (json_ver, "version");
698863
+	if (version == 0) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_INVALID_FORMAT,
698863
+				     "no version in map!");
698863
+		return FALSE;
698863
+	}
698863
+	shell_version = g_strdup_printf ("%" G_GINT64_FORMAT, version);
698863
+
698863
+	/* add a dummy release */
698863
+	xb_builder_node_insert_text (app, "release", NULL,
698863
+				     "version", shell_version,
698863
+				     NULL);
698863
+	return TRUE;
698863
+}
698863
+
698863
+
698863
+
698863
+static XbBuilderNode *
698863
+gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
698863
+				      JsonObject *json_app,
698863
+				      GError **error)
698863
+{
698863
+	JsonObject *json_ver_map;
698863
+	const gchar *tmp;
698863
+	g_autofree gchar *component_id = NULL;
698863
+	g_autoptr(XbBuilderNode) app = NULL;
698863
+	g_autoptr(XbBuilderNode) categories = NULL;
698863
+	g_autoptr(XbBuilderNode) metadata = NULL;
698863
+
698863
+	app = xb_builder_node_new ("component");
698863
+	xb_builder_node_set_attr (app, "kind", "shell-extension");
698863
+	xb_builder_node_insert_text (app, "project_license", "GPL-2.0+", NULL);
698863
+	categories = xb_builder_node_insert (app, "categories", NULL);
698863
+	xb_builder_node_insert_text (categories, "category", "Addon", NULL);
698863
+	xb_builder_node_insert_text (categories, "category", "ShellExtension", NULL);
698863
+	metadata = xb_builder_node_insert (app, "custom", NULL);
698863
+
698863
+	tmp = json_object_get_string_member (json_app, "description");
698863
+	if (tmp != NULL) {
698863
+		g_auto(GStrv) paras = g_strsplit (tmp, "\n", -1);
698863
+		g_autoptr(XbBuilderNode) desc = xb_builder_node_insert (app, "description", NULL);
698863
+		for (guint i = 0; paras[i] != NULL; i++)
698863
+			xb_builder_node_insert_text (desc, "p", paras[i], NULL);
698863
+	}
698863
+	tmp = json_object_get_string_member (json_app, "screenshot");
698863
+	if (tmp != NULL) {
698863
+		g_autoptr(XbBuilderNode) screenshots = NULL;
698863
+		g_autoptr(XbBuilderNode) screenshot = NULL;
698863
+		g_autofree gchar *uri = NULL;
698863
+		screenshots = xb_builder_node_insert (app, "screenshots", NULL);
698863
+		screenshot = xb_builder_node_insert (screenshots, "screenshot",
698863
+						     "kind", "default",
698863
+						     NULL);
698863
+		uri = g_build_path ("/", SHELL_EXTENSIONS_API_URI, tmp, NULL);
698863
+		xb_builder_node_insert_text (screenshot, "image", uri,
698863
+					     "kind", "source",
698863
+					     NULL);
698863
+	}
698863
+	tmp = json_object_get_string_member (json_app, "name");
698863
+	if (tmp != NULL)
698863
+		xb_builder_node_insert_text (app, "name", tmp, NULL);
698863
+	tmp = json_object_get_string_member (json_app, "uuid");
698863
+	if (tmp != NULL) {
698863
+		component_id = as_utils_appstream_id_build (tmp);
698863
+		xb_builder_node_insert_text (app, "id", component_id, NULL);
698863
+		xb_builder_node_insert_text (metadata, "value", tmp,
698863
+					     "key", "shell-extensions::uuid",
698863
+					     NULL);
698863
+	}
698863
+	tmp = json_object_get_string_member (json_app, "link");
698863
+	if (tmp != NULL) {
698863
+		g_autofree gchar *uri = NULL;
698863
+		uri = g_build_filename (SHELL_EXTENSIONS_API_URI, tmp, NULL);
698863
+		xb_builder_node_insert_text (app, "url", uri,
698863
+					     "type", "homepage",
698863
+					     NULL);
698863
+	}
698863
+	tmp = json_object_get_string_member (json_app, "icon");
698863
+	if (tmp != NULL) {
698863
+		/* just use a stock icon as the remote icons are
698863
+		 * sometimes missing, poor quality and low resolution */
698863
+		xb_builder_node_insert_text (app, "icon",
698863
+					     "application-x-addon-symbolic",
698863
+					     "type", "stock",
698863
+					     NULL);
698863
+	}
698863
+
698863
+	/* try to get version */
698863
+	json_ver_map = json_object_get_object_member (json_app, "shell_version_map");
698863
+	if (json_ver_map != NULL) {
698863
+		if (!gs_plugin_shell_extensions_parse_version (plugin,
698863
+							       component_id,
698863
+							       app,
698863
+							       json_ver_map,
698863
+							       error))
698863
+			return NULL;
698863
+	}
698863
+
698863
+	return g_steal_pointer (&app);
698863
+}
698863
+
698863
+static GInputStream *
698863
+gs_plugin_appstream_load_json_cb (XbBuilderSource *self,
698863
+				  XbBuilderSourceCtx *ctx,
698863
+				  gpointer user_data,
698863
+				  GCancellable *cancellable,
698863
+				  GError **error)
698863
+{
698863
+	GsPlugin *plugin = GS_PLUGIN (user_data);
698863
+	JsonArray *json_extensions_array;
698863
+	JsonNode *json_extensions;
698863
+	JsonNode *json_root;
698863
+	JsonObject *json_item;
698863
+	gchar *xml;
698863
+	g_autoptr(JsonParser) json_parser = NULL;
698863
+	g_autoptr(XbBuilderNode) apps = NULL;
698863
+
698863
+	/* parse the data and find the success */
698863
+	json_parser = json_parser_new ();
698863
+	if (!json_parser_load_from_stream (json_parser,
698863
+					   xb_builder_source_ctx_get_stream (ctx),
698863
+					   cancellable, error)) {
698863
+		gs_utils_error_convert_json_glib (error);
698863
+		return NULL;
698863
+	}
698863
+	json_root = json_parser_get_root (json_parser);
698863
+	if (json_root == NULL) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_INVALID_FORMAT,
698863
+				     "no data root");
698863
+		return NULL;
698863
+	}
698863
+	if (json_node_get_node_type (json_root) != JSON_NODE_OBJECT) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_INVALID_FORMAT,
698863
+				     "no data object");
698863
+		return NULL;
698863
+	}
698863
+	json_item = json_node_get_object (json_root);
698863
+	if (json_item == NULL) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_INVALID_FORMAT,
698863
+				     "no data object");
698863
+		return NULL;
698863
+	}
698863
+
698863
+	/* load extensions */
698863
+	apps = xb_builder_node_new ("components");
698863
+	json_extensions = json_object_get_member (json_item, "extensions");
698863
+	if (json_extensions == NULL) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_INVALID_FORMAT,
698863
+				     "no extensions object");
698863
+		return NULL;
698863
+	}
698863
+	json_extensions_array = json_node_get_array (json_extensions);
698863
+	if (json_extensions_array == NULL) {
698863
+		g_set_error_literal (error,
698863
+				     GS_PLUGIN_ERROR,
698863
+				     GS_PLUGIN_ERROR_INVALID_FORMAT,
698863
+				     "no extensions array");
698863
+		return NULL;
698863
+	}
698863
+
698863
+	/* parse each app */
698863
+	for (guint i = 0; i < json_array_get_length (json_extensions_array); i++) {
698863
+		JsonNode *json_extension;
698863
+		JsonObject *json_extension_obj;
698863
+		g_autoptr(XbBuilderNode) component = NULL;
698863
+
698863
+		json_extension = json_array_get_element (json_extensions_array, i);
698863
+		json_extension_obj = json_node_get_object (json_extension);
698863
+		component = gs_plugin_shell_extensions_parse_app (plugin,
698863
+							    json_extension_obj,
698863
+							    error);
698863
+		if (component == NULL)
698863
+			return NULL;
698863
+		xb_builder_node_add_child (apps, component);
698863
+	}
698863
+
698863
+	/* convert back to XML */
698863
+	xml = xb_builder_node_export (apps, XB_NODE_EXPORT_FLAG_ADD_HEADER, error);
698863
+	if (xml == NULL)
698863
+		return NULL;
698863
+	return g_memory_input_stream_new_from_data (xml, -1, g_free);
698863
+}
698863
+
698863
+static gboolean
698863
+gs_plugin_shell_extensions_refresh (GsPlugin *plugin,
698863
+				    guint cache_age,
698863
+				    GCancellable *cancellable,
698863
+				    GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autofree gchar *fn = NULL;
698863
+	g_autofree gchar *uri = NULL;
698863
+	g_autoptr(GFile) file = NULL;
698863
+	g_autoptr(GRWLockReaderLocker) locker = NULL;
698863
+	g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
698863
+
698863
+	/* get cache filename */
698863
+	fn = gs_utils_get_cache_filename ("shell-extensions",
698863
+					  "gnome.json",
698863
+					  GS_UTILS_CACHE_FLAG_WRITEABLE,
698863
+					  error);
698863
+	if (fn == NULL)
698863
+		return FALSE;
698863
+
698863
+	/* check age */
698863
+	file = g_file_new_for_path (fn);
698863
+	if (g_file_query_exists (file, NULL)) {
698863
+		guint age = gs_utils_get_file_age (file);
698863
+		if (age < cache_age) {
698863
+			g_debug ("%s is only %u seconds old, ignoring", fn, age);
698863
+			return TRUE;
698863
+		}
698863
+	}
698863
+
698863
+	/* download the file */
698863
+	uri = g_strdup_printf ("%s/static/extensions.json",
698863
+			       SHELL_EXTENSIONS_API_URI);
698863
+	gs_app_set_summary_missing (app_dl,
698863
+				    /* TRANSLATORS: status text when downloading */
698863
+				    _("Downloading shell extension metadata…"));
698863
+	if (!gs_plugin_download_file (plugin, app_dl, uri, fn, cancellable, error)) {
698863
+		gs_utils_error_add_origin_id (error, priv->cached_origin);
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	/* be explicit */
698863
+	locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
698863
+	if (priv->silo != NULL)
698863
+		xb_silo_invalidate (priv->silo);
698863
+
698863
+	return TRUE;
698863
+}
698863
+
698863
+static gboolean
698863
+_check_silo (GsPlugin *plugin, GCancellable *cancellable, GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autofree gchar *blobfn = NULL;
698863
+	g_autofree gchar *fn = NULL;
698863
+	g_autoptr(GError) error_local = NULL;
698863
+	g_autoptr(GFile) blobfile = NULL;
698863
+	g_autoptr(GFile) file = NULL;
698863
+	g_autoptr(GRWLockReaderLocker) reader_locker = NULL;
698863
+	g_autoptr(GRWLockWriterLocker) writer_locker = NULL;
698863
+	g_autoptr(XbBuilder) builder = xb_builder_new ();
698863
+	g_autoptr(XbBuilderNode) info = NULL;
698863
+	g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
698863
+
698863
+	reader_locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
698863
+	/* everything is okay */
698863
+	if (priv->silo != NULL && xb_silo_is_valid (priv->silo)) {
698863
+		g_debug ("silo already valid");
698863
+		return TRUE;
698863
+	}
698863
+	g_clear_pointer (&reader_locker, g_rw_lock_reader_locker_free);
698863
+
698863
+	/* drat! silo needs regenerating */
698863
+	writer_locker = g_rw_lock_writer_locker_new (&priv->silo_lock);
698863
+	g_clear_object (&priv->silo);
698863
+
698863
+	/* verbose profiling */
698863
+	if (g_getenv ("GS_XMLB_VERBOSE") != NULL) {
698863
+		xb_builder_set_profile_flags (builder,
698863
+					      XB_SILO_PROFILE_FLAG_XPATH |
698863
+					      XB_SILO_PROFILE_FLAG_DEBUG);
698863
+	}
698863
+
698863
+	/* add metadata */
698863
+	info = xb_builder_node_insert (NULL, "info", NULL);
698863
+	xb_builder_node_insert_text (info, "scope", "user", NULL);
698863
+	xb_builder_source_set_info (source, info);
698863
+
698863
+	/* add support for JSON files */
698863
+	fn = gs_utils_get_cache_filename ("shell-extensions",
698863
+					  "gnome.json",
698863
+					  GS_UTILS_CACHE_FLAG_WRITEABLE,
698863
+					  error);
698863
+	if (fn == NULL)
698863
+		return FALSE;
698863
+	xb_builder_source_add_adapter (source, "application/json",
698863
+				       gs_plugin_appstream_load_json_cb,
698863
+				       plugin, NULL);
698863
+	file = g_file_new_for_path (fn);
698863
+	if (!xb_builder_source_load_file (source, file,
698863
+					  XB_BUILDER_SOURCE_FLAG_WATCH_FILE,
698863
+					  cancellable,
698863
+					  error)) {
698863
+		return FALSE;
698863
+	}
698863
+	xb_builder_import_source (builder, source);
698863
+
698863
+	/* create binary cache */
698863
+	blobfn = gs_utils_get_cache_filename ("shell-extensions",
698863
+					      "extensions-web.xmlb",
698863
+					      GS_UTILS_CACHE_FLAG_WRITEABLE,
698863
+					      error);
698863
+	if (blobfn == NULL)
698863
+		return FALSE;
698863
+	blobfile = g_file_new_for_path (blobfn);
698863
+	g_debug ("ensuring %s", blobfn);
698863
+	priv->silo = xb_builder_ensure (builder, blobfile,
698863
+					XB_BUILDER_COMPILE_FLAG_IGNORE_INVALID,
698863
+					NULL, &error_local);
698863
+	if (priv->silo == NULL) {
698863
+		g_set_error (error,
698863
+			     GS_PLUGIN_ERROR,
698863
+			     GS_PLUGIN_ERROR_FAILED,
698863
+			     "failed to compile %s",
698863
+			     error_local->message);
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	/* success */
698863
+	return TRUE;
698863
+}
698863
+
698863
+static void
698863
+_claim_components (GsPlugin *plugin, GsAppList *list)
698863
+{
698863
+	for (guint i = 0; i < gs_app_list_length (list); i++) {
698863
+		GsApp *app = gs_app_list_index (list, i);
698863
+		gs_app_set_kind (app, AS_APP_KIND_SHELL_EXTENSION);
698863
+		gs_app_set_origin_hostname (app, SHELL_EXTENSIONS_API_URI);
698863
+		gs_app_set_origin (app, _("GNOME"));
698863
+		gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
698863
+		gs_app_set_summary (app, GS_APP_QUALITY_LOWEST,
698863
+				    /* TRANSLATORS: the one-line summary */
698863
+				    _("GNOME Shell Extension"));
698863
+	}
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_add_search (GsPlugin *plugin, gchar **values, GsAppList *list,
698863
+		      GCancellable *cancellable, GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autoptr(GRWLockReaderLocker) locker = NULL;
698863
+	g_autoptr(GsAppList) list_tmp = gs_app_list_new ();
698863
+	if (!g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		return TRUE;
698863
+	if (!_check_silo (plugin, cancellable, error))
698863
+		return FALSE;
698863
+	locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
698863
+	if (!gs_appstream_search (plugin, priv->silo, (const gchar * const *) values, list_tmp,
698863
+				  cancellable, error))
698863
+		return FALSE;
698863
+	_claim_components (plugin, list_tmp);
698863
+	gs_app_list_add_list (list, list_tmp);
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_add_category_apps (GsPlugin *plugin, GsCategory *category, GsAppList *list,
698863
+			     GCancellable *cancellable, GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autoptr(GRWLockReaderLocker) locker = NULL;
698863
+	if (!g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		return TRUE;
698863
+	if (!_check_silo (plugin, cancellable, error))
698863
+		return FALSE;
698863
+	locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
698863
+	return gs_appstream_add_category_apps (plugin, priv->silo, category,
698863
+					       list, cancellable, error);
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_refresh (GsPlugin *plugin,
698863
+		   guint cache_age,
698863
+		   GCancellable *cancellable,
698863
+		   GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	if (!g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		return TRUE;
698863
+	if (!gs_plugin_shell_extensions_refresh (plugin,
698863
+						 cache_age,
698863
+						 cancellable,
698863
+						 error))
698863
+		return FALSE;
698863
+	return _check_silo (plugin, cancellable, error);
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_app_remove (GsPlugin *plugin,
698863
+		      GsApp *app,
698863
+		      GCancellable *cancellable,
698863
+		      GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	const gchar *uuid;
698863
+	gboolean ret;
698863
+	g_autoptr(GVariant) retval = NULL;
698863
+
698863
+	/* only process this app if was created by this plugin */
698863
+	if (g_strcmp0 (gs_app_get_management_plugin (app),
698863
+		       gs_plugin_get_name (plugin)) != 0)
698863
+		return TRUE;
698863
+
698863
+	/* disable repository */
698863
+	if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE) {
698863
+		gs_app_set_state (app, AS_APP_STATE_REMOVING);
698863
+		g_settings_set_boolean (priv->settings, "enable-shell-extensions-repo", FALSE);
698863
+		/* remove appstream data */
698863
+		ret = gs_plugin_shell_extensions_refresh (plugin,
698863
+		                                          G_MAXUINT,
698863
+		                                          cancellable,
698863
+		                                          error);
698863
+		gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
698863
+		return ret;
698863
+	}
698863
+
698863
+	/* remove */
698863
+	gs_app_set_state (app, AS_APP_STATE_REMOVING);
698863
+	uuid = gs_app_get_metadata_item (app, "shell-extensions::uuid");
698863
+	retval = g_dbus_proxy_call_sync (priv->proxy,
698863
+					 "UninstallExtension",
698863
+					 g_variant_new ("(s)", uuid),
698863
+					 G_DBUS_CALL_FLAGS_NONE,
698863
+					 -1,
698863
+					 cancellable,
698863
+					 error);
698863
+	if (retval == NULL) {
698863
+		gs_utils_error_convert_gio (error);
698863
+		gs_app_set_state_recover (app);
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	/* not sure why this would fail -- perhaps installed in /usr? */
698863
+	g_variant_get (retval, "(b)", &ret;;
698863
+	if (!ret) {
698863
+		gs_app_set_state_recover (app);
698863
+		g_set_error (error,
698863
+			     GS_PLUGIN_ERROR,
698863
+			     GS_PLUGIN_ERROR_NOT_SUPPORTED,
698863
+			     "failed to uninstall %s",
698863
+			     gs_app_get_id (app));
698863
+		return FALSE;
698863
+	}
698863
+
698863
+	/* state is not known: we don't know if we can re-install this app */
698863
+	gs_app_set_state (app, AS_APP_STATE_UNKNOWN);
698863
+
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_app_install (GsPlugin *plugin,
698863
+		       GsApp *app,
698863
+		       GCancellable *cancellable,
698863
+		       GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	const gchar *uuid;
698863
+	const gchar *retstr;
698863
+	g_autoptr(GVariant) retval = NULL;
698863
+
698863
+	/* only process this app if was created by this plugin */
698863
+	if (g_strcmp0 (gs_app_get_management_plugin (app),
698863
+		       gs_plugin_get_name (plugin)) != 0)
698863
+		return TRUE;
698863
+
698863
+	/* enable repository */
698863
+	if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE) {
698863
+		gboolean ret;
698863
+
698863
+		gs_app_set_state (app, AS_APP_STATE_INSTALLING);
698863
+		g_settings_set_boolean (priv->settings, "enable-shell-extensions-repo", TRUE);
698863
+		/* refresh metadata */
698863
+		ret = gs_plugin_shell_extensions_refresh (plugin,
698863
+		                                          G_MAXUINT,
698863
+		                                          cancellable,
698863
+		                                          error);
698863
+		gs_app_set_state (app, AS_APP_STATE_INSTALLED);
698863
+		return ret;
698863
+	}
698863
+
698863
+	/* install */
698863
+	uuid = gs_app_get_metadata_item (app, "shell-extensions::uuid");
698863
+	gs_app_set_state (app, AS_APP_STATE_INSTALLING);
698863
+	retval = g_dbus_proxy_call_sync (priv->proxy,
698863
+					 "InstallRemoteExtension",
698863
+					 g_variant_new ("(s)", uuid),
698863
+					 G_DBUS_CALL_FLAGS_NONE,
698863
+					 -1,
698863
+					 cancellable,
698863
+					 error);
698863
+	if (retval == NULL) {
698863
+		gs_app_set_state_recover (app);
698863
+		return FALSE;
698863
+	}
698863
+	g_variant_get (retval, "(&s)", &retstr);
698863
+
698863
+	/* user declined download */
698863
+	if (g_strcmp0 (retstr, "cancelled") == 0) {
698863
+		gs_app_set_state_recover (app);
698863
+		g_set_error (error,
698863
+			     GS_PLUGIN_ERROR,
698863
+			     GS_PLUGIN_ERROR_CANCELLED,
698863
+			     "extension %s download was cancelled",
698863
+			     gs_app_get_id (app));
698863
+		return FALSE;
698863
+	}
698863
+	g_debug ("shell returned: %s", retstr);
698863
+
698863
+	/* state is known */
698863
+	gs_app_set_state (app, AS_APP_STATE_INSTALLED);
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_launch (GsPlugin *plugin,
698863
+		  GsApp *app,
698863
+		  GCancellable *cancellable,
698863
+		  GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+	g_autofree gchar *uuid = NULL;
698863
+	g_autoptr(GVariant) retval = NULL;
698863
+
698863
+	/* launch both PackageKit-installed and user-installed */
698863
+	if (gs_app_get_kind (app) != AS_APP_KIND_SHELL_EXTENSION)
698863
+		return TRUE;
698863
+
698863
+	uuid = g_strdup (gs_app_get_metadata_item (app, "shell-extensions::uuid"));
698863
+	if (uuid == NULL) {
698863
+		const gchar *suffix = ".shell-extension";
698863
+		const gchar *id = gs_app_get_id (app);
698863
+		/* PackageKit-installed extension ID generated by appstream-builder */
698863
+		if (g_str_has_suffix (id, suffix))
698863
+			uuid = g_strndup (id, strlen (id) - strlen (suffix));
698863
+	}
698863
+	if (uuid == NULL) {
698863
+		g_set_error (error,
698863
+			     GS_PLUGIN_ERROR,
698863
+			     GS_PLUGIN_ERROR_FAILED,
698863
+			     "no uuid set for %s",
698863
+			     gs_app_get_id (app));
698863
+		return FALSE;
698863
+	}
698863
+	/* launch */
698863
+	retval = g_dbus_proxy_call_sync (priv->proxy,
698863
+					 "LaunchExtensionPrefs",
698863
+					 g_variant_new ("(s)", uuid),
698863
+					 G_DBUS_CALL_FLAGS_NONE,
698863
+					 -1,
698863
+					 cancellable,
698863
+					 error);
698863
+	if (retval == NULL) {
698863
+		gs_utils_error_convert_gio (error);
698863
+		return FALSE;
698863
+	}
698863
+	return TRUE;
698863
+}
698863
+
698863
+gboolean
698863
+gs_plugin_add_categories (GsPlugin *plugin,
698863
+			  GPtrArray *list,
698863
+			  GCancellable *cancellable,
698863
+			  GError **error)
698863
+{
698863
+	GsPluginData *priv = gs_plugin_get_data (plugin);
698863
+
698863
+	/* repo not enabled */
698863
+	if (!g_settings_get_boolean (priv->settings, "enable-shell-extensions-repo"))
698863
+		return TRUE;
698863
+
698863
+	/* just ensure there is any data, no matter how old */
698863
+	return gs_plugin_shell_extensions_refresh (plugin,
698863
+						   G_MAXUINT,
698863
+						   cancellable,
698863
+						   error);
698863
+}
698863
diff --git a/plugins/shell-extensions/gs-self-test.c b/plugins/shell-extensions/gs-self-test.c
698863
new file mode 100644
698863
index 00000000..f96ee60d
698863
--- /dev/null
698863
+++ b/plugins/shell-extensions/gs-self-test.c
698863
@@ -0,0 +1,156 @@
698863
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
698863
+ *
698863
+ * Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
698863
+ *
698863
+ * SPDX-License-Identifier: GPL-2.0+
698863
+ */
698863
+
698863
+#include "config.h"
698863
+
698863
+#include <glib/gstdio.h>
698863
+#include <xmlb.h>
698863
+
698863
+#include "gnome-software-private.h"
698863
+
698863
+#include "gs-test.h"
698863
+
698863
+static void
698863
+gs_plugins_shell_extensions_installed_func (GsPluginLoader *plugin_loader)
698863
+{
698863
+	GsApp *app;
698863
+	g_autoptr(GError) error = NULL;
698863
+	g_autoptr(GsAppList) list = NULL;
698863
+	g_autoptr(GsPluginJob) plugin_job = NULL;
698863
+
698863
+	/* no shell-extensions, abort */
698863
+	if (!gs_plugin_loader_get_enabled (plugin_loader, "shell-extensions")) {
698863
+		g_test_skip ("not enabled");
698863
+		return;
698863
+	}
698863
+
698863
+	/* get installed packages */
698863
+	plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_INSTALLED,
698863
+					 "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES,
698863
+					 NULL);
698863
+	list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
698863
+	gs_test_flush_main_context ();
698863
+	g_assert_no_error (error);
698863
+	g_assert (list != NULL);
698863
+
698863
+	/* no shell-extensions installed, abort */
698863
+	if (gs_app_list_length (list) < 1) {
698863
+		g_test_skip ("no shell extensions installed");
698863
+		return;
698863
+	}
698863
+
698863
+	/* test properties */
698863
+	app = gs_app_list_lookup (list, "*/*/*/*/background-logo_fedorahosted.org/*");
698863
+	if (app == NULL) {
698863
+		g_test_skip ("not found");
698863
+		return;
698863
+	}
698863
+
698863
+	g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_INSTALLED);
698863
+	g_assert_cmpint (gs_app_get_scope (app), ==, AS_APP_SCOPE_USER);
698863
+	g_assert_cmpstr (gs_app_get_name (app), ==, "Background Logo");
698863
+	g_assert_cmpstr (gs_app_get_summary (app), ==, "GNOME Shell Extension");
698863
+	g_assert_cmpstr (gs_app_get_description (app), ==,
698863
+			 "Overlay a tasteful logo on the background to "
698863
+			 "enhance the user experience");
698863
+	g_assert_cmpstr (gs_app_get_license (app), ==, "GPL-2.0+");
698863
+	g_assert_cmpstr (gs_app_get_management_plugin (app), ==, "shell-extensions");
698863
+	g_assert (gs_app_has_category (app, "Addon"));
698863
+	g_assert (gs_app_has_category (app, "ShellExtension"));
698863
+	g_assert_cmpstr (gs_app_get_metadata_item (app, "shell-extensions::has-prefs"), ==, "");
698863
+	g_assert_cmpstr (gs_app_get_metadata_item (app, "shell-extensions::uuid"), ==,
698863
+			 "background-logo@fedorahosted.org");
698863
+}
698863
+
698863
+static void
698863
+gs_plugins_shell_extensions_remote_func (GsPluginLoader *plugin_loader)
698863
+{
698863
+	const gchar *cachedir = "/var/tmp/gs-self-test";
698863
+	gboolean ret;
698863
+	g_autofree gchar *fn = NULL;
698863
+	g_autoptr(GError) error = NULL;
698863
+	g_autoptr(GFile) file = NULL;
698863
+	g_autoptr(GPtrArray) components = NULL;
698863
+	g_autoptr(GsPluginJob) plugin_job = NULL;
698863
+	g_autoptr(XbSilo) silo = NULL;
698863
+
698863
+	/* no shell-extensions, abort */
698863
+	if (!gs_plugin_loader_get_enabled (plugin_loader, "shell-extensions")) {
698863
+		g_test_skip ("not enabled");
698863
+		return;
698863
+	}
698863
+
698863
+	/* ensure files are removed */
698863
+	g_setenv ("GS_SELF_TEST_CACHEDIR", cachedir, TRUE);
698863
+	gs_utils_rmtree (cachedir, NULL);
698863
+
698863
+	/* refresh the metadata */
698863
+	plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFRESH,
698863
+					 "age", (guint64) G_MAXUINT,
698863
+					 NULL);
698863
+	ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error);
698863
+	g_assert_no_error (error);
698863
+	g_assert (ret);
698863
+
698863
+	/* ensure file was populated */
698863
+	silo = xb_silo_new ();
698863
+	fn = gs_utils_get_cache_filename ("shell-extensions",
698863
+					  "extensions-web.xmlb",
698863
+					  GS_UTILS_CACHE_FLAG_WRITEABLE,
698863
+					  &error);
698863
+	g_assert_no_error (error);
698863
+	g_assert_nonnull (fn);
698863
+	file = g_file_new_for_path (fn);
698863
+	ret = xb_silo_load_from_file (silo, file,
698863
+				      XB_SILO_LOAD_FLAG_NONE,
698863
+				      NULL, &error);
698863
+	g_assert_no_error (error);
698863
+	g_assert (ret);
698863
+	components = xb_silo_query (silo, "components/component", 0, &error);
698863
+	g_assert_no_error (error);
698863
+	g_assert_nonnull (components);
698863
+	g_assert_cmpint (components->len, >, 20);
698863
+}
698863
+
698863
+int
698863
+main (int argc, char **argv)
698863
+{
698863
+	gboolean ret;
698863
+	g_autoptr(GError) error = NULL;
698863
+	g_autoptr(GsPluginLoader) plugin_loader = NULL;
698863
+	const gchar *whitelist[] = {
698863
+		"shell-extensions",
698863
+		NULL
698863
+	};
698863
+
698863
+	g_test_init (&argc, &argv, NULL);
698863
+	g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
698863
+
698863
+	/* only critical and error are fatal */
698863
+	g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
698863
+
698863
+	/* we can only load this once per process */
698863
+	plugin_loader = gs_plugin_loader_new ();
698863
+	gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
698863
+	ret = gs_plugin_loader_setup (plugin_loader,
698863
+				      (gchar**) whitelist,
698863
+				      NULL,
698863
+				      NULL,
698863
+				      &error);
698863
+	g_assert_no_error (error);
698863
+	g_assert (ret);
698863
+
698863
+	/* plugin tests go here */
698863
+	g_test_add_data_func ("/gnome-software/plugins/shell-extensions/installed",
698863
+			      plugin_loader,
698863
+			      (GTestDataFunc) gs_plugins_shell_extensions_installed_func);
698863
+	g_test_add_data_func ("/gnome-software/plugins/shell-extensions/remote",
698863
+			      plugin_loader,
698863
+			      (GTestDataFunc) gs_plugins_shell_extensions_remote_func);
698863
+
698863
+	return g_test_run ();
698863
+}
698863
diff --git a/plugins/shell-extensions/meson.build b/plugins/shell-extensions/meson.build
698863
new file mode 100644
698863
index 00000000..3a008f7b
698863
--- /dev/null
698863
+++ b/plugins/shell-extensions/meson.build
698863
@@ -0,0 +1,47 @@
698863
+cargs = ['-DG_LOG_DOMAIN="GsPluginShellExtensions"']
698863
+cargs += ['-DLOCALPLUGINDIR="' + meson.current_build_dir() + '"']
698863
+
698863
+shared_module(
698863
+  'gs_plugin_shell-extensions',
698863
+  sources : [
698863
+    'gs-appstream.c',
698863
+    'gs-plugin-shell-extensions.c'
698863
+  ],
698863
+  include_directories : [
698863
+    include_directories('../..'),
698863
+    include_directories('../../lib'),
698863
+  ],
698863
+  install : true,
698863
+  install_dir: plugin_dir,
698863
+  c_args : cargs,
698863
+  dependencies : [
698863
+    plugin_libs,
698863
+    libxmlb,
698863
+  ],
698863
+  link_with : [
698863
+    libgnomesoftware
698863
+  ]
698863
+)
698863
+
698863
+if get_option('tests')
698863
+  e = executable(
698863
+    'gs-self-test-shell-extensions',
698863
+    compiled_schemas,
698863
+    sources : [
698863
+      'gs-self-test.c'
698863
+    ],
698863
+    include_directories : [
698863
+      include_directories('../..'),
698863
+      include_directories('../../lib'),
698863
+    ],
698863
+    dependencies : [
698863
+      plugin_libs,
698863
+      libxmlb,
698863
+    ],
698863
+    link_with : [
698863
+      libgnomesoftware
698863
+    ],
698863
+    c_args : cargs,
698863
+  )
698863
+  test('gs-self-test-shell-extensions', e, suite: ['plugins', 'shell-extensions'], env: test_env)
698863
+endif
698863
diff --git a/src/gs-category-page.c b/src/gs-category-page.c
698863
index 10467436..a786d48d 100644
698863
--- a/src/gs-category-page.c
698863
+++ b/src/gs-category-page.c
698863
@@ -38,6 +38,8 @@ struct _GsCategoryPage
698863
 	guint		sort_name_handler_id;
698863
 	SubcategorySortType sort_type;
698863
 
698863
+	GtkWidget	*infobar_category_shell_extensions;
698863
+	GtkWidget	*button_category_shell_extensions;
698863
 	GtkWidget	*category_detail_box;
698863
 	GtkWidget	*scrolledwindow_category;
698863
 	GtkWidget	*subcats_filter_label;
698863
@@ -321,6 +323,12 @@ gs_category_page_reload (GsPage *page)
698863
 		gtk_widget_set_visible (self->subcats_sort_button, TRUE);
698863
 	}
698863
 
698863
+	/* show the shell extensions header */
698863
+	if (g_strcmp0 (gs_category_get_id (self->subcategory), "shell-extensions") == 0)
698863
+		gtk_widget_set_visible (self->infobar_category_shell_extensions, TRUE);
698863
+	else
698863
+		gtk_widget_set_visible (self->infobar_category_shell_extensions, FALSE);
698863
+
698863
 	if (self->sort_rating_handler_id > 0) {
698863
 		g_signal_handler_disconnect (self->sort_rating_button,
698863
 					     self->sort_rating_handler_id);
698863
@@ -524,6 +532,18 @@ gs_category_page_dispose (GObject *object)
698863
 	G_OBJECT_CLASS (gs_category_page_parent_class)->dispose (object);
698863
 }
698863
 
698863
+static void
698863
+button_shell_extensions_cb (GtkButton *button, GsCategoryPage *self)
698863
+{
698863
+	gboolean ret;
698863
+	g_autoptr(GError) error = NULL;
698863
+	const gchar *argv[] = { "gnome-shell-extension-prefs", NULL };
698863
+	ret = g_spawn_async (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH,
698863
+			     NULL, NULL, NULL, &error);
698863
+	if (!ret)
698863
+		g_warning ("failed to exec %s: %s", argv[0], error->message);
698863
+}
698863
+
698863
 static gboolean
698863
 gs_category_page_setup (GsPage *page,
698863
                         GsShell *shell,
698863
@@ -545,6 +565,9 @@ gs_category_page_setup (GsPage *page,
698863
 
698863
 	adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolledwindow_category));
698863
 	gtk_container_set_focus_vadjustment (GTK_CONTAINER (self->category_detail_box), adj);
698863
+
698863
+	g_signal_connect (self->button_category_shell_extensions, "clicked",
698863
+			  G_CALLBACK (button_shell_extensions_cb), self);
698863
 	return TRUE;
698863
 }
698863
 
698863
@@ -563,6 +586,8 @@ gs_category_page_class_init (GsCategoryPageClass *klass)
698863
 	gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-category-page.ui");
698863
 
698863
 	gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, category_detail_box);
698863
+	gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, infobar_category_shell_extensions);
698863
+	gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, button_category_shell_extensions);
698863
 	gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, scrolledwindow_category);
698863
 	gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_filter_label);
698863
 	gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_filter_button_label);
698863
diff --git a/src/gs-category-page.ui b/src/gs-category-page.ui
698863
index cbb82840..2a3c789f 100644
698863
--- a/src/gs-category-page.ui
698863
+++ b/src/gs-category-page.ui
698863
@@ -97,6 +97,51 @@
698863
                                 <property name="margin_end">24</property>
698863
                               </object>
698863
                             </child>
698863
+                            <child>
698863
+                              <object class="GtkInfoBar" id="infobar_category_shell_extensions">
698863
+                                <property name="visible">False</property>
698863
+                                <property name="app_paintable">True</property>
698863
+                                <property name="hexpand">True</property>
698863
+                                <property name="message_type">other</property>
698863
+                                <property name="margin_start">24</property>
698863
+                                <property name="margin_top">24</property>
698863
+                                <property name="margin_end">24</property>
698863
+                                <style>
698863
+                                  <class name="application-details-infobar"/>
698863
+                                </style>
698863
+                                <child internal-child="action_area">
698863
+                                  <object class="GtkButtonBox">
698863
+                                    <property name="spacing">6</property>
698863
+                                    <property name="layout_style">end</property>
698863
+                                    <child>
698863
+                                      <object class="GtkButton" id="button_category_shell_extensions">
698863
+                                        <property name="label" translatable="yes">Extension Settings</property>
698863
+                                        <property name="visible">True</property>
698863
+                                        <property name="can_focus">True</property>
698863
+                                        <property name="receives_default">True</property>
698863
+                                        <property name="hexpand">True</property>
698863
+                                      </object>
698863
+                                    </child>
698863
+                                  </object>
698863
+                                </child>
698863
+                                <child internal-child="content_area">
698863
+                                  <object class="GtkBox">
698863
+                                    <property name="halign">start</property>
698863
+                                    <property name="hexpand">True</property>
698863
+                                    <property name="spacing">16</property>
698863
+                                    <child>
698863
+                                      <object class="GtkLabel">
698863
+                                        <property name="visible">True</property>
698863
+                                        <property name="wrap">True</property>
698863
+                                        <property name="label" translatable="yes">Extensions are used at your own risk. If you have any system problems, it is recommended to disable them.</property>
698863
+                                        <property name="hexpand">True</property>
698863
+                                      </object>
698863
+                                    </child>
698863
+                                  </object>
698863
+                                </child>
698863
+                              </object>
698863
+                            </child>
698863
+
698863
                             <child>
698863
                               <object class="GtkBox">
698863
                                 <property name="visible">True</property>
698863
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
698863
index 8eb07bd3..37a717bf 100644
698863
--- a/src/gs-details-page.c
698863
+++ b/src/gs-details-page.c
698863
@@ -923,9 +923,17 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
698863
 		break;
698863
 	}
698863
 
698863
-	gtk_button_set_label (GTK_BUTTON (self->button_details_launch),
698863
-			      /* TRANSLATORS: A label for a button to execute the selected application. */
698863
-			      _("_Launch"));
698863
+	if (gs_app_get_kind (self->app) == AS_APP_KIND_SHELL_EXTENSION) {
698863
+		gtk_button_set_label (GTK_BUTTON (self->button_details_launch),
698863
+		                      /* TRANSLATORS: A label for a button to show the settings for
698863
+		                         the selected shell extension. */
698863
+		                      _("Extension Settings"));
698863
+	} else {
698863
+		gtk_button_set_label (GTK_BUTTON (self->button_details_launch),
698863
+		                      /* TRANSLATORS: A label for a button to execute the selected
698863
+		                         application. */
698863
+		                      _("_Launch"));
698863
+	}
698863
 
698863
 	/* don't show the launch and shortcut buttons if the app doesn't have a desktop ID */
698863
 	if (gs_app_get_id (self->app) == NULL) {
698863
diff --git a/src/gs-repo-row.c b/src/gs-repo-row.c
698863
index 35b35045..7ce7e618 100644
698863
--- a/src/gs-repo-row.c
698863
+++ b/src/gs-repo-row.c
698863
@@ -68,7 +68,8 @@ repo_supports_removal (GsApp *repo)
698863
 	/* can't remove a repo, only enable/disable existing ones */
698863
 	if (g_strcmp0 (management_plugin, "fwupd") == 0 ||
698863
 	    g_strcmp0 (management_plugin, "packagekit") == 0 ||
698863
-	    g_strcmp0 (management_plugin, "rpm-ostree") == 0)
698863
+	    g_strcmp0 (management_plugin, "rpm-ostree") == 0 ||
698863
+	    g_strcmp0 (management_plugin, "shell-extensions") == 0)
698863
 		return FALSE;
698863
 
698863
 	return TRUE;
698863
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
698863
index 93830308..7c11dc78 100644
698863
--- a/src/gs-repos-dialog.c
698863
+++ b/src/gs-repos-dialog.c
698863
@@ -136,7 +136,8 @@ repo_supports_removal (GsApp *repo)
698863
 	/* can't remove a repo, only enable/disable existing ones */
698863
 	if (g_strcmp0 (management_plugin, "fwupd") == 0 ||
698863
 	    g_strcmp0 (management_plugin, "packagekit") == 0 ||
698863
-	    g_strcmp0 (management_plugin, "rpm-ostree") == 0)
698863
+	    g_strcmp0 (management_plugin, "rpm-ostree") == 0 ||
698863
+	    g_strcmp0 (management_plugin, "shell-extensions") == 0)
698863
 		return FALSE;
698863
 
698863
 	return TRUE;
698863
diff --git a/src/gs-summary-tile.c b/src/gs-summary-tile.c
698863
index 446200de..90e810c9 100644
698863
--- a/src/gs-summary-tile.c
698863
+++ b/src/gs-summary-tile.c
698863
@@ -41,7 +41,7 @@ gs_summary_tile_refresh (GsAppTile *self)
698863
 	const GdkPixbuf *pixbuf;
698863
 	gboolean installed;
698863
 	g_autofree gchar *name = NULL;
698863
-	const gchar *summary;
698863
+	g_autofree gchar *summary = NULL;
698863
 	const gchar *css;
698863
 
698863
 	if (app == NULL)
698863
@@ -53,7 +53,18 @@ gs_summary_tile_refresh (GsAppTile *self)
698863
 	/* set name */
698863
 	gtk_label_set_label (GTK_LABEL (tile->name), gs_app_get_name (app));
698863
 
698863
-	summary = gs_app_get_summary (app);
698863
+	/* some kinds have boring summaries */
698863
+	switch (gs_app_get_kind (app)) {
698863
+	case AS_APP_KIND_SHELL_EXTENSION:
698863
+		summary = g_strdup (gs_app_get_description (app));
698863
+		if (summary != NULL)
698863
+			g_strdelimit (summary, "\n\t", ' ');
698863
+		break;
698863
+	default:
698863
+		summary = g_strdup (gs_app_get_summary (app));
698863
+		break;
698863
+	}
698863
+
698863
 	gtk_label_set_label (GTK_LABEL (tile->summary), summary);
698863
 	gtk_widget_set_visible (tile->summary, summary && summary[0]);
698863
 
698863
-- 
698863
2.18.2
698863
698863
698863
From 420396f45380ce4da2a609f139e5f7f47a6d5d5d Mon Sep 17 00:00:00 2001
698863
From: Kalev Lember <klember@redhat.com>
698863
Date: Wed, 3 Jun 2020 15:50:44 +0200
698863
Subject: [PATCH 2/2] Revert "Update POTFILES.in"
698863
698863
This reverts commit 9afc91a6de17117a32e4d36210230ba218e8ea7d.
698863
---
698863
 po/POTFILES.in | 1 +
698863
 1 file changed, 1 insertion(+)
698863
698863
diff --git a/po/POTFILES.in b/po/POTFILES.in
698863
index a44a6ad3..c38c56e2 100644
698863
--- a/po/POTFILES.in
698863
+++ b/po/POTFILES.in
698863
@@ -88,5 +88,6 @@ plugins/fwupd/gs-plugin-fwupd.c
698863
 plugins/fwupd/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
698863
 plugins/odrs/gs-plugin-odrs.c
698863
 plugins/odrs/org.gnome.Software.Plugin.Odrs.metainfo.xml.in
698863
+plugins/shell-extensions/gs-plugin-shell-extensions.c
698863
 plugins/snap/gs-plugin-snap.c
698863
 plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in
698863
-- 
698863
2.18.2
698863