[gnome-software/1486-gs-repos-dialog-call-refresh-on-repository-setup-change] gs-application: Introduce gs_application_refresh()



commit ca49eb3974e220ff17262c6189e3cdf0a92746fe
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 5 19:45:10 2021 +0200

    gs-application: Introduce gs_application_refresh()
    
    It can be used to call a non-interactive refresh call for the plugins.

 src/gs-application.c | 28 ++++++++++++++++++++++++++++
 src/gs-application.h |  3 ++-
 2 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 90487df62..df982df19 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -1371,3 +1371,31 @@ gs_application_emit_install_resources_done (GsApplication *application,
 {
        g_signal_emit (application, signals[INSTALL_RESOURCES_DONE], 0, ident, op_error, NULL);
 }
+
+static void
+gs_application_refresh_cb (GsPluginLoader *plugin_loader,
+                          GAsyncResult *result,
+                          GsApplication *self)
+{
+       gboolean success;
+       g_autoptr(GError) error = NULL;
+
+       success = gs_plugin_loader_job_action_finish (plugin_loader, result, &error);
+       if (!success &&
+           !g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               g_warning ("failed to refresh: %s", error->message);
+}
+
+void
+gs_application_refresh (GsApplication *self)
+{
+       g_autoptr(GsPluginJob) plugin_job = NULL;
+       plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFRESH,
+                                        "interactive", FALSE,
+                                        "age", (guint64) 1,
+                                        NULL);
+       gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
+                                           self->cancellable,
+                                           (GAsyncReadyCallback) gs_application_refresh_cb,
+                                           self);
+}
diff --git a/src/gs-application.h b/src/gs-application.h
index 40bad4d4c..92978e1f5 100644
--- a/src/gs-application.h
+++ b/src/gs-application.h
@@ -23,4 +23,5 @@ gboolean       gs_application_has_active_window       (GsApplication *application);
 void            gs_application_emit_install_resources_done
                                                        (GsApplication *application,
                                                         const gchar *ident,
-                                                        const GError *op_error);
\ No newline at end of file
+                                                        const GError *op_error);
+void            gs_application_refresh                 (GsApplication *self);


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