[gnome-software: 13/18] gs-plugin-loader: Move ODRS refresh functionality into the plugin loader




commit 4396283cfd5e06738aac8a3907d21f91469ff32d
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed May 19 12:11:05 2021 +0100

    gs-plugin-loader: Move ODRS refresh functionality into the plugin loader
    
    See the previous commit.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-plugin-loader.c        | 15 +++++++++++++++
 plugins/odrs/gs-plugin-odrs.c | 12 ------------
 2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 6a35a96a0..bf2b579ae 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1129,6 +1129,21 @@ gs_plugin_loader_run_results (GsPluginLoaderHelper *helper,
                gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
        }
 
+       if (action == GS_PLUGIN_ACTION_REFRESH &&
+           plugin_loader->odrs_provider != NULL) {
+               /* FIXME: Using plugin_loader->plugins->pdata[0] is a hack; the
+                * GsOdrsProvider needs access to a GsPlugin to access global
+                * state for gs_plugin_download_file(), but it doesn’t really
+                * matter which plugin it’s accessed through. In lieu of
+                * refactoring gs_plugin_download_file(), use the first plugin
+                * in the list for now. */
+               if (!gs_odrs_provider_refresh (plugin_loader->odrs_provider,
+                                              plugin_loader->plugins->pdata[0],
+                                              gs_plugin_job_get_age (helper->plugin_job),
+                                              cancellable, error))
+                       return FALSE;
+       }
+
 #ifdef HAVE_SYSPROF
        if (plugin_loader->sysprof_writer != NULL) {
                g_autofree gchar *sysprof_name = NULL;
diff --git a/plugins/odrs/gs-plugin-odrs.c b/plugins/odrs/gs-plugin-odrs.c
index af733100e..4df620ad3 100644
--- a/plugins/odrs/gs-plugin-odrs.c
+++ b/plugins/odrs/gs-plugin-odrs.c
@@ -90,18 +90,6 @@ gs_plugin_initialize (GsPlugin *plugin)
        gs_plugin_set_enabled (plugin, review_server && *review_server);
 }
 
-gboolean
-gs_plugin_refresh (GsPlugin *plugin,
-                  guint cache_age,
-                  GCancellable *cancellable,
-                  GError **error)
-{
-       GsPluginData *priv = gs_plugin_get_data (plugin);
-
-       return gs_odrs_provider_refresh (priv->provider, plugin, cache_age,
-                                        cancellable, error);
-}
-
 void
 gs_plugin_destroy (GsPlugin *plugin)
 {


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