[gnome-software] Add support for pending updates



commit 0b52d572ab5b6b42ddf3ab5666db78e7b4b9f2b4
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 21 16:39:17 2016 +0100

    Add support for pending updates
    
    A pending update is one we're aware of, but that isn't yet downloaded.
    Pending updates may be requested if we are not downloading updates in the
    refresh vfunc, for instance where the 'download-updates' GSetting is FALSE.

 src/gs-plugin-loader.c |   51 ++++++++++++++++++++++++++++++++++++-----------
 src/gs-plugin-vfuncs.h |   21 +++++++++++++++++++
 2 files changed, 60 insertions(+), 12 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 41d835c..ffd991c 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -1238,25 +1238,52 @@ gs_plugin_loader_get_updates_thread_cb (GTask *task,
                                        gpointer task_data,
                                        GCancellable *cancellable)
 {
-       const gchar *method_name = "gs_plugin_add_updates";
        GsPluginLoaderAsyncState *state = (GsPluginLoaderAsyncState *) task_data;
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (object);
+       GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
        GError *error = NULL;
        gboolean ret;
 
        /* do things that would block */
-       if ((state->flags & GS_PLUGIN_REFINE_FLAGS_USE_HISTORY) > 0)
-               method_name = "gs_plugin_add_updates_historical";
+       if ((state->flags & GS_PLUGIN_REFINE_FLAGS_USE_HISTORY) > 0) {
+               state->list = gs_plugin_loader_run_results (plugin_loader,
+                                                           state->action,
+                                                           "gs_plugin_add_updates_historical",
+                                                           state->flags,
+                                                           cancellable,
+                                                           &error);
+               if (error != NULL) {
+                       g_task_return_error (task, error);
+                       return;
+               }
+       } else {
+               /* get downloaded updates */
+               state->list = gs_plugin_loader_run_results (plugin_loader,
+                                                           state->action,
+                                                           "gs_plugin_add_updates",
+                                                           state->flags,
+                                                           cancellable,
+                                                           &error);
+               if (error != NULL) {
+                       g_task_return_error (task, error);
+                       return;
+               }
 
-       state->list = gs_plugin_loader_run_results (plugin_loader,
-                                                   state->action,
-                                                   method_name,
-                                                   state->flags,
-                                                   cancellable,
-                                                   &error);
-       if (error != NULL) {
-               g_task_return_error (task, error);
-               return;
+               /* get not-yet-downloaded updates */
+               if (!g_settings_get_boolean (priv->settings, "download-updates")) {
+                       g_autoptr(GsAppList) list = NULL;
+                       list = gs_plugin_loader_run_results (plugin_loader,
+                                                            state->action,
+                                                            "gs_plugin_add_updates_pending",
+                                                            state->flags,
+                                                            cancellable,
+                                                            &error);
+                       if (error != NULL) {
+                               g_task_return_error (task, error);
+                               return;
+                       }
+                       gs_app_list_add_list (state->list, list);
+               }
        }
 
        /* add OS Update item if required */
diff --git a/src/gs-plugin-vfuncs.h b/src/gs-plugin-vfuncs.h
index b75496c..713d351 100644
--- a/src/gs-plugin-vfuncs.h
+++ b/src/gs-plugin-vfuncs.h
@@ -207,6 +207,27 @@ gboolean    gs_plugin_add_updates                  (GsPlugin       *plugin,
                                                         GError         **error);
 
 /**
+ * gs_plugin_add_updates_pending:
+ * @plugin: a #GsPlugin
+ * @list: a #GsAppList
+ * @cancellable: a #GCancellable, or %NULL
+ * @error: a #GError, or %NULL
+ *
+ * Get the list of not-yet-downloaded updates, with the write lock held.
+ *
+ * NOTE: Actually downloading the updates is normally done in
+ * gs_plugin_refresh() when called with %GS_PLUGIN_REFRESH_FLAGS_PAYLOAD.
+ *
+ * Plugins are expected to add new apps using gs_app_list_add().
+ *
+ * Returns: %TRUE for success or if not relevant
+ **/
+gboolean        gs_plugin_add_updates_pending          (GsPlugin       *plugin,
+                                                        GsAppList      *list,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
+
+/**
  * gs_plugin_add_distro_upgrades:
  * @plugin: a #GsPlugin
  * @list: a #GsAppList


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