Commit b74a42da authored by Matthias Klumpp's avatar Matthias Klumpp
Browse files

Recognize more "provides" item types

The "id" type was simply missing due to an oversight, and the
"mediatype" type will likely exist in a future release of the
specification, so let's support it early.
parent 775e7e56
...@@ -3323,7 +3323,11 @@ as_component_load_provides_from_xml (AsComponent *cpt, xmlNode *node) ...@@ -3323,7 +3323,11 @@ as_component_load_provides_from_xml (AsComponent *cpt, xmlNode *node)
if (content == NULL) if (content == NULL)
continue; continue;
if (g_strcmp0 (node_name, "library") == 0) { if (g_strcmp0 (node_name, "id") == 0) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_ID, content);
} else if (g_strcmp0 (node_name, "mediatype") == 0) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_MEDIATYPE, content);
} else if (g_strcmp0 (node_name, "library") == 0) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_LIBRARY, content); as_component_add_provided_item (cpt, AS_PROVIDED_KIND_LIBRARY, content);
} else if (g_strcmp0 (node_name, "binary") == 0) { } else if (g_strcmp0 (node_name, "binary") == 0) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_BINARY, content); as_component_add_provided_item (cpt, AS_PROVIDED_KIND_BINARY, content);
...@@ -3802,6 +3806,11 @@ as_component_xml_serialize_provides (AsComponent *cpt, xmlNode *cnode) ...@@ -3802,6 +3806,11 @@ as_component_xml_serialize_provides (AsComponent *cpt, xmlNode *cnode)
case AS_PROVIDED_KIND_MIMETYPE: case AS_PROVIDED_KIND_MIMETYPE:
/* we already handled those */ /* we already handled those */
break; break;
case AS_PROVIDED_KIND_ID:
as_xml_add_node_list (node, NULL,
"id",
items);
break;
case AS_PROVIDED_KIND_LIBRARY: case AS_PROVIDED_KIND_LIBRARY:
as_xml_add_node_list (node, NULL, as_xml_add_node_list (node, NULL,
"library", "library",
...@@ -4294,7 +4303,11 @@ as_component_yaml_parse_provides (AsComponent *cpt, GNode *node) ...@@ -4294,7 +4303,11 @@ as_component_yaml_parse_provides (AsComponent *cpt, GNode *node)
for (n = node->children; n != NULL; n = n->next) { for (n = node->children; n != NULL; n = n->next) {
const gchar *key = as_yaml_node_get_key (n); const gchar *key = as_yaml_node_get_key (n);
if (g_strcmp0 (key, "libraries") == 0) { if (g_strcmp0 (key, "ids") == 0) {
for (sn = n->children; sn != NULL; sn = sn->next) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_ID, (gchar*) sn->data);
}
} else if (g_strcmp0 (key, "libraries") == 0) {
for (sn = n->children; sn != NULL; sn = sn->next) { for (sn = n->children; sn != NULL; sn = sn->next) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_LIBRARY, (gchar*) sn->data); as_component_add_provided_item (cpt, AS_PROVIDED_KIND_LIBRARY, (gchar*) sn->data);
} }
...@@ -4347,7 +4360,7 @@ as_component_yaml_parse_provides (AsComponent *cpt, GNode *node) ...@@ -4347,7 +4360,7 @@ as_component_yaml_parse_provides (AsComponent *cpt, GNode *node)
for (sn = n->children; sn != NULL; sn = sn->next) { for (sn = n->children; sn != NULL; sn = sn->next) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_PYTHON, (gchar*) sn->data); as_component_add_provided_item (cpt, AS_PROVIDED_KIND_PYTHON, (gchar*) sn->data);
} }
} else if (g_strcmp0 (key, "mimetypes") == 0) { } else if ((g_strcmp0 (key, "mimetypes") == 0) || (g_strcmp0 (key, "mediatypes") == 0)) {
for (sn = n->children; sn != NULL; sn = sn->next) { for (sn = n->children; sn != NULL; sn = sn->next) {
as_component_add_provided_item (cpt, AS_PROVIDED_KIND_MIMETYPE, (gchar*) sn->data); as_component_add_provided_item (cpt, AS_PROVIDED_KIND_MIMETYPE, (gchar*) sn->data);
} }
...@@ -4720,6 +4733,11 @@ as_component_yaml_emit_provides (AsComponent *cpt, yaml_emitter_t *emitter) ...@@ -4720,6 +4733,11 @@ as_component_yaml_emit_provides (AsComponent *cpt, yaml_emitter_t *emitter)
kind = as_provided_get_kind (prov); kind = as_provided_get_kind (prov);
switch (kind) { switch (kind) {
case AS_PROVIDED_KIND_ID:
as_yaml_emit_sequence (emitter,
"ids",
items);
break;
case AS_PROVIDED_KIND_LIBRARY: case AS_PROVIDED_KIND_LIBRARY:
as_yaml_emit_sequence (emitter, as_yaml_emit_sequence (emitter,
"libraries", "libraries",
......
...@@ -65,8 +65,8 @@ as_provided_kind_to_string (AsProvidedKind kind) ...@@ -65,8 +65,8 @@ as_provided_kind_to_string (AsProvidedKind kind)
return "lib"; return "lib";
if (kind == AS_PROVIDED_KIND_BINARY) if (kind == AS_PROVIDED_KIND_BINARY)
return "bin"; return "bin";
if (kind == AS_PROVIDED_KIND_MIMETYPE) if (kind == AS_PROVIDED_KIND_MEDIATYPE)
return "mimetype"; return "mediatype";
if (kind == AS_PROVIDED_KIND_FONT) if (kind == AS_PROVIDED_KIND_FONT)
return "font"; return "font";
if (kind == AS_PROVIDED_KIND_MODALIAS) if (kind == AS_PROVIDED_KIND_MODALIAS)
...@@ -103,8 +103,8 @@ as_provided_kind_from_string (const gchar *kind_str) ...@@ -103,8 +103,8 @@ as_provided_kind_from_string (const gchar *kind_str)
return AS_PROVIDED_KIND_LIBRARY; return AS_PROVIDED_KIND_LIBRARY;
if (g_strcmp0 (kind_str, "bin") == 0) if (g_strcmp0 (kind_str, "bin") == 0)
return AS_PROVIDED_KIND_BINARY; return AS_PROVIDED_KIND_BINARY;
if (g_strcmp0 (kind_str, "mimetype") == 0) if (g_strcmp0 (kind_str, "mediatype") == 0)
return AS_PROVIDED_KIND_MIMETYPE; return AS_PROVIDED_KIND_MEDIATYPE;
if (g_strcmp0 (kind_str, "font") == 0) if (g_strcmp0 (kind_str, "font") == 0)
return AS_PROVIDED_KIND_FONT; return AS_PROVIDED_KIND_FONT;
if (g_strcmp0 (kind_str, "modalias") == 0) if (g_strcmp0 (kind_str, "modalias") == 0)
...@@ -144,7 +144,7 @@ as_provided_kind_to_l10n_string (AsProvidedKind kind) ...@@ -144,7 +144,7 @@ as_provided_kind_to_l10n_string (AsProvidedKind kind)
return _("Libraries"); return _("Libraries");
if (kind == AS_PROVIDED_KIND_BINARY) if (kind == AS_PROVIDED_KIND_BINARY)
return _("Binaries"); return _("Binaries");
if (kind == AS_PROVIDED_KIND_MIMETYPE) if (kind == AS_PROVIDED_KIND_MEDIATYPE)
return _("Media types"); return _("Media types");
if (kind == AS_PROVIDED_KIND_FONT) if (kind == AS_PROVIDED_KIND_FONT)
return _("Fonts"); return _("Fonts");
......
...@@ -49,7 +49,7 @@ struct _AsProvidedClass ...@@ -49,7 +49,7 @@ struct _AsProvidedClass
* @AS_PROVIDED_KIND_UNKNOWN: Unknown kind * @AS_PROVIDED_KIND_UNKNOWN: Unknown kind
* @AS_PROVIDED_KIND_LIBRARY: A shared library * @AS_PROVIDED_KIND_LIBRARY: A shared library
* @AS_PROVIDED_KIND_BINARY: A binary installed into a directory in PATH * @AS_PROVIDED_KIND_BINARY: A binary installed into a directory in PATH
* @AS_PROVIDED_KIND_MIMETYPE: Provides a handler for a mimetype * @AS_PROVIDED_KIND_MEDIATYPE: Provides a handler for a mimetype
* @AS_PROVIDED_KIND_FONT: A font * @AS_PROVIDED_KIND_FONT: A font
* @AS_PROVIDED_KIND_MODALIAS: A modalias * @AS_PROVIDED_KIND_MODALIAS: A modalias
* @AS_PROVIDED_KIND_PYTHON_2: A Python2 module * @AS_PROVIDED_KIND_PYTHON_2: A Python2 module
...@@ -66,7 +66,7 @@ typedef enum { ...@@ -66,7 +66,7 @@ typedef enum {
AS_PROVIDED_KIND_UNKNOWN, AS_PROVIDED_KIND_UNKNOWN,
AS_PROVIDED_KIND_LIBRARY, AS_PROVIDED_KIND_LIBRARY,
AS_PROVIDED_KIND_BINARY, AS_PROVIDED_KIND_BINARY,
AS_PROVIDED_KIND_MIMETYPE, AS_PROVIDED_KIND_MEDIATYPE,
AS_PROVIDED_KIND_FONT, AS_PROVIDED_KIND_FONT,
AS_PROVIDED_KIND_MODALIAS, AS_PROVIDED_KIND_MODALIAS,
AS_PROVIDED_KIND_PYTHON_2, AS_PROVIDED_KIND_PYTHON_2,
...@@ -80,6 +80,8 @@ typedef enum { ...@@ -80,6 +80,8 @@ typedef enum {
AS_PROVIDED_KIND_LAST AS_PROVIDED_KIND_LAST
} AsProvidedKind; } AsProvidedKind;
#define AS_PROVIDED_KIND_MIMETYPE AS_PROVIDED_KIND_MEDIATYPE
const gchar *as_provided_kind_to_string (AsProvidedKind kind); const gchar *as_provided_kind_to_string (AsProvidedKind kind);
AsProvidedKind as_provided_kind_from_string (const gchar *kind_str); AsProvidedKind as_provided_kind_from_string (const gchar *kind_str);
const gchar *as_provided_kind_to_l10n_string (AsProvidedKind kind); const gchar *as_provided_kind_to_l10n_string (AsProvidedKind kind);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment