[gnome-software] flatpak: Add support for pending updates
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] flatpak: Add support for pending updates
- Date: Fri, 21 Oct 2016 15:44:00 +0000 (UTC)
commit 28680a520ebd418aeaaddb8745e802aa088db169
Author: Richard Hughes <richard hughsie com>
Date: Fri Oct 21 16:41:35 2016 +0100
flatpak: Add support for pending updates
src/plugins/gs-flatpak.c | 52 ++++++++++++++++++++++++++++++++
src/plugins/gs-flatpak.h | 4 ++
src/plugins/gs-plugin-flatpak-system.c | 10 ++++++
src/plugins/gs-plugin-flatpak-user.c | 10 ++++++
4 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 40f8d0c..ff35c22 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -958,6 +958,58 @@ gs_flatpak_add_updates (GsFlatpak *self, GsAppList *list,
return TRUE;
}
+gboolean
+gs_flatpak_add_updates_pending (GsFlatpak *self, GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ guint i;
+ g_autoptr(GPtrArray) xrefs = NULL;
+
+ /* get all the updatable apps and runtimes (no network I/O) */
+ xrefs = flatpak_installation_list_installed_refs_for_update (self->installation,
+ cancellable,
+ error);
+ if (xrefs == NULL) {
+ gs_plugin_flatpak_error_convert (error);
+ return FALSE;
+ }
+ for (i = 0; i < xrefs->len; i++) {
+ FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
+ guint64 download_size = 0;
+ g_autoptr(GsApp) app = NULL;
+ g_autoptr(GError) error_local = NULL;
+
+ /* we have an update to show */
+ g_debug ("%s has update", flatpak_ref_get_name (FLATPAK_REF (xref)));
+ app = gs_flatpak_create_installed (self, xref, &error_local);
+ if (app == NULL) {
+ g_warning ("failed to add flatpak: %s", error_local->message);
+ continue;
+ }
+ gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
+
+ /* get the current download size */
+ if (!flatpak_installation_fetch_remote_size_sync (self->installation,
+ gs_app_get_origin (app),
+ FLATPAK_REF (xref),
+ &download_size,
+ NULL,
+ cancellable,
+ &error_local)) {
+ g_warning ("failed to get download size: %s",
+ error_local->message);
+ gs_app_set_size_download (app, GS_APP_SIZE_UNKNOWABLE);
+ } else {
+ gs_app_set_size_download (app, download_size);
+ }
+
+ gs_app_list_add (list, app);
+ }
+
+ return TRUE;
+}
+
static void
gs_flatpak_progress_cb (const gchar *status,
guint progress,
diff --git a/src/plugins/gs-flatpak.h b/src/plugins/gs-flatpak.h
index d7c4865..90f36a5 100644
--- a/src/plugins/gs-flatpak.h
+++ b/src/plugins/gs-flatpak.h
@@ -59,6 +59,10 @@ gboolean gs_flatpak_add_updates (GsFlatpak *self,
GsAppList *list,
GCancellable *cancellable,
GError **error);
+gboolean gs_flatpak_add_updates_pending (GsFlatpak *self,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error);
gboolean gs_flatpak_refresh (GsFlatpak *self,
guint cache_age,
GsPluginRefreshFlags flags,
diff --git a/src/plugins/gs-plugin-flatpak-system.c b/src/plugins/gs-plugin-flatpak-system.c
index 240abeb..f2c8d5a 100644
--- a/src/plugins/gs-plugin-flatpak-system.c
+++ b/src/plugins/gs-plugin-flatpak-system.c
@@ -111,6 +111,16 @@ gs_plugin_add_updates (GsPlugin *plugin,
}
gboolean
+gs_plugin_add_updates_pending (GsPlugin *plugin,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GsPluginData *priv = gs_plugin_get_data (plugin);
+ return gs_flatpak_add_updates_pending (priv->flatpak, list, cancellable, error);
+}
+
+gboolean
gs_plugin_refresh (GsPlugin *plugin,
guint cache_age,
GsPluginRefreshFlags flags,
diff --git a/src/plugins/gs-plugin-flatpak-user.c b/src/plugins/gs-plugin-flatpak-user.c
index 9c3ff48..902f34f 100644
--- a/src/plugins/gs-plugin-flatpak-user.c
+++ b/src/plugins/gs-plugin-flatpak-user.c
@@ -111,6 +111,16 @@ gs_plugin_add_updates (GsPlugin *plugin,
}
gboolean
+gs_plugin_add_updates_pending (GsPlugin *plugin,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GsPluginData *priv = gs_plugin_get_data (plugin);
+ return gs_flatpak_add_updates_pending (priv->flatpak, list, cancellable, error);
+}
+
+gboolean
gs_plugin_refresh (GsPlugin *plugin,
guint cache_age,
GsPluginRefreshFlags flags,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]