[gnome-software: 23/38] gs-plugin-types: Drop GS_PLUGIN_ACTION_REFRESH




commit 40b21f8af7660c63eae509ace28323a2a0570a7e
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Jan 31 18:42:30 2022 +0000

    gs-plugin-types: Drop GS_PLUGIN_ACTION_REFRESH
    
    It’s no longer used.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-plugin-loader.c | 149 -------------------------------------------------
 lib/gs-plugin-types.h  |   2 -
 lib/gs-plugin-vfuncs.h |  22 --------
 lib/gs-plugin.c        |   6 --
 4 files changed, 179 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 0fe038dc8..c5727359c 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -711,14 +711,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
                                           cancellable, &error_local);
                }
                break;
-       case GS_PLUGIN_ACTION_REFRESH:
-               {
-                       GsPluginRefreshFunc plugin_func = func;
-                       ret = plugin_func (plugin,
-                                          gs_plugin_job_get_age (helper->plugin_job),
-                                          cancellable, &error_local);
-               }
-               break;
        case GS_PLUGIN_ACTION_FILE_TO_APP:
                {
                        GsPluginFileToAppFunc plugin_func = func;
@@ -870,39 +862,12 @@ gs_plugin_loader_job_sorted_truncation (GsPluginLoaderHelper *helper)
        gs_app_list_truncate (list, max_results);
 }
 
