[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 9/13] gs-appstream: Add gs_appstream_add_deployment_featured()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 9/13] gs-appstream: Add gs_appstream_add_deployment_featured()
- Date: Tue, 24 May 2022 15:41:04 +0000 (UTC)
commit 3204f2dfdf2f603729d026cb0eba529e407e25ed
Author: Milan Crha <mcrha redhat com>
Date: Fri May 6 11:51:30 2022 +0200
gs-appstream: Add gs_appstream_add_deployment_featured()
To be used to get featured apps in given deployments.
lib/gs-appstream.c | 49 ++++++++++++++++++++++++++++++++++++++++---------
lib/gs-appstream.h | 5 +++++
2 files changed, 45 insertions(+), 9 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 38cc31bb5..59d7ca82a 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1811,20 +1811,18 @@ gs_appstream_add_alternates (XbSilo *silo,
return TRUE;
}
-gboolean
-gs_appstream_add_featured (XbSilo *silo,
- GsAppList *list,
- GCancellable *cancellable,
- GError **error)
+static gboolean
+gs_appstream_add_featured_with_query (XbSilo *silo,
+ const gchar *query,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
{
g_autoptr(GError) error_local = NULL;
g_autoptr(GPtrArray) array = NULL;
/* find out how many packages are in each category */
- array = xb_silo_query (silo,
- "components/component/custom/value[@key='GnomeSoftware::FeatureTile']/../..|"
-
"components/component/custom/value[@key='GnomeSoftware::FeatureTile-css']/../..",
- 0, &error_local);
+ array = xb_silo_query (silo, query, 0, &error_local);
if (array == NULL) {
if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
return TRUE;
@@ -1848,6 +1846,39 @@ gs_appstream_add_featured (XbSilo *silo,
return TRUE;
}
+gboolean
+gs_appstream_add_featured (XbSilo *silo,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ const gchar *query = "components/component/custom/value[@key='GnomeSoftware::FeatureTile']/../..|"
+ "components/component/custom/value[@key='GnomeSoftware::FeatureTile-css']/../..";
+ return gs_appstream_add_featured_with_query (silo, query, list, cancellable, error);
+}
+
+gboolean
+gs_appstream_add_deployment_featured (XbSilo *silo,
+ const gchar * const *deployments,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_autoptr(GString) query = g_string_new (NULL);
+ g_return_val_if_fail (deployments != NULL, FALSE);
+ for (guint ii = 0; deployments[ii] != NULL; ii++) {
+ g_autofree gchar *escaped = xb_string_escape (deployments[ii]);
+ if (escaped != NULL && *escaped != '\0') {
+ xb_string_append_union (query,
+
"components/component/custom/value[@key='GnomeSoftware::DeploymentFeatured'][text()='%s']/../..",
+ escaped);
+ }
+ }
+ if (!query->len)
+ return TRUE;
+ return gs_appstream_add_featured_with_query (silo, query->str, list, cancellable, error);
+}
+
gboolean
gs_appstream_url_to_app (GsPlugin *plugin,
XbSilo *silo,
diff --git a/lib/gs-appstream.h b/lib/gs-appstream.h
index 5a8fb6eda..f1ed8b6fa 100644
--- a/lib/gs-appstream.h
+++ b/lib/gs-appstream.h
@@ -52,6 +52,11 @@ gboolean gs_appstream_add_featured (XbSilo *silo,
GsAppList *list,
GCancellable *cancellable,
GError **error);
+gboolean gs_appstream_add_deployment_featured (XbSilo *silo,
+ const gchar * const *deployments,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error);
gboolean gs_appstream_add_alternates (XbSilo *silo,
GsApp *app,
GsAppList *list,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]