summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-store.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-03-23 10:49:14 +0000
committerRichard Hughes <richard@hughsie.com>2016-03-23 10:49:16 +0000
commitb8d0b8f7b9c617de173c1f4b6b77c95dd779b5fa (patch)
tree0d1de880f48f48f0394848f1eea5e9adb1383c86 /libappstream-glib/as-store.c
parent91a4d62016f79dc6bd8c1d897908296abb9fed78 (diff)
downloadappstream-glib-b8d0b8f7b9c617de173c1f4b6b77c95dd779b5fa.tar.gz
Add as_store_get_app_by_id_ignore_prefix()
This allows applications to be fetched from the store when we don't care what the prefix is.
Diffstat (limited to 'libappstream-glib/as-store.c')
-rw-r--r--libappstream-glib/as-store.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 6c99536..b72f7e9 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -486,6 +486,36 @@ as_store_get_app_by_provide (AsStore *store, AsProvideKind kind, const gchar *va
}
/**
+ * as_store_get_app_by_id_ignore_prefix:
+ * @store: a #AsStore instance.
+ * @id: the application full ID.
+ *
+ * Finds an application in the store ignoring the prefix type.
+ *
+ * Returns: (transfer none): a #AsApp or %NULL
+ *
+ * Since: 0.5.12
+ **/
+AsApp *
+as_store_get_app_by_id_ignore_prefix (AsStore *store, const gchar *id)
+{
+ AsApp *app;
+ AsStorePrivate *priv = GET_PRIVATE (store);
+ guint i;
+
+ g_return_val_if_fail (AS_IS_STORE (store), NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+
+ /* find an application that provides something */
+ for (i = 0; i < priv->array->len; i++) {
+ app = g_ptr_array_index (priv->array, i);
+ if (g_strcmp0 (as_app_get_id_no_prefix (app), id) == 0)
+ return app;
+ }
+ return NULL;
+}
+
+/**
* as_store_get_app_by_id_with_fallbacks:
* @store: a #AsStore instance.
* @id: the application full ID.