summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-store.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-08-15 09:33:27 +0100
committerRichard Hughes <richard@hughsie.com>2014-08-15 09:35:14 +0100
commit5154977db3c536d39f1f412dcdd9696b9ce1ad4d (patch)
tree842d7c869ca2d193112823032368d1c256d82f21 /libappstream-glib/as-store.c
parent615ad59f0471b6e9922254bb680f206f4e2c2fcd (diff)
downloadappstream-glib-5154977db3c536d39f1f412dcdd9696b9ce1ad4d.tar.gz
Add as_store_set_builder_id()
This is used to identify builder versions with compatible metadata.
Diffstat (limited to 'libappstream-glib/as-store.c')
-rw-r--r--libappstream-glib/as-store.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 75400b2..140a08e 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -56,6 +56,7 @@ struct _AsStorePrivate
{
gchar *destdir;
gchar *origin;
+ gchar *builder_id;
gdouble api_version;
GPtrArray *array; /* of AsApp */
GHashTable *hash_id; /* of AsApp{id_full} */
@@ -103,6 +104,7 @@ as_store_finalize (GObject *object)
g_free (priv->destdir);
g_free (priv->origin);
+ g_free (priv->builder_id);
g_ptr_array_unref (priv->array);
g_ptr_array_unref (priv->file_monitors);
g_hash_table_unref (priv->hash_id);
@@ -483,6 +485,11 @@ as_store_from_root (AsStore *store,
if (tmp != NULL)
as_store_set_origin (store, tmp);
+ /* set in the XML file */
+ tmp = as_node_get_attribute (apps, "builder_id");
+ if (tmp != NULL)
+ as_store_set_builder_id (store, tmp);
+
/* if we have an origin either from the XML or _set_origin() */
if (priv->origin != NULL) {
if (icon_root == NULL)
@@ -650,6 +657,10 @@ as_store_to_xml (AsStore *store, AsNodeToXmlFlags flags)
if (priv->origin != NULL)
as_node_add_attribute (node_apps, "origin", priv->origin, -1);
+ /* set origin attribute */
+ if (priv->builder_id != NULL)
+ as_node_add_attribute (node_apps, "builder_id", priv->builder_id, -1);
+
/* set version attribute */
if (priv->api_version > 0.1f) {
g_ascii_formatd (version, sizeof (version),
@@ -775,6 +786,42 @@ as_store_set_origin (AsStore *store, const gchar *origin)
}
/**
+ * as_store_get_builder_id:
+ * @store: a #AsStore instance.
+ *
+ * Gets the metadata builder identifier, which is used to work out if old
+ * metadata is compatible with this builder.
+ *
+ * Returns: the builder_id string, or %NULL if unset
+ *
+ * Since: 0.2.5
+ **/
+const gchar *
+as_store_get_builder_id (AsStore *store)
+{
+ AsStorePrivate *priv = GET_PRIVATE (store);
+ return priv->builder_id;
+}
+
+/**
+ * as_store_set_builder_id:
+ * @store: a #AsStore instance.
+ * @builder_id: the builder_id, e.g. "appstream-glib:1"
+ *
+ * Sets the metadata builder identifier, which is used to work out if old
+ * metadata can be used.
+ *
+ * Since: 0.2.5
+ **/
+void
+as_store_set_builder_id (AsStore *store, const gchar *builder_id)
+{
+ AsStorePrivate *priv = GET_PRIVATE (store);
+ g_free (priv->builder_id);
+ priv->builder_id = g_strdup (builder_id);
+}
+
+/**
* as_store_set_destdir:
* @store: a #AsStore instance.
* @destdir: the destdir, e.g. "/tmp"