diff options
-rw-r--r-- | libappstream-glib/as-app.c | 19 | ||||
-rw-r--r-- | libappstream-glib/as-node-private.h | 3 | ||||
-rw-r--r-- | libappstream-glib/as-node.c | 37 | ||||
-rw-r--r-- | libappstream-glib/as-store.c | 1 |
4 files changed, 58 insertions, 2 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 1d6449b..6a3103e 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -3267,6 +3267,15 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } } + /* <metadata_license> */ + if (as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_APPDATA || + as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_METAINFO) { + if (priv->metadata_license != NULL) { + as_node_insert (node_app, "metadata_license", + priv->metadata_license, 0, NULL); + } + } + /* <project_license> or <licence> */ if (priv->project_license != NULL) { if (api_version >= 0.4) { @@ -3340,6 +3349,15 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) if (g_hash_table_size (priv->languages) > 0 && api_version >= 0.4) as_app_node_insert_languages (app, node_app); + /* <update_contact> */ + if (as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_APPDATA || + as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_METAINFO) { + if (priv->update_contact != NULL) { + as_node_insert (node_app, "update_contact", + priv->update_contact, 0, NULL); + } + } + /* <metadata> */ if (g_hash_table_size (priv->metadata) > 0 && api_version >= 0.4) { node_tmp = as_node_insert (node_app, "metadata", NULL, 0, NULL); @@ -4566,6 +4584,7 @@ as_app_to_file (AsApp *app, root = as_node_new (); ctx = as_node_context_new (); as_node_context_set_version (ctx, 1.0); + as_node_context_set_output (ctx, AS_APP_SOURCE_KIND_APPDATA); as_app_node_insert (app, root, ctx); xml = as_node_to_xml (root, AS_NODE_TO_XML_FLAG_ADD_HEADER | diff --git a/libappstream-glib/as-node-private.h b/libappstream-glib/as-node-private.h index b2856ea..71ecc08 100644 --- a/libappstream-glib/as-node-private.h +++ b/libappstream-glib/as-node-private.h @@ -39,6 +39,9 @@ void as_node_context_set_version (AsNodeContext *ctx, AsAppSourceKind as_node_context_get_source_kind (AsNodeContext *ctx); void as_node_context_set_source_kind (AsNodeContext *ctx, AsAppSourceKind source_kind); +AsAppSourceKind as_node_context_get_output (AsNodeContext *ctx); +void as_node_context_set_output (AsNodeContext *ctx, + AsAppSourceKind output); gchar *as_node_take_data (const GNode *node); gchar *as_node_take_attribute (const GNode *node, diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c index 9db5d11..00ef50c 100644 --- a/libappstream-glib/as-node.c +++ b/libappstream-glib/as-node.c @@ -1909,6 +1909,7 @@ as_node_get_localized_unwrap (const GNode *node, GError **error) /* helper struct */ struct _AsNodeContext { AsAppSourceKind source_kind; + AsAppSourceKind output; gdouble version; }; @@ -1928,6 +1929,7 @@ as_node_context_new (void) ctx = g_new0 (AsNodeContext, 1); ctx->version = 0.f; ctx->source_kind = AS_APP_SOURCE_KIND_APPSTREAM; + ctx->output = AS_APP_SOURCE_KIND_UNKNOWN; return ctx; } @@ -1966,7 +1968,7 @@ as_node_context_set_version (AsNodeContext *ctx, gdouble version) * as_node_context_get_source_kind: (skip) * @ctx: a #AsNodeContext. * - * Gets the AppStream API source_kind used when parsing or inserting nodes. + * Gets the AppStream API source_kind used when parsing nodes. * * Returns: source_kind number * @@ -1983,7 +1985,7 @@ as_node_context_get_source_kind (AsNodeContext *ctx) * @ctx: a #AsNodeContext. * @source_kind: an API source_kind number to target. * - * Sets the AppStream API source_kind used when parsing or inserting nodes. + * Sets the AppStream API source_kind used when parsing nodes. * * Since: 0.3.6 **/ @@ -1992,3 +1994,34 @@ as_node_context_set_source_kind (AsNodeContext *ctx, AsAppSourceKind source_kind { ctx->source_kind = source_kind; } + +/** + * as_node_context_get_output: (skip) + * @ctx: a #AsNodeContext. + * + * Gets the AppStream API destination kind used when inserting nodes. + * + * Returns: output format, e.g. %AS_APP_SOURCE_KIND_APPDATA + * + * Since: 0.3.6 + **/ +AsAppSourceKind +as_node_context_get_output (AsNodeContext *ctx) +{ + return ctx->output; +} + +/** + * as_node_context_set_output: (skip) + * @ctx: a #AsNodeContext. + * @output: an output kind, e.g. %AS_APP_SOURCE_KIND_APPDATA + * + * Sets the AppStream API destination kind used when inserting nodes. + * + * Since: 0.3.6 + **/ +void +as_node_context_set_output (AsNodeContext *ctx, AsAppSourceKind output) +{ + ctx->output = output; +} diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index 8fdc0a4..4333910 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -931,6 +931,7 @@ as_store_to_xml (AsStore *store, AsNodeToXmlFlags flags) /* add applications */ ctx = as_node_context_new (); as_node_context_set_version (ctx, priv->api_version); + as_node_context_set_output (ctx, AS_APP_SOURCE_KIND_APPSTREAM); for (i = 0; i < priv->array->len; i++) { app = g_ptr_array_index (priv->array, i); as_app_node_insert (app, node_apps, ctx); |