-typedef struct {
-       GsPluginLoader *plugin_loader;  /* (not nullable) (unowned) */
-       GsApp *app;  /* (not nullable) (unowned) */
-} RefreshProgressData;
-
-static void
-refresh_progress_cb (gsize    bytes_downloaded,
-                     gsize    total_download_size,
-                     gpointer user_data)
-{
-       RefreshProgressData *data = user_data;
-       guint percentage;
-
-       if (total_download_size > 0)
-               percentage = (guint) ((100 * bytes_downloaded) / total_download_size);
-       else
-               percentage = 0;
-
-       g_debug ("%s progress: %u%%", gs_app_get_id (data->app), percentage);
-       gs_app_set_progress (data->app, percentage);
-
-       gs_plugin_loader_status_changed_cb (NULL, data->app,
-                                           GS_PLUGIN_STATUS_DOWNLOADING,
-                                           data->plugin_loader);
-}
-
 static gboolean
 gs_plugin_loader_run_results (GsPluginLoaderHelper *helper,
                              GCancellable *cancellable,
                              GError **error)
 {
        GsPluginLoader *plugin_loader = helper->plugin_loader;
-       GsPluginAction action = gs_plugin_job_get_action (helper->plugin_job);
 #ifdef HAVE_SYSPROF
        gint64 begin_time_nsec G_GNUC_UNUSED = SYSPROF_CAPTURE_CURRENT_TIME;
 #endif
@@ -910,62 +875,6 @@ gs_plugin_loader_run_results (GsPluginLoaderHelper *helper,
        /* Refining is done separately as it’s a special action */
        g_assert (!GS_IS_PLUGIN_JOB_REFINE (helper->plugin_job));
 
-       /* Download updated external appstream before anything else */
-#ifdef ENABLE_EXTERNAL_APPSTREAM
-       if (action == GS_PLUGIN_ACTION_REFRESH) {
-               g_autoptr(GsApp) app_dl = NULL;
-               RefreshProgressData progress_data;
-               g_autoptr(GAsyncResult) external_appstream_result = NULL;
-               g_autoptr(GError) local_error = NULL;
-
-               app_dl = gs_app_new ("external-appstream");
-               gs_app_set_summary_missing (app_dl,
-                                           /* TRANSLATORS: status text when downloading */
-                                           _("Downloading extra metadata files…"));
-
-               progress_data.plugin_loader = plugin_loader;
-               progress_data.app = app_dl;
-
-               gs_external_appstream_refresh_async (gs_plugin_job_get_age (helper->plugin_job),
-                                                    refresh_progress_cb,
-                                                    &progress_data,
-                                                    cancellable,
-                                                    async_result_cb,
-                                                    &external_appstream_result);
-
-               /* FIXME: Make this sync until the enclosing function is
-                * refactored to be async. */
-               while (external_appstream_result == NULL)
-                       g_main_context_iteration (g_main_context_get_thread_default (), TRUE);
-
-               if (!gs_external_appstream_refresh_finish (external_appstream_result, &local_error)) {
-                       /* Don’t fail updates if the external AppStream server is unavailable */
-                       if (g_error_matches (local_error, GS_EXTERNAL_APPSTREAM_ERROR,
-                                            GS_EXTERNAL_APPSTREAM_ERROR_DOWNLOADING) ||
-                           g_error_matches (local_error, GS_EXTERNAL_APPSTREAM_ERROR,
-                                            GS_EXTERNAL_APPSTREAM_ERROR_NO_NETWORK)) {
-                               g_autoptr(GsPluginEvent) event = NULL;
-
-                               event = gs_plugin_event_new ("error", local_error,
-                                                            "action", GS_PLUGIN_ACTION_DOWNLOAD,
-                                                            NULL);
-
-                               if (gs_plugin_job_get_interactive (helper->plugin_job))
-                                       gs_plugin_event_add_flag (event, GS_PLUGIN_EVENT_FLAG_INTERACTIVE);
-                               else
-                                       gs_plugin_event_add_flag (event, GS_PLUGIN_EVENT_FLAG_WARNING);
-                               gs_plugin_loader_add_event (plugin_loader, event);
-
-                               return TRUE;
-                       }
-
-                       g_propagate_error (error, g_steal_pointer (&local_error));
-
-                       return FALSE;
-               }
-       }
-#endif
-
        /* run each plugin */
        for (guint i = 0; i < plugin_loader->plugins->len; i++) {
                GsPlugin *plugin = g_ptr_array_index (plugin_loader->plugins, i);
@@ -981,63 +890,6 @@ gs_plugin_loader_run_results (GsPluginLoaderHelper *helper,
                gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
        }
 
-       if (action == GS_PLUGIN_ACTION_REFRESH &&
-           plugin_loader->odrs_provider != NULL) {
-               g_autoptr(GsApp) app_dl = NULL;
-               RefreshProgressData progress_data;
-               g_autoptr(GAsyncResult) odrs_result = NULL;
-               g_autoptr(GError) local_error = NULL;
-
-               app_dl = gs_app_new ("odrs");
-               gs_app_set_summary_missing (app_dl,
-                                           /* TRANSLATORS: status text when downloading */
-                                           _("Downloading application ratings…"));
-
-               progress_data.plugin_loader = plugin_loader;
-               progress_data.app = app_dl;
-
-               gs_odrs_provider_refresh_ratings_async (plugin_loader->odrs_provider,
-                                                       gs_plugin_job_get_age (helper->plugin_job),
-                                                       refresh_progress_cb,
-                                                       &progress_data,
-                                                       cancellable,
-                                                       async_result_cb,
-                                                       &odrs_result);
-
-               /* FIXME: Make this sync until the enclosing function is
-                * refactored to be async. */
-               while (odrs_result == NULL)
-                       g_main_context_iteration (g_main_context_get_thread_default (), TRUE);
-
-               if (!gs_odrs_provider_refresh_ratings_finish (plugin_loader->odrs_provider,
-                                                             odrs_result,
-                                                             &local_error)) {
-                       /* Don’t fail updates if the ratings server is unavailable */
-                       if (g_error_matches (local_error, GS_ODRS_PROVIDER_ERROR,
-                                            GS_ODRS_PROVIDER_ERROR_DOWNLOADING) ||
-                           g_error_matches (local_error, GS_ODRS_PROVIDER_ERROR,
-                                            GS_ODRS_PROVIDER_ERROR_NO_NETWORK)) {
-                               g_autoptr(GsPluginEvent) event = NULL;
-
-                               event = gs_plugin_event_new ("error", local_error,
-                                                            "action", GS_PLUGIN_ACTION_DOWNLOAD,
-                                                            NULL);
-
-                               if (gs_plugin_job_get_interactive (helper->plugin_job))
-                                       gs_plugin_event_add_flag (event, GS_PLUGIN_EVENT_FLAG_INTERACTIVE);
-                               else
-                                       gs_plugin_event_add_flag (event, GS_PLUGIN_EVENT_FLAG_WARNING);
-                               gs_plugin_loader_add_event (plugin_loader, event);
-
-                               return TRUE;
-                       }
-
-                       g_propagate_error (error, g_steal_pointer (&local_error));
-
-                       return FALSE;
-               }
-       }
-
 #ifdef HAVE_SYSPROF
        if (plugin_loader->sysprof_writer != NULL) {
                g_autofree gchar *sysprof_name = NULL;
@@ -3353,7 +3205,6 @@ gs_plugin_loader_process_thread_cb (GTask *task,
        case GS_PLUGIN_ACTION_INSTALL:
        case GS_PLUGIN_ACTION_DOWNLOAD:
        case GS_PLUGIN_ACTION_LAUNCH:
-       case GS_PLUGIN_ACTION_REFRESH:
        case GS_PLUGIN_ACTION_REMOVE:
        case GS_PLUGIN_ACTION_SEARCH:
        case GS_PLUGIN_ACTION_UPDATE:
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index ae8f0a903..50373f682 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -223,7 +223,6 @@ typedef enum {
  * @GS_PLUGIN_ACTION_SEARCH_PROVIDES:          Get the search results for a provide query
  * @GS_PLUGIN_ACTION_GET_CATEGORIES:           Get the list of categories
  * @GS_PLUGIN_ACTION_GET_CATEGORY_APPS:                Get the apps for a specific category
- * @GS_PLUGIN_ACTION_REFRESH:                  Refresh all the sources
  * @GS_PLUGIN_ACTION_FILE_TO_APP:              Convert the file to an application
  * @GS_PLUGIN_ACTION_URL_TO_APP:               Convert the URI to an application
  * @GS_PLUGIN_ACTION_GET_RECENT:               Get the apps recently released
@@ -257,7 +256,6 @@ typedef enum {
        GS_PLUGIN_ACTION_SEARCH_PROVIDES,
        GS_PLUGIN_ACTION_GET_CATEGORIES,
        GS_PLUGIN_ACTION_GET_CATEGORY_APPS,
-       GS_PLUGIN_ACTION_REFRESH,
        GS_PLUGIN_ACTION_FILE_TO_APP,
        GS_PLUGIN_ACTION_URL_TO_APP,
        GS_PLUGIN_ACTION_GET_RECENT,
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 2dd294e31..918b93890 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -555,28 +555,6 @@ gboolean    gs_plugin_app_upgrade_trigger          (GsPlugin       *plugin,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
 
-/**
- * gs_plugin_refresh:
- * @plugin: a #GsPlugin
- * @cache_age: the acceptable cache age in seconds, or MAXUINT for "any"
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Refreshes the state of all the plugins. Plugins should make sure
- * there's enough metadata to start the application, for example lists of
- * available applications.
- *
- * All functions can block, but should send progress notifications, e.g. using
- * gs_app_set_progress() if they will take more than tens of milliseconds
- * to complete.
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean        gs_plugin_refresh                      (GsPlugin       *plugin,
-                                                        guint           cache_age,
-                                                        GCancellable   *cancellable,
-                                                        GError         **error);
-
 /**
  * gs_plugin_file_to_app:
  * @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index e1e3c7288..d2bd657ce 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1425,8 +1425,6 @@ gs_plugin_error_to_string (GsPluginError error)
 const gchar *
 gs_plugin_action_to_function_name (GsPluginAction action)
 {
-       if (action == GS_PLUGIN_ACTION_REFRESH)
-               return "gs_plugin_refresh";
        if (action == GS_PLUGIN_ACTION_INSTALL)
                return "gs_plugin_app_install";
        if (action == GS_PLUGIN_ACTION_REMOVE)
@@ -1535,8 +1533,6 @@ gs_plugin_action_to_string (GsPluginAction action)
                return "get-categories";
        if (action == GS_PLUGIN_ACTION_GET_CATEGORY_APPS)
                return "get-category-apps";
-       if (action == GS_PLUGIN_ACTION_REFRESH)
-               return "refresh";
        if (action == GS_PLUGIN_ACTION_FILE_TO_APP)
                return "file-to-app";
        if (action == GS_PLUGIN_ACTION_URL_TO_APP)
@@ -1609,8 +1605,6 @@ gs_plugin_action_from_string (const gchar *action)
                return GS_PLUGIN_ACTION_GET_CATEGORIES;
        if (g_strcmp0 (action, "get-category-apps") == 0)
                return GS_PLUGIN_ACTION_GET_CATEGORY_APPS;
-       if (g_strcmp0 (action, "refresh") == 0)
-               return GS_PLUGIN_ACTION_REFRESH;
        if (g_strcmp0 (action, "file-to-app") == 0)
                return GS_PLUGIN_ACTION_FILE_TO_APP;
        if (g_strcmp0 (action, "url-to-app") == 0)


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