diff options
author | Richard Hughes <richard@hughsie.com> | 2017-02-27 09:44:42 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2017-02-27 11:36:28 +0000 |
commit | 96c0cb0498790b04f4918264d230cf67e8cf1f03 (patch) | |
tree | 0db2e07b57163b45e4f16e0892c0f1bcb570286c | |
parent | 407d3839fe54d4f7f130f77141b8b8a1c114e056 (diff) | |
download | appstream-glib-96c0cb0498790b04f4918264d230cf67e8cf1f03.tar.gz |
trivial: Use the new AsFormatKind defines
No code changes, and ensure we don't break API/ABI by using #define's.
-rw-r--r-- | client/as-util.c | 54 | ||||
-rw-r--r-- | libappstream-glib/as-app-validate.c | 44 | ||||
-rw-r--r-- | libappstream-glib/as-app.c | 108 | ||||
-rw-r--r-- | libappstream-glib/as-app.h | 30 | ||||
-rw-r--r-- | libappstream-glib/as-node-private.h | 8 | ||||
-rw-r--r-- | libappstream-glib/as-node.c | 20 | ||||
-rw-r--r-- | libappstream-glib/as-release.c | 2 | ||||
-rw-r--r-- | libappstream-glib/as-self-test.c | 42 | ||||
-rw-r--r-- | libappstream-glib/as-store-cab.c | 2 | ||||
-rw-r--r-- | libappstream-glib/as-store.c | 52 | ||||
-rw-r--r-- | libappstream-glib/as-utils.c | 8 |
11 files changed, 161 insertions, 209 deletions
diff --git a/client/as-util.c b/client/as-util.c index c913934..78736ac 100644 --- a/client/as-util.c +++ b/client/as-util.c @@ -512,8 +512,8 @@ as_util_convert_appstream (GFile *file_input, static gboolean as_util_convert (AsUtilPrivate *priv, gchar **values, GError **error) { - AsAppSourceKind input_kind; - AsAppSourceKind output_kind; + AsFormatKind input_kind; + AsFormatKind output_kind; gdouble new_version; g_autoptr(GFile) file_input = NULL; g_autoptr(GFile) file_output = NULL; @@ -530,15 +530,15 @@ as_util_convert (AsUtilPrivate *priv, gchar **values, GError **error) } /* work out what to do */ - input_kind = as_app_guess_source_kind (values[0]); - output_kind = as_app_guess_source_kind (values[1]); + input_kind = as_format_guess_kind (values[0]); + output_kind = as_format_guess_kind (values[1]); file_input = g_file_new_for_path (values[0]); file_output = g_file_new_for_path (values[1]); new_version = g_ascii_strtod (values[2], NULL); /* AppData -> AppData */ - if (input_kind == AS_APP_SOURCE_KIND_APPDATA && - output_kind == AS_APP_SOURCE_KIND_APPDATA) { + if (input_kind == AS_FORMAT_KIND_APPDATA && + output_kind == AS_FORMAT_KIND_APPDATA) { return as_util_convert_appdata (file_input, file_output, new_version, @@ -546,8 +546,8 @@ as_util_convert (AsUtilPrivate *priv, gchar **values, GError **error) } /* AppStream -> AppStream */ - if (input_kind == AS_APP_SOURCE_KIND_APPSTREAM && - output_kind == AS_APP_SOURCE_KIND_APPSTREAM) { + if (input_kind == AS_FORMAT_KIND_APPSTREAM && + output_kind == AS_FORMAT_KIND_APPSTREAM) { return as_util_convert_appstream (file_input, file_output, new_version, @@ -561,8 +561,8 @@ as_util_convert (AsUtilPrivate *priv, gchar **values, GError **error) /* TRANSLATORS: the %s and %s are file types, * e.g. "appdata" to "appstream" */ _("Conversion %s to %s is not implemented"), - as_app_source_kind_to_string (input_kind), - as_app_source_kind_to_string (output_kind)); + as_format_kind_to_string (input_kind), + as_format_kind_to_string (output_kind)); return FALSE; } @@ -585,15 +585,14 @@ as_util_upgrade (AsUtilPrivate *priv, gchar **values, GError **error) /* process each file */ for (i = 0; values[i] != NULL; i++) { g_autoptr(GFile) file = NULL; - AsAppSourceKind source_kind; - source_kind = as_app_guess_source_kind (values[i]); - switch (source_kind) { - case AS_APP_SOURCE_KIND_APPDATA: + AsFormatKind format_kind = as_format_guess_kind (values[i]); + switch (format_kind) { + case AS_FORMAT_KIND_APPDATA: file = g_file_new_for_path (values[i]); if (!as_util_convert_appdata (file, file, 0.8, error)) return FALSE; break; - case AS_APP_SOURCE_KIND_APPSTREAM: + case AS_FORMAT_KIND_APPSTREAM: file = g_file_new_for_path (values[i]); if (!as_util_convert_appstream (file, file, 0.8, error)) return FALSE; @@ -605,7 +604,7 @@ as_util_upgrade (AsUtilPrivate *priv, gchar **values, GError **error) /* TRANSLATORS: %s is a file type, * e.g. 'appdata' */ _("File format '%s' cannot be upgraded"), - as_app_source_kind_to_string (source_kind)); + as_format_kind_to_string (format_kind)); return FALSE; } } @@ -641,7 +640,7 @@ as_util_appdata_to_news (AsUtilPrivate *priv, gchar **values, GError **error) g_print ("\n\n"); /* check types */ - if (as_app_guess_source_kind (values[f]) != AS_APP_SOURCE_KIND_APPDATA) { + if (as_format_guess_kind (values[f]) != AS_FORMAT_KIND_APPDATA) { g_set_error_literal (error, AS_ERROR, AS_ERROR_INVALID_ARGUMENTS, @@ -1038,8 +1037,8 @@ as_util_appdata_from_desktop (AsUtilPrivate *priv, gchar **values, GError **erro } /* check types */ - if (as_app_guess_source_kind (values[0]) != AS_APP_SOURCE_KIND_DESKTOP || - as_app_guess_source_kind (values[1]) != AS_APP_SOURCE_KIND_APPDATA) { + if (as_format_guess_kind (values[0]) != AS_FORMAT_KIND_DESKTOP || + as_format_guess_kind (values[1]) != AS_FORMAT_KIND_APPDATA) { g_set_error_literal (error, AS_ERROR, AS_ERROR_INVALID_ARGUMENTS, @@ -1124,18 +1123,17 @@ as_util_add_file_to_store (AsStore *store, const gchar *filename, GError **error g_autoptr(AsApp) app = NULL; g_autoptr(GFile) file_input = NULL; - switch (as_app_guess_source_kind (filename)) { - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: - case AS_APP_SOURCE_KIND_DESKTOP: - case AS_APP_SOURCE_KIND_INF: + switch (as_format_guess_kind (filename)) { + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: + case AS_FORMAT_KIND_DESKTOP: app = as_app_new (); if (!as_app_parse_file (app, filename, AS_APP_PARSE_FLAG_USE_HEURISTICS, error)) return FALSE; as_store_add_app (store, app); break; - case AS_APP_SOURCE_KIND_APPSTREAM: + case AS_FORMAT_KIND_APPSTREAM: /* load file */ file_input = g_file_new_for_path (filename); if (!as_store_from_file (store, file_input, NULL, NULL, error)) @@ -2780,7 +2778,7 @@ as_util_validate_file (const gchar *filename, /* is AppStream */ g_print ("%s: ", filename); - if (as_app_guess_source_kind (filename) == AS_APP_SOURCE_KIND_APPSTREAM) { + if (as_format_guess_kind (filename) == AS_FORMAT_KIND_APPSTREAM) { gboolean ret; g_autoptr(AsStore) store = NULL; g_autoptr(GFile) file = NULL; @@ -2975,11 +2973,11 @@ as_util_check_root_app (AsApp *app, GPtrArray *problems) g_autoptr(GError) error_local = NULL; /* skip */ - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_METAINFO) + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_METAINFO) return; /* relax this for now */ - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_DESKTOP) + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_DESKTOP) return; /* check one line summary */ diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c index 8c67792..afdaab9 100644 --- a/libappstream-glib/as-app-validate.c +++ b/libappstream-glib/as-app-validate.c @@ -765,11 +765,11 @@ as_app_validate_screenshots (AsApp *app, AsAppValidateHelper *helper) number_screenshots_min = 0; /* metainfo and inf do not require any screenshots */ - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_METAINFO) + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_METAINFO) number_screenshots_min = 0; /* only for AppData and AppStream */ - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_DESKTOP) + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_DESKTOP) return; screenshots = as_app_get_screenshots (app); @@ -882,8 +882,8 @@ as_app_validate_releases (AsApp *app, AsAppValidateHelper *helper, GError **erro GPtrArray *releases; /* only for AppData */ - if (as_app_get_source_kind (app) != AS_APP_SOURCE_KIND_APPDATA && - as_app_get_source_kind (app) != AS_APP_SOURCE_KIND_METAINFO) + if (as_app_get_source_kind (app) != AS_FORMAT_KIND_APPDATA && + as_app_get_source_kind (app) != AS_FORMAT_KIND_METAINFO) return TRUE; releases = as_app_get_releases (app); @@ -1111,8 +1111,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) require_sentence_case = FALSE; require_translation = FALSE; switch (as_app_get_source_kind (app)) { - case AS_APP_SOURCE_KIND_METAINFO: - case AS_APP_SOURCE_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: require_name = FALSE; break; default: @@ -1132,8 +1132,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* addons don't need such a long description */ switch (as_app_get_source_kind (app)) { - case AS_APP_SOURCE_KIND_METAINFO: - case AS_APP_SOURCE_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: number_para_min = 1; break; default: @@ -1212,8 +1212,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) } if (license == NULL) { switch (as_app_get_source_kind (app)) { - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_MISSING, "<metadata_license> is not present"); @@ -1239,8 +1239,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) } if (require_project_license && license == NULL) { switch (as_app_get_source_kind (app)) { - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_MISSING, "<project_license> is not present"); @@ -1252,7 +1252,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* translation */ if (require_translation && - as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPDATA && + as_app_get_source_kind (app) == AS_FORMAT_KIND_APPDATA && as_app_get_translations (app)->len == 0) { ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_MISSING, @@ -1261,7 +1261,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* pkgname */ if (as_app_get_pkgname_default (app) != NULL && - as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_METAINFO) { + as_app_get_source_kind (app) == AS_FORMAT_KIND_METAINFO) { ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_INVALID, "<pkgname> not allowed in metainfo"); @@ -1269,7 +1269,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* appdata */ if (as_app_get_icon_default (app) != NULL && - as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPDATA && + as_app_get_source_kind (app) == AS_FORMAT_KIND_APPDATA && as_app_get_kind (app) == AS_APP_KIND_DESKTOP) { ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_INVALID, @@ -1279,7 +1279,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* extends */ if (as_app_get_extends(app)->len == 0 && as_app_get_kind (app) == AS_APP_KIND_ADDON && - as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_METAINFO) { + as_app_get_source_kind (app) == AS_FORMAT_KIND_METAINFO) { ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_MISSING, "<extends> is not present"); @@ -1301,8 +1301,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) } if (require_contactdetails && update_contact == NULL) { switch (as_app_get_source_kind (app)) { - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_MISSING, "<update_contact> is not present"); @@ -1314,8 +1314,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* only found for files */ problems = as_app_get_problems (app); - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPDATA || - as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_METAINFO) { + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_APPDATA || + as_app_get_source_kind (app) == AS_FORMAT_KIND_METAINFO) { if ((problems & AS_APP_PROBLEM_NO_XML_HEADER) > 0) { ai_app_validate_add (helper, AS_PROBLEM_KIND_MARKUP_INVALID, @@ -1580,8 +1580,8 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) /* require homepage */ if (require_url && as_app_get_url_item (app, AS_URL_KIND_HOMEPAGE) == NULL) { switch (as_app_get_source_kind (app)) { - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: ai_app_validate_add (helper, AS_PROBLEM_KIND_TAG_MISSING, "<url> is not present"); diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index e8e9ac9..a5d96a8 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -90,7 +90,7 @@ typedef struct GPtrArray *suggests; /* of AsSuggest */ GPtrArray *requires; /* of AsRequire */ GPtrArray *vetos; /* of AsRefString */ - AsAppSourceKind source_kind; + AsFormatKind source_kind; AsAppScope scope; AsAppMergeKind merge_kind; AsAppState state; @@ -242,29 +242,19 @@ as_app_kind_from_string (const gchar *kind) * * Converts the text representation to an enumerated value. * - * Return value: A #AsAppSourceKind, e.g. %AS_APP_SOURCE_KIND_APPSTREAM. + * Return value: A #AsFormatKind, e.g. %AS_FORMAT_KIND_APPSTREAM. * * Since: 0.2.2 **/ -AsAppSourceKind +AsFormatKind as_app_source_kind_from_string (const gchar *source_kind) { - if (g_strcmp0 (source_kind, "appstream") == 0) - return AS_APP_SOURCE_KIND_APPSTREAM; - if (g_strcmp0 (source_kind, "appdata") == 0) - return AS_APP_SOURCE_KIND_APPDATA; - if (g_strcmp0 (source_kind, "metainfo") == 0) - return AS_APP_SOURCE_KIND_METAINFO; - if (g_strcmp0 (source_kind, "desktop") == 0) - return AS_APP_SOURCE_KIND_DESKTOP; - if (g_strcmp0 (source_kind, "inf") == 0) - return AS_APP_SOURCE_KIND_INF; - return AS_APP_SOURCE_KIND_UNKNOWN; + return as_format_kind_from_string (source_kind); } /** * as_app_source_kind_to_string: - * @source_kind: the #AsAppSourceKind. + * @source_kind: the #AsFormatKind. * * Converts the enumerated value to an text representation. * @@ -273,19 +263,9 @@ as_app_source_kind_from_string (const gchar *source_kind) * Since: 0.2.2 **/ const gchar * -as_app_source_kind_to_string (AsAppSourceKind source_kind) -{ - if (source_kind == AS_APP_SOURCE_KIND_APPSTREAM) - return "appstream"; - if (source_kind == AS_APP_SOURCE_KIND_APPDATA) - return "appdata"; - if (source_kind == AS_APP_SOURCE_KIND_METAINFO) - return "metainfo"; - if (source_kind == AS_APP_SOURCE_KIND_DESKTOP) - return "desktop"; - if (source_kind == AS_APP_SOURCE_KIND_INF) - return "inf"; - return NULL; +as_app_source_kind_to_string (AsFormatKind source_kind) +{ + return as_format_kind_to_string (source_kind); } /** @@ -418,40 +398,14 @@ as_app_merge_kind_to_string (AsAppMergeKind merge_kind) * * Guesses the source kind based from the filename. * - * Return value: A #AsAppSourceKind, e.g. %AS_APP_SOURCE_KIND_APPSTREAM. + * Return value: A #AsFormatKind, e.g. %AS_FORMAT_KIND_APPSTREAM. * * Since: 0.1.8 **/ -AsAppSourceKind +AsFormatKind as_app_guess_source_kind (const gchar *filename) { - if (g_str_has_suffix (filename, ".xml.gz")) - return AS_APP_SOURCE_KIND_APPSTREAM; - if (g_str_has_suffix (filename, ".yml")) - return AS_APP_SOURCE_KIND_APPSTREAM; - if (g_str_has_suffix (filename, ".yml.gz")) - return AS_APP_SOURCE_KIND_APPSTREAM; -#ifdef HAVE_GCAB - if (g_str_has_suffix (filename, ".cab")) - return AS_APP_SOURCE_KIND_APPSTREAM; -#endif - if (g_str_has_suffix (filename, ".desktop")) - return AS_APP_SOURCE_KIND_DESKTOP; - if (g_str_has_suffix (filename, ".desktop.in")) - return AS_APP_SOURCE_KIND_DESKTOP; - if (g_str_has_suffix (filename, ".appdata.xml")) - return AS_APP_SOURCE_KIND_APPDATA; - if (g_str_has_suffix (filename, ".appdata.xml.in")) - return AS_APP_SOURCE_KIND_APPDATA; - if (g_str_has_suffix (filename, ".metainfo.xml")) - return AS_APP_SOURCE_KIND_METAINFO; - if (g_str_has_suffix (filename, ".metainfo.xml.in")) - return AS_APP_SOURCE_KIND_METAINFO; - if (g_str_has_suffix (filename, ".xml")) - return AS_APP_SOURCE_KIND_APPSTREAM; - if (g_str_has_suffix (filename, ".inf")) - return AS_APP_SOURCE_KIND_INF; - return AS_APP_SOURCE_KIND_UNKNOWN; + return as_format_guess_kind (filename); } static void @@ -1552,7 +1506,7 @@ as_app_get_description_size (AsApp *app) * * Since: 0.1.4 **/ -AsAppSourceKind +AsFormatKind as_app_get_source_kind (AsApp *app) { AsAppPrivate *priv = GET_PRIVATE (app); @@ -1973,7 +1927,7 @@ as_app_get_origin (AsApp *app) * * Gets the source filename the instance was populated from. * - * NOTE: this is not set for %AS_APP_SOURCE_KIND_APPSTREAM entries. + * NOTE: this is not set for %AS_FORMAT_KIND_APPSTREAM entries. * * Returns: string, or %NULL if unset * @@ -2084,14 +2038,14 @@ as_app_set_id (AsApp *app, const gchar *id) /** * as_app_set_source_kind: * @app: a #AsApp instance. - * @source_kind: the #AsAppSourceKind. + * @source_kind: the #AsFormatKind. * * Sets the source kind. * * Since: 0.1.4 **/ void -as_app_set_source_kind (AsApp *app, AsAppSourceKind source_kind) +as_app_set_source_kind (AsApp *app, AsFormatKind source_kind) { AsAppPrivate *priv = GET_PRIVATE (app); priv->source_kind = source_kind; @@ -3571,9 +3525,9 @@ as_app_subsume_private (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags) /* AppData or AppStream can overwrite the id-kind of desktop files */ if (flags & AS_APP_SUBSUME_FLAG_SOURCE_KIND) { - if ((priv->source_kind == AS_APP_SOURCE_KIND_APPDATA || - priv->source_kind == AS_APP_SOURCE_KIND_APPSTREAM) && - papp->source_kind == AS_APP_SOURCE_KIND_DESKTOP) + if ((priv->source_kind == AS_FORMAT_KIND_APPDATA || + priv->source_kind == AS_FORMAT_KIND_APPSTREAM) && + papp->source_kind == AS_FORMAT_KIND_DESKTOP) as_app_set_kind (app, priv->kind); } @@ -4210,8 +4164,8 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <metadata_license> */ - if (as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_APPDATA || - as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_METAINFO) { + if (as_node_context_get_output (ctx) == AS_FORMAT_KIND_APPDATA || + as_node_context_get_output (ctx) == AS_FORMAT_KIND_METAINFO) { if (priv->metadata_license != NULL) { as_node_insert (node_app, "metadata_license", priv->metadata_license, 0, NULL); @@ -4307,8 +4261,8 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) as_app_node_insert_languages (app, node_app); /* <update_contact> */ - if (as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_APPDATA || - as_node_context_get_output (ctx) == AS_APP_SOURCE_KIND_METAINFO || + if (as_node_context_get_output (ctx) == AS_FORMAT_KIND_APPDATA || + as_node_context_get_output (ctx) == AS_FORMAT_KIND_METAINFO || as_node_context_get_output_trusted (ctx)) { if (priv->update_contact != NULL) { as_node_insert (node_app, "update_contact", @@ -4455,7 +4409,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, case AS_TAG_DESCRIPTION: /* unwrap appdata inline */ - if (priv->source_kind == AS_APP_SOURCE_KIND_APPDATA) { + if (priv->source_kind == AS_FORMAT_KIND_APPDATA) { GError *error_local = NULL; g_autoptr(GHashTable) unwrapped = NULL; unwrapped = as_node_get_localized_unwrap (n, &error_local); @@ -5708,7 +5662,7 @@ as_app_parse_appdata_file (AsApp *app, } } ctx = as_node_context_new (); - as_node_context_set_source_kind (ctx, AS_APP_SOURCE_KIND_APPDATA); + as_node_context_set_source_kind (ctx, AS_FORMAT_KIND_APPDATA); if (!as_app_node_parse_full (app, node, flags, ctx, error)) return FALSE; @@ -5746,9 +5700,9 @@ as_app_parse_file (AsApp *app, GPtrArray *vetos; /* autodetect */ - if (priv->source_kind == AS_APP_SOURCE_KIND_UNKNOWN) { - priv->source_kind = as_app_guess_source_kind (filename); - if (priv->source_kind == AS_APP_SOURCE_KIND_UNKNOWN) { + if (priv->source_kind == AS_FORMAT_KIND_UNKNOWN) { + priv->source_kind = as_format_guess_kind (filename); + if (priv->source_kind == AS_FORMAT_KIND_UNKNOWN) { g_set_error (error, AS_APP_ERROR, AS_APP_ERROR_INVALID_TYPE, @@ -5773,12 +5727,12 @@ as_app_parse_file (AsApp *app, /* parse */ switch (priv->source_kind) { - case AS_APP_SOURCE_KIND_DESKTOP: + case AS_FORMAT_KIND_DESKTOP: if (!as_app_parse_desktop_file (app, filename, flags, error)) return FALSE; break; - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: if (!as_app_parse_appdata_file (app, filename, flags, error)) return FALSE; break; @@ -5832,7 +5786,7 @@ as_app_to_file (AsApp *app, root = as_node_new (); ctx = as_node_context_new (); as_node_context_set_version (ctx, 1.0); - as_node_context_set_output (ctx, AS_APP_SOURCE_KIND_APPDATA); + as_node_context_set_output (ctx, AS_FORMAT_KIND_APPDATA); as_app_node_insert (app, root, ctx); xml = as_node_to_xml (root, AS_NODE_TO_XML_FLAG_ADD_HEADER | diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h index bbb7249..0569abb 100644 --- a/libappstream-glib/as-app.h +++ b/libappstream-glib/as-app.h @@ -30,6 +30,7 @@ #include "as-bundle.h" #include "as-enums.h" +#include "as-format.h" #include "as-icon.h" #include "as-provide.h" #include "as-release.h" @@ -271,17 +272,16 @@ typedef enum { * @AS_APP_SOURCE_KIND_INF: Sourced from a inf file * * The source kind. + * + * This has been deprecated since 0.6.9 in favour of using AsFormatKind. **/ -typedef enum { - AS_APP_SOURCE_KIND_UNKNOWN, /* Since: 0.1.4 */ - AS_APP_SOURCE_KIND_APPSTREAM, /* Since: 0.1.4 */ - AS_APP_SOURCE_KIND_DESKTOP, /* Since: 0.1.4 */ - AS_APP_SOURCE_KIND_APPDATA, /* Since: 0.1.4 */ - AS_APP_SOURCE_KIND_METAINFO, /* Since: 0.1.7 */ - AS_APP_SOURCE_KIND_INF, /* Since: 0.3.5 (deprecated 0.6.2) */ - /*< private >*/ - AS_APP_SOURCE_KIND_LAST -} AsAppSourceKind; +typedef AsFormatKind AsAppSourceKind; +#define AS_APP_SOURCE_KIND_UNKNOWN AS_FORMAT_KIND_UNKNOWN /* Since: 0.1.4 */ +#define AS_APP_SOURCE_KIND_APPSTREAM AS_FORMAT_KIND_APPSTREAM /* Since: 0.1.4 */ +#define AS_APP_SOURCE_KIND_DESKTOP AS_FORMAT_KIND_DESKTOP /* Since: 0.1.4 */ +#define AS_APP_SOURCE_KIND_APPDATA AS_FORMAT_KIND_APPDATA /* Since: 0.1.4 */ +#define AS_APP_SOURCE_KIND_METAINFO AS_FORMAT_KIND_METAINFO /* Since: 0.1.7 */ +#define AS_APP_SOURCE_KIND_INF AS_FORMAT_KIND_UNKNOWN /* Since: 0.3.5 */ /** * AsAppKind: @@ -460,9 +460,9 @@ typedef enum __attribute__((__packed__)) { AsApp *as_app_new (void); GQuark as_app_error_quark (void); -AsAppSourceKind as_app_guess_source_kind (const gchar *filename); -AsAppSourceKind as_app_source_kind_from_string (const gchar *source_kind); -const gchar *as_app_source_kind_to_string (AsAppSourceKind source_kind); +AsFormatKind as_app_guess_source_kind (const gchar *filename); +AsFormatKind as_app_source_kind_from_string (const gchar *source_kind); +const gchar *as_app_source_kind_to_string (AsFormatKind source_kind); const gchar *as_app_state_to_string (AsAppState state); const gchar *as_app_kind_to_string (AsAppKind kind); AsAppKind as_app_kind_from_string (const gchar *kind); @@ -473,7 +473,7 @@ const gchar *as_app_merge_kind_to_string (AsAppMergeKind merge_kind); /* getters */ AsAppKind as_app_get_kind (AsApp *app); -AsAppSourceKind as_app_get_source_kind (AsApp *app); +AsFormatKind as_app_get_source_kind (AsApp *app); AsAppScope as_app_get_scope (AsApp *app); AsAppMergeKind as_app_get_merge_kind (AsApp *app); AsAppState as_app_get_state (AsApp *app); @@ -555,7 +555,7 @@ void as_app_set_id (AsApp *app, void as_app_set_kind (AsApp *app, AsAppKind kind); void as_app_set_source_kind (AsApp *app, - AsAppSourceKind source_kind); + AsFormatKind source_kind); void as_app_set_scope (AsApp *app, AsAppScope scope); void as_app_set_merge_kind (AsApp *app, diff --git a/libappstream-glib/as-node-private.h b/libappstream-glib/as-node-private.h index 56aca21..ac3630c 100644 --- a/libappstream-glib/as-node-private.h +++ b/libappstream-glib/as-node-private.h @@ -38,15 +38,15 @@ void as_node_context_free (AsNodeContext *ctx); gdouble as_node_context_get_version (AsNodeContext *ctx); void as_node_context_set_version (AsNodeContext *ctx, gdouble version); -AsAppSourceKind as_node_context_get_source_kind (AsNodeContext *ctx); +AsFormatKind as_node_context_get_source_kind (AsNodeContext *ctx); void as_node_context_set_source_kind (AsNodeContext *ctx, - AsAppSourceKind source_kind); + AsFormatKind source_kind); gboolean as_node_context_get_output_trusted (AsNodeContext *ctx); void as_node_context_set_output_trusted (AsNodeContext *ctx, gboolean output_trusted); -AsAppSourceKind as_node_context_get_output (AsNodeContext *ctx); +AsFormatKind as_node_context_get_output (AsNodeContext *ctx); void as_node_context_set_output (AsNodeContext *ctx, - AsAppSourceKind output); + AsFormatKind output); const gchar *as_node_context_get_media_base_url (AsNodeContext *ctx); void as_node_context_set_media_base_url (AsNodeContext *ctx, const gchar *url); diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c index 33899d8..83e6307 100644 --- a/libappstream-glib/as-node.c +++ b/libappstream-glib/as-node.c @@ -2047,8 +2047,8 @@ as_node_get_localized_unwrap (const AsNode *node, GError **error) /* helper struct */ struct _AsNodeContext { - AsAppSourceKind source_kind; - AsAppSourceKind output; + AsFormatKind source_kind; + AsFormatKind output; gdouble version; gboolean output_trusted; AsRefString *media_base_url; @@ -2069,8 +2069,8 @@ as_node_context_new (void) AsNodeContext *ctx; ctx = g_new0 (AsNodeContext, 1); ctx->version = 0.f; - ctx->source_kind = AS_APP_SOURCE_KIND_APPSTREAM; - ctx->output = AS_APP_SOURCE_KIND_UNKNOWN; + ctx->source_kind = AS_FORMAT_KIND_APPSTREAM; + ctx->output = AS_FORMAT_KIND_UNKNOWN; return ctx; } @@ -2133,7 +2133,7 @@ as_node_context_set_version (AsNodeContext *ctx, gdouble version) * * Since: 0.3.6 **/ -AsAppSourceKind +AsFormatKind as_node_context_get_source_kind (AsNodeContext *ctx) { return ctx->source_kind; @@ -2149,7 +2149,7 @@ as_node_context_get_source_kind (AsNodeContext *ctx) * Since: 0.3.6 **/ void -as_node_context_set_source_kind (AsNodeContext *ctx, AsAppSourceKind source_kind) +as_node_context_set_source_kind (AsNodeContext *ctx, AsFormatKind source_kind) { ctx->source_kind = source_kind; } @@ -2191,11 +2191,11 @@ as_node_context_set_output_trusted (AsNodeContext *ctx, gboolean output_trusted) * * Gets the AppStream API destination kind used when inserting nodes. * - * Returns: output format, e.g. %AS_APP_SOURCE_KIND_APPDATA + * Returns: output format, e.g. %AS_FORMAT_KIND_APPDATA * * Since: 0.3.6 **/ -AsAppSourceKind +AsFormatKind as_node_context_get_output (AsNodeContext *ctx) { return ctx->output; @@ -2204,14 +2204,14 @@ as_node_context_get_output (AsNodeContext *ctx) /** * as_node_context_set_output: (skip) * @ctx: a #AsNodeContext. - * @output: an output kind, e.g. %AS_APP_SOURCE_KIND_APPDATA + * @output: an output kind, e.g. %AS_FORMAT_KIND_APPDATA * * Sets the AppStream API destination kind used when inserting nodes. * * Since: 0.3.6 **/ void -as_node_context_set_output (AsNodeContext *ctx, AsAppSourceKind output) +as_node_context_set_output (AsNodeContext *ctx, AsFormatKind output) { ctx->output = output; } diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c index ce756a5..4aa197d 100644 --- a/libappstream-glib/as-release.c +++ b/libappstream-glib/as-release.c @@ -782,7 +782,7 @@ as_release_node_parse (AsRelease *release, GNode *node, } /* AppStream: multiple <description> tags */ - if (as_node_context_get_source_kind (ctx) == AS_APP_SOURCE_KIND_APPSTREAM) { + if (as_node_context_get_source_kind (ctx) == AS_FORMAT_KIND_APPSTREAM) { for (n = node->children; n != NULL; n = n->next) { g_autoptr(GString) xml = NULL; if (as_node_get_tag (n) != AS_TAG_DESCRIPTION) diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 4e1d976..e333cf0 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -639,7 +639,7 @@ as_test_release_appstream_func (void) /* back to node */ root = as_node_new (); as_node_context_set_version (ctx, 1.0); - as_node_context_set_source_kind (ctx, AS_APP_SOURCE_KIND_APPSTREAM); + as_node_context_set_source_kind (ctx, AS_FORMAT_KIND_APPSTREAM); n = as_release_node_insert (release, root, ctx); xml = as_node_to_xml (n, AS_NODE_TO_XML_FLAG_FORMAT_MULTILINE); ret = as_test_compare_lines (xml->str, src, &error); @@ -676,7 +676,7 @@ as_test_release_appdata_func (void) n = as_node_find (root, "release"); g_assert (n != NULL); ctx = as_node_context_new (); - as_node_context_set_source_kind (ctx, AS_APP_SOURCE_KIND_APPDATA); + as_node_context_set_source_kind (ctx, AS_FORMAT_KIND_APPDATA); ret = as_release_node_parse (release, n, ctx, &error); g_assert_no_error (error); g_assert (ret); @@ -1686,7 +1686,7 @@ as_test_app_func (void) g_assert_cmpstr (as_app_get_description (app, "pt_BR"), ==, "<p>O aplicativo Software.</p>"); g_assert_cmpstr (as_app_get_developer_name (app, NULL), ==, "GNOME Foundation"); g_assert_cmpstr (as_app_get_source_pkgname (app), ==, "gnome-software-src"); - g_assert_cmpint (as_app_get_source_kind (app), ==, AS_APP_SOURCE_KIND_UNKNOWN); + g_assert_cmpint (as_app_get_source_kind (app), ==, AS_FORMAT_KIND_UNKNOWN); g_assert_cmpstr (as_app_get_project_group (app), ==, "GNOME"); g_assert_cmpstr (as_app_get_project_license (app), ==, "GPLv2+"); g_assert_cmpstr (as_app_get_branch (app), ==, "master"); @@ -2112,7 +2112,7 @@ as_test_store_local_appdata_func (void) app = as_store_get_app_by_id (store, "broken.desktop"); g_assert (app != NULL); g_assert_cmpstr (as_app_get_name (app, "C"), ==, "Broken"); - g_assert_cmpint (as_app_get_source_kind (app), ==, AS_APP_SOURCE_KIND_APPDATA); + g_assert_cmpint (as_app_get_source_kind (app), ==, AS_FORMAT_KIND_APPDATA); } static void @@ -2165,7 +2165,7 @@ as_test_app_validate_style_func (void) as_app_add_url (app, AS_URL_KIND_UNKNOWN, "dave.com"); as_app_set_id (app, "dave.exe"); as_app_set_kind (app, AS_APP_KIND_DESKTOP); - as_app_set_source_kind (app, AS_APP_SOURCE_KIND_APPDATA); + as_app_set_source_kind (app, AS_FORMAT_KIND_APPDATA); as_app_set_metadata_license (app, "BSD"); as_app_set_project_license (app, "GPL-2.0+"); as_app_set_name (app, "C", "Test app name that is very log indeed."); @@ -3285,7 +3285,7 @@ as_test_store_merges_func (void) app_desktop = as_app_new (); as_app_set_id (app_desktop, "gimp.desktop"); - as_app_set_source_kind (app_desktop, AS_APP_SOURCE_KIND_DESKTOP); + as_app_set_source_kind (app_desktop, AS_FORMAT_KIND_DESKTOP); as_app_set_name (app_desktop, NULL, "GIMP"); as_app_set_comment (app_desktop, NULL, "GNU Bla Bla"); as_app_set_priority (app_desktop, -1); @@ -3294,7 +3294,7 @@ as_test_store_merges_func (void) app_appdata = as_app_new (); as_app_set_id (app_appdata, "gimp.desktop"); - as_app_set_source_kind (app_appdata, AS_APP_SOURCE_KIND_APPDATA); + as_app_set_source_kind (app_appdata, AS_FORMAT_KIND_APPDATA); as_app_set_description (app_appdata, NULL, "<p>Gimp is awesome</p>"); as_app_add_pkgname (app_appdata, "gimp"); as_app_set_priority (app_appdata, -1); @@ -3310,7 +3310,7 @@ as_test_store_merges_func (void) g_assert_cmpstr (as_app_get_comment (app_tmp, NULL), ==, "GNU Bla Bla"); g_assert_cmpstr (as_app_get_description (app_tmp, NULL), ==, "<p>Gimp is awesome</p>"); g_assert_cmpstr (as_app_get_pkgname_default (app_tmp), ==, "gimp"); - g_assert_cmpint (as_app_get_source_kind (app_tmp), ==, AS_APP_SOURCE_KIND_APPDATA); + g_assert_cmpint (as_app_get_source_kind (app_tmp), ==, AS_FORMAT_KIND_APPDATA); g_assert_cmpint (as_app_get_state (app_tmp), ==, AS_APP_STATE_INSTALLED); /* test desktop + appdata + appstream */ @@ -3318,7 +3318,7 @@ as_test_store_merges_func (void) app_appinfo = as_app_new (); as_app_set_id (app_appinfo, "gimp.desktop"); - as_app_set_source_kind (app_appinfo, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app_appinfo, AS_FORMAT_KIND_APPSTREAM); as_app_set_name (app_appinfo, NULL, "GIMP"); as_app_set_comment (app_appinfo, NULL, "GNU Bla Bla"); as_app_set_description (app_appinfo, NULL, "<p>Gimp is Distro</p>"); @@ -3336,7 +3336,7 @@ as_test_store_merges_func (void) g_assert_cmpstr (as_app_get_comment (app_tmp, NULL), ==, "GNU Bla Bla"); g_assert_cmpstr (as_app_get_description (app_tmp, NULL), ==, "<p>Gimp is Distro</p>"); g_assert_cmpstr (as_app_get_pkgname_default (app_tmp), ==, "gimp"); - g_assert_cmpint (as_app_get_source_kind (app_tmp), ==, AS_APP_SOURCE_KIND_APPSTREAM); + g_assert_cmpint (as_app_get_source_kind (app_tmp), ==, AS_FORMAT_KIND_APPSTREAM); g_assert_cmpint (as_app_get_state (app_tmp), ==, AS_APP_STATE_INSTALLED); } @@ -3355,7 +3355,7 @@ as_test_store_merges_local_func (void) app_desktop = as_app_new (); as_app_set_id (app_desktop, "gimp.desktop"); - as_app_set_source_kind (app_desktop, AS_APP_SOURCE_KIND_DESKTOP); + as_app_set_source_kind (app_desktop, AS_FORMAT_KIND_DESKTOP); as_app_set_name (app_desktop, NULL, "GIMP"); as_app_set_comment (app_desktop, NULL, "GNU Bla Bla"); as_app_set_priority (app_desktop, -1); @@ -3363,7 +3363,7 @@ as_test_store_merges_local_func (void) app_appdata = as_app_new (); as_app_set_id (app_appdata, "gimp.desktop"); - as_app_set_source_kind (app_appdata, AS_APP_SOURCE_KIND_APPDATA); + as_app_set_source_kind (app_appdata, AS_FORMAT_KIND_APPDATA); as_app_set_description (app_appdata, NULL, "<p>Gimp is awesome</p>"); as_app_add_pkgname (app_appdata, "gimp"); as_app_set_priority (app_appdata, -1); @@ -3371,7 +3371,7 @@ as_test_store_merges_local_func (void) app_appinfo = as_app_new (); as_app_set_id (app_appinfo, "gimp.desktop"); - as_app_set_source_kind (app_appinfo, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app_appinfo, AS_FORMAT_KIND_APPSTREAM); as_app_set_name (app_appinfo, NULL, "GIMP"); as_app_set_comment (app_appinfo, NULL, "Fedora GNU Bla Bla"); as_app_set_description (app_appinfo, NULL, "<p>Gimp is Distro</p>"); @@ -3390,7 +3390,7 @@ as_test_store_merges_local_func (void) g_assert_cmpstr (as_app_get_comment (app_tmp, NULL), ==, "GNU Bla Bla"); g_assert_cmpstr (as_app_get_description (app_tmp, NULL), ==, "<p>Gimp is awesome</p>"); g_assert_cmpstr (as_app_get_pkgname_default (app_tmp), ==, "gimp"); - g_assert_cmpint (as_app_get_source_kind (app_tmp), ==, AS_APP_SOURCE_KIND_APPDATA); + g_assert_cmpint (as_app_get_source_kind (app_tmp), ==, AS_FORMAT_KIND_APPDATA); g_assert_cmpint (as_app_get_state (app_tmp), ==, AS_APP_STATE_INSTALLED); } @@ -3679,7 +3679,7 @@ as_test_store_versions_func (void) /* verify source kind */ app = as_store_get_app_by_id (store, "test.desktop"); - g_assert_cmpint (as_app_get_source_kind (app), ==, AS_APP_SOURCE_KIND_APPSTREAM); + g_assert_cmpint (as_app_get_source_kind (app), ==, AS_FORMAT_KIND_APPSTREAM); /* test with latest features */ as_store_set_api_version (store, 0.6); @@ -4984,7 +4984,7 @@ as_test_store_merge_func (void) app1 = as_app_new (); as_app_set_id (app1, "org.gnome.Software.desktop"); as_app_set_branch (app1, "master"); - as_app_set_source_kind (app1, AS_APP_SOURCE_KIND_APPDATA); + as_app_set_source_kind (app1, AS_FORMAT_KIND_APPDATA); as_app_add_pkgname (app1, "gnome-software"); g_assert_cmpstr (as_app_get_unique_id (app1), ==, "*/package/*/*/org.gnome.Software.desktop/master"); @@ -4994,7 +4994,7 @@ as_test_store_merge_func (void) app_merge = as_app_new (); as_app_set_kind (app_merge, AS_APP_KIND_DESKTOP); as_app_set_id (app_merge, "org.gnome.Software.desktop"); - as_app_set_source_kind (app_merge, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app_merge, AS_FORMAT_KIND_APPSTREAM); as_app_set_origin (app_merge, "utopia"); as_app_set_scope (app_merge, AS_APP_SCOPE_USER); as_app_add_category (app_merge, "special"); @@ -5007,7 +5007,7 @@ as_test_store_merge_func (void) app2 = as_app_new (); as_app_set_id (app2, "org.gnome.Software.desktop"); as_app_set_branch (app2, "stable"); - as_app_set_source_kind (app2, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app2, AS_FORMAT_KIND_APPSTREAM); as_app_add_pkgname (app2, "gnome-software"); g_assert_cmpstr (as_app_get_unique_id (app2), ==, "*/package/*/*/org.gnome.Software.desktop/stable"); @@ -5037,7 +5037,7 @@ as_test_store_merge_replace_func (void) app1 = as_app_new (); as_app_set_id (app1, "org.gnome.Software.desktop"); as_app_set_branch (app1, "master"); - as_app_set_source_kind (app1, AS_APP_SOURCE_KIND_APPDATA); + as_app_set_source_kind (app1, AS_FORMAT_KIND_APPDATA); as_app_add_pkgname (app1, "gnome-software"); as_app_add_category (app1, "Family"); as_store_add_app (store, app1); @@ -5046,7 +5046,7 @@ as_test_store_merge_replace_func (void) app_merge = as_app_new (); as_app_set_kind (app_merge, AS_APP_KIND_DESKTOP); as_app_set_id (app_merge, "org.gnome.Software.desktop"); - as_app_set_source_kind (app_merge, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app_merge, AS_FORMAT_KIND_APPSTREAM); as_app_set_origin (app_merge, "utopia"); as_app_set_scope (app_merge, AS_APP_SCOPE_USER); as_app_set_merge_kind (app_merge, AS_APP_MERGE_KIND_REPLACE); @@ -5059,7 +5059,7 @@ as_test_store_merge_replace_func (void) app2 = as_app_new (); as_app_set_id (app2, "org.gnome.Software.desktop"); as_app_set_branch (app2, "stable"); - as_app_set_source_kind (app2, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app2, AS_FORMAT_KIND_APPSTREAM); as_app_add_pkgname (app2, "gnome-software"); as_app_add_category (app2, "Family"); as_store_add_app (store, app2); diff --git a/libappstream-glib/as-store-cab.c b/libappstream-glib/as-store-cab.c index 63c1e0c..3979118 100644 --- a/libappstream-glib/as-store-cab.c +++ b/libappstream-glib/as-store-cab.c @@ -260,7 +260,7 @@ as_store_cab_from_bytes_with_origin (AsStore *store, g_debug ("found file %u\t%s", i, fn); /* if inf or metainfo, add */ - if (as_app_guess_source_kind (fn) != AS_APP_SOURCE_KIND_METAINFO) + if (as_format_guess_kind (fn) != AS_FORMAT_KIND_METAINFO) continue; tmp_fn = g_build_filename (tmp_path, fn, NULL); diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index f2848ae..5b3f0a7 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -984,7 +984,7 @@ _as_app_is_perhaps_merge_component (AsApp *app) { if (as_app_get_kind (app) != AS_APP_KIND_DESKTOP) return FALSE; - if (as_app_get_source_kind (app) != AS_APP_SOURCE_KIND_APPSTREAM) + if (as_app_get_source_kind (app) != AS_FORMAT_KIND_APPSTREAM) return FALSE; if (as_app_get_bundle_kind (app) != AS_BUNDLE_KIND_UNKNOWN) return FALSE; @@ -1133,22 +1133,22 @@ as_store_add_app (AsStore *store, AsApp *app) /* the previously stored app is what we actually want */ if ((priv->add_flags & AS_STORE_ADD_FLAG_PREFER_LOCAL) > 0) { - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPSTREAM && - as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_APPDATA) { + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_APPSTREAM && + as_app_get_source_kind (item) == AS_FORMAT_KIND_APPDATA) { g_debug ("ignoring AppStream entry as AppData exists: %s:%s", as_app_get_unique_id (app), as_app_get_unique_id (item)); return; } - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPSTREAM && - as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_DESKTOP) { + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_APPSTREAM && + as_app_get_source_kind (item) == AS_FORMAT_KIND_DESKTOP) { g_debug ("ignoring AppStream entry as desktop exists: %s:%s", as_app_get_unique_id (app), as_app_get_unique_id (item)); return; } - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPDATA && - as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_DESKTOP) { + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_APPDATA && + as_app_get_source_kind (item) == AS_FORMAT_KIND_DESKTOP) { g_debug ("merging duplicate AppData:desktop entries: %s:%s", as_app_get_unique_id (app), as_app_get_unique_id (item)); @@ -1156,11 +1156,11 @@ as_store_add_app (AsStore *store, AsApp *app) AS_APP_SUBSUME_FLAG_BOTH_WAYS | AS_APP_SUBSUME_FLAG_DEDUPE); /* promote the desktop source to AppData */ - as_app_set_source_kind (item, AS_APP_SOURCE_KIND_APPDATA); + as_app_set_source_kind (item, AS_FORMAT_KIND_APPDATA); return; } - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_DESKTOP && - as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_APPDATA) { + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_DESKTOP && + as_app_get_source_kind (item) == AS_FORMAT_KIND_APPDATA) { g_debug ("merging duplicate desktop:AppData entries: %s:%s", as_app_get_unique_id (app), as_app_get_unique_id (item)); @@ -1171,8 +1171,8 @@ as_store_add_app (AsStore *store, AsApp *app) } } else { - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPDATA && - as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_APPSTREAM && + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_APPDATA && + as_app_get_source_kind (item) == AS_FORMAT_KIND_APPSTREAM && as_app_get_scope (app) == AS_APP_SCOPE_SYSTEM) { as_app_set_state (item, AS_APP_STATE_INSTALLED); g_debug ("ignoring AppData entry as AppStream exists: %s:%s", @@ -1182,8 +1182,8 @@ as_store_add_app (AsStore *store, AsApp *app) AS_APP_SUBSUME_FLAG_RELEASES); return; } - if (as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_DESKTOP && - as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_APPSTREAM && + if (as_app_get_source_kind (app) == AS_FORMAT_KIND_DESKTOP && + as_app_get_source_kind (item) == AS_FORMAT_KIND_APPSTREAM && as_app_get_scope (app) == AS_APP_SCOPE_SYSTEM) { as_app_set_state (item, AS_APP_STATE_INSTALLED); g_debug ("ignoring desktop entry as AppStream exists: %s:%s", @@ -1196,8 +1196,8 @@ as_store_add_app (AsStore *store, AsApp *app) if (as_app_get_priority (item) > as_app_get_priority (app)) { g_debug ("ignoring duplicate %s:%s entry: %s:%s", - as_app_source_kind_to_string (as_app_get_source_kind (app)), - as_app_source_kind_to_string (as_app_get_source_kind (item)), + as_format_kind_to_string (as_app_get_source_kind (app)), + as_format_kind_to_string (as_app_get_source_kind (item)), as_app_get_unique_id (app), as_app_get_unique_id (item)); return; @@ -1207,8 +1207,8 @@ as_store_add_app (AsStore *store, AsApp *app) if (as_app_get_priority (item) == as_app_get_priority (app)) { g_debug ("merging duplicate %s:%s entries: %s:%s", - as_app_source_kind_to_string (as_app_get_source_kind (app)), - as_app_source_kind_to_string (as_app_get_source_kind (item)), + as_format_kind_to_string (as_app_get_source_kind (app)), + as_format_kind_to_string (as_app_get_source_kind (item)), as_app_get_unique_id (app), as_app_get_unique_id (item)); as_app_subsume_full (app, item, @@ -1216,9 +1216,9 @@ as_store_add_app (AsStore *store, AsApp *app) AS_APP_SUBSUME_FLAG_DEDUPE); /* promote the desktop source to AppData */ - if (as_app_get_source_kind (item) == AS_APP_SOURCE_KIND_DESKTOP && - as_app_get_source_kind (app) == AS_APP_SOURCE_KIND_APPDATA) - as_app_set_source_kind (item, AS_APP_SOURCE_KIND_APPDATA); + if (as_app_get_source_kind (item) == AS_FORMAT_KIND_DESKTOP && + as_app_get_source_kind (app) == AS_FORMAT_KIND_APPDATA) + as_app_set_source_kind (item, AS_FORMAT_KIND_APPDATA); return; } } @@ -1226,7 +1226,7 @@ as_store_add_app (AsStore *store, AsApp *app) /* this new item has a higher priority than the one we've * previously stored */ g_debug ("removing %s entry: %s", - as_app_source_kind_to_string (as_app_get_source_kind (item)), + as_format_kind_to_string (as_app_get_source_kind (item)), as_app_get_unique_id (item)); if (as_app_get_state (item) == AS_APP_STATE_INSTALLED) as_app_set_state (app, AS_APP_STATE_INSTALLED); @@ -1516,7 +1516,7 @@ as_store_from_root (AsStore *store, if (arch != NULL) as_app_add_arch (app, arch); as_app_set_scope (app, scope); - as_app_set_source_kind (app, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app, AS_FORMAT_KIND_APPSTREAM); if (!as_app_node_parse (app, n, ctx, &error_local)) { g_set_error (error, AS_STORE_ERROR, @@ -1631,7 +1631,7 @@ as_store_load_yaml_file (AsStore *store, if (icon_path != NULL) as_app_set_icon_path (app, icon_path); as_app_set_scope (app, scope); - as_app_set_source_kind (app, AS_APP_SOURCE_KIND_APPSTREAM); + as_app_set_source_kind (app, AS_FORMAT_KIND_APPSTREAM); if (!as_app_node_parse_dep11 (app, app_n, ctx, error)) return FALSE; as_app_set_origin (app, priv->origin); @@ -2169,7 +2169,7 @@ as_store_to_xml (AsStore *store, AsNodeToXmlFlags flags) /* add applications */ ctx = as_node_context_new (); as_node_context_set_version (ctx, priv->api_version); - as_node_context_set_output (ctx, AS_APP_SOURCE_KIND_APPSTREAM); + as_node_context_set_output (ctx, AS_FORMAT_KIND_APPSTREAM); as_node_context_set_output_trusted (ctx, output_trusted); for (i = 0; i < priv->array->len; i++) { app = g_ptr_array_index (priv->array, i); @@ -2739,7 +2739,7 @@ as_store_load_installed (AsStore *store, if ((priv->add_flags & AS_STORE_ADD_FLAG_PREFER_LOCAL) == 0) { app_tmp = as_store_get_app_by_id (store, tmp); if (app_tmp != NULL && - as_app_get_source_kind (app_tmp) == AS_APP_SOURCE_KIND_DESKTOP) { + as_app_get_source_kind (app_tmp) == AS_FORMAT_KIND_DESKTOP) { as_app_set_state (app_tmp, AS_APP_STATE_INSTALLED); g_debug ("not parsing %s as %s already exists", filename, tmp); diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c index a85c3f4..c2fd618 100644 --- a/libappstream-glib/as-utils.c +++ b/libappstream-glib/as-utils.c @@ -1225,8 +1225,8 @@ as_utils_install_filename (AsUtilsLocation location, if (destdir == NULL) destdir = ""; - switch (as_app_guess_source_kind (filename)) { - case AS_APP_SOURCE_KIND_APPSTREAM: + switch (as_format_guess_kind (filename)) { + case AS_FORMAT_KIND_APPSTREAM: if (g_strstr_len (filename, -1, ".yml.gz") != NULL) { path = g_build_filename (as_utils_location_get_prefix (location), "app-info", "yaml", NULL); @@ -1237,8 +1237,8 @@ as_utils_install_filename (AsUtilsLocation location, ret = as_utils_install_xml (filename, origin, path, destdir, error); } break; - case AS_APP_SOURCE_KIND_APPDATA: - case AS_APP_SOURCE_KIND_METAINFO: + case AS_FORMAT_KIND_APPDATA: + case AS_FORMAT_KIND_METAINFO: if (location == AS_UTILS_LOCATION_CACHE) { g_set_error_literal (error, AS_UTILS_ERROR, |