[gnome-software: 4/29] gs-plugin: Add a setup vfunc




commit 45432368bf7d5a453aa109ece191ebf6d8b4f82f
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Nov 25 16:37:48 2021 +0000

    gs-plugin: Add a setup vfunc
    
    This will allow plugins to be set up asynchronously.
    
    The previous `gs_plugin_setup()` function was synchronous and blocking,
    which didn’t allow the plugins to be set up in parallel.
    
    No plugins currently implement this vfunc, but the plugins which
    currently implement `gs_plugin_setup()` will be ported to it in the
    following commits.
    
    `GsPluginLoader` has not yet been ported to use this vfunc instead of
    `gs_plugin_setup()`; that will happen in a following commit. The
    intermediate state of the source tree before then may be non-functional.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-plugin.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index 0903a735f..48e7c12ff 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -28,6 +28,14 @@ G_DECLARE_DERIVABLE_TYPE (GsPlugin, gs_plugin, GS, PLUGIN, GObject)
 
 /**
  * GsPluginClass:
+ * @setup_async: (nullable): Setup method for the plugin. This is called after
+ *   the #GsPlugin object is constructed, before it’s used for anything. It
+ *   should do any long-running setup operations which the plugin needs, such as
+ *   file or network access. It may be %NULL if the plugin doesn’t need to be
+ *   explicitly shut down. It is not called if the plugin is disabled during
+ *   construction.
+ * @setup_finish: (nullable): Finish method for @setup_async. Must be
+ *   implemented if @setup_async is implemented.
  * @shutdown_async: (nullable): Shutdown method for the plugin. This is called
  *   by the #GsPluginLoader when the process is terminating or the
  *   #GsPluginLoader is being destroyed. It should be used to cancel or stop any
@@ -65,6 +73,14 @@ struct _GsPluginClass
                                                         const gchar    *details,
                                                         const gchar    *accept_label);
 
+       void                    (*setup_async)          (GsPlugin               *plugin,
+                                                        GCancellable           *cancellable,
+                                                        GAsyncReadyCallback     callback,
+                                                        gpointer                user_data);
+       gboolean                (*setup_finish)         (GsPlugin               *plugin,
+                                                        GAsyncResult           *result,
+                                                        GError                 **error);
+
        void                    (*shutdown_async)       (GsPlugin               *plugin,
                                                         GCancellable           *cancellable,
                                                         GAsyncReadyCallback     callback,


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