summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-01-16 21:32:58 +0000
committerRichard Hughes <richard@hughsie.com>2017-01-16 21:33:00 +0000
commit31bc7ef5765f9d54c7d52b93c5f5a6d617eb7ee9 (patch)
tree63e5fcfbd72d4d1f3c087bd84dbb4c9632e66560
parent280dec786fdc49e2b95b4297c0a7091cc4705514 (diff)
downloadappstream-glib-31bc7ef5765f9d54c7d52b93c5f5a6d617eb7ee9.tar.gz
Read and write the <custom> tag
Upstream ximion went with <custom> rather than <metadata> so write that if the context version is new enough. Support reading both as we have to support either way for basically forever. Resolves: https://github.com/hughsie/appstream-glib/issues/147
-rw-r--r--libappstream-glib/as-app.c8
-rw-r--r--libappstream-glib/as-tag.c1
-rw-r--r--libappstream-glib/as-tag.gperf1
-rw-r--r--libappstream-glib/as-tag.h2
4 files changed, 9 insertions, 3 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index 1d6fbe5..0017c7d 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -4315,9 +4315,10 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx)
}
}
- /* <metadata> */
+ /* <custom> or <metadata> */
if (g_hash_table_size (priv->metadata) > 0) {
- node_tmp = as_node_insert (node_app, "metadata", NULL, 0, NULL);
+ tmp = as_node_context_get_version (ctx) > 0.9 ? "custom" : "metadata";
+ node_tmp = as_node_insert (node_app, tmp, NULL, 0, NULL);
as_node_insert_hash (node_tmp, "value", "key", priv->metadata, FALSE);
}
@@ -4785,8 +4786,9 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags,
priv->problems |= AS_APP_PROBLEM_EXPECTED_CHILDREN;
break;
- /* <metadata> */
+ /* <custom> or <metadata> */
case AS_TAG_METADATA:
+ case AS_TAG_CUSTOM:
if (!(flags & AS_APP_PARSE_FLAG_APPEND_DATA))
g_hash_table_remove_all (priv->metadata);
for (c = n->children; c != NULL; c = c->next) {
diff --git a/libappstream-glib/as-tag.c b/libappstream-glib/as-tag.c
index 021425c..9e84381 100644
--- a/libappstream-glib/as-tag.c
+++ b/libappstream-glib/as-tag.c
@@ -201,6 +201,7 @@ as_tag_to_string (AsTag tag)
"reviewer_id",
"suggests",
"requires",
+ "custom",
NULL };
if (tag > AS_TAG_LAST)
tag = AS_TAG_LAST;
diff --git a/libappstream-glib/as-tag.gperf b/libappstream-glib/as-tag.gperf
index 1b5eb79..f002ee0 100644
--- a/libappstream-glib/as-tag.gperf
+++ b/libappstream-glib/as-tag.gperf
@@ -65,3 +65,4 @@ reviewer_name, AS_TAG_REVIEWER_NAME
reviewer_id, AS_TAG_REVIEWER_ID
suggests, AS_TAG_SUGGESTS
requires, AS_TAG_REQUIRES
+custom, AS_TAG_CUSTOM
diff --git a/libappstream-glib/as-tag.h b/libappstream-glib/as-tag.h
index 66a4ad1..2fa91e6 100644
--- a/libappstream-glib/as-tag.h
+++ b/libappstream-glib/as-tag.h
@@ -90,6 +90,7 @@ G_BEGIN_DECLS
* @AS_TAG_REVIEWER_ID: `reviewer_id`
* @AS_TAG_SUGGESTS: `suggests`
* @AS_TAG_REQUIRES: `requires`
+ * @AS_TAG_CUSTOM: `custom`
*
* The tag type.
**/
@@ -152,6 +153,7 @@ typedef enum {
AS_TAG_REVIEWER_ID, /* Since: 0.6.1 */
AS_TAG_SUGGESTS, /* Since: 0.6.1 */
AS_TAG_REQUIRES, /* Since: 0.6.7 */
+ AS_TAG_CUSTOM, /* Since: 0.6.8 */
/*< private >*/
AS_TAG_LAST
} AsTag;