[gnome-software: 1/3] gs-flatpak: Port to libxmlb 0.3.0 query context API
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/3] gs-flatpak: Port to libxmlb 0.3.0 query context API
- Date: Sat, 30 Jan 2021 00:07:17 +0000 (UTC)
commit cf2b30945978e0d9570af84e195845f737aa1aff
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Jan 28 11:13:00 2021 +0000
gs-flatpak: Port to libxmlb 0.3.0 query context API
This location was missed out in the original port in commit
4dc409a5fe2b6.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
plugins/flatpak/gs-flatpak.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 9b3aa9629..79d7a29a6 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2507,7 +2507,12 @@ get_renamed_component (GsFlatpak *self,
const gchar *origin = gs_app_get_origin (app);
const gchar *renamed_to;
g_autofree gchar *xpath = NULL;
+#if LIBXMLB_CHECK_VERSION(0, 3, 0)
+ g_autoptr(XbQuery) query = NULL;
+ g_auto(XbQueryContext) context = XB_QUERY_CONTEXT_INIT ();
+#else
g_autofree gchar *source_safe = NULL;
+#endif
g_autoptr(FlatpakRemoteRef) remote_ref = NULL;
g_autoptr(XbNode) component = NULL;
@@ -2525,13 +2530,17 @@ get_renamed_component (GsFlatpak *self,
if (renamed_to == NULL)
return NULL;
- /* FIXME: This libxmlb query will need reworking after this PR lands:
- * https://github.com/hughsie/libxmlb/pull/67
- */
+#if LIBXMLB_CHECK_VERSION(0, 3, 0)
+ query = xb_silo_lookup_query (silo,
"components[@origin=?/component/bundle[@type='flatpak'][text()=?]/..");
+ xb_value_bindings_bind_str (xb_query_context_get_bindings (&context), 0, origin, NULL);
+ xb_value_bindings_bind_str (xb_query_context_get_bindings (&context), 1, renamed_to, NULL);
+ component = xb_silo_query_first_with_context (silo, query, &context, NULL);
+#else
source_safe = xb_string_escape (renamed_to);
xpath = g_strdup_printf ("components[@origin='%s']/component/bundle[@type='flatpak'][text()='%s']/..",
origin, source_safe);
component = xb_silo_query_first (silo, xpath, NULL);
+#endif
/* Get the previous name so it can be displayed in the UI */
if (component != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]