[gnome-software: 26/29] gs-plugin: Drop gs_plugin_setup() and GS_PLUGIN_ACTION_SETUP




commit 530d8ec4fb80dc353f9e26acadde0ec395350777
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Oct 15 13:42:38 2021 +0100

    gs-plugin: Drop gs_plugin_setup() and GS_PLUGIN_ACTION_SETUP
    
    All the plugins now use `setup_async` and `setup_finish` vfuncs instead.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-plugin-loader.c | 28 +++-------------------------
 lib/gs-plugin-types.h  |  2 --
 lib/gs-plugin-vfuncs.h | 23 +----------------------
 lib/gs-plugin.c        |  6 ------
 4 files changed, 4 insertions(+), 55 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 4d31eb289..ef8ccac82 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -514,8 +514,7 @@ gs_plugin_error_handle_failure (GsPluginLoaderHelper *helper,
        }
 
        /* fatal error */
-       if (gs_plugin_job_get_action (helper->plugin_job) == GS_PLUGIN_ACTION_SETUP ||
-           gs_plugin_loader_is_error_fatal (error_local_copy) ||
+       if (gs_plugin_loader_is_error_fatal (error_local_copy) ||
            g_getenv ("GS_SELF_TEST_PLUGIN_ERROR_FAIL_HARD") != NULL) {
                if (error != NULL)
                        *error = g_steal_pointer (&error_local_copy);
@@ -623,12 +622,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
        if (gs_plugin_job_get_interactive (helper->plugin_job))
                gs_plugin_interactive_inc (plugin);
        switch (action) {
-       case GS_PLUGIN_ACTION_SETUP:
-               {
-                       GsPluginSetupFunc plugin_func = func;
-                       ret = plugin_func (plugin, cancellable, &error_local);
-               }
-               break;
        case GS_PLUGIN_ACTION_REFINE:
                if (g_strcmp0 (helper->function_name, "gs_plugin_refine_wildcard") == 0) {
                        GsPluginRefineWildcardFunc plugin_func = func;
@@ -839,21 +832,7 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
 
        /* check the plugin didn't take too long */
        if (g_timer_elapsed (timer, NULL) > 1.0f) {
-               GLogLevelFlags log_level;
-
-               switch (action) {
-               case GS_PLUGIN_ACTION_SETUP:
-                       if (g_getenv ("GS_SELF_TEST_PLUGIN_ERROR_FAIL_HARD") == NULL)
-                               log_level = G_LOG_LEVEL_WARNING;
-                       else
-                               log_level = G_LOG_LEVEL_DEBUG;
-                       break;
-               default:
-                       log_level = G_LOG_LEVEL_DEBUG;
-                       break;
-               }
-
-               g_log_structured_standard (G_LOG_DOMAIN, log_level,
+               g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
                                           __FILE__, G_STRINGIFY (__LINE__),
                                           G_STRFUNC,
                                           "plugin %s took %.1f seconds to do %s",
@@ -2355,7 +2334,7 @@ gs_plugin_loader_software_app_created_cb (GObject *source_object,
        app = gs_plugin_loader_app_create_finish (plugin_loader, result, NULL);
 
        /* add app */
-       gs_plugin_event_set_action (event, GS_PLUGIN_ACTION_SETUP);
+       gs_plugin_event_set_action (event, GS_PLUGIN_ACTION_UNKNOWN);
        if (app != NULL)
                gs_plugin_event_set_app (event, app);
 
@@ -3525,7 +3504,6 @@ gs_plugin_loader_process_thread_cb (GTask *task,
        case GS_PLUGIN_ACTION_REFRESH:
        case GS_PLUGIN_ACTION_REMOVE:
        case GS_PLUGIN_ACTION_SEARCH:
-       case GS_PLUGIN_ACTION_SETUP:
        case GS_PLUGIN_ACTION_UPDATE:
        case GS_PLUGIN_ACTION_INSTALL_REPO:
        case GS_PLUGIN_ACTION_REMOVE_REPO:
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index db6c5b8e0..415409ce0 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -189,7 +189,6 @@ typedef enum {
 /**
  * GsPluginAction:
  * @GS_PLUGIN_ACTION_UNKNOWN:                  Action is unknown
- * @GS_PLUGIN_ACTION_SETUP:                    Plugin setup (internal)
  * @GS_PLUGIN_ACTION_INSTALL:                  Install an application
  * @GS_PLUGIN_ACTION_REMOVE:                   Remove an application
  * @GS_PLUGIN_ACTION_UPDATE:                   Update an application
@@ -229,7 +228,6 @@ typedef enum {
  **/
 typedef enum {
        GS_PLUGIN_ACTION_UNKNOWN,
-       GS_PLUGIN_ACTION_SETUP,
        GS_PLUGIN_ACTION_INSTALL,
        GS_PLUGIN_ACTION_REMOVE,
        GS_PLUGIN_ACTION_UPDATE,
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index f4073312c..65764578c 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -39,7 +39,7 @@ G_BEGIN_DECLS
  * init function.
  *
  * NOTE: Do not do any failable actions in the plugin class’ init function; use
- * gs_plugin_setup() instead.
+ * #GsPluginClass.setup_async instead.
  *
  * Since: 42
  */
@@ -146,27 +146,6 @@ gboolean    gs_plugin_add_alternates               (GsPlugin       *plugin,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
 
-/**
- * gs_plugin_setup:
- * @plugin: a #GsPlugin
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Called when the plugin should set up the initial state, and with the write
- * lock held.
- *
- * All functions can block, but should sent progress notifications, e.g. using
- * gs_app_set_progress() if they will take more than tens of milliseconds
- * to complete.
- *
- * This function will also not be called if the plugin is disabled.
- *
- * Returns: %TRUE for success
- **/
-gboolean        gs_plugin_setup                        (GsPlugin       *plugin,
-                                                        GCancellable   *cancellable,
-                                                        GError         **error);
-
 /**
  * gs_plugin_add_installed:
  * @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 990aa0044..352094d64 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1719,8 +1719,6 @@ gs_plugin_action_to_function_name (GsPluginAction action)
                return "gs_plugin_add_category_apps";
        if (action == GS_PLUGIN_ACTION_GET_CATEGORIES)
                return "gs_plugin_add_categories";
-       if (action == GS_PLUGIN_ACTION_SETUP)
-               return "gs_plugin_setup";
        if (action == GS_PLUGIN_ACTION_GET_ALTERNATES)
                return "gs_plugin_add_alternates";
        if (action == GS_PLUGIN_ACTION_GET_LANGPACKS)
@@ -1749,8 +1747,6 @@ gs_plugin_action_to_string (GsPluginAction action)
 {
        if (action == GS_PLUGIN_ACTION_UNKNOWN)
                return "unknown";
-       if (action == GS_PLUGIN_ACTION_SETUP)
-               return "setup";
        if (action == GS_PLUGIN_ACTION_INSTALL)
                return "install";
        if (action == GS_PLUGIN_ACTION_DOWNLOAD)
@@ -1835,8 +1831,6 @@ gs_plugin_action_to_string (GsPluginAction action)
 GsPluginAction
 gs_plugin_action_from_string (const gchar *action)
 {
-       if (g_strcmp0 (action, "setup") == 0)
-               return GS_PLUGIN_ACTION_SETUP;
        if (g_strcmp0 (action, "install") == 0)
                return GS_PLUGIN_ACTION_INSTALL;
        if (g_strcmp0 (action, "download") == 0)


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