summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-01-24 20:45:35 +0000
committerRichard Hughes <richard@hughsie.com>2015-01-24 20:45:40 +0000
commitf943c04292617cf4e8db12bf6b18f0d775cd2e48 (patch)
treea18c203f8d1f0c9f7ed38df4e9062fc808b2cb2c
parent920d939aeaf2c6f8bb625742049df0d4ec8792d3 (diff)
downloadappstream-glib-f943c04292617cf4e8db12bf6b18f0d775cd2e48.tar.gz
Make the failed AppStream metadata optional
Also, clean up a lot of booleans into one sane bitfield. The libappstream-builder library isn't API stable and has no external users, so we can move things around a bit without worrying.
-rw-r--r--client/as-builder.c62
-rw-r--r--libappstream-builder/asb-context.c158
-rw-r--r--libappstream-builder/asb-context.h48
-rw-r--r--libappstream-builder/asb-self-test.c28
-rw-r--r--libappstream-builder/asb-task.c6
-rw-r--r--libappstream-builder/plugins/asb-plugin-appdata.c4
-rw-r--r--libappstream-builder/plugins/asb-plugin-desktop.c8
-rw-r--r--libappstream-builder/plugins/asb-plugin-font.c4
-rw-r--r--libappstream-builder/plugins/asb-plugin-gstreamer.c4
-rw-r--r--libappstream-builder/plugins/asb-plugin-ibus-sql.c4
-rw-r--r--libappstream-builder/plugins/asb-plugin-ibus-xml.c4
-rw-r--r--libappstream-builder/plugins/asb-plugin-metainfo.c4
12 files changed, 135 insertions, 199 deletions
diff --git a/client/as-builder.c b/client/as-builder.c
index 0140f9d..f33f967 100644
--- a/client/as-builder.c
+++ b/client/as-builder.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -121,12 +121,13 @@ int
main (int argc, char **argv)
{
AsbContext *ctx = NULL;
- AsbContextProcessFlags flags = AS_CONTEXT_PARSE_FLAG_NONE;
+ AsbContextFlags flags = ASB_CONTEXT_FLAG_NONE;
GOptionContext *option_context;
const gchar *filename;
gboolean add_cache_id = FALSE;
gboolean embedded_icons = FALSE;
gboolean hidpi_enabled = FALSE;
+ gboolean include_failed = FALSE;
gboolean no_net = FALSE;
gboolean ret;
gboolean verbose = FALSE;
@@ -164,6 +165,9 @@ main (int argc, char **argv)
{ "add-cache-id", '\0', 0, G_OPTION_ARG_NONE, &add_cache_id,
/* TRANSLATORS: command line option */
_("Add a cache ID to each component"), NULL },
+ { "include-failed", '\0', 0, G_OPTION_ARG_NONE, &include_failed,
+ /* TRANSLATORS: command line option */
+ _("Include failed results in the output"), NULL },
{ "enable-hidpi", '\0', 0, G_OPTION_ARG_NONE, &hidpi_enabled,
/* TRANSLATORS: command line option */
_("Add HiDPI icons to the tarball"), NULL },
@@ -280,11 +284,7 @@ main (int argc, char **argv)
setlocale (LC_ALL, "");
ctx = asb_context_new ();
- asb_context_set_no_net (ctx, no_net);
asb_context_set_api_version (ctx, api_version);
- asb_context_set_add_cache_id (ctx, add_cache_id);
- asb_context_set_hidpi_enabled (ctx, hidpi_enabled);
- asb_context_set_embedded_icons (ctx, embedded_icons);
asb_context_set_old_metadata (ctx, old_metadata);
asb_context_set_extra_appstream (ctx, extra_appstream);
asb_context_set_extra_appdata (ctx, extra_appdata);
@@ -299,6 +299,37 @@ main (int argc, char **argv)
asb_context_set_origin (ctx, origin);
asb_context_set_max_threads (ctx, max_threads);
asb_context_set_min_icon_size (ctx, min_icon_size);
+
+ /* parse the veto ignore flags */
+ if (veto_ignore != NULL) {
+ for (i = 0; veto_ignore[i] != NULL; i++) {
+ if (g_strcmp0 (veto_ignore[i], "missing-info") == 0) {
+ flags |= ASB_CONTEXT_FLAG_IGNORE_MISSING_INFO;
+ continue;
+ }
+ if (g_strcmp0 (veto_ignore[i], "missing-parents") == 0) {
+ flags |= ASB_CONTEXT_FLAG_IGNORE_MISSING_PARENTS;
+ continue;
+ }
+ g_warning ("Unknown flag name: %s, "
+ "expected 'missing-info' or 'missing-parents'",
+ veto_ignore[i]);
+ }
+ }
+
+ /* set build flags */
+ if (hidpi_enabled)
+ flags |= ASB_CONTEXT_FLAG_HIDPI_ICONS;
+ if (add_cache_id)
+ flags |= ASB_CONTEXT_FLAG_ADD_CACHE_ID;
+ if (no_net)
+ flags |= ASB_CONTEXT_FLAG_NO_NETWORK;
+ if (embedded_icons)
+ flags |= ASB_CONTEXT_FLAG_EMBEDDED_ICONS;
+ if (include_failed)
+ flags |= ASB_CONTEXT_FLAG_INCLUDE_FAILED;
+ asb_context_set_flags (ctx, flags);
+
ret = asb_context_setup (ctx, &error);
if (!ret) {
/* TRANSLATORS: error message */
@@ -362,25 +393,8 @@ main (int argc, char **argv)
}
}
- /* parse the context flags */
- if (veto_ignore != NULL) {
- for (i = 0; veto_ignore[i] != NULL; i++) {
- if (g_strcmp0 (veto_ignore[i], "missing-info") == 0) {
- flags |= AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_INFO;
- continue;
- }
- if (g_strcmp0 (veto_ignore[i], "missing-parents") == 0) {
- flags |= AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_PARENTS;
- continue;
- }
- g_warning ("Unknown flag name: %s, "
- "expected 'missing-info' or 'missing-parents'",
- veto_ignore[i]);
- }
- }
-
/* process all packages in the pool */
- ret = asb_context_process (ctx, flags, &error);
+ ret = asb_context_process (ctx, &error);
if (!ret) {
/* TRANSLATORS: error message */
g_warning ("%s: %s", _("Failed to generate metadata"), error->message);
diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c
index 4cfafbb..86f0ced 100644
--- a/libappstream-builder/asb-context.c
+++ b/libappstream-builder/asb-context.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -63,10 +63,7 @@ struct _AsbContextPrivate
GPtrArray *packages; /* of AsbPackage */
AsbPanel *panel;
AsbPluginLoader *plugin_loader;
- gboolean add_cache_id;
- gboolean hidpi_enabled;
- gboolean embedded_icons;
- gboolean no_net;
+ AsbContextFlags flags;
guint max_threads;
guint min_icon_size;
gdouble api_version;
@@ -111,22 +108,6 @@ asb_context_realpath (const gchar *path)
}
/**
- * asb_context_set_no_net:
- * @ctx: A #AsbContext
- * @no_net: if network is disallowed
- *
- * Sets if network access is disallowed.
- *
- * Since: 0.1.0
- **/
-void
-asb_context_set_no_net (AsbContext *ctx, gboolean no_net)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- priv->no_net = no_net;
-}
-
-/**
* asb_context_set_api_version:
* @ctx: A #AsbContext
* @api_version: the AppStream API version
@@ -143,56 +124,24 @@ asb_context_set_api_version (AsbContext *ctx, gdouble api_version)
}
/**
- * asb_context_set_add_cache_id:
+ * asb_context_set_flags:
* @ctx: A #AsbContext
- * @add_cache_id: boolean
+ * @flags: #AsbContextFlags, e.g. %ASB_CONTEXT_FLAG_ADD_CACHE_ID
*
* Sets if the cache id should be included in the metadata.
*
- * Since: 0.1.0
+ * Since: 0.3.5
**/
void
-asb_context_set_add_cache_id (AsbContext *ctx, gboolean add_cache_id)
+asb_context_set_flags (AsbContext *ctx, AsbContextFlags flags)
{
AsbContextPrivate *priv = GET_PRIVATE (ctx);
- if (add_cache_id) {
+ if (flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) {
as_store_add_metadata_index (priv->store_failed, "X-CacheID");
as_store_add_metadata_index (priv->store_ignore, "X-CacheID");
as_store_add_metadata_index (priv->store_old, "X-CacheID");
}
- priv->add_cache_id = add_cache_id;
-}
-
-/**
- * asb_context_set_hidpi_enabled:
- * @ctx: A #AsbContext
- * @hidpi_enabled: boolean
- *
- * Sets if the high DPI icons should be included in the metadata.
- *
- * Since: 0.3.1
- **/
-void
-asb_context_set_hidpi_enabled (AsbContext *ctx, gboolean hidpi_enabled)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- priv->hidpi_enabled = hidpi_enabled;
-}
-
-/**
- * asb_context_set_embedded_icons:
- * @ctx: A #AsbContext
- * @embedded_icons: boolean
- *
- * Sets if the icons should be Base64 embedded in the metadata.
- *
- * Since: 0.3.1
- **/
-void
-asb_context_set_embedded_icons (AsbContext *ctx, gboolean embedded_icons)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- priv->embedded_icons = embedded_icons;
+ priv->flags = flags;
}
/**
@@ -441,71 +390,38 @@ asb_context_set_origin (AsbContext *ctx, const gchar *origin)
}
/**
- * asb_context_get_add_cache_id:
+ * asb_context_get_flags:
* @ctx: A #AsbContext
*
- * Gets if the cache_id should be added to the metadata.
+ * Gets the build flags.
*
- * Returns: boolean
+ * Returns: #AsbContextFlags
*
- * Since: 0.1.0
- **/
-gboolean
-asb_context_get_add_cache_id (AsbContext *ctx)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- return priv->add_cache_id;
-}
-
-/**
- * asb_context_get_hidpi_enabled:
- * @ctx: A #AsbContext
- *
- * Gets if the HiDPI support should be used.
- *
- * Returns: boolean
- *
- * Since: 0.3.1
- **/
-gboolean
-asb_context_get_hidpi_enabled (AsbContext *ctx)
-{
- AsbContextPrivate *priv = GET_PRIVATE (ctx);
- return priv->hidpi_enabled;
-}
-
-/**
- * asb_context_get_embedded_icons:
- * @ctx: A #AsbContext
- *
- * Gets if the icons should be embedded in the XML.
- *
- * Returns: boolean
- *
- * Since: 0.3.1
+ * Since: 0.3.5
**/
-gboolean
-asb_context_get_embedded_icons (AsbContext *ctx)
+AsbContextFlags
+asb_context_get_flags (AsbContext *ctx)
{
AsbContextPrivate *priv = GET_PRIVATE (ctx);
- return priv->embedded_icons;
+ return priv->flags;
}
/**
- * asb_context_get_no_net:
+ * asb_context_get_flag:
* @ctx: A #AsbContext
+ * @flag: A #AsbContextFlags
*
- * Gets if network access is forbidden.
+ * Gets one specific build flag.
*
- * Returns: boolean
+ * Returns: %TRUE if the flag was set
*
- * Since: 0.2.5
+ * Since: 0.3.5
**/
gboolean
-asb_context_get_no_net (AsbContext *ctx)
+asb_context_get_flag (AsbContext *ctx, AsbContextFlags flag)
{
AsbContextPrivate *priv = GET_PRIVATE (ctx);
- return priv->no_net;
+ return (priv->flags & flag) > 0;
}
/**
@@ -689,7 +605,7 @@ asb_context_load_extra_screenshots (AsbContext *ctx, AsApp *app, GError **error)
/* create a new AsbApp and add all the extra screenshots */
app_build = asb_app_new (pkg, as_app_get_id (app));
- asb_app_set_hidpi_enabled (app_build, priv->hidpi_enabled);
+ asb_app_set_hidpi_enabled (app_build, (priv->flags & ASB_CONTEXT_FLAG_HIDPI_ICONS) > 0);
as_app_subsume_full (AS_APP (app_build), app,
AS_APP_SUBSUME_FLAG_NO_OVERWRITE);
dir = g_dir_open (path, 0, error);
@@ -778,7 +694,7 @@ asb_context_setup (AsbContext *ctx, GError **error)
icons_dir = g_build_filename (priv->temp_dir, "icons", NULL);
if (!asb_utils_ensure_exists (icons_dir, error))
return FALSE;
- if (priv->hidpi_enabled) {
+ if (priv->flags & ASB_CONTEXT_FLAG_HIDPI_ICONS) {
_cleanup_free_ gchar *icons_dir_hidpi = NULL;
_cleanup_free_ gchar *icons_dir_lodpi = NULL;
icons_dir_lodpi = g_build_filename (icons_dir, "64x64", NULL);
@@ -791,6 +707,7 @@ asb_context_setup (AsbContext *ctx, GError **error)
/* create all the screenshot sizes */
if (priv->screenshot_dir != NULL) {
+ gboolean hidpi_enabled = (priv->flags & ASB_CONTEXT_FLAG_HIDPI_ICONS) > 0;
_cleanup_free_ gchar *ss_src = NULL;
ss_src = g_build_filename (priv->screenshot_dir,
"source", NULL);
@@ -807,7 +724,7 @@ asb_context_setup (AsbContext *ctx, GError **error)
if (!asb_utils_ensure_exists (ss_dir, error))
return FALSE;
}
- for (i = 0; sizes[i] != 0 && priv->hidpi_enabled; i += 2) {
+ for (i = 0; sizes[i] != 0 && hidpi_enabled; i += 2) {
_cleanup_free_ gchar *size_str = NULL;
_cleanup_free_ gchar *ss_dir = NULL;
size_str = g_strdup_printf ("%ix%i",
@@ -1010,7 +927,7 @@ asb_context_write_xml (AsbContext *ctx, GError **error)
g_print ("Writing %s...\n", filename);
as_store_set_origin (store, priv->origin);
as_store_set_api_version (store, priv->api_version);
- if (priv->add_cache_id) {
+ if (priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) {
_cleanup_free_ gchar *builder_id = asb_utils_get_builder_id ();
as_store_set_builder_id (store, builder_id);
}
@@ -1033,7 +950,7 @@ asb_context_convert_icons (AsbContext *ctx, GError **error)
GList *l;
/* not enabled */
- if (!asb_context_get_embedded_icons (ctx))
+ if ((priv->flags & ASB_CONTEXT_FLAG_EMBEDDED_ICONS) == 0)
return TRUE;
/* convert each one before saving resources */
@@ -1232,6 +1149,10 @@ asb_context_write_xml_fail (AsbContext *ctx, GError **error)
_cleanup_free_ gchar *filename = NULL;
_cleanup_object_unref_ GFile *file = NULL;
+ /* no need to create */
+ if ((priv->flags & ASB_CONTEXT_FLAG_INCLUDE_FAILED) == 0)
+ return TRUE;
+
for (l = priv->apps; l != NULL; l = l->next) {
app = AS_APP (l->data);
if (!ASB_IS_APP (app))
@@ -1253,7 +1174,7 @@ asb_context_write_xml_fail (AsbContext *ctx, GError **error)
basename_failed = g_strdup_printf ("%s-failed", priv->origin);
as_store_set_origin (priv->store_failed, basename_failed);
as_store_set_api_version (priv->store_failed, priv->api_version);
- if (priv->add_cache_id) {
+ if (priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) {
_cleanup_free_ gchar *builder_id = asb_utils_get_builder_id ();
as_store_set_builder_id (priv->store_failed, builder_id);
}
@@ -1277,7 +1198,7 @@ asb_context_write_xml_ignore (AsbContext *ctx, GError **error)
_cleanup_object_unref_ GFile *file = NULL;
/* no need to create */
- if (!priv->add_cache_id)
+ if ((priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) == 0)
return TRUE;
/* the store is already populated */
@@ -1289,7 +1210,7 @@ asb_context_write_xml_ignore (AsbContext *ctx, GError **error)
basename_cache = g_strdup_printf ("%s-ignore", priv->origin);
as_store_set_origin (priv->store_ignore, basename_cache);
as_store_set_api_version (priv->store_ignore, priv->api_version);
- if (priv->add_cache_id) {
+ if (priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) {
_cleanup_free_ gchar *builder_id = asb_utils_get_builder_id ();
as_store_set_builder_id (priv->store_ignore, builder_id);
}
@@ -1369,7 +1290,6 @@ asb_context_disable_multiarch_pkgs (AsbContext *ctx)
/**
* asb_context_process:
* @ctx: A #AsbContext
- * @flags: Some #AsbContextProcessFlags, e.g. %AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_PARENTS
* @error: A #GError or %NULL
*
* Processes all the packages that have been added to the context.
@@ -1379,7 +1299,7 @@ asb_context_disable_multiarch_pkgs (AsbContext *ctx)
* Since: 0.1.0
**/
gboolean
-asb_context_process (AsbContext *ctx, AsbContextProcessFlags flags, GError **error)
+asb_context_process (AsbContext *ctx, GError **error)
{
AsbContextPrivate *priv = GET_PRIVATE (ctx);
AsbPackage *pkg;
@@ -1448,11 +1368,11 @@ asb_context_process (AsbContext *ctx, AsbContextProcessFlags flags, GError **err
asb_plugin_loader_merge (priv->plugin_loader, priv->apps);
/* print any warnings */
- if ((flags & AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_INFO) == 0) {
+ if ((priv->flags & ASB_CONTEXT_FLAG_IGNORE_MISSING_INFO) == 0) {
if (!asb_context_detect_missing_data (ctx, error))
return FALSE;
}
- if ((flags & AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_PARENTS) == 0) {
+ if ((priv->flags & ASB_CONTEXT_FLAG_IGNORE_MISSING_PARENTS) == 0) {
if (!asb_context_detect_missing_parents (ctx, error))
return FALSE;
}
@@ -1600,7 +1520,7 @@ asb_context_add_app_ignore (AsbContext *ctx, AsbPackage *pkg)
_cleanup_ptrarray_unref_ GPtrArray *apps = NULL;
/* only do this when we are using a cache-id */
- if (!priv->add_cache_id)
+ if ((priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) == 0)
return;
/* check not already added a dummy application for this package */
diff --git a/libappstream-builder/asb-context.h b/libappstream-builder/asb-context.h
index bf963b3..7f4adeb 100644
--- a/libappstream-builder/asb-context.h
+++ b/libappstream-builder/asb-context.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -59,20 +59,30 @@ struct _AsbContextClass
};
/**
- * AsbContextProcessFlags:
- * @AS_CONTEXT_PARSE_FLAG_NONE: No special actions to use
- * @AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_INFO: Ignore missing information
- * @AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_PARENTS: Ignore missing parents
+ * AsbContextFlags:
+ * @ASB_CONTEXT_FLAG_NONE: No special actions to use
+ * @ASB_CONTEXT_FLAG_IGNORE_MISSING_INFO: Ignore missing information
+ * @ASB_CONTEXT_FLAG_IGNORE_MISSING_PARENTS: Ignore missing parents
+ * @ASB_CONTEXT_FLAG_ADD_CACHE_ID: Add cache ID to reuse metadata
+ * @ASB_CONTEXT_FLAG_HIDPI_ICONS: Include HiDPI icons
+ * @ASB_CONTEXT_FLAG_EMBEDDED_ICONS: Embed the icons in the XML
+ * @ASB_CONTEXT_FLAG_NO_NETWORK: Do not download files
+ * @ASB_CONTEXT_FLAG_INCLUDE_FAILED: Write the origin-ignore.xml file
*
* The flags to use when processing the context.
**/
typedef enum {
- AS_CONTEXT_PARSE_FLAG_NONE,
- AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_INFO = 1, /* Since: 0.3.2 */
- AS_CONTEXT_PARSE_FLAG_IGNORE_MISSING_PARENTS = 2, /* Since: 0.3.2 */
+ ASB_CONTEXT_FLAG_NONE,
+ ASB_CONTEXT_FLAG_IGNORE_MISSING_INFO = 0, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_IGNORE_MISSING_PARENTS = 1 << 0, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_ADD_CACHE_ID = 1 << 1, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_HIDPI_ICONS = 1 << 2, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_EMBEDDED_ICONS = 1 << 3, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_NO_NETWORK = 1 << 4, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_INCLUDE_FAILED = 1 << 5, /* Since: 0.3.5 */
/*< private >*/
- AS_CONTEXT_PARSE_FLAG_LAST,
-} AsbContextProcessFlags;
+ ASB_CONTEXT_FLAG_LAST,
+} AsbContextFlags;
GType asb_context_get_type (void);
@@ -83,16 +93,10 @@ void asb_context_add_app (AsbContext *ctx,
AsbApp *app);
void asb_context_add_app_ignore (AsbContext *ctx,
AsbPackage *pkg);
-void asb_context_set_no_net (AsbContext *ctx,
- gboolean no_net);
void asb_context_set_api_version (AsbContext *ctx,
gdouble api_version);
-void asb_context_set_add_cache_id (AsbContext *ctx,
- gboolean add_cache_id);
-void asb_context_set_hidpi_enabled (AsbContext *ctx,
- gboolean hidpi_enabled);
-void asb_context_set_embedded_icons (AsbContext *ctx,
- gboolean embedded_icons);
+void asb_context_set_flags (AsbContext *ctx,
+ AsbContextFlags flags);
void asb_context_set_max_threads (AsbContext *ctx,
guint max_threads);
void asb_context_set_min_icon_size (AsbContext *ctx,
@@ -122,17 +126,15 @@ void asb_context_set_basename (AsbContext *ctx,
void asb_context_set_origin (AsbContext *ctx,
const gchar *origin);
const gchar *asb_context_get_temp_dir (AsbContext *ctx);
-gboolean asb_context_get_add_cache_id (AsbContext *ctx);
-gboolean asb_context_get_hidpi_enabled (AsbContext *ctx);
-gboolean asb_context_get_embedded_icons (AsbContext *ctx);
-gboolean asb_context_get_no_net (AsbContext *ctx);
+AsbContextFlags asb_context_get_flags (AsbContext *ctx);
+gboolean asb_context_get_flag (AsbContext *ctx,
+ AsbContextFlags flag);
gdouble asb_context_get_api_version (AsbContext *ctx);
guint asb_context_get_min_icon_size (AsbContext *ctx);
gboolean asb_context_setup (AsbContext *ctx,
GError **error);
gboolean asb_context_process (AsbContext *ctx,
- AsbContextProcessFlags flags,
GError **error);
void asb_context_add_package (AsbContext *ctx,
AsbPackage *pkg);
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c
index 9d9ecdf..be488c7 100644
--- a/libappstream-builder/asb-self-test.c
+++ b/libappstream-builder/asb-self-test.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -223,19 +223,18 @@ asb_test_plugin_loader_func (void)
/* get the list of globs */
globs = asb_plugin_loader_get_globs (loader);\
- g_assert_cmpint (globs->len, ==, 45);
+ g_assert_cmpint (globs->len, >=, 44);
g_assert_cmpstr (asb_glob_value_search (globs, "/usr/share/applications/gimp.desktop"), ==, "");
g_assert_cmpstr (asb_glob_value_search (globs, "/files/share/applications/gimp.desktop"), ==, "");
g_assert_cmpstr (asb_glob_value_search (globs, "/srv/dave.txt"), ==, NULL);
/* get the list of plugins */
plugins = asb_plugin_loader_get_plugins (loader);
- g_assert_cmpint (plugins->len, ==, 18);
+ g_assert_cmpint (plugins->len, >=, 17);
plugin = g_ptr_array_index (plugins, 0);
g_assert (plugin != NULL);
g_assert (plugin->module != NULL);
g_assert (plugin->enabled);
- g_assert_cmpstr (plugin->name, ==, "ostree");
g_assert (plugin->ctx == ctx);
/* match the correct one */
@@ -284,12 +283,13 @@ asb_test_context_test_func (AsbTestContextMode mode)
/* set up the context */
ctx = asb_context_new ();
- g_assert (!asb_context_get_add_cache_id (ctx));
+ g_assert (!asb_context_get_flag (ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID));
asb_context_set_max_threads (ctx, 1);
asb_context_set_api_version (ctx, 0.8);
- asb_context_set_add_cache_id (ctx, TRUE);
- asb_context_set_no_net (ctx, TRUE);
- asb_context_set_hidpi_enabled (ctx, TRUE);
+ asb_context_set_flags (ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID |
+ ASB_CONTEXT_FLAG_NO_NETWORK |
+ ASB_CONTEXT_FLAG_INCLUDE_FAILED |
+ ASB_CONTEXT_FLAG_HIDPI_ICONS);
asb_context_set_basename (ctx, "appstream");
asb_context_set_origin (ctx, "asb-self-test");
asb_context_set_cache_dir (ctx, "/tmp/asbuilder/cache");
@@ -309,7 +309,7 @@ asb_test_context_test_func (AsbTestContextMode mode)
default:
break;
}
- g_assert (asb_context_get_add_cache_id (ctx));
+ g_assert (asb_context_get_flag (ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID));
g_assert_cmpstr (asb_context_get_temp_dir (ctx), ==, "/tmp/asbuilder/temp");
ret = asb_context_setup (ctx, &error);
g_assert_no_error (error);
@@ -340,7 +340,7 @@ asb_test_context_test_func (AsbTestContextMode mode)
}
/* run the plugins */
- ret = asb_context_process (ctx, AS_CONTEXT_PARSE_FLAG_NONE, &error);
+ ret = asb_context_process (ctx, &error);
g_assert_no_error (error);
g_assert (ret);
@@ -771,9 +771,9 @@ asb_test_context_extra_appstream_func (void)
asb_context_set_extra_appstream (ctx, extra_appdata);
asb_context_set_max_threads (ctx, 1);
asb_context_set_api_version (ctx, 0.8);
- asb_context_set_add_cache_id (ctx, TRUE);
- asb_context_set_no_net (ctx, TRUE);
- asb_context_set_hidpi_enabled (ctx, TRUE);
+ asb_context_set_flags (ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID |
+ ASB_CONTEXT_FLAG_NO_NETWORK |
+ ASB_CONTEXT_FLAG_HIDPI_ICONS);
asb_context_set_basename (ctx, "appstream");
asb_context_set_origin (ctx, "asb-self-test");
asb_context_set_cache_dir (ctx, "/tmp/asbuilder/cache");
@@ -784,7 +784,7 @@ asb_test_context_extra_appstream_func (void)
g_assert (ret);
/* run the plugins */
- ret = asb_context_process (ctx, AS_CONTEXT_PARSE_FLAG_NONE, &error);
+ ret = asb_context_process (ctx, &error);
g_assert_no_error (error);
g_assert (ret);
diff --git a/libappstream-builder/asb-task.c b/libappstream-builder/asb-task.c
index 42fb671..1bf26b6 100644
--- a/libappstream-builder/asb-task.c
+++ b/libappstream-builder/asb-task.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -399,7 +399,7 @@ asb_task_process (AsbTask *task, GError **error_not_used)
}
/* set cache-id in case we want to use the metadata directly */
- if (asb_context_get_add_cache_id (priv->ctx)) {
+ if (asb_context_get_flag (priv->ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID)) {
cache_id = asb_utils_get_cache_id_for_filename (priv->filename);
as_app_add_metadata (AS_APP (app),
"X-CacheID",
@@ -429,7 +429,7 @@ asb_task_process (AsbTask *task, GError **error_not_used)
skip:
/* add a dummy element to the AppStream metadata so that we don't keep
* parsing this every time */
- if (asb_context_get_add_cache_id (priv->ctx) && nr_added == 0)
+ if (asb_context_get_flag (priv->ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID) && nr_added == 0)
asb_context_add_app_ignore (priv->ctx, priv->pkg);
/* delete tree */
diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c
index 41d5c0e..06eea1c 100644
--- a/libappstream-builder/plugins/asb-plugin-appdata.c
+++ b/libappstream-builder/plugins/asb-plugin-appdata.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -199,7 +199,7 @@ asb_plugin_appdata_load_url (AsbPlugin *plugin,
as_app_get_id_filename (AS_APP (app)),
basename);
if (!g_file_test (cache_filename, G_FILE_TEST_EXISTS)) {
- if (asb_context_get_no_net (plugin->ctx)) {
+ if (asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_NO_NETWORK)) {
asb_package_log (asb_app_get_package (app),
ASB_PACKAGE_LOG_LEVEL_WARNING,
"Could not download %s as no network", url);
diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c
index ef82929..44da4fa 100644
--- a/libappstream-builder/plugins/asb-plugin-desktop.c
+++ b/libappstream-builder/plugins/asb-plugin-desktop.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -250,7 +250,7 @@ asb_plugin_desktop_add_icons (AsbPlugin *plugin,
}
/* save in target directory */
- if (asb_context_get_hidpi_enabled (plugin->ctx)) {
+ if (asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS)) {
name = g_strdup_printf ("%ix%i/%s.png",
64, 64,
as_app_get_id_filename (AS_APP (app)));
@@ -266,7 +266,7 @@ asb_plugin_desktop_add_icons (AsbPlugin *plugin,
as_app_add_icon (AS_APP (app), icon);
/* is HiDPI disabled */
- if (!asb_context_get_hidpi_enabled (plugin->ctx))
+ if (!asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS))
return TRUE;
/* try to get a HiDPI icon */
@@ -321,7 +321,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
/* create app */
app_id = g_path_get_basename (filename);
app = asb_app_new (pkg, app_id);
- asb_app_set_hidpi_enabled (app, asb_context_get_hidpi_enabled (plugin->ctx));
+ asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
full_filename = g_build_filename (tmpdir, filename, NULL);
ret = as_app_parse_file (AS_APP (app),
full_filename,
diff --git a/libappstream-builder/plugins/asb-plugin-font.c b/libappstream-builder/plugins/asb-plugin-font.c
index 0407ff2..0305ae6 100644
--- a/libappstream-builder/plugins/asb-plugin-font.c
+++ b/libappstream-builder/plugins/asb-plugin-font.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -643,7 +643,7 @@ asb_plugin_font_app (AsbPlugin *plugin, AsbApp *app,
}
/* add icon */
- if (asb_context_get_hidpi_enabled (plugin->ctx)) {
+ if (asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS)) {
icon_filename = g_strdup_printf ("64x64/%s.png",
as_app_get_id_filename (AS_APP (app)));
} else {
diff --git a/libappstream-builder/plugins/asb-plugin-gstreamer.c b/libappstream-builder/plugins/asb-plugin-gstreamer.c
index c5fa518..8d6b4fb 100644
--- a/libappstream-builder/plugins/asb-plugin-gstreamer.c
+++ b/libappstream-builder/plugins/asb-plugin-gstreamer.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -160,7 +160,7 @@ asb_plugin_process (AsbPlugin *plugin,
as_app_set_id_kind (AS_APP (app), AS_ID_KIND_CODEC);
as_app_set_name (AS_APP (app), "C", "GStreamer Multimedia Codecs", -1);
asb_app_set_requires_appdata (app, TRUE);
- asb_app_set_hidpi_enabled (app, asb_context_get_hidpi_enabled (plugin->ctx));
+ asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
as_app_add_category (AS_APP (app), "Addons", -1);
as_app_add_category (AS_APP (app), "Codecs", -1);
diff --git a/libappstream-builder/plugins/asb-plugin-ibus-sql.c b/libappstream-builder/plugins/asb-plugin-ibus-sql.c
index 0ba77dc..ca7a973 100644
--- a/libappstream-builder/plugins/asb-plugin-ibus-sql.c
+++ b/libappstream-builder/plugins/asb-plugin-ibus-sql.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -204,7 +204,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
}
}
asb_app_set_requires_appdata (app, TRUE);
- asb_app_set_hidpi_enabled (app, asb_context_get_hidpi_enabled (plugin->ctx));
+ asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
/* add icon */
icon = as_icon_new ();
diff --git a/libappstream-builder/plugins/asb-plugin-ibus-xml.c b/libappstream-builder/plugins/asb-plugin-ibus-xml.c
index 0f3ac67..d3f8437 100644
--- a/libappstream-builder/plugins/asb-plugin-ibus-xml.c
+++ b/libappstream-builder/plugins/asb-plugin-ibus-xml.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -122,7 +122,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
as_app_add_category (AS_APP (app), "Addons", -1);
as_app_add_category (AS_APP (app), "InputSources", -1);
asb_app_set_requires_appdata (app, TRUE);
- asb_app_set_hidpi_enabled (app, asb_context_get_hidpi_enabled (plugin->ctx));
+ asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
/* add icon */
icon = as_icon_new ();
diff --git a/libappstream-builder/plugins/asb-plugin-metainfo.c b/libappstream-builder/plugins/asb-plugin-metainfo.c
index 0cb7b82..9a3f2e1 100644
--- a/libappstream-builder/plugins/asb-plugin-metainfo.c
+++ b/libappstream-builder/plugins/asb-plugin-metainfo.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
@@ -89,7 +89,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
return FALSE;
}
asb_app_set_requires_appdata (app, FALSE);
- asb_app_set_hidpi_enabled (app, asb_context_get_hidpi_enabled (plugin->ctx));
+ asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
asb_plugin_add_app (apps, AS_APP (app));
return TRUE;
}