[gnome-software/wip/hughsie/xdg-app] Use the library from xdg-app rather than spawning a process for each request
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/xdg-app] Use the library from xdg-app rather than spawning a process for each request
- Date: Wed, 16 Dec 2015 16:53:29 +0000 (UTC)
commit 34b8e591d8d078bf372d5f16f32f61a7bbcaf55b
Author: Richard Hughes <richard hughsie com>
Date: Wed Dec 16 16:53:15 2015 +0000
Use the library from xdg-app rather than spawning a process for each request
configure.ac | 17 ++
src/gs-plugin-loader.c | 7 +-
src/plugins/Makefile.am | 10 +-
src/plugins/gs-plugin-appstream.c | 4 +-
src/plugins/gs-plugin-packagekit.c | 3 +
src/plugins/gs-plugin-xdg-app.c | 388 +++++++++++++++++++++++++++++-------
6 files changed, 348 insertions(+), 81 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2c30e6f..2db39c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,22 @@ AS_IF([test "x$enable_firmware" != "xno"], [
have_firmware=no
])
+# xdg-app
+AC_ARG_ENABLE(xdg-app,
+ [AS_HELP_STRING([--enable-xdg-app],
+ [enable xdg-app support [default=auto]])],,
+ enable_xdg_app=maybe)
+
+AS_IF([test "x$enable_xdg_app" != "xno"], [
+ PKG_CHECK_MODULES(XDG_APP,
+ [xdg-app],
+ [have_xdg_app=yes],
+ [have_xdg_app=no])
+], [
+ have_xdg_app=no
+])
+AM_CONDITIONAL(HAVE_XDG_APP, test "$have_xdg_app" != no)
+
AS_IF([test "x$have_firmware" = "xyes"], [
AC_DEFINE(HAVE_FIRMWARE,1,[Build firmware support])
], [
@@ -182,5 +198,6 @@ echo "
cppflags: ${CPPFLAGS}
Dogtail: ${enable_dogtail}
Firmware support: ${have_firmware}
+ XDG-APP support: ${have_xdg_app}
"
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index e822f67..eb2ce6a 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -354,14 +354,15 @@ gs_plugin_loader_run_launch (GsPluginLoader *plugin_loader,
GCancellable *cancellable,
GError **error)
{
+ GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
GsPluginLaunchFunc plugin_func = NULL;
GsPlugin *plugin;
gboolean ret = TRUE;
guint i;
/* run each plugin */
- for (i = 0; i < plugin_loader->priv->plugins->len; i++) {
- plugin = g_ptr_array_index (plugin_loader->priv->plugins, i);
+ for (i = 0; i < priv->plugins->len; i++) {
+ plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
if (!g_module_symbol (plugin->module,
@@ -2375,7 +2376,7 @@ gs_plugin_loader_app_launch_async (GsPluginLoader *plugin_loader,
gpointer user_data)
{
GsPluginLoaderAsyncState *state;
- _cleanup_object_unref_ GTask *task = NULL;
+ g_autoptr(GTask) task = NULL;
g_return_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader));
g_return_if_fail (GS_IS_APP (app));
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 6fa3f2b..d9ce48a 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -11,6 +11,7 @@ AM_CPPFLAGS = \
$(SQLITE_CFLAGS) \
$(FWUPD_CFLAGS) \
$(LIMBA_CFLAGS) \
+ $(XDG_APP_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
-DGS_MODULESETDIR=\"$(datadir)/gnome-software/modulesets.d\" \
@@ -28,7 +29,6 @@ noinst_LTLIBRARIES = \
plugindir = $(libdir)/gs-plugins-${GS_PLUGIN_API_VERSION}
plugin_LTLIBRARIES = \
- libgs_plugin_xdg_app.la \
libgs_plugin_appstream.la \
libgs_plugin_hardcoded-featured.la \
libgs_plugin_moduleset.la \
@@ -51,6 +51,10 @@ if HAVE_FIRMWARE
plugin_LTLIBRARIES += libgs_plugin_fwupd.la
endif
+if HAVE_XDG_APP
+plugin_LTLIBRARIES += libgs_plugin_xdg_app.la
+endif
+
if HAVE_LIMBA
plugin_LTLIBRARIES += libgs_plugin_limba.la
endif
@@ -103,10 +107,12 @@ libgs_plugin_limba_la_LDFLAGS = -module -avoid-version
libgs_plugin_limba_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
endif
+if HAVE_XDG_APP
libgs_plugin_xdg_app_la_SOURCES = gs-plugin-xdg-app.c
-libgs_plugin_xdg_app_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_xdg_app_la_LIBADD = $(GS_PLUGIN_LIBS) $(XDG_APP_LIBS)
libgs_plugin_xdg_app_la_LDFLAGS = -module -avoid-version
libgs_plugin_xdg_app_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
+endif
libgs_plugin_moduleset_la_SOURCES = \
gs-moduleset.c \
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 84593b4..33fa2e9 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -98,6 +98,8 @@ gs_plugin_initialize (GsPlugin *plugin)
gs_plugin_check_distro_id (plugin, "ubuntu")) {
plugin->use_pkg_descriptions = TRUE;
}
+
+gs_plugin_set_enabled(plugin, FALSE);
}
/**
@@ -1034,7 +1036,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
GPtrArray *array;
guint i;
g_autoptr(AsProfileTask) ptask = NULL;
-
+g_error ("MOO");
/* load XML files */
if (g_once_init_enter (&plugin->priv->done_init)) {
ret = gs_plugin_startup (plugin, error);
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index 48841f5..541b6e9 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -54,6 +54,9 @@ gs_plugin_initialize (GsPlugin *plugin)
pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
pk_client_set_interactive (PK_CLIENT (plugin->priv->task), FALSE);
pk_client_set_cache_age (PK_CLIENT (plugin->priv->task), G_MAXUINT);
+
+gs_plugin_set_enabled(plugin, FALSE);
+
}
/**
diff --git a/src/plugins/gs-plugin-xdg-app.c b/src/plugins/gs-plugin-xdg-app.c
index b149ab4..be8f341 100644
--- a/src/plugins/gs-plugin-xdg-app.c
+++ b/src/plugins/gs-plugin-xdg-app.c
@@ -23,11 +23,23 @@
*
* All GsApp's created have management-plugin set to XgdApp
* Some GsApp's created have have XgdApp::type of app or runtime
- * The GsApp:source is the remote name, e.g. test-repo
+ * The GsApp:origin is the remote name, e.g. test-repo
+ *
+ * Some outstanding notes:
+ *
+ * - What is xdg_app_installed_ref_get_current() for? Should we only show current apps?
+ * - Why xdg_app_installation_list_installed_refs() not return a GPtrArray? Makes g_autoptr support hard.
+ * - Is xdg_app_installation_new_user() cheap, is it threadsafe? Should I keep a ref for this all the time
g-s is running.
+ * - How can I get the AppStream metadata using libxdgapp (need to do searching on long application
descriptions)
+ * - Are we only supporting per-user application installs?
+ * - Is there a faster way to get the installed apps and frameworks; i.e. pass a bitfield of types rather
than a type to get both at the same time
+ * - How do I get the list of updates using libxdg-app, e.g. like "xdg-app --user --updates repo-contents
test-repo" used to work
*/
#include <config.h>
+#include <xdg-app.h>
+
#include <gs-plugin.h>
struct GsPluginPrivate {
@@ -135,6 +147,167 @@ gs_plugin_add_search (GsPlugin *plugin,
return TRUE;
}
+static int
+lib_demo (void)
+{
+ XdgAppInstallation *installation;
+ XdgAppInstalledRef **apps;
+ XdgAppRemoteRef **refs;
+ XdgAppInstalledRef *xapp;
+ XdgAppInstalledRef *app2;
+ XdgAppInstalledRef **runtimes;
+ XdgAppRemoteRef *remote_ref;
+ XdgAppRemote **remotes;
+ GError *error = NULL;
+ int i, j;
+
+ installation = xdg_app_installation_new_user ();
+
+ g_print ("\n**** Getting installed gedit master\n");
+ xapp = xdg_app_installation_get_installed_ref (installation,
+ XDG_APP_REF_KIND_APP,
+ "org.gnome.gedit",
+ NULL, "master", NULL, NULL);
+ if (xapp) {
+ g_print ("gedit master: %d %s %s %s %s %s %s %d\n",
+ xdg_app_ref_get_kind (XDG_APP_REF(xapp)),
+ xdg_app_ref_get_name (XDG_APP_REF(xapp)),
+ xdg_app_ref_get_arch (XDG_APP_REF(xapp)),
+ xdg_app_ref_get_version (XDG_APP_REF(xapp)),
+ xdg_app_ref_get_commit (XDG_APP_REF(xapp)),
+ xdg_app_installed_ref_get_origin (xapp),
+ xdg_app_installed_ref_get_deploy_dir (xapp),
+ xdg_app_installed_ref_get_current (xapp));
+ xdg_app_installed_ref_launch (xapp, NULL, NULL);
+ }
+
+ g_print ("\n**** Getting current installed gedit\n");
+ app2 = xdg_app_installation_get_current_installed_app (installation,
+ "org.gnome.gedit",
+ NULL, NULL);
+ if (app2)
+ g_print ("gedit current: %d %s %s %s %s %s %s %d\n",
+ xdg_app_ref_get_kind (XDG_APP_REF(app2)),
+ xdg_app_ref_get_name (XDG_APP_REF(app2)),
+ xdg_app_ref_get_arch (XDG_APP_REF(app2)),
+ xdg_app_ref_get_version (XDG_APP_REF(app2)),
+ xdg_app_ref_get_commit (XDG_APP_REF(app2)),
+ xdg_app_installed_ref_get_origin (app2),
+ xdg_app_installed_ref_get_deploy_dir (app2),
+ xdg_app_installed_ref_get_current (app2));
+
+
+ g_print ("\n**** Listing remotes\n");
+ remotes = xdg_app_installation_list_remotes (installation,
+ NULL, NULL);
+
+ for (i = 0; remotes[i] != NULL; i++) {
+ g_print ("\nRemote: %s %s %s %d %d\n",
+ xdg_app_remote_get_name (remotes[i]),
+ xdg_app_remote_get_url (remotes[i]),
+ xdg_app_remote_get_title (remotes[i]),
+ xdg_app_remote_get_gpg_verify (remotes[i]),
+ xdg_app_remote_get_noenumerate (remotes[i]));
+
+ g_print ("\n**** Listing remote refs on %s\n", xdg_app_remote_get_name (remotes[i]));
+ refs = xdg_app_remote_list_refs_sync (remotes[i],
+ NULL, NULL);
+ if (refs) {
+ for (j = 0; refs[j] != NULL; j++) {
+ const gchar *name;
+ name = xdg_app_ref_get_name (XDG_APP_REF(refs[j]));
+ if (g_strrstr (name, ".Locale") != NULL)
+ continue;
+ if (g_strrstr (name, ".AutoBuild") != NULL)
+ continue;
+ g_print ("%d %s %s %s %s %s\n",
+ xdg_app_ref_get_kind (XDG_APP_REF(refs[j])),
+ name,
+ xdg_app_ref_get_arch (XDG_APP_REF(refs[j])),
+ xdg_app_ref_get_version (XDG_APP_REF(refs[j])),
+ xdg_app_ref_get_commit (XDG_APP_REF(refs[j])),
+ xdg_app_remote_ref_get_remote_name (refs[j]));
+ }
+ }
+
+ g_print ("\n**** Getting remote gedit master on %s\n", xdg_app_remote_get_name (remotes[i]));
+ error = NULL;
+ remote_ref = xdg_app_remote_fetch_ref_sync (remotes[i],
+ XDG_APP_REF_KIND_APP,
+ "org.gnome.gedit", NULL, "master",
+ NULL, &error);
+ if (remote_ref) {
+ GBytes *metadata;
+
+ g_print ("%d %s %s %s %s %s\n",
+ xdg_app_ref_get_kind (XDG_APP_REF(remote_ref)),
+ xdg_app_ref_get_name (XDG_APP_REF(remote_ref)),
+ xdg_app_ref_get_arch (XDG_APP_REF(remote_ref)),
+ xdg_app_ref_get_version (XDG_APP_REF(remote_ref)),
+ xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)),
+ xdg_app_remote_ref_get_remote_name (remote_ref));
+
+ metadata = xdg_app_remote_ref_fetch_metadata_sync (remote_ref, NULL, &error);
+ if (metadata) {
+ g_print ("metadata: %s\n", (char *)g_bytes_get_data (metadata, NULL));
+ } else {
+ g_print ("fetch error\n");
+ g_print ("error: %s\n", error->message);
+ g_clear_error (&error);
+ }
+ } else {
+ g_print ("error: %s\n", error->message);
+ g_clear_error (&error);
+ }
+ }
+ return 0;
+}
+
+/**
+ * gs_plugin_xdg_app_create_installed:
+ */
+static GsApp *
+gs_plugin_xdg_app_create_installed (XdgAppInstalledRef *app_ref)
+{
+ g_autoptr(GsApp) app = NULL;
+
+ g_return_val_if_fail (app_ref != NULL, NULL);
+
+ /* create new object */
+ app = gs_app_new (xdg_app_ref_get_name (XDG_APP_REF(app_ref)));
+ gs_app_set_management_plugin (app, "XgdApp");
+ gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+ gs_app_set_kind (app, GS_APP_KIND_NORMAL);
+ gs_app_set_id_kind (app, AS_ID_KIND_DESKTOP);
+ gs_app_set_version (app, xdg_app_ref_get_version (XDG_APP_REF(app_ref)));
+ gs_app_set_origin (app, xdg_app_installed_ref_get_origin (app_ref));
+
+ switch (xdg_app_ref_get_kind (XDG_APP_REF(app_ref))) {
+ case XDG_APP_REF_KIND_APP:
+ gs_app_set_metadata (app, "XgdApp::type", "app");
+ break;
+ case XDG_APP_REF_KIND_RUNTIME:
+ gs_app_set_metadata (app, "XgdApp::type", "runtime");
+ break;
+ default:
+ return NULL;
+ }
+
+ /* we need this for uninstalling */
+ gs_app_set_metadata (app, "XgdApp::arch", xdg_app_ref_get_arch (XDG_APP_REF(app_ref)));
+
+ // read AppData from here: xdg_app_installed_ref_get_deploy_dir (app_ref)
+ // xdg_app_ref_get_commit (XDG_APP_REF(app_ref)),
+ // xdg_app_installed_ref_get_current (app_ref));
+
+ //FIXME need to refine using AppData/AppStream
+ gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "GNOME Builder");
+ gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "GNOME BUILDER");
+ gs_app_set_pixbuf (app, gdk_pixbuf_new_from_file
("/usr/share/icons/hicolor/48x48/apps/gnome-boxes.png", NULL));
+
+ return g_object_ref (app);
+}
+
/**
* gs_plugin_add_installed:
*/
@@ -144,49 +317,42 @@ gs_plugin_add_installed (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- const gchar *args_apps[] = { "--user", "list-apps", NULL };
- const gchar *args_runt[] = { "--user", "list-runtimes", NULL };
+ XdgAppInstalledRef **apps;
+ XdgAppInstalledRef **runtimes;
guint i;
- g_auto(GStrv) results_apps = NULL;
- g_auto(GStrv) results_runt = NULL;
+ g_autoptr(XdgAppInstallation) installation = NULL;
/* get apps */
- results_apps = gs_plugin_xdg_app_exec (args_apps, error);
- if (results_apps == NULL)
+ installation = xdg_app_installation_new_user ();
+ apps = xdg_app_installation_list_installed_refs (installation,
+ XDG_APP_REF_KIND_APP,
+ cancellable, error);
+ if (apps == NULL)
return FALSE;
- for (i = 0; results_apps[i] != NULL; i++) {
+ for (i = 0; apps[i] != NULL; i++) {
g_autoptr(GsApp) app = NULL;
- app = gs_app_new (results_apps[i]);
- gs_app_set_management_plugin (app, "XgdApp");
- gs_app_set_metadata (app, "XgdApp::type", "app");
- gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "GNOME Builder");
- gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "GNOME BUILDER");
- gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
- gs_app_set_kind (app, GS_APP_KIND_NORMAL);
- gs_app_set_id_kind (app, AS_ID_KIND_DESKTOP);
- //FIXME need to refine using AppData
- gs_app_set_pixbuf (app, gdk_pixbuf_new_from_file
("/usr/share/icons/hicolor/48x48/apps/gnome-boxes.png", NULL));
+ app = gs_plugin_xdg_app_create_installed (apps[i]);
+ if (app == NULL)
+ continue;
gs_plugin_add_app (list, app);
}
/* get runtimes */
- results_runt = gs_plugin_xdg_app_exec (args_runt, error);
- if (results_runt == NULL)
+ runtimes = xdg_app_installation_list_installed_refs (installation,
+ XDG_APP_REF_KIND_RUNTIME,
+ cancellable, error);
+ if (runtimes == NULL)
return FALSE;
- for (i = 0; results_runt[i] != NULL; i++) {
+ for (i = 0; runtimes[i] != NULL; i++) {
g_autoptr(GsApp) app = NULL;
- app = gs_app_new (results_runt[i]);
- gs_app_set_management_plugin (app, "XgdApp");
- gs_app_set_metadata (app, "XgdApp::type", "runtime");
- gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "GNOME Platform");
- gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "GNOME PLATFORM");
- gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
- gs_app_set_kind (app, GS_APP_KIND_NORMAL);
- gs_app_set_id_kind (app, AS_ID_KIND_DESKTOP);
- //FIXME need to refine using AppData
- gs_app_set_pixbuf (app, gdk_pixbuf_new_from_file
("/usr/share/icons/hicolor/48x48/apps/gnome-boxes.png", NULL));
+ app = gs_plugin_xdg_app_create_installed (runtimes[i]);
+ if (app == NULL)
+ continue;
gs_plugin_add_app (list, app);
}
+
+lib_demo();
+
return TRUE;
}
@@ -199,28 +365,31 @@ gs_plugin_add_sources (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- const gchar *args[] = { "--user", "list-remotes", NULL };
+ XdgAppRemote **remotes;
guint i;
- g_auto(GStrv) results = NULL;
+ g_autoptr(XdgAppInstallation) installation = NULL;
- /* get remotes */
- results = gs_plugin_xdg_app_exec (args, error);
- if (results == NULL)
+ installation = xdg_app_installation_new_user ();
+ remotes = xdg_app_installation_list_remotes (installation,
+ cancellable,
+ error);
+ if (remotes == NULL)
return FALSE;
- for (i = 0; results[i] != NULL; i++) {
+ for (i = 0; remotes[i] != NULL; i++) {
g_autoptr(GsApp) app = NULL;
- app = gs_app_new (results[i]);
+ app = gs_app_new (xdg_app_remote_get_name (remotes[i]));
gs_app_set_management_plugin (app, "XgdApp");
gs_app_set_kind (app, GS_APP_KIND_SOURCE);
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
- //FIXME: need this from the keyfile / AppStream
gs_app_set_name (app,
GS_APP_QUALITY_LOWEST,
- results[i]);
- //FIXME: need this from the keyfile
+ xdg_app_remote_get_name (remotes[i]));
gs_app_set_summary (app,
GS_APP_QUALITY_LOWEST,
- results[i]);
+ xdg_app_remote_get_title (remotes[i]));
+ gs_app_set_url (app,
+ AS_URL_KIND_HOMEPAGE,
+ xdg_app_remote_get_url (remotes[i]));
gs_plugin_add_app (list, app);
}
return TRUE;
@@ -274,9 +443,6 @@ gs_plugin_refine_item (GsPlugin *plugin, GsApp *app, GError **error)
/* only process this app if was created by this plugin */
if (g_strcmp0 (gs_app_get_management_plugin (app), "XgdApp") != 0)
return TRUE;
-
- //FIXME need to set to remote somehow
- gs_app_add_source (app, "test-repo");
return TRUE;
}
@@ -310,14 +476,42 @@ gs_plugin_launch (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- const gchar *args[] = { "run", gs_app_get_id (app), NULL };
- g_auto(GStrv) results = NULL;
-
- /* run tool sync */
- results = gs_plugin_xdg_app_exec (args, error);
- if (results == NULL)
+ const gchar *version = NULL;
+ g_autoptr(XdgAppInstalledRef) xapp = NULL;
+ g_autoptr(XdgAppInstallation) installation = NULL;
+
+ installation = xdg_app_installation_new_user ();
+ version = gs_app_get_version (app);
+ if (version == NULL)
+ version = "master";
+ xapp = xdg_app_installation_get_installed_ref (installation,
+ XDG_APP_REF_KIND_APP,
+ gs_app_get_id (app),
+ NULL,
+ version,
+ cancellable,
+ error);
+ if (xapp == NULL)
return FALSE;
- return TRUE;
+ return xdg_app_installed_ref_launch (xapp, cancellable, error);
+}
+
+typedef struct {
+ GsApp *app;
+ GsPlugin *plugin;
+} GsPluginHelper;
+
+/**
+ * gs_plugin_xdg_app_progress_cb:
+ */
+static void
+gs_plugin_xdg_app_progress_cb (const gchar *status,
+ guint progress,
+ gboolean estimating,
+ gpointer user_data)
+{
+ GsPluginHelper *helper = (GsPluginHelper *) user_data;
+ gs_plugin_progress_update (helper->plugin, helper->app, progress);
}
/**
@@ -329,22 +523,26 @@ gs_plugin_app_remove (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- const gchar *args[] = { "--user", "uninstall-app", gs_app_get_id (app), NULL };
- g_auto(GStrv) results = NULL;
+ GsPluginHelper helper;
+ g_autoptr(XdgAppInstallation) installation = NULL;
/* only process this app if was created by this plugin */
if (g_strcmp0 (gs_app_get_management_plugin (app), "XgdApp") != 0)
return TRUE;
- /* this should be much less common */
- if (g_strcmp0 (gs_app_get_metadata_item (app, "XgdApp::type"), "runtime") == 0)
- args[1] = "uninstall-runtime";
-
- /* run tool sync */
- results = gs_plugin_xdg_app_exec (args, error);
- if (results == NULL)
- return FALSE;
- return TRUE;
+ /* use helper: FIXME: new()&ref? */
+ helper.app = app;
+ helper.plugin = plugin;
+
+ /* remove */
+ installation = xdg_app_installation_new_user ();
+ return xdg_app_installation_uninstall (installation,
+ XDG_APP_REF_KIND_APP,
+ gs_app_get_id (app),
+ gs_app_get_metadata_item (app, "XgdApp::arch"),
+ gs_app_get_version (app),
+ gs_plugin_xdg_app_progress_cb, &helper,
+ cancellable, error);
}
/**
@@ -356,22 +554,62 @@ gs_plugin_app_install (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- const gchar *args[] = { "--user", "install-app",
- gs_app_get_source_default (app),
- gs_app_get_id (app), NULL };
- g_auto(GStrv) results = NULL;
+ GsPluginHelper helper;
+ g_autoptr(XdgAppInstalledRef) xapp = NULL;
+ g_autoptr(XdgAppInstallation) installation = NULL;
/* only process this app if was created by this plugin */
if (g_strcmp0 (gs_app_get_management_plugin (app), "XgdApp") != 0)
return TRUE;
- /* this should be much less common */
- if (g_strcmp0 (gs_app_get_metadata_item (app, "XgdApp::type"), "runtime") == 0)
- args[1] = "install-runtime";
+ /* use helper: FIXME: new()&ref? */
+ helper.app = app;
+ helper.plugin = plugin;
+
+ /* install */
+ installation = xdg_app_installation_new_user ();
+ xapp = xdg_app_installation_install (installation,
+ gs_app_get_origin (app),
+ XDG_APP_REF_KIND_APP,
+ gs_app_get_id (app),
+ gs_app_get_metadata_item (app, "XgdApp::arch"),
+ gs_app_get_version (app),
+ gs_plugin_xdg_app_progress_cb, &helper,
+ cancellable, error);
+ return xapp != NULL;
+}
- /* run tool sync */
- results = gs_plugin_xdg_app_exec (args, error);
- if (results == NULL)
- return FALSE;
- return TRUE;
+/**
+ * gs_plugin_app_update:
+ *
+ * This is only called when updating device firmware live.
+ */
+gboolean
+gs_plugin_app_update (GsPlugin *plugin,
+ GsApp *app,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GsPluginHelper helper;
+ g_autoptr(XdgAppInstalledRef) xapp = NULL;
+ g_autoptr(XdgAppInstallation) installation = NULL;
+
+ /* only process this app if was created by this plugin */
+ if (g_strcmp0 (gs_app_get_management_plugin (app), "XgdApp") != 0)
+ return TRUE;
+
+ /* use helper: FIXME: new()&ref? */
+ helper.app = app;
+ helper.plugin = plugin;
+
+ /* install */
+ installation = xdg_app_installation_new_user ();
+ xapp = xdg_app_installation_update (installation,
+ XDG_APP_REF_KIND_APP,
+ gs_app_get_id (app),
+ gs_app_get_metadata_item (app, "XgdApp::arch"),
+ gs_app_get_version (app),
+ gs_plugin_xdg_app_progress_cb, &helper,
+ cancellable, error);
+ return xapp != NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]