[gnome-software: 2/15] gs-plugin-loader: Move popular apps overrides to dummy plugin
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 2/15] gs-plugin-loader: Move popular apps overrides to dummy plugin
- Date: Mon, 9 May 2022 13:09:05 +0000 (UTC)
commit 46df6de6a65715750d60b654665b90c176af4fe7
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 3 16:47:35 2022 +0100
gs-plugin-loader: Move popular apps overrides to dummy plugin
This environment variable was only used during the dummy plugin tests,
so its implementation can live in the dummy plugin and stop complicating
the `GsPluginLoader`.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-plugin-loader.c | 47 -----------------------------------------
plugins/dummy/gs-plugin-dummy.c | 15 +++++++++++++
plugins/dummy/gs-self-test.c | 4 ++--
3 files changed, 17 insertions(+), 49 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 2c785b780..00b776477 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3881,9 +3881,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (CancellableData, cancellable_data_free)
static gboolean job_process_setup_complete_cb (GCancellable *cancellable,
gpointer user_data);
static void job_process_cb (GTask *task);
-static void job_process_refine_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data);
/**
* gs_plugin_loader_job_process_async:
@@ -4021,32 +4018,6 @@ job_process_cb (GTask *task)
}
}
- /* hardcoded, so resolve a set list */
- if (action == GS_PLUGIN_ACTION_GET_POPULAR) {
- g_auto(GStrv) apps = NULL;
- if (g_getenv ("GNOME_SOFTWARE_POPULAR") != NULL) {
- apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
- }
- if (apps != NULL && g_strv_length (apps) > 0) {
- GsAppList *list = gs_plugin_job_get_list (plugin_job);
- g_autoptr(GsPluginJob) refine_job = NULL;
-
- for (guint i = 0; apps[i] != NULL; i++) {
- g_autoptr(GsApp) app = gs_app_new (apps[i]);
- gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
- gs_app_list_add (list, app);
- }
-
- /* Refine the list of wildcard popular apps and return
- * to the caller. */
- refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID |
GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
- gs_plugin_loader_job_process_async (plugin_loader, refine_job,
- cancellable,
- job_process_refine_cb, g_object_ref (task));
- return;
- }
- }
-
/* FIXME: the plugins should specify this, rather than hardcoding */
if (gs_plugin_job_has_refine_flags (plugin_job,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI)) {
@@ -4179,24 +4150,6 @@ job_process_cb (GTask *task)
g_task_run_in_thread (task, gs_plugin_loader_process_thread_cb);
}
-static void
-job_process_refine_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
- g_autoptr(GsAppList) results = NULL;
- g_autoptr(GTask) task = g_steal_pointer (&user_data);
- g_autoptr(GError) local_error = NULL;
-
- results = gs_plugin_loader_job_process_finish (plugin_loader, result, &local_error);
-
- if (results == NULL)
- g_task_return_error (task, g_steal_pointer (&local_error));
- else
- g_task_return_pointer (task, g_steal_pointer (&results), (GDestroyNotify) g_object_unref);
-}
-
/******************************************************************************/
/**
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index cf2bccd4d..0fb31ab4b 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -596,6 +596,21 @@ gs_plugin_add_popular (GsPlugin *plugin,
{
g_autoptr(GsApp) app1 = NULL;
g_autoptr(GsApp) app2 = NULL;
+ g_auto(GStrv) apps = NULL;
+
+ if (g_getenv ("GNOME_SOFTWARE_POPULAR") != NULL) {
+ apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
+ }
+
+ if (apps != NULL && g_strv_length (apps) > 0) {
+ for (gsize i = 0; apps[i] != NULL; i++) {
+ g_autoptr(GsApp) app = gs_app_new (apps[i]);
+ gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+ gs_app_list_add (list, app);
+ }
+
+ return TRUE;
+ }
/* add wildcard */
app1 = gs_app_new ("zeus.desktop");
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 1945fc6c8..faca17711 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -579,7 +579,7 @@ gs_plugins_dummy_wildcard_func (GsPluginLoader *plugin_loader)
g_auto(GStrv) apps = NULL;
g_autoptr(GsPluginJob) plugin_job = NULL;
- /* use the plugin's add_popular function */
+ /* use the plugin's default popular list */
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_POPULAR,
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
NULL);
@@ -589,7 +589,7 @@ gs_plugins_dummy_wildcard_func (GsPluginLoader *plugin_loader)
g_assert (list1 != NULL);
g_assert_cmpint (gs_app_list_length (list1), ==, 1);
- /* override the popular list (do not use the add_popular function) */
+ /* override the list */
g_setenv ("GNOME_SOFTWARE_POPULAR", popular_override, TRUE);
g_object_unref (plugin_job);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_POPULAR,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]