summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-01-16 15:55:17 +0000
committerRichard Hughes <richard@hughsie.com>2017-01-16 16:14:08 +0000
commit280dec786fdc49e2b95b4297c0a7091cc4705514 (patch)
treec2ab0c9e5880e003f49c8e59fda5e5c49f7c7fd6 /client
parentab04101afcdf8b2cd69c2d3b8e80361b99f00044 (diff)
downloadappstream-glib-280dec786fdc49e2b95b4297c0a7091cc4705514.tar.gz
Support reading metainfo.xml files when using appstream-compose
Diffstat (limited to 'client')
-rw-r--r--client/as-compose.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/client/as-compose.c b/client/as-compose.c
index b53423f..979ff9c 100644
--- a/client/as-compose.c
+++ b/client/as-compose.c
@@ -246,10 +246,33 @@ load_desktop (const gchar *prefix,
return g_steal_pointer (&app);
}
+static gchar *
+get_appdata_filename (const gchar *prefix, const gchar *app_name)
+{
+ const gchar *dirs[] = { "metainfo", "appdata", NULL };
+ const gchar *exts[] = { ".metainfo.xml", ".appdata.xml", NULL };
+
+ /* fall back to the legacy path and extensions */
+ for (guint j = 0; dirs[j] != NULL; j++) {
+ for (guint i = 0; exts[i] != NULL; i++) {
+ g_autofree gchar *basename = NULL;
+ g_autofree gchar *tmp = NULL;
+ basename = g_strconcat (app_name, exts[i], NULL);
+ tmp = g_build_filename (prefix,
+ "share",
+ dirs[j],
+ basename,
+ NULL);
+ if (g_file_test (tmp, G_FILE_TEST_EXISTS))
+ return g_steal_pointer (&tmp);
+ }
+ }
+ return NULL;
+}
+
static AsApp *
load_appdata (const gchar *prefix, const gchar *app_name, GError **error)
{
- g_autofree gchar *appdata_basename = NULL;
g_autofree gchar *appdata_path = NULL;
g_autoptr(AsApp) app = NULL;
g_autoptr(GPtrArray) problems = NULL;
@@ -257,23 +280,7 @@ load_appdata (const gchar *prefix, const gchar *app_name, GError **error)
AsProblem *problem;
guint i;
- appdata_basename = g_strconcat (app_name,
- ".appdata.xml",
- NULL);
- appdata_path = g_build_filename (prefix,
- "share",
- "metainfo",
- appdata_basename,
- NULL);
- /* fall back to the legacy path */
- if (!g_file_test (appdata_path, G_FILE_TEST_EXISTS)) {
- g_free (appdata_path);
- appdata_path = g_build_filename (prefix,
- "share",
- "appdata",
- appdata_basename,
- NULL);
- }
+ appdata_path = get_appdata_filename (prefix, app_name);
g_debug ("Looking for %s", appdata_path);
app = as_app_new ();