summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-01-27 15:01:14 +0000
committerRichard Hughes <richard@hughsie.com>2016-01-27 15:01:14 +0000
commitb6cd0775bae56e9c090920cd907a4f76a0802216 (patch)
treede259f2237ddfa0b6ff884d4ee8cf88dbe95816b
parentce181c28b9bf67c1dcfe8531d1ac53981d4219c4 (diff)
downloadappstream-glib-b6cd0775bae56e9c090920cd907a4f76a0802216.tar.gz
Add support for the GENERIC component kind
Fixes https://github.com/hughsie/appstream-glib/issues/82
-rw-r--r--libappstream-glib/as-app.c4
-rw-r--r--libappstream-glib/as-enums.c6
-rw-r--r--libappstream-glib/as-enums.h6
3 files changed, 12 insertions, 4 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index 333e5af..2f738c3 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -3751,7 +3751,9 @@ as_app_node_parse_full (AsApp *app, GNode *node, AsAppParseFlags flags,
/* new style */
if (g_strcmp0 (as_node_get_name (node), "component") == 0) {
tmp = as_node_get_attribute (node, "type");
- if (tmp != NULL)
+ if (tmp == NULL)
+ as_app_set_id_kind (app, AS_ID_KIND_GENERIC);
+ else
as_app_set_id_kind (app, as_id_kind_from_string (tmp));
prio = as_node_get_attribute_as_int (node, "priority");
if (prio != G_MAXINT && prio != 0)
diff --git a/libappstream-glib/as-enums.c b/libappstream-glib/as-enums.c
index 41badf6..3ad08cb 100644
--- a/libappstream-glib/as-enums.c
+++ b/libappstream-glib/as-enums.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2016 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -63,6 +63,8 @@ as_id_kind_to_string (AsIdKind id_kind)
return "firmware";
if (id_kind == AS_ID_KIND_RUNTIME)
return "runtime";
+ if (id_kind == AS_ID_KIND_GENERIC)
+ return "generic";
return "unknown";
}
@@ -97,6 +99,8 @@ as_id_kind_from_string (const gchar *id_kind)
return AS_ID_KIND_FIRMWARE;
if (g_strcmp0 (id_kind, "runtime") == 0)
return AS_ID_KIND_RUNTIME;
+ if (g_strcmp0 (id_kind, "generic") == 0)
+ return AS_ID_KIND_GENERIC;
return AS_ID_KIND_UNKNOWN;
}
diff --git a/libappstream-glib/as-enums.h b/libappstream-glib/as-enums.h
index 4aeb562..3a55440 100644
--- a/libappstream-glib/as-enums.h
+++ b/libappstream-glib/as-enums.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2016 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -42,8 +42,9 @@ G_BEGIN_DECLS
* @AS_ID_KIND_ADDON: An addon, e.g. a plugin
* @AS_ID_KIND_FIRMWARE: A firmware update
* @AS_ID_KIND_RUNTIME: Runtime platform
+ * @AS_ID_KIND_GENERIC: Generic component
*
- * The ID type.
+ * The component type.
**/
typedef enum {
AS_ID_KIND_UNKNOWN, /* Since: 0.1.0 */
@@ -56,6 +57,7 @@ typedef enum {
AS_ID_KIND_ADDON, /* Since: 0.1.7 */
AS_ID_KIND_FIRMWARE, /* Since: 0.3.5 */
AS_ID_KIND_RUNTIME, /* Since: 0.5.6 */
+ AS_ID_KIND_GENERIC, /* Since: 0.5.8 */
/*< private >*/
AS_ID_KIND_LAST
} AsIdKind;