[gnome-software: 4/14] appstream: Make listing category apps asynchronous
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 4/14] appstream: Make listing category apps asynchronous
- Date: Mon, 9 May 2022 13:34:15 +0000 (UTC)
commit f9c419779af3bc833f8bb3b800bd8074ffe552d5
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed May 4 14:42:34 2022 +0100
appstream: Make listing category apps asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/core/gs-plugin-appstream.c | 35 +++++++++++------------------------
1 file changed, 11 insertions(+), 24 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index ae9bb66c8..5923dfa1e 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -1343,28 +1343,6 @@ refine_wildcard (GsPluginAppstream *self,
return TRUE;
}
-gboolean
-gs_plugin_add_category_apps (GsPlugin *plugin,
- GsCategory *category,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
-{
- GsPluginAppstream *self = GS_PLUGIN_APPSTREAM (plugin);
- g_autoptr(GRWLockReaderLocker) locker = NULL;
-
- if (!gs_plugin_appstream_check_silo (self, cancellable, error))
- return FALSE;
-
- locker = g_rw_lock_reader_locker_new (&self->silo_lock);
- return gs_appstream_add_category_apps (plugin,
- self->silo,
- category,
- list,
- cancellable,
- error);
-}
-
gboolean
gs_plugin_add_search (GsPlugin *plugin,
gchar **values,
@@ -1540,6 +1518,7 @@ list_apps_thread_cb (GTask *task,
GsPluginListAppsData *data = task_data;
GDateTime *released_since = NULL;
GsAppQueryTristate is_curated = GS_APP_QUERY_TRISTATE_UNSET;
+ GsCategory *category = NULL;
guint64 age_secs = 0;
g_autoptr(GError) local_error = NULL;
@@ -1548,6 +1527,7 @@ list_apps_thread_cb (GTask *task,
if (data->query != NULL) {
released_since = gs_app_query_get_released_since (data->query);
is_curated = gs_app_query_get_is_curated (data->query);
+ category = gs_app_query_get_category (data->query);
}
if (released_since != NULL) {
@@ -1555,9 +1535,10 @@ list_apps_thread_cb (GTask *task,
age_secs = g_date_time_difference (now, released_since) / G_TIME_SPAN_SECOND;
}
- /* Currently only support released-since or is-curated queries (but not both).
+ /* Currently only support released-since, is-curated and category queries (but only one at once).
* Also don’t currently support is-curated==GS_APP_QUERY_TRISTATE_FALSE. */
- if ((released_since == NULL) == (is_curated == GS_APP_QUERY_TRISTATE_UNSET) ||
+ if ((released_since == NULL && is_curated == GS_APP_QUERY_TRISTATE_UNSET && category == NULL) ||
+ gs_app_query_get_n_properties_set (data->query) != 1 ||
is_curated == GS_APP_QUERY_TRISTATE_FALSE) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Unsupported query");
@@ -1585,6 +1566,12 @@ list_apps_thread_cb (GTask *task,
return;
}
+ if (category != NULL &&
+ !gs_appstream_add_category_apps (GS_PLUGIN (self), self->silo, category, list, cancellable,
&local_error)) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
+
g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]