[gnome-software/1422-gnome-software-does-not-realize-it-has-uninstalled-software-allows-it-to-be-uninstalled-again] gs-plugin-loader: Introduce gs_plugin_action_finished() GsPlugin function



commit 3a2860a4612ee86f992e4073b72a8b3ea5259e95
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 14 17:27:56 2021 +0200

    gs-plugin-loader: Introduce gs_plugin_action_finished() GsPlugin function
    
    Plugins can define it, to be notified when a plugin action is finished
    by all plugins.

 lib/gs-plugin-loader.c | 12 ++++++++++++
 lib/gs-plugin-vfuncs.h | 14 ++++++++++++++
 2 files changed, 26 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 4d5240c32..a16ac03c4 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -183,6 +183,8 @@ typedef gboolean     (*GsPluginGetLangPacksFunc)    (GsPlugin       *plugin,
                                                         const gchar    *locale,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+typedef void            (*GsPluginActionFinishedFunc)  (GsPlugin       *plugin,
+                                                        GsPluginAction  action);
 
 
 /* async helper */
@@ -1230,6 +1232,16 @@ gs_plugin_loader_run_results (GsPluginLoaderHelper *helper,
                        return FALSE;
        }
 
+       /* Notify plugins about the action being finished */
+       for (guint i = 0; i < plugin_loader->plugins->len; i++) {
+               GsPlugin *plugin = g_ptr_array_index (plugin_loader->plugins, i);
+               gpointer func = gs_plugin_get_symbol (plugin, "gs_plugin_action_finished");
+               if (func != NULL) {
+                       GsPluginActionFinishedFunc action_finished_func = func;
+                       action_finished_func (plugin, action);
+               }
+       }
+
 #ifdef HAVE_SYSPROF
        if (plugin_loader->sysprof_writer != NULL) {
                g_autofree gchar *sysprof_name = NULL;
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 23b7829db..14f19d669 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -933,4 +933,18 @@ gboolean    gs_plugin_disable_repo                 (GsPlugin       *plugin,
                                                         GsApp          *repo,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+
+/**
+ * gs_plugin_action_finished:
+ * @plugin: a #GsPlugin
+ * @action: a #GsPluginAction
+ *
+ * This is a notification function, calls after the @action is finished,
+ * which means every plugin had been called with this @action.
+ *
+ * Since: 41.1
+ **/
+void            gs_plugin_action_finished              (GsPlugin       *plugin,
+                                                        GsPluginAction  action);
+
 G_END_DECLS


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