diff options
author | Richard Hughes <richard@hughsie.com> | 2015-08-03 16:59:36 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-08-03 17:04:09 +0100 |
commit | 5d3c5ba292a001c4d4b1eeafda0ede282e286e66 (patch) | |
tree | 28a5b80ea65526c3bc35ae14e17f594befcc4cb8 | |
parent | 930cda7e590e1bd1a4b44ccc74f39309f3989174 (diff) | |
download | appstream-glib-5d3c5ba292a001c4d4b1eeafda0ede282e286e66.tar.gz |
Remove support for lower than AppStream 0.6
This was the big <application> --> <component> rename...
-rw-r--r-- | client/as-builder.c | 2 | ||||
-rw-r--r-- | libappstream-glib/as-app.c | 79 | ||||
-rw-r--r-- | libappstream-glib/as-self-test.c | 102 | ||||
-rw-r--r-- | libappstream-glib/as-store.c | 10 | ||||
-rw-r--r-- | libappstream-glib/as-tag.c | 6 | ||||
-rw-r--r-- | libappstream-glib/as-tag.gperf | 4 | ||||
-rw-r--r-- | libappstream-glib/as-tag.h | 14 |
7 files changed, 90 insertions, 127 deletions
diff --git a/client/as-builder.c b/client/as-builder.c index 520bd0c..5e9e2bf 100644 --- a/client/as-builder.c +++ b/client/as-builder.c @@ -260,7 +260,7 @@ main (int argc, char **argv) setlocale (LC_ALL, ""); /* obsolete */ - if (api_version < 0.4) { + if (api_version < 0.6) { /* TRANSLATORS: error message */ g_warning ("%s", _("API version no longer supported")); retval = EXIT_FAILURE; diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 3a49cf1..ed834e2 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -3031,7 +3031,6 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) const gchar *tmp; gdouble api_version = as_node_context_get_version (ctx); guint i; - static gint old_prio_value = 0; /* no addons allowed here */ if (api_version < 0.7 && priv->id_kind == AS_ID_KIND_ADDON) { @@ -3048,40 +3047,20 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <component> or <application> */ - if (api_version >= 0.6) { - node_app = as_node_insert (parent, "component", NULL, 0, NULL); - if (priv->id_kind != AS_ID_KIND_UNKNOWN) { - as_node_add_attribute (node_app, - "type", - as_id_kind_to_string (priv->id_kind)); - } - } else { - node_app = as_node_insert (parent, "application", NULL, 0, NULL); - } - - /* <id> */ - node_tmp = as_node_insert (node_app, "id", priv->id, 0, NULL); - if (api_version < 0.6 && priv->id_kind != AS_ID_KIND_UNKNOWN) { - as_node_add_attribute (node_tmp, + node_app = as_node_insert (parent, "component", NULL, 0, NULL); + if (priv->id_kind != AS_ID_KIND_UNKNOWN) { + as_node_add_attribute (node_app, "type", as_id_kind_to_string (priv->id_kind)); } + /* <id> */ + as_node_insert (node_app, "id", priv->id, 0, NULL); + /* <priority> */ - if (priv->priority != 0 && api_version >= 0.61) + if (priv->priority != 0) as_node_add_attribute_as_int (node_app, "priority", priv->priority); - /* this looks crazy, but priority was initially implemented on - * the <applications> node and was designed to be per-file */ - if (api_version <= 0.5 && - api_version > 0.3 && - old_prio_value != priv->priority) { - gchar prio[6]; - g_snprintf (prio, sizeof (prio), "%i", priv->priority); - as_node_insert (parent, "priority", prio, 0, NULL); - old_prio_value = priv->priority; - } - /* <pkgname> */ g_ptr_array_sort (priv->pkgnames, as_app_ptr_array_sort_cb); for (i = 0; i < priv->pkgnames->len; i++) { @@ -3119,17 +3098,10 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <description> */ - if (api_version < 0.6) { - as_node_insert_localized (node_app, "description", - priv->descriptions, - AS_NODE_INSERT_FLAG_NO_MARKUP | - AS_NODE_INSERT_FLAG_DEDUPE_LANG); - } else { - as_node_insert_localized (node_app, "description", - priv->descriptions, - AS_NODE_INSERT_FLAG_PRE_ESCAPED | - AS_NODE_INSERT_FLAG_DEDUPE_LANG); - } + as_node_insert_localized (node_app, "description", + priv->descriptions, + AS_NODE_INSERT_FLAG_PRE_ESCAPED | + AS_NODE_INSERT_FLAG_DEDUPE_LANG); /* <icon> */ g_ptr_array_sort (priv->icons, as_app_icons_sort_cb); @@ -3139,28 +3111,17 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <categories> */ - if (api_version >= 0.5) { + if (priv->categories->len > 0) { g_ptr_array_sort (priv->categories, as_app_ptr_array_sort_cb); - if (priv->categories->len > 0) { - node_tmp = as_node_insert (node_app, "categories", NULL, 0, NULL); - for (i = 0; i < priv->categories->len; i++) { - tmp = g_ptr_array_index (priv->categories, i); - as_node_insert (node_tmp, "category", tmp, 0, NULL); - } - } - } else { - g_ptr_array_sort (priv->categories, as_app_ptr_array_sort_cb); - if (priv->categories->len > 0) { - node_tmp = as_node_insert (node_app, "appcategories", NULL, 0, NULL); - for (i = 0; i < priv->categories->len; i++) { - tmp = g_ptr_array_index (priv->categories, i); - as_node_insert (node_tmp, "appcategory", tmp, 0, NULL); - } + node_tmp = as_node_insert (node_app, "categories", NULL, 0, NULL); + for (i = 0; i < priv->categories->len; i++) { + tmp = g_ptr_array_index (priv->categories, i); + as_node_insert (node_tmp, "category", tmp, 0, NULL); } } /* <architectures> */ - if (priv->architectures->len > 0 && api_version >= 0.6) { + if (priv->architectures->len > 0) { g_ptr_array_sort (priv->architectures, as_app_ptr_array_sort_cb); node_tmp = as_node_insert (node_app, "architectures", NULL, 0, NULL); for (i = 0; i < priv->architectures->len; i++) { @@ -3269,7 +3230,7 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <releases> */ - if (priv->releases->len > 0 && api_version >= 0.6) { + if (priv->releases->len > 0) { g_ptr_array_sort (priv->releases, as_app_releases_sort_cb); node_tmp = as_node_insert (node_app, "releases", NULL, 0, NULL); for (i = 0; i < priv->releases->len && i < 3; i++) { @@ -3279,7 +3240,7 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <provides> */ - if (priv->provides->len > 0 && api_version >= 0.6) { + if (priv->provides->len > 0) { AsProvide *provide; node_tmp = as_node_insert (node_app, "provides", NULL, 0, NULL); for (i = 0; i < priv->provides->len; i++) { @@ -4396,7 +4357,7 @@ as_app_parse_appdata_file (AsApp *app, priv->problems |= AS_APP_PROBLEM_DEPRECATED_LICENCE; continue; } - if (as_node_get_tag (l) == AS_TAG_APPLICATION) { + if (as_node_get_tag (l) == AS_TAG_COMPONENT) { if (seen_application) priv->problems |= AS_APP_PROBLEM_MULTIPLE_ENTRIES; seen_application = TRUE; diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 2090aa7..247cfca 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -1890,10 +1890,10 @@ as_test_app_no_markup_func (void) GString *xml; gboolean ret; const gchar *src = - "<application>\n" - "<id type=\"desktop\">org.gnome.Software.desktop</id>\n" + "<component type=\"desktop\">\n" + "<id>org.gnome.Software.desktop</id>\n" "<description>Software is awesome:\n\n * Bada\n * Boom!</description>\n" - "</application>\n"; + "</component>\n"; _cleanup_free_ AsNodeContext *ctx = NULL; _cleanup_object_unref_ AsApp *app = NULL; @@ -1905,7 +1905,7 @@ as_test_app_no_markup_func (void) &error); g_assert_no_error (error); g_assert (root != NULL); - n = as_node_find (root, "application"); + n = as_node_find (root, "component"); g_assert (n != NULL); ctx = as_node_context_new (); ret = as_app_node_parse (app, n, ctx, &error); @@ -2862,14 +2862,14 @@ as_test_store_func (void) as_store_remove_app (store, app); /* check string output */ - as_store_set_api_version (store, 0.4); + as_store_set_api_version (store, 0.6); xml = as_store_to_xml (store, 0); g_assert_cmpstr (xml->str, ==, - "<applications version=\"0.4\">" - "<application>" - "<id type=\"desktop\">gnome-software.desktop</id>" - "</application>" - "</applications>"); + "<components version=\"0.6\">" + "<component type=\"desktop\">" + "<id>gnome-software.desktop</id>" + "</component>" + "</components>"); g_string_free (xml, TRUE); /* add another app and ensure it's sorted */ @@ -2880,14 +2880,14 @@ as_test_store_func (void) g_object_unref (app); xml = as_store_to_xml (store, 0); g_assert_cmpstr (xml->str, ==, - "<applications version=\"0.4\">" - "<application>" - "<id type=\"font\">aaa.desktop</id>" - "</application>" - "<application>" - "<id type=\"desktop\">gnome-software.desktop</id>" - "</application>" - "</applications>"); + "<components version=\"0.6\">" + "<component type=\"font\">" + "<id>aaa.desktop</id>" + "</component>" + "<component type=\"desktop\">" + "<id>gnome-software.desktop</id>" + "</component>" + "</components>"); g_string_free (xml, TRUE); /* empty the store */ @@ -2897,7 +2897,7 @@ as_test_store_func (void) g_assert (as_store_get_app_by_id (store, "gnome-software.desktop") == NULL); xml = as_store_to_xml (store, 0); g_assert_cmpstr (xml->str, ==, - "<applications version=\"0.4\"/>"); + "<components version=\"0.6\"/>"); g_string_free (xml, TRUE); } @@ -2913,9 +2913,9 @@ as_test_store_versions_func (void) /* load a file to the store */ store = as_store_new (); ret = as_store_from_xml (store, - "<applications version=\"0.4\">" - "<application>" - "<id type=\"desktop\">test.desktop</id>" + "<components version=\"0.6\">" + "<component type=\"desktop\">" + "<id>test.desktop</id>" "<description><p>Hello world</p></description>" "<architectures><arch>i386</arch></architectures>" "<releases>" @@ -2923,12 +2923,12 @@ as_test_store_versions_func (void) "<description><p>Hello</p></description>" "</release>" "</releases>" - "</application>" - "</applications>", NULL, &error); + "</component>" + "</components>", NULL, &error); g_assert_no_error (error); g_assert (ret); - g_assert_cmpfloat (as_store_get_api_version (store), <, 0.4 + 0.01); - g_assert_cmpfloat (as_store_get_api_version (store), >, 0.4 - 0.01); + g_assert_cmpfloat (as_store_get_api_version (store), <, 0.6 + 0.01); + g_assert_cmpfloat (as_store_get_api_version (store), >, 0.6 - 0.01); /* verify source kind */ app = as_store_get_app_by_id (store, "test.desktop"); @@ -2955,15 +2955,21 @@ as_test_store_versions_func (void) g_string_free (str, TRUE); /* test with legacy options */ - as_store_set_api_version (store, 0.3); + as_store_set_api_version (store, 0.6); str = as_store_to_xml (store, 0); g_assert_cmpstr (str->str, ==, - "<applications version=\"0.3\">" - "<application>" - "<id type=\"desktop\">test.desktop</id>" - "<description>Hello world</description>" - "</application>" - "</applications>"); + "<components version=\"0.6\">" + "<component type=\"desktop\">" + "<id>test.desktop</id>" + "<description><p>Hello world</p></description>" + "<architectures><arch>i386</arch></architectures>" + "<releases>" + "<release version=\"0.1.2\" timestamp=\"123\">" + "<description><p>Hello</p></description>" + "</release>" + "</releases>" + "</component>" + "</components>"); g_string_free (str, TRUE); g_object_unref (store); @@ -3057,11 +3063,11 @@ as_test_node_no_dup_c_func (void) GString *xml; gboolean ret; const gchar *src = - "<application>" - "<id type=\"desktop\">test.desktop</id>" + "<component type=\"desktop\">" + "<id>test.desktop</id>" "<name>Krita</name>" "<name xml:lang=\"pl\">Krita</name>" - "</application>"; + "</component>"; _cleanup_free_ AsNodeContext *ctx = NULL; _cleanup_object_unref_ AsApp *app = NULL; @@ -3070,7 +3076,7 @@ as_test_node_no_dup_c_func (void) root = as_node_from_xml (src, 0, &error); g_assert_no_error (error); g_assert (root != NULL); - n = as_node_find (root, "application"); + n = as_node_find (root, "component"); g_assert (n != NULL); ctx = as_node_context_new (); ret = as_app_node_parse (app, n, ctx, &error); @@ -3088,10 +3094,10 @@ as_test_node_no_dup_c_func (void) n = as_app_node_insert (app, root, ctx); xml = as_node_to_xml (n, AS_NODE_TO_XML_FLAG_NONE); g_assert_cmpstr (xml->str, ==, - "<application>" - "<id type=\"desktop\">test.desktop</id>" + "<component type=\"desktop\">" + "<id>test.desktop</id>" "<name>Krita</name>" - "</application>"); + "</component>"); g_string_free (xml, TRUE); as_node_unref (root); } @@ -3524,20 +3530,20 @@ as_test_store_metadata_func (void) GPtrArray *apps; gboolean ret; const gchar *xml = - "<applications version=\"0.3\">" - "<application>" - "<id type=\"desktop\">test.desktop</id>" + "<components version=\"0.6\">" + "<component type=\"desktop\">" + "<id>test.desktop</id>" "<metadata>" "<value key=\"foo\">bar</value>" "</metadata>" - "</application>" - "<application>" - "<id type=\"desktop\">tested.desktop</id>" + "</component>" + "<component type=\"desktop\">" + "<id>tested.desktop</id>" "<metadata>" "<value key=\"foo\">bar</value>" "</metadata>" - "</application>" - "</applications>"; + "</component>" + "</components>"; _cleanup_object_unref_ AsStore *store = NULL; store = as_store_new (); diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index 06ebd17..d9949bc 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -45,7 +45,7 @@ #include "as-utils-private.h" #include "as-yaml.h" -#define AS_API_VERSION_NEWEST 0.6 +#define AS_API_VERSION_NEWEST 0.8 typedef enum { AS_STORE_PROBLEM_NONE = 0, @@ -859,7 +859,7 @@ as_store_from_root (AsStore *store, for (n = apps->children; n != NULL; n = n->next) { _cleanup_error_free_ GError *error_local = NULL; _cleanup_object_unref_ AsApp *app = NULL; - if (as_node_get_tag (n) != AS_TAG_APPLICATION) + if (as_node_get_tag (n) != AS_TAG_COMPONENT) continue; /* do the filtering here */ @@ -1215,11 +1215,7 @@ as_store_to_xml (AsStore *store, AsNodeToXmlFlags flags) /* get XML text */ node_root = as_node_new (); - if (priv->api_version >= 0.6) { - node_apps = as_node_insert (node_root, "components", NULL, 0, NULL); - } else { - node_apps = as_node_insert (node_root, "applications", NULL, 0, NULL); - } + node_apps = as_node_insert (node_root, "components", NULL, 0, NULL); /* set origin attribute */ if (priv->origin != NULL) diff --git a/libappstream-glib/as-tag.c b/libappstream-glib/as-tag.c index 31cf7e8..08c5af5 100644 --- a/libappstream-glib/as-tag.c +++ b/libappstream-glib/as-tag.c @@ -25,7 +25,7 @@ * @include: appstream-glib.h * @stability: Stable * - * These functions will convert a tag enum such as %AS_TAG_APPLICATION to + * These functions will convert a tag enum such as %AS_TAG_COMPONENT to * it's string form, and also vice-versa. * * These helper functions may be useful if implementing an AppStream parser. @@ -106,9 +106,9 @@ as_tag_from_string_full (const gchar *tag, AsTagFlags flags) if (g_strcmp0 (tag, "licence") == 0) return AS_TAG_PROJECT_LICENSE; if (g_strcmp0 (tag, "applications") == 0) - return AS_TAG_APPLICATIONS; + return AS_TAG_COMPONENTS; if (g_strcmp0 (tag, "application") == 0) - return AS_TAG_APPLICATION; + return AS_TAG_COMPONENT; if (g_strcmp0 (tag, "updatecontact") == 0) return AS_TAG_UPDATE_CONTACT; /* fix spelling error */ diff --git a/libappstream-glib/as-tag.gperf b/libappstream-glib/as-tag.gperf index 3c31b46..2add710 100644 --- a/libappstream-glib/as-tag.gperf +++ b/libappstream-glib/as-tag.gperf @@ -8,8 +8,8 @@ struct tag_data { gint name; guint etag; }; %% unknown, AS_TAG_UNKNOWN -components, AS_TAG_APPLICATIONS -component, AS_TAG_APPLICATION +components, AS_TAG_COMPONENTS +component, AS_TAG_COMPONENT id, AS_TAG_ID pkgname, AS_TAG_PKGNAME name, AS_TAG_NAME diff --git a/libappstream-glib/as-tag.h b/libappstream-glib/as-tag.h index ed16c5b..27eaa22 100644 --- a/libappstream-glib/as-tag.h +++ b/libappstream-glib/as-tag.h @@ -31,8 +31,8 @@ /** * AsTag: * @AS_TAG_UNKNOWN: Type invalid or not known - * @AS_TAG_APPLICATIONS: `applications` - * @AS_TAG_APPLICATION: `application` + * @AS_TAG_COMPONENTS: `components` + * @AS_TAG_COMPONENT: `component` * @AS_TAG_ID: `id` * @AS_TAG_PKGNAME: `pkgname` * @AS_TAG_NAME: `name` @@ -40,14 +40,14 @@ * @AS_TAG_DESCRIPTION: `description` * @AS_TAG_URL: `url` * @AS_TAG_ICON: `icon` - * @AS_TAG_CATEGORIES: `categories` (or `appcategories`) - * @AS_TAG_CATEGORY: `category` (or `appcategory`) + * @AS_TAG_CATEGORIES: `categories` + * @AS_TAG_CATEGORY: `category` * @AS_TAG_KEYWORDS: `keywords` * @AS_TAG_KEYWORD: `keyword` * @AS_TAG_MIMETYPES: `mimetypes` * @AS_TAG_MIMETYPE: `mimetype` * @AS_TAG_PROJECT_GROUP: `project_group` - * @AS_TAG_PROJECT_LICENSE: `project_license` (or `licence`) + * @AS_TAG_PROJECT_LICENSE: `project_license` * @AS_TAG_SCREENSHOT: `screenshot` * @AS_TAG_SCREENSHOTS: `screenshots` * @AS_TAG_UPDATE_CONTACT: `update_contact` @@ -82,8 +82,8 @@ **/ typedef enum { AS_TAG_UNKNOWN, /* Since: 0.1.0 */ - AS_TAG_APPLICATIONS, /* Since: 0.1.0 */ - AS_TAG_APPLICATION, /* Since: 0.1.0 */ + AS_TAG_COMPONENTS, /* Since: 0.5.0 */ + AS_TAG_COMPONENT, /* Since: 0.5.0 */ AS_TAG_ID, /* Since: 0.1.0 */ AS_TAG_PKGNAME, /* Since: 0.1.0 */ AS_TAG_NAME, /* Since: 0.1.0 */ |