summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-05-19 09:44:20 +0100
committerRichard Hughes <richard@hughsie.com>2014-05-19 09:48:25 +0100
commit93301c198eac4401441c8eda12c5aa8472125991 (patch)
tree5b127f5a81e8b2f7a093d30bc65a71d0c1627bfd
parent9d1f53401aa9d835d650704bad8944ec01da06f1 (diff)
downloadappstream-glib-93301c198eac4401441c8eda12c5aa8472125991.tar.gz
Add AsProvide
This is an abstract AppStream provide.
-rw-r--r--docs/api/appstream-glib-docs.sgml1
-rw-r--r--libappstream-glib/Makefile.am4
-rw-r--r--libappstream-glib/appstream-glib.h1
-rw-r--r--libappstream-glib/as-app.c63
-rw-r--r--libappstream-glib/as-app.h4
-rw-r--r--libappstream-glib/as-provide-private.h42
-rw-r--r--libappstream-glib/as-provide.c274
-rw-r--r--libappstream-glib/as-provide.h108
-rw-r--r--libappstream-glib/as-self-test.c45
-rw-r--r--libappstream-glib/as-tag.c1
-rw-r--r--libappstream-glib/as-tag.gperf1
-rw-r--r--libappstream-glib/as-tag.h2
12 files changed, 546 insertions, 0 deletions
diff --git a/docs/api/appstream-glib-docs.sgml b/docs/api/appstream-glib-docs.sgml
index 4b44016..7a0c0fb 100644
--- a/docs/api/appstream-glib-docs.sgml
+++ b/docs/api/appstream-glib-docs.sgml
@@ -36,6 +36,7 @@
<xi:include href="xml/as-app.xml"/>
<xi:include href="xml/as-image.xml"/>
<xi:include href="xml/as-release.xml"/>
+ <xi:include href="xml/as-provide.xml"/>
<xi:include href="xml/as-screenshot.xml"/>
<xi:include href="xml/as-store.xml"/>
<xi:include href="xml/as-problem.xml"/>
diff --git a/libappstream-glib/Makefile.am b/libappstream-glib/Makefile.am
index d38c884..9b9d7d9 100644
--- a/libappstream-glib/Makefile.am
+++ b/libappstream-glib/Makefile.am
@@ -78,6 +78,8 @@ libappstream_glib_la_SOURCES = \
as-node-private.h \
as-problem.c \
as-problem.h \
+ as-provide.c \
+ as-provide.h \
as-release.c \
as-release-private.h \
as-resources.c \
@@ -137,6 +139,8 @@ introspection_sources = \
as-node.h \
as-problem.c \
as-problem.h \
+ as-provide.c \
+ as-provide.h \
as-release.c \
as-release.h \
as-screenshot.c \
diff --git a/libappstream-glib/appstream-glib.h b/libappstream-glib/appstream-glib.h
index 795f4c0..b15db6d 100644
--- a/libappstream-glib/appstream-glib.h
+++ b/libappstream-glib/appstream-glib.h
@@ -29,6 +29,7 @@
#include <as-image.h>
#include <as-node.h>
#include <as-problem.h>
+#include <as-provide.h>
#include <as-release.h>
#include <as-screenshot.h>
#include <as-store.h>
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index d2ed763..ea6cd9a 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -40,6 +40,7 @@
#include "as-app-private.h"
#include "as-enums.h"
#include "as-node-private.h"
+#include "as-provide-private.h"
#include "as-release-private.h"
#include "as-screenshot-private.h"
#include "as-tag.h"
@@ -64,6 +65,7 @@ struct _AsAppPrivate
GPtrArray *pkgnames; /* of string */
GPtrArray *architectures; /* of string */
GPtrArray *releases; /* of AsRelease */
+ GPtrArray *provides; /* of AsProvide */
GPtrArray *screenshots; /* of AsScreenshot */
AsAppSourceKind source_kind;
gchar *icon;
@@ -135,6 +137,7 @@ as_app_finalize (GObject *object)
g_ptr_array_unref (priv->pkgnames);
g_ptr_array_unref (priv->architectures);
g_ptr_array_unref (priv->releases);
+ g_ptr_array_unref (priv->provides);
g_ptr_array_unref (priv->screenshots);
g_ptr_array_unref (priv->token_cache);
@@ -166,6 +169,7 @@ as_app_init (AsApp *app)
priv->pkgnames = g_ptr_array_new_with_free_func (g_free);
priv->architectures = g_ptr_array_new_with_free_func (g_free);
priv->releases = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
+ priv->provides = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
priv->screenshots = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
priv->token_cache = g_ptr_array_new_with_free_func ((GDestroyNotify) as_app_token_item_free);
@@ -319,6 +323,23 @@ as_app_get_releases (AsApp *app)
}
/**
+ * as_app_get_provides:
+ * @app: a #AsApp instance.
+ *
+ * Gets all the provides the application has.
+ *
+ * Returns: (element-type AsProvide) (transfer none): an array
+ *
+ * Since: 0.1.6
+ **/
+GPtrArray *
+as_app_get_provides (AsApp *app)
+{
+ AsAppPrivate *priv = GET_PRIVATE (app);
+ return priv->provides;
+}
+
+/**
* as_app_get_screenshots:
* @app: a #AsApp instance.
*
@@ -1275,6 +1296,22 @@ as_app_add_release (AsApp *app, AsRelease *release)
}
/**
+ * as_app_add_provide:
+ * @app: a #AsApp instance.
+ * @provide: a #AsProvide instance.
+ *
+ * Adds a provide to an application.
+ *
+ * Since: 0.1.6
+ **/
+void
+as_app_add_provide (AsApp *app, AsProvide *provide)
+{
+ AsAppPrivate *priv = GET_PRIVATE (app);
+ g_ptr_array_add (priv->provides, g_object_ref (provide));
+}
+
+/**
* as_app_add_screenshot:
* @app: a #AsApp instance.
* @screenshot: a #AsScreenshot instance.
@@ -1781,6 +1818,16 @@ as_app_node_insert (AsApp *app, GNode *parent, gdouble api_version)
}
}
+ /* <provides> */
+ if (priv->provides->len > 0 && api_version >= 0.6) {
+ AsProvide *provide;
+ node_tmp = as_node_insert (node_app, "provides", NULL, 0, NULL);
+ for (i = 0; i < priv->provides->len; i++) {
+ provide = g_ptr_array_index (priv->provides, i);
+ as_provide_node_insert (provide, node_tmp, api_version);
+ }
+ }
+
/* <languages> */
if (g_hash_table_size (priv->languages) > 0 && api_version >= 0.4)
as_app_node_insert_languages (app, node_app);
@@ -2002,6 +2049,22 @@ as_app_node_parse_child (AsApp *app, GNode *n, GError **error)
}
break;
+ /* <provides> */
+ case AS_TAG_PROVIDES:
+ g_ptr_array_set_size (priv->provides, 0);
+ for (c = n->children; c != NULL; c = c->next) {
+ AsProvide *p;
+ p = as_provide_new ();
+ ret = as_provide_node_parse (p, c, error);
+ if (!ret) {
+ g_object_unref (p);
+ goto out;
+ }
+ as_app_add_provide (app, p);
+ g_object_unref (p);
+ }
+ break;
+
/* <languages> */
case AS_TAG_LANGUAGES:
g_hash_table_remove_all (priv->languages);
diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h
index ba5a768..f4607d7 100644
--- a/libappstream-glib/as-app.h
+++ b/libappstream-glib/as-app.h
@@ -29,6 +29,7 @@
#include <glib-object.h>
#include "as-enums.h"
+#include "as-provide.h"
#include "as-release.h"
#include "as-screenshot.h"
@@ -160,6 +161,7 @@ GPtrArray *as_app_get_keywords (AsApp *app);
GPtrArray *as_app_get_pkgnames (AsApp *app);
GPtrArray *as_app_get_architectures (AsApp *app);
GPtrArray *as_app_get_releases (AsApp *app);
+GPtrArray *as_app_get_provides (AsApp *app);
GPtrArray *as_app_get_screenshots (AsApp *app);
GHashTable *as_app_get_names (AsApp *app);
GHashTable *as_app_get_comments (AsApp *app);
@@ -247,6 +249,8 @@ void as_app_add_arch (AsApp *app,
gssize arch_len);
void as_app_add_release (AsApp *app,
AsRelease *release);
+void as_app_add_provide (AsApp *app,
+ AsProvide *provide);
void as_app_add_screenshot (AsApp *app,
AsScreenshot *screenshot);
void as_app_add_language (AsApp *app,
diff --git a/libappstream-glib/as-provide-private.h b/libappstream-glib/as-provide-private.h
new file mode 100644
index 0000000..c2527e8
--- /dev/null
+++ b/libappstream-glib/as-provide-private.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined (__APPSTREAM_GLIB_PRIVATE_H) && !defined (AS_COMPILATION)
+#error "Only <appstream-glib.h> can be included directly."
+#endif
+
+#ifndef __AS_PROVIDE_PRIVATE_H
+#define __AS_PROVIDE_PRIVATE_H
+
+#include "as-provide.h"
+
+G_BEGIN_DECLS
+
+GNode *as_provide_node_insert (AsProvide *provide,
+ GNode *parent,
+ gdouble api_version);
+gboolean as_provide_node_parse (AsProvide *provide,
+ GNode *node,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __AS_PROVIDE_PRIVATE_H */
diff --git a/libappstream-glib/as-provide.c b/libappstream-glib/as-provide.c
new file mode 100644
index 0000000..3d419c4
--- /dev/null
+++ b/libappstream-glib/as-provide.c
@@ -0,0 +1,274 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * SECTION:as-provide
+ * @short_description: Object representing a single object the application provides.
+ * @include: appstream-glib.h
+ * @stability: Stable
+ *
+ * Applications may provide different binary names, firmware files and that
+ * kind of thing. This is the place to express those extra items.
+ *
+ * See also: #AsApp
+ */
+
+#include "config.h"
+
+#include "as-node-private.h"
+#include "as-provide-private.h"
+#include "as-utils-private.h"
+
+typedef struct _AsProvidePrivate AsProvidePrivate;
+struct _AsProvidePrivate
+{
+ AsProvideKind kind;
+ gchar *value;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (AsProvide, as_provide, G_TYPE_OBJECT)
+
+#define GET_PRIVATE(o) (as_provide_get_instance_private (o))
+
+/**
+ * as_provide_finalize:
+ **/
+static void
+as_provide_finalize (GObject *object)
+{
+ AsProvide *provide = AS_PROVIDE (object);
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+
+ g_free (priv->value);
+
+ G_OBJECT_CLASS (as_provide_parent_class)->finalize (object);
+}
+
+/**
+ * as_provide_init:
+ **/
+static void
+as_provide_init (AsProvide *provide)
+{
+}
+
+/**
+ * as_provide_class_init:
+ **/
+static void
+as_provide_class_init (AsProvideClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = as_provide_finalize;
+}
+
+
+/**
+ * as_provide_kind_from_string:
+ * @kind: the string.
+ *
+ * Converts the text representation to an enumerated value.
+ *
+ * Returns: (transfer full): a #AsProvideKind, or %AS_PROVIDE_KIND_UNKNOWN for unknown.
+ *
+ * Since: 0.1.6
+ **/
+AsProvideKind
+as_provide_kind_from_string (const gchar *kind)
+{
+ if (g_strcmp0 (kind, "library") == 0)
+ return AS_PROVIDE_KIND_LIBRARY;
+ if (g_strcmp0 (kind, "binary") == 0)
+ return AS_PROVIDE_KIND_BINARY;
+ if (g_strcmp0 (kind, "font") == 0)
+ return AS_PROVIDE_KIND_FONT;
+ if (g_strcmp0 (kind, "modalias") == 0)
+ return AS_PROVIDE_KIND_MODALIAS;
+ if (g_strcmp0 (kind, "firmware") == 0)
+ return AS_PROVIDE_KIND_FIRMWARE;
+ if (g_strcmp0 (kind, "python2") == 0)
+ return AS_PROVIDE_KIND_PYTHON2;
+ if (g_strcmp0 (kind, "python3") == 0)
+ return AS_PROVIDE_KIND_PYTHON3;
+ return AS_PROVIDE_KIND_UNKNOWN;
+}
+
+/**
+ * as_provide_kind_to_string:
+ * @kind: the #AsProvideKind.
+ *
+ * Converts the enumerated value to an text representation.
+ *
+ * Returns: string version of @kind
+ *
+ * Since: 0.1.6
+ **/
+const gchar *
+as_provide_kind_to_string (AsProvideKind kind)
+{
+ if (kind == AS_PROVIDE_KIND_LIBRARY)
+ return "library";
+ if (kind == AS_PROVIDE_KIND_BINARY)
+ return "binary";
+ if (kind == AS_PROVIDE_KIND_FONT)
+ return "font";
+ if (kind == AS_PROVIDE_KIND_MODALIAS)
+ return "modalias";
+ if (kind == AS_PROVIDE_KIND_FIRMWARE)
+ return "firmware";
+ if (kind == AS_PROVIDE_KIND_PYTHON2)
+ return "python2";
+ if (kind == AS_PROVIDE_KIND_PYTHON3)
+ return "python3";
+ return NULL;
+}
+
+/**
+ * as_provide_get_value:
+ * @provide: a #AsProvide instance.
+ *
+ * Gets the full qualified URL for the provide, usually pointing at some mirror.
+ *
+ * Returns: URL
+ *
+ * Since: 0.1.6
+ **/
+const gchar *
+as_provide_get_value (AsProvide *provide)
+{
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+ return priv->value;
+}
+
+/**
+ * as_provide_get_kind:
+ * @provide: a #AsProvide instance.
+ *
+ * Gets the provide kind.
+ *
+ * Returns: the #AsProvideKind
+ *
+ * Since: 0.1.6
+ **/
+AsProvideKind
+as_provide_get_kind (AsProvide *provide)
+{
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+ return priv->kind;
+}
+
+/**
+ * as_provide_set_value:
+ * @provide: a #AsProvide instance.
+ * @value: the URL.
+ * @value_len: the size of @value, or -1 if %NULL-terminated.
+ *
+ * Sets the fully-qualified mirror URL to use for the provide.
+ *
+ * Since: 0.1.6
+ **/
+void
+as_provide_set_value (AsProvide *provide, const gchar *value, gssize value_len)
+{
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+ g_free (priv->value);
+ priv->value = as_strndup (value, value_len);
+}
+
+/**
+ * as_provide_set_kind:
+ * @provide: a #AsProvide instance.
+ * @kind: the #AsProvideKind, e.g. %AS_PROVIDE_KIND_LIBRARY.
+ *
+ * Sets the provide kind.
+ *
+ * Since: 0.1.6
+ **/
+void
+as_provide_set_kind (AsProvide *provide, AsProvideKind kind)
+{
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+ priv->kind = kind;
+}
+
+/**
+ * as_provide_node_insert: (skip)
+ * @provide: a #AsProvide instance.
+ * @parent: the parent #GNode to use..
+ * @api_version: the AppStream API version
+ *
+ * Inserts the provide into the DOM tree.
+ *
+ * Returns: (transfer full): A populated #GNode
+ *
+ * Since: 0.1.6
+ **/
+GNode *
+as_provide_node_insert (AsProvide *provide, GNode *parent, gdouble api_version)
+{
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+ GNode *n;
+
+ n = as_node_insert (parent, as_provide_kind_to_string (priv->kind),
+ priv->value,
+ AS_NODE_INSERT_FLAG_NONE,
+ NULL);
+ return n;
+}
+
+/**
+ * as_provide_node_parse:
+ * @provide: a #AsProvide instance.
+ * @node: a #GNode.
+ * @error: A #GError or %NULL.
+ *
+ * Populates the object from a DOM node.
+ *
+ * Returns: %TRUE for success
+ *
+ * Since: 0.1.6
+ **/
+gboolean
+as_provide_node_parse (AsProvide *provide, GNode *node, GError **error)
+{
+ AsProvidePrivate *priv = GET_PRIVATE (provide);
+ priv->kind = as_provide_kind_from_string (as_node_get_name (node));
+ g_free (priv->value);
+ priv->value = as_node_take_data (node);
+ return TRUE;
+}
+
+/**
+ * as_provide_new:
+ *
+ * Creates a new #AsProvide.
+ *
+ * Returns: (transfer full): a #AsProvide
+ *
+ * Since: 0.1.6
+ **/
+AsProvide *
+as_provide_new (void)
+{
+ AsProvide *provide;
+ provide = g_object_new (AS_TYPE_PROVIDE, NULL);
+ return AS_PROVIDE (provide);
+}
diff --git a/libappstream-glib/as-provide.h b/libappstream-glib/as-provide.h
new file mode 100644
index 0000000..0f3ff16
--- /dev/null
+++ b/libappstream-glib/as-provide.h
@@ -0,0 +1,108 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined (__APPSTREAM_GLIB_H) && !defined (AS_COMPILATION)
+#error "Only <appstream-glib.h> can be included directly."
+#endif
+
+#ifndef __AS_PROVIDE_H
+#define __AS_PROVIDE_H
+
+#include <glib-object.h>
+
+#define AS_TYPE_PROVIDE (as_provide_get_type())
+#define AS_PROVIDE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AS_TYPE_PROVIDE, AsProvide))
+#define AS_PROVIDE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), AS_TYPE_PROVIDE, AsProvideClass))
+#define AS_IS_PROVIDE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AS_TYPE_PROVIDE))
+#define AS_IS_PROVIDE_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), AS_TYPE_PROVIDE))
+#define AS_PROVIDE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AS_TYPE_PROVIDE, AsProvideClass))
+
+G_BEGIN_DECLS
+
+typedef struct _AsProvide AsProvide;
+typedef struct _AsProvideClass AsProvideClass;
+
+struct _AsProvide
+{
+ GObject parent;
+};
+
+struct _AsProvideClass
+{
+ GObjectClass parent_class;
+ /*< private >*/
+ void (*_as_reserved1) (void);
+ void (*_as_reserved2) (void);
+ void (*_as_reserved3) (void);
+ void (*_as_reserved4) (void);
+ void (*_as_reserved5) (void);
+ void (*_as_reserved6) (void);
+ void (*_as_reserved7) (void);
+ void (*_as_reserved8) (void);
+};
+
+/**
+ * AsProvideKind:
+ * @AS_PROVIDE_KIND_UNKNOWN: Type invalid or not known
+ * @AS_PROVIDE_KIND_LIBRARY: A library file
+ * @AS_PROVIDE_KIND_BINARY: A binary file
+ * @AS_PROVIDE_KIND_FONT: A font file
+ * @AS_PROVIDE_KIND_MODALIAS: A hardware modalias
+ * @AS_PROVIDE_KIND_FIRMWARE: A firmware file
+ * @AS_PROVIDE_KIND_PYTHON2: A Python 2 module
+ * @AS_PROVIDE_KIND_PYTHON3: A Python 3 module
+ *
+ * The provide type.
+ **/
+typedef enum {
+ AS_PROVIDE_KIND_UNKNOWN,
+ AS_PROVIDE_KIND_LIBRARY,
+ AS_PROVIDE_KIND_BINARY,
+ AS_PROVIDE_KIND_FONT,
+ AS_PROVIDE_KIND_MODALIAS,
+ AS_PROVIDE_KIND_FIRMWARE,
+ AS_PROVIDE_KIND_PYTHON2,
+ AS_PROVIDE_KIND_PYTHON3,
+ /*< private >*/
+ AS_PROVIDE_KIND_LAST
+} AsProvideKind;
+
+GType as_provide_get_type (void);
+AsProvide *as_provide_new (void);
+
+/* helpers */
+AsProvideKind as_provide_kind_from_string (const gchar *kind);
+const gchar *as_provide_kind_to_string (AsProvideKind kind);
+
+/* getters */
+const gchar *as_provide_get_value (AsProvide *provide);
+AsProvideKind as_provide_get_kind (AsProvide *provide);
+
+/* setters */
+void as_provide_set_value (AsProvide *provide,
+ const gchar *value,
+ gssize value_len);
+void as_provide_set_kind (AsProvide *provide,
+ AsProvideKind kind);
+
+G_END_DECLS
+
+#endif /* __AS_PROVIDE_H */
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 8c21da8..a62f4b8 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -29,6 +29,7 @@
#include "as-image-private.h"
#include "as-node-private.h"
#include "as-problem.h"
+#include "as-provide-private.h"
#include "as-release-private.h"
#include "as-screenshot-private.h"
#include "as-store.h"
@@ -117,6 +118,45 @@ ch_test_release_func (void)
}
static void
+ch_test_provide_func (void)
+{
+ AsProvide *provide;
+ GError *error = NULL;
+ GNode *n;
+ GNode *root;
+ GString *xml;
+ const gchar *src = "<binary>/usr/bin/gnome-shell</binary>";
+ gboolean ret;
+
+ provide = as_provide_new ();
+
+ /* to object */
+ root = as_node_from_xml (src, -1, 0, &error);
+ g_assert_no_error (error);
+ g_assert (root != NULL);
+ n = as_node_find (root, "binary");
+ g_assert (n != NULL);
+ ret = as_provide_node_parse (provide, n, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+ as_node_unref (root);
+
+ /* verify */
+ g_assert_cmpint (as_provide_get_kind (provide), ==, AS_PROVIDE_KIND_BINARY);
+ g_assert_cmpstr (as_provide_get_value (provide), ==, "/usr/bin/gnome-shell");
+
+ /* back to node */
+ root = as_node_new ();
+ n = as_provide_node_insert (provide, root, 0.4);
+ xml = as_node_to_xml (n, AS_NODE_TO_XML_FLAG_NONE);
+ g_assert_cmpstr (xml->str, ==, src);
+ g_string_free (xml, TRUE);
+ as_node_unref (root);
+
+ g_object_unref (provide);
+}
+
+static void
ch_test_release_desc_func (void)
{
AsRelease *release;
@@ -329,6 +369,9 @@ ch_test_app_func (void)
"<releases>"
"<release version=\"3.11.90\" timestamp=\"1392724800\"/>"
"</releases>"
+ "<provides>"
+ "<binary>/usr/bin/gnome-shell</binary>"
+ "</provides>"
"<languages>"
"<lang percentage=\"90\">en_GB</lang>"
"<lang>pl</lang>"
@@ -363,6 +406,7 @@ ch_test_app_func (void)
g_assert_cmpint (as_app_get_categories(app)->len, ==, 1);
g_assert_cmpint (as_app_get_screenshots(app)->len, ==, 2);
g_assert_cmpint (as_app_get_releases(app)->len, ==, 1);
+ g_assert_cmpint (as_app_get_provides(app)->len, ==, 1);
g_assert_cmpstr (as_app_get_metadata_item (app, "X-Kudo-GTK3"), ==, "");
g_assert_cmpint (as_app_get_language (app, "en_GB"), ==, 90);
g_assert_cmpint (as_app_get_language (app, "pl"), ==, 0);
@@ -1504,6 +1548,7 @@ main (int argc, char **argv)
/* tests go here */
g_test_add_func ("/AppStream/tag", ch_test_tag_func);
+ g_test_add_func ("/AppStream/provide", ch_test_provide_func);
g_test_add_func ("/AppStream/release", ch_test_release_func);
g_test_add_func ("/AppStream/release{description}", ch_test_release_desc_func);
g_test_add_func ("/AppStream/image", ch_test_image_func);
diff --git a/libappstream-glib/as-tag.c b/libappstream-glib/as-tag.c
index 86a927d..6227199 100644
--- a/libappstream-glib/as-tag.c
+++ b/libappstream-glib/as-tag.c
@@ -157,6 +157,7 @@ as_tag_to_string (AsTag tag)
"architectures",
"arch",
"metadata_license",
+ "provides",
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 5aa5a9c..82580d1 100644
--- a/libappstream-glib/as-tag.gperf
+++ b/libappstream-glib/as-tag.gperf
@@ -41,3 +41,4 @@ release, AS_TAG_RELEASE
architectures, AS_TAG_ARCHITECTURES
arch, AS_TAG_ARCH
metadata_license, AS_TAG_METADATA_LICENSE
+provides, AS_TAG_PROVIDES
diff --git a/libappstream-glib/as-tag.h b/libappstream-glib/as-tag.h
index 92cfa10..b3f51e8 100644
--- a/libappstream-glib/as-tag.h
+++ b/libappstream-glib/as-tag.h
@@ -64,6 +64,7 @@
* @AS_TAG_ARCHITECTURES: `architectures`
* @AS_TAG_ARCH: `arch`
* @AS_TAG_METADATA_LICENSE: `metadata_license`
+ * @AS_TAG_PROVIDES: `provides`
*
* The tag type.
**/
@@ -102,6 +103,7 @@ typedef enum {
AS_TAG_ARCHITECTURES, /* Since: 0.1.1 */
AS_TAG_ARCH, /* Since: 0.1.1 */
AS_TAG_METADATA_LICENSE, /* Since: 0.1.4 */
+ AS_TAG_PROVIDES, /* Since: 0.1.6 */
/*< private >*/
AS_TAG_LAST
} AsTag;