summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-08-15 09:33:27 +0100
committerRichard Hughes <richard@hughsie.com>2014-08-18 10:44:01 +0100
commit4f8e36da36e8ddd6538fa16690b71b3662ccdda6 (patch)
treef442f470615744ad659bc5e03378579e2be8d446
parentd30bf2c124f132931544695e9469568ae765e27a (diff)
downloadappstream-glib-4f8e36da36e8ddd6538fa16690b71b3662ccdda6.tar.gz
Add as_store_set_builder_id()
This is used to identify builder versions with compatible metadata.
-rw-r--r--libappstream-glib/as-store.c47
-rw-r--r--libappstream-glib/as-store.h3
2 files changed, 50 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"
diff --git a/libappstream-glib/as-store.h b/libappstream-glib/as-store.h
index edc00bb..6a74d0d 100644
--- a/libappstream-glib/as-store.h
+++ b/libappstream-glib/as-store.h
@@ -163,6 +163,9 @@ gboolean as_store_to_file (AsStore *store,
const gchar *as_store_get_origin (AsStore *store);
void as_store_set_origin (AsStore *store,
const gchar *origin);
+const gchar *as_store_get_builder_id (AsStore *store);
+void as_store_set_builder_id (AsStore *store,
+ const gchar *builder_id);
const gchar *as_store_get_destdir (AsStore *store);
void as_store_set_destdir (AsStore *store,
const gchar *destdir);