[gnome-software: 7/11] lib: Drop GS_PLUGIN_ACTION_GET_CATEGORIES and gs_plugin_add_categories()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/11] lib: Drop GS_PLUGIN_ACTION_GET_CATEGORIES and gs_plugin_add_categories()
- Date: Mon, 18 Jul 2022 09:57:06 +0000 (UTC)
commit 3001824181e375a9255f22f7794e0958b7546f70
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Jul 14 17:15:48 2022 +0100
lib: Drop GS_PLUGIN_ACTION_GET_CATEGORIES and gs_plugin_add_categories()
Neither of them are used any more: instead, plugins and call sites use
`GsPluginJobListCategories`, which internally queries the
`GsCategoryManager` and then calls `GsPlugin.refine_categories_async()`
on the resulting category list.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-plugin-loader-sync.c | 37 -----------
lib/gs-plugin-loader-sync.h | 4 --
lib/gs-plugin-loader.c | 148 --------------------------------------------
lib/gs-plugin-loader.h | 8 ---
lib/gs-plugin-types.h | 2 -
lib/gs-plugin-vfuncs.h | 18 ------
lib/gs-plugin.c | 6 --
7 files changed, 223 deletions(-)
---
diff --git a/lib/gs-plugin-loader-sync.c b/lib/gs-plugin-loader-sync.c
index 345fa4cc7..2b8b39a8e 100644
--- a/lib/gs-plugin-loader-sync.c
+++ b/lib/gs-plugin-loader-sync.c
@@ -65,43 +65,6 @@ gs_plugin_loader_job_process (GsPluginLoader *plugin_loader,
return list;
}
-GPtrArray *
-gs_plugin_loader_job_get_categories (GsPluginLoader *plugin_loader,
- GsPluginJob *plugin_job,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginLoaderHelper helper;
- GPtrArray *catlist;
-
- /* create temp object */
- helper.res = NULL;
- helper.context = g_main_context_new ();
- helper.loop = g_main_loop_new (helper.context, FALSE);
-
- g_main_context_push_thread_default (helper.context);
-
- /* run async method */
- gs_plugin_loader_job_get_categories_async (plugin_loader,
- plugin_job,
- cancellable,
- _helper_finish_sync,
- &helper);
- g_main_loop_run (helper.loop);
- catlist = gs_plugin_loader_job_get_categories_finish (plugin_loader,
- helper.res,
- error);
-
- g_main_context_pop_thread_default (helper.context);
-
- g_main_loop_unref (helper.loop);
- g_main_context_unref (helper.context);
- if (helper.res != NULL)
- g_object_unref (helper.res);
-
- return catlist;
-}
-
gboolean
gs_plugin_loader_job_action (GsPluginLoader *plugin_loader,
GsPluginJob *plugin_job,
diff --git a/lib/gs-plugin-loader-sync.h b/lib/gs-plugin-loader-sync.h
index 55ddb3e05..844e2aa99 100644
--- a/lib/gs-plugin-loader-sync.h
+++ b/lib/gs-plugin-loader-sync.h
@@ -26,10 +26,6 @@ gboolean gs_plugin_loader_job_action (GsPluginLoader *plugin_loader,
GsPluginJob *plugin_job,
GCancellable *cancellable,
GError **error);
-GPtrArray *gs_plugin_loader_job_get_categories (GsPluginLoader *plugin_loader,
- GsPluginJob *plugin_job,
- GCancellable *cancellable,
- GError **error);
GsApp *gs_plugin_loader_app_create (GsPluginLoader *plugin_loader,
const gchar *unique_id,
GCancellable *cancellable,
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 8cbe7a885..073008d55 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -639,13 +639,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
ret = plugin_func (plugin, list, cancellable, &error_local);
}
break;
- case GS_PLUGIN_ACTION_GET_CATEGORIES:
- {
- GsPluginCategoriesFunc plugin_func = func;
- ret = plugin_func (plugin, helper->catlist,
- cancellable, &error_local);
- }
- break;
case GS_PLUGIN_ACTION_FILE_TO_APP:
{
GsPluginFileToAppFunc plugin_func = func;
@@ -1071,147 +1064,6 @@ gs_plugin_loader_job_action_finish (GsPluginLoader *plugin_loader,
/******************************************************************************/
-static gint
-gs_plugin_loader_category_sort_cb (gconstpointer a, gconstpointer b)
-{
- GsCategory *cata = GS_CATEGORY (*(GsCategory **) a);
- GsCategory *catb = GS_CATEGORY (*(GsCategory **) b);
- if (gs_category_get_score (cata) < gs_category_get_score (catb))
- return 1;
- if (gs_category_get_score (cata) > gs_category_get_score (catb))
- return -1;
- return gs_utils_sort_strcmp (gs_category_get_name (cata),
- gs_category_get_name (catb));
-}
-
-static void
-gs_plugin_loader_job_get_categories_thread_cb (GTask *task,
- gpointer object,
- gpointer task_data,
- GCancellable *cancellable)
-{
- GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (g_task_get_source_object (task));
- GError *error = NULL;
- GsPluginLoaderHelper *helper = (GsPluginLoaderHelper *) task_data;
- g_autoptr(GMainContext) context = g_main_context_new ();
- g_autoptr(GMainContextPusher) pusher = g_main_context_pusher_new (context);
- GsCategory * const *categories = NULL;
- gsize n_categories;
- g_autofree gchar *job_debug = NULL;
-#ifdef HAVE_SYSPROF
- gint64 begin_time_nsec G_GNUC_UNUSED = SYSPROF_CAPTURE_CURRENT_TIME;
-#endif
-
- /* get the categories */
- categories = gs_category_manager_get_categories (plugin_loader->category_manager, &n_categories);
-
- for (gsize i = 0; i < n_categories; i++)
- g_ptr_array_add (helper->catlist, g_object_ref (categories[i]));
-
- /* run each plugin */
- if (!gs_plugin_loader_run_results (helper, cancellable, &error)) {
- g_task_return_error (task, error);
- return;
- }
-
- /* sort by name */
- g_ptr_array_sort (helper->catlist, gs_plugin_loader_category_sort_cb);
- for (guint i = 0; i < helper->catlist->len; i++) {
- GsCategory *cat = GS_CATEGORY (g_ptr_array_index (helper->catlist, i));
- gs_category_sort_children (cat);
- }
-
-#ifdef HAVE_SYSPROF
- if (plugin_loader->sysprof_writer != NULL) {
- g_autofree gchar *sysprof_message = gs_plugin_job_to_string (helper->plugin_job);
- sysprof_capture_writer_add_mark (plugin_loader->sysprof_writer,
- begin_time_nsec,
- sched_getcpu (),
- getpid (),
- SYSPROF_CAPTURE_CURRENT_TIME - begin_time_nsec,
- "gnome-software",
- "get-categories",
- sysprof_message);
- }
-#endif /* HAVE_SYSPROF */
-
- /* show elapsed time */
- job_debug = gs_plugin_job_to_string (helper->plugin_job);
- g_debug ("%s", job_debug);
-
- /* success */
- if (helper->catlist->len == 0)
- g_task_return_new_error (task,
- GS_PLUGIN_ERROR,
- GS_PLUGIN_ERROR_NOT_SUPPORTED,
- "no categories to show");
- else
- g_task_return_pointer (task, g_ptr_array_ref (helper->catlist), (GDestroyNotify)
g_ptr_array_unref);
-}
-
-/**
- * gs_plugin_loader_job_get_categories_async:
- * @plugin_loader: A #GsPluginLoader
- * @plugin_job: job to process
- * @cancellable: a #GCancellable, or %NULL
- * @callback: function to call when complete
- * @user_data: user data to pass to @callback
- *
- * This method calls all plugins that implement the gs_plugin_add_categories()
- * function. The plugins return #GsCategory objects.
- **/
-void
-gs_plugin_loader_job_get_categories_async (GsPluginLoader *plugin_loader,
- GsPluginJob *plugin_job,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GsPluginLoaderHelper *helper;
- g_autoptr(GTask) task = NULL;
-
- g_return_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader));
- g_return_if_fail (GS_IS_PLUGIN_JOB (plugin_job));
- g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
-
- /* save helper */
- helper = gs_plugin_loader_helper_new (plugin_loader, plugin_job);
- helper->catlist = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
- /* run in a thread */
- task = g_task_new (plugin_loader, cancellable, callback, user_data);
- g_task_set_source_tag (task, gs_plugin_loader_job_get_categories_async);
- g_task_set_task_data (task, helper, (GDestroyNotify) gs_plugin_loader_helper_free);
- g_task_run_in_thread (task, gs_plugin_loader_job_get_categories_thread_cb);
-}
-
-/**
- * gs_plugin_loader_job_get_categories_finish:
- * @plugin_loader: A #GsPluginLoader
- * @res: a #GAsyncResult
- * @error: A #GError, or %NULL
- *
- * Return value: (element-type GsCategory) (transfer full): A list of applications
- **/
-GPtrArray *
-gs_plugin_loader_job_get_categories_finish (GsPluginLoader *plugin_loader,
- GAsyncResult *res,
- GError **error)
-{
- GPtrArray *array;
-
- g_return_val_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader), NULL);
- g_return_val_if_fail (G_IS_TASK (res), NULL);
- g_return_val_if_fail (g_task_is_valid (res, plugin_loader), NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- array = g_task_propagate_pointer (G_TASK (res), error);
- gs_utils_error_convert_gio (error);
- return array;
-}
-
-/******************************************************************************/
-
static gboolean
emit_pending_apps_idle (gpointer loader)
{
diff --git a/lib/gs-plugin-loader.h b/lib/gs-plugin-loader.h
index 91c5f643c..93a44d681 100644
--- a/lib/gs-plugin-loader.h
+++ b/lib/gs-plugin-loader.h
@@ -38,14 +38,6 @@ GsAppList *gs_plugin_loader_job_process_finish (GsPluginLoader *plugin_loader,
gboolean gs_plugin_loader_job_action_finish (GsPluginLoader *plugin_loader,
GAsyncResult *res,
GError **error);
-void gs_plugin_loader_job_get_categories_async (GsPluginLoader *plugin_loader,
- GsPluginJob *plugin_job,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GPtrArray *gs_plugin_loader_job_get_categories_finish (GsPluginLoader *plugin_loader,
- GAsyncResult *res,
- GError **error);
void gs_plugin_loader_setup_async (GsPluginLoader *plugin_loader,
const gchar * const *allowlist,
const gchar * const *blocklist,
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index 5198733c9..038976adf 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -279,7 +279,6 @@ typedef enum {
* @GS_PLUGIN_ACTION_UPDATE_CANCEL: Cancel the update
* @GS_PLUGIN_ACTION_GET_UPDATES: Get the list of updates
* @GS_PLUGIN_ACTION_GET_SOURCES: Get the list of sources
- * @GS_PLUGIN_ACTION_GET_CATEGORIES: Get the list of categories
* @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_UPDATES_HISTORICAL: Get the list of historical updates
@@ -303,7 +302,6 @@ typedef enum {
GS_PLUGIN_ACTION_UPDATE_CANCEL,
GS_PLUGIN_ACTION_GET_UPDATES,
GS_PLUGIN_ACTION_GET_SOURCES,
- GS_PLUGIN_ACTION_GET_CATEGORIES,
GS_PLUGIN_ACTION_FILE_TO_APP,
GS_PLUGIN_ACTION_URL_TO_APP,
GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL,
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 66fd69562..39093f508 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -123,24 +123,6 @@ gboolean gs_plugin_add_updates_historical (GsPlugin *plugin,
GCancellable *cancellable,
GError **error);
-/**
- * gs_plugin_add_categories:
- * @plugin: a #GsPlugin
- * @list: (element-type GsCategory): a #GPtrArray
- * @cancellable: a #GCancellable, or %NULL
- * @error: a #GError, or %NULL
- *
- * Get the category tree, for instance Games->Action or Internet->Email.
- *
- * Plugins are expected to add new categories using g_ptr_array_add().
- *
- * Returns: %TRUE for success or if not relevant
- **/
-gboolean gs_plugin_add_categories (GsPlugin *plugin,
- GPtrArray *list,
- GCancellable *cancellable,
- GError **error);
-
/**
* gs_plugin_launch:
* @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 13c6e8d94..e4aa78b24 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1586,8 +1586,6 @@ gs_plugin_action_to_function_name (GsPluginAction action)
return "gs_plugin_add_updates_historical";
if (action == GS_PLUGIN_ACTION_GET_UPDATES)
return "gs_plugin_add_updates";
- if (action == GS_PLUGIN_ACTION_GET_CATEGORIES)
- return "gs_plugin_add_categories";
if (action == GS_PLUGIN_ACTION_GET_LANGPACKS)
return "gs_plugin_add_langpacks";
return NULL;
@@ -1626,8 +1624,6 @@ gs_plugin_action_to_string (GsPluginAction action)
return "get-updates";
if (action == GS_PLUGIN_ACTION_GET_SOURCES)
return "get-sources";
- if (action == GS_PLUGIN_ACTION_GET_CATEGORIES)
- return "get-categories";
if (action == GS_PLUGIN_ACTION_FILE_TO_APP)
return "file-to-app";
if (action == GS_PLUGIN_ACTION_URL_TO_APP)
@@ -1680,8 +1676,6 @@ gs_plugin_action_from_string (const gchar *action)
return GS_PLUGIN_ACTION_GET_UPDATES;
if (g_strcmp0 (action, "get-sources") == 0)
return GS_PLUGIN_ACTION_GET_SOURCES;
- if (g_strcmp0 (action, "get-categories") == 0)
- return GS_PLUGIN_ACTION_GET_CATEGORIES;
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]