summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-10-12 11:22:36 +0100
committerRichard Hughes <richard@hughsie.com>2016-10-12 11:22:39 +0100
commit0e3e7807146d19e6cc31273ee3162d0ce37d2907 (patch)
tree01317e9e7fbb3b5a0c94323aa0301e11b608887b
parent6c3ec7e6e2958296cb9f05fd8e701e0fc13211cf (diff)
downloadappstream-glib-0e3e7807146d19e6cc31273ee3162d0ce37d2907.tar.gz
Allow filtering applications based on merge type
This allows us to load only merge-type components, which we might want when sharing per-system or per-user overrides.
-rw-r--r--libappstream-glib/as-store.c19
-rw-r--r--libappstream-glib/as-store.h1
2 files changed, 19 insertions, 1 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index c7fdf5d..467adef 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -109,6 +109,7 @@ static gboolean as_store_from_file_internal (AsStore *store,
GFile *file,
AsAppScope scope,
const gchar *arch,
+ AsStoreLoadFlags load_flags,
AsStoreWatchFlags watch_flags,
GCancellable *cancellable,
GError **error);
@@ -1231,6 +1232,7 @@ as_store_from_root (AsStore *store,
const gchar *icon_prefix,
const gchar *source_filename,
const gchar *arch,
+ AsStoreLoadFlags load_flags,
GError **error)
{
AsStorePrivate *priv = GET_PRIVATE (store);
@@ -1397,6 +1399,14 @@ as_store_from_root (AsStore *store,
return FALSE;
}
+ /* filter out non-merge types */
+ if (load_flags & AS_STORE_LOAD_FLAG_ONLY_MERGE_APPS) {
+ if (as_app_get_merge_kind (app) != AS_APP_MERGE_KIND_APPEND &&
+ as_app_get_merge_kind (app) != AS_APP_MERGE_KIND_APPEND) {
+ continue;
+ }
+ }
+
/* set the ID prefix */
if ((priv->add_flags & AS_STORE_ADD_FLAG_USE_UNIQUE_ID) == 0)
as_store_fixup_id_prefix (app, id_prefix_app);
@@ -1567,6 +1577,7 @@ as_store_watch_source_added (AsStore *store, const gchar *filename)
file,
path_data->scope,
path_data->arch,
+ AS_STORE_LOAD_FLAG_NONE,
AS_STORE_WATCH_FLAG_NONE,
NULL, /* cancellable */
&error)){
@@ -1681,6 +1692,7 @@ as_store_from_file_internal (AsStore *store,
GFile *file,
AsAppScope scope,
const gchar *arch,
+ AsStoreLoadFlags load_flags,
AsStoreWatchFlags watch_flags,
GCancellable *cancellable,
GError **error)
@@ -1737,7 +1749,8 @@ as_store_from_file_internal (AsStore *store,
/* icon prefix is the directory the XML has been found in */
icon_prefix = g_path_get_dirname (filename);
return as_store_from_root (store, root, scope,
- icon_prefix, filename, arch, error);
+ icon_prefix, filename, arch, load_flags,
+ error);
}
/**
@@ -1771,6 +1784,7 @@ as_store_from_file (AsStore *store,
return as_store_from_file_internal (store, file,
AS_APP_SCOPE_UNKNOWN,
NULL, /* arch */
+ AS_STORE_LOAD_FLAG_NONE,
priv->watch_flags,
cancellable, error);
}
@@ -1880,6 +1894,7 @@ as_store_from_xml (AsStore *store,
icon_root,
NULL, /* filename */
NULL, /* arch */
+ AS_STORE_LOAD_FLAG_NONE,
error);
}
@@ -2411,6 +2426,7 @@ as_store_load_app_info_file (AsStore *store,
file,
scope,
arch,
+ flags,
AS_STORE_WATCH_FLAG_NONE,
cancellable,
error);
@@ -2466,6 +2482,7 @@ as_store_load_app_info (AsStore *store,
scope,
filename_md,
arch,
+ flags,
cancellable,
&error_store)) {
if (flags & AS_STORE_LOAD_FLAG_IGNORE_INVALID) {
diff --git a/libappstream-glib/as-store.h b/libappstream-glib/as-store.h
index c35ca40..55338e4 100644
--- a/libappstream-glib/as-store.h
+++ b/libappstream-glib/as-store.h
@@ -80,6 +80,7 @@ typedef enum {
AS_STORE_LOAD_FLAG_FLATPAK_SYSTEM = 1 << 7, /* Since: 0.5.7 */
AS_STORE_LOAD_FLAG_IGNORE_INVALID = 1 << 8, /* Since: 0.5.8 */
AS_STORE_LOAD_FLAG_ONLY_UNCOMPRESSED = 1 << 9, /* Since: 0.6.4 */
+ AS_STORE_LOAD_FLAG_ONLY_MERGE_APPS = 1 << 10, /* Since: 0.6.4 */
/*< private >*/
AS_STORE_LOAD_FLAG_LAST
} AsStoreLoadFlags;