[gnome-software] Use a GsApp when downloading CSS resources



commit 593e89b78229418aaf61c25f6c04ccc2cda8661c
Author: Richard Hughes <richard hughsie com>
Date:   Mon May 22 10:43:18 2017 +0100

    Use a GsApp when downloading CSS resources
    
    We need to report progress back to the UI somehow, and this is how the other
    plugins already do it.

 lib/gs-plugin.c                           |   11 +++++------
 lib/gs-plugin.h                           |    1 +
 lib/gs-self-test.c                        |    1 +
 plugins/core/gs-plugin-rewrite-resource.c |    2 ++
 4 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 4a0b479..f21faa5 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1333,6 +1333,7 @@ gs_plugin_download_file (GsPlugin *plugin,
 
 static gchar *
 gs_plugin_download_rewrite_resource_uri (GsPlugin *plugin,
+                                        GsApp *app,
                                         const gchar *uri,
                                         GCancellable *cancellable,
                                         GError **error)
@@ -1366,12 +1367,8 @@ gs_plugin_download_rewrite_resource_uri (GsPlugin *plugin,
                return g_steal_pointer (&cachefn);
 
        /* download */
-       if (!gs_plugin_download_file (plugin,
-                                     NULL, /* GsApp */
-                                     uri,
-                                     cachefn,
-                                     cancellable,
-                                     error)) {
+       if (!gs_plugin_download_file (plugin, app, uri, cachefn,
+                                     cancellable, error)) {
                return NULL;
        }
        return g_steal_pointer (&cachefn);
@@ -1392,6 +1389,7 @@ gs_plugin_download_rewrite_resource_uri (GsPlugin *plugin,
  **/
 gchar *
 gs_plugin_download_rewrite_resource (GsPlugin *plugin,
+                                    GsApp *app,
                                     const gchar *resource,
                                     GCancellable *cancellable,
                                     GError **error)
@@ -1433,6 +1431,7 @@ gs_plugin_download_rewrite_resource (GsPlugin *plugin,
 
                        /* download them to per-user cache */
                        cachefn = gs_plugin_download_rewrite_resource_uri (plugin,
+                                                                          app,
                                                                           uri,
                                                                           cancellable,
                                                                           error);
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index 67b86f2..fe10aa1 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -106,6 +106,7 @@ gboolean     gs_plugin_download_file                (GsPlugin       *plugin,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
 gchar          *gs_plugin_download_rewrite_resource    (GsPlugin       *plugin,
+                                                        GsApp          *app,
                                                         const gchar    *resource,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
diff --git a/lib/gs-self-test.c b/lib/gs-self-test.c
index 434ec6f..c6a5f57 100644
--- a/lib/gs-self-test.c
+++ b/lib/gs-self-test.c
@@ -158,6 +158,7 @@ gs_plugin_download_rewrite_func (void)
        plugin = gs_plugin_new ();
        gs_plugin_set_name (plugin, "self-test");
        css = gs_plugin_download_rewrite_resource (plugin,
+                                                  NULL, /* app */
                                                   resource,
                                                   NULL,
                                                   &error);
diff --git a/plugins/core/gs-plugin-rewrite-resource.c b/plugins/core/gs-plugin-rewrite-resource.c
index 32b9065..95959bd 100644
--- a/plugins/core/gs-plugin-rewrite-resource.c
+++ b/plugins/core/gs-plugin-rewrite-resource.c
@@ -48,7 +48,9 @@ gs_plugin_refine_app (GsPlugin *plugin,
                const gchar *css = gs_app_get_metadata_item (app, keys[i]);
                if (css != NULL) {
                        g_autofree gchar *css_new = NULL;
+                       g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
                        css_new = gs_plugin_download_rewrite_resource (plugin,
+                                                                      app,
                                                                       css,
                                                                       cancellable,
                                                                       error);


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