[gnome-software/wip/mak/libas: 12/13] Parse all provided item types properly
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mak/libas: 12/13] Parse all provided item types properly
- Date: Wed, 10 Feb 2021 15:16:29 +0000 (UTC)
commit cc0d0fac126bf88691fed2cdd29a48e0a4940729
Author: Matthias Klumpp <matthias tenstral net>
Date: Sun Jan 31 07:17:57 2021 +0100
Parse all provided item types properly
Having some duplicated logic in GNOME Software is annoying, but since
AppStream can't parse XbNodes and GNOME Software doesn't use the XML
directly parsed by AppStream, this is the best solution to really read
all provided item types.
plugins/core/gs-appstream.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index d7df3843f..b0fe2e42f 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -369,9 +369,47 @@ gs_appstream_refine_add_provides (GsApp *app, XbNode *component, GError **error)
return FALSE;
}
for (guint i = 0; i < provides->len; i++) {
+ AsProvidedKind kind;
+ const gchar *element_name;
XbNode *provide = g_ptr_array_index (provides, i);
+ element_name = xb_node_get_element (provide);
+
+ /* try the simple case */
+ kind = as_provided_kind_from_string (element_name);
+ if (kind == AS_PROVIDED_KIND_UNKNOWN) {
+ /* try the complex cases */
+
+ if (g_strcmp0 (element_name, "library") == 0) {
+ kind = AS_PROVIDED_KIND_LIBRARY;
+ } else if (g_strcmp0 (element_name, "binary") == 0) {
+ kind = AS_PROVIDED_KIND_BINARY;
+ } else if (g_strcmp0 (element_name, "firmware") == 0) {
+ const gchar *fw_type = xb_node_get_attr (provide, "type");
+ if (g_strcmp0 (fw_type, "runtime") == 0)
+ kind = AS_PROVIDED_KIND_FIRMWARE_RUNTIME;
+ else if (g_strcmp0 (fw_type, "flashed") == 0)
+ kind = AS_PROVIDED_KIND_FIRMWARE_FLASHED;
+ } else if (g_strcmp0 (element_name, "python2") == 0) {
+ kind = AS_PROVIDED_KIND_PYTHON_2;
+ } else if (g_strcmp0 (element_name, "python3") == 0) {
+ kind = AS_PROVIDED_KIND_PYTHON;
+ } else if (g_strcmp0 (element_name, "dbus") == 0) {
+ const gchar *dbus_type = xb_node_get_attr (provide, "type");
+ if (g_strcmp0 (dbus_type, "system") == 0)
+ kind = AS_PROVIDED_KIND_DBUS_SYSTEM;
+ else if ((g_strcmp0 (dbus_type, "user") == 0) || (g_strcmp0 (dbus_type,
"session") == 0))
+ kind = AS_PROVIDED_KIND_DBUS_USER;
+ }
+ }
+
+ if (kind == AS_PROVIDED_KIND_UNKNOWN) {
+ /* give up */
+ g_warning ("ignoring unknown provided item type: %s", element_name);
+ continue;
+ }
+
gs_app_add_provided_item (app,
- as_provided_kind_from_string (xb_node_get_element (provide)),
+ kind,
xb_node_get_text (provide));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]