diff options
author | Richard Hughes <richard@hughsie.com> | 2014-08-22 18:53:22 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-08-22 19:23:16 +0100 |
commit | 208fe0c7bc623b7c1a1513d1dc3cb77f7bef48af (patch) | |
tree | 1fd6e21c21b077de699af1b5200106cb247ed06a | |
parent | 194ee99b9648a18858ade33f88b3375aab6ae5e4 (diff) | |
download | appstream-glib-208fe0c7bc623b7c1a1513d1dc3cb77f7bef48af.tar.gz |
Rename as_app_get_id() to as_app_get_id_filename()
This makes the API a little more sane with a better defined return value.
-rw-r--r-- | docs/PORTING.txt | 1 | ||||
-rw-r--r-- | libappstream-builder/asb-app.c | 2 | ||||
-rw-r--r-- | libappstream-builder/asb-context.c | 2 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-appdata.c | 6 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-desktop.c | 2 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-font.c | 6 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-hardcoded.c | 2 | ||||
-rw-r--r-- | libappstream-glib/as-app-validate.c | 2 | ||||
-rw-r--r-- | libappstream-glib/as-app.c | 29 | ||||
-rw-r--r-- | libappstream-glib/as-app.h | 2 | ||||
-rw-r--r-- | libappstream-glib/as-self-test.c | 2 |
11 files changed, 28 insertions, 28 deletions
diff --git a/docs/PORTING.txt b/docs/PORTING.txt index 285690b..63cc071 100644 --- a/docs/PORTING.txt +++ b/docs/PORTING.txt @@ -3,6 +3,7 @@ * as_app_get_keywords(app) -> as_app_get_keywords(app,locale) * as_app_add_keyword(app,kw,len) -> as_app_add_keyword(app,locale,kw,len) +* as_app_get_id(app) -> as_app_get_id_filename(app) Planned, but not yet done: diff --git a/libappstream-builder/asb-app.c b/libappstream-builder/asb-app.c index 16a21ff..d0dabc8 100644 --- a/libappstream-builder/asb-app.c +++ b/libappstream-builder/asb-app.c @@ -408,7 +408,7 @@ asb_app_add_screenshot_source (AsbApp *app, const gchar *filename, GError **erro /* include the app-id in the basename */ basename = g_strdup_printf ("%s-%s.png", - as_app_get_id (AS_APP (app)), + as_app_get_id_filename (AS_APP (app)), as_image_get_md5 (im_src)); as_image_set_basename (im_src, basename); diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c index 8027628..b689cf0 100644 --- a/libappstream-builder/asb-context.c +++ b/libappstream-builder/asb-context.c @@ -536,7 +536,7 @@ asb_context_load_extra_screenshots (AsbContext *ctx, AsApp *app, GError **error) priv->screenshot_uri == NULL || priv->screenshot_dir == NULL) return TRUE; - path = g_build_filename (priv->extra_screenshots, as_app_get_id (app), NULL); + path = g_build_filename (priv->extra_screenshots, as_app_get_id_filename (app), NULL); if (!g_file_test (path, G_FILE_TEST_EXISTS)) return TRUE; diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c index 762cd1e..cf41c74 100644 --- a/libappstream-builder/plugins/asb-plugin-appdata.c +++ b/libappstream-builder/plugins/asb-plugin-appdata.c @@ -196,7 +196,7 @@ asb_plugin_appdata_load_url (AsbPlugin *plugin, cache_dir = asb_package_get_config (asb_app_get_package (app), "CacheDir"); cache_filename = g_strdup_printf ("%s/%s-%s", cache_dir, - as_app_get_id (AS_APP (app)), + 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)) { @@ -493,7 +493,7 @@ asb_plugin_process_app (AsbPlugin *plugin, /* get possible sources */ appdata_filename = g_strdup_printf ("%s/usr/share/appdata/%s.appdata.xml", - tmpdir, as_app_get_id (AS_APP (app))); + tmpdir, as_app_get_id_filename (AS_APP (app))); tmp = asb_package_get_config (pkg, "AppDataExtra"); if (tmp != NULL && g_file_test (tmp, G_FILE_TEST_EXISTS)) { if (!asb_plugin_appdata_add_files (plugin, tmp, error)) @@ -502,7 +502,7 @@ asb_plugin_process_app (AsbPlugin *plugin, appdata_filename_extra = g_strdup_printf ("%s/%s/%s.appdata.xml", tmp, kind_str, - as_app_get_id (AS_APP (app))); + as_app_get_id_filename (AS_APP (app))); if (g_file_test (appdata_filename, G_FILE_TEST_EXISTS) && g_file_test (appdata_filename_extra, G_FILE_TEST_EXISTS)) { asb_package_log (pkg, diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c index 4408a38..3033207 100644 --- a/libappstream-builder/plugins/asb-plugin-desktop.c +++ b/libappstream-builder/plugins/asb-plugin-desktop.c @@ -274,7 +274,7 @@ asb_plugin_process_filename (AsbPlugin *plugin, } else { /* save in target directory */ icon_filename = g_strdup_printf ("%s.png", - as_app_get_id (AS_APP (app))); + as_app_get_id_filename (AS_APP (app))); as_app_set_icon (AS_APP (app), icon_filename, -1); as_app_set_icon_kind (AS_APP (app), AS_ICON_KIND_CACHED); asb_app_set_pixbuf (app, pixbuf); diff --git a/libappstream-builder/plugins/asb-plugin-font.c b/libappstream-builder/plugins/asb-plugin-font.c index 543f067..371de6e 100644 --- a/libappstream-builder/plugins/asb-plugin-font.c +++ b/libappstream-builder/plugins/asb-plugin-font.c @@ -409,7 +409,7 @@ asb_font_add_screenshot (AsbApp *app, FT_Face ft_face, GError **error) cache_dir = asb_package_get_config (asb_app_get_package (app), "CacheDir"); cache_fn = g_strdup_printf ("%s/%s.png", cache_dir, - as_app_get_id (AS_APP (app))); + as_app_get_id_filename (AS_APP (app))); if (g_file_test (cache_fn, G_FILE_TEST_EXISTS)) { pixbuf = gdk_pixbuf_new_from_file (cache_fn, error); if (pixbuf == NULL) @@ -435,7 +435,7 @@ asb_font_add_screenshot (AsbApp *app, FT_Face ft_face, GError **error) as_image_set_pixbuf (im, pixbuf); as_image_set_kind (im, AS_IMAGE_KIND_SOURCE); basename = g_strdup_printf ("%s-%s.png", - as_app_get_id (AS_APP (app)), + as_app_get_id_filename (AS_APP (app)), as_image_get_md5 (im)); as_image_set_basename (im, basename); url_tmp = g_build_filename (mirror_uri, @@ -611,7 +611,7 @@ asb_plugin_process_filename (AsbPlugin *plugin, /* generate icon */ tmp = as_app_get_metadata_item (AS_APP (app), "FontIconText"); if (tmp != NULL) { - icon_filename = g_strdup_printf ("%s.png", as_app_get_id (AS_APP (app))); + icon_filename = g_strdup_printf ("%s.png", as_app_get_id_filename (AS_APP (app))); as_app_set_icon (AS_APP (app), icon_filename, -1); pixbuf = asb_font_get_pixbuf (ft_face, AS_APP_ICON_DEFAULT_WIDTH, diff --git a/libappstream-builder/plugins/asb-plugin-hardcoded.c b/libappstream-builder/plugins/asb-plugin-hardcoded.c index df2834e..194fdab 100644 --- a/libappstream-builder/plugins/asb-plugin-hardcoded.c +++ b/libappstream-builder/plugins/asb-plugin-hardcoded.c @@ -304,7 +304,7 @@ asb_plugin_process_app (AsbPlugin *plugin, tmp = asb_package_get_config (pkg, "ScreenshotsExtra"); if (tmp != NULL) { _cleanup_free_ gchar *dirname = NULL; - dirname = g_build_filename (tmp, as_app_get_id (AS_APP (app)), NULL); + dirname = g_build_filename (tmp, as_app_get_id_filename (AS_APP (app)), NULL); if (g_file_test (dirname, G_FILE_TEST_EXISTS)) { if (!asb_plugin_hardcoded_add_screenshots (app, dirname, error)) return FALSE; diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c index 7e307ec..8ff772e 100644 --- a/libappstream-glib/as-app-validate.c +++ b/libappstream-glib/as-app-validate.c @@ -158,8 +158,6 @@ as_app_validate_has_first_word_capital (AsAppValidateHelper *helper, const gchar } /* is the first word the project name */ - if (g_strcmp0 (first_word, as_app_get_id (helper->app)) == 0) - return TRUE; if (g_strcmp0 (first_word, as_app_get_name (helper->app, NULL)) == 0) return TRUE; diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index e3a5084..f3a3798 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -79,7 +79,7 @@ struct _AsAppPrivate AsAppTrustFlags trust_flags; gchar *icon; gchar *icon_path; - gchar *id; + gchar *id_filename; gchar *id_full; gchar *project_group; gchar *project_license; @@ -243,7 +243,7 @@ as_app_finalize (GObject *object) g_free (priv->icon); g_free (priv->icon_path); - g_free (priv->id); + g_free (priv->id_filename); g_free (priv->id_full); g_free (priv->project_group); g_free (priv->project_license); @@ -349,20 +349,21 @@ as_app_get_id_full (AsApp *app) } /** - * as_app_get_id: + * as_app_get_id_filename: * @app: a #AsApp instance. * - * Returns the short version of the ID. + * Returns a filename which represents the applications ID, e.g. "gimp.desktop" + * becomes "gimp" and is used for cache directories. * - * Returns: the short ID, e.g. "org.gnome.Software" + * Returns: A utf8 filename * - * Since: 0.1.0 + * Since: 0.3.0 **/ const gchar * -as_app_get_id (AsApp *app) +as_app_get_id_filename (AsApp *app) { AsAppPrivate *priv = GET_PRIVATE (app); - return priv->id; + return priv->id_filename; } /** @@ -1295,12 +1296,12 @@ as_app_set_id_full (AsApp *app, const gchar *id_full, gssize id_full_len) } g_free (priv->id_full); - g_free (priv->id); + g_free (priv->id_filename); priv->id_full = as_strndup (id_full, id_full_len); - g_strdelimit (priv->id_full, "&<>", '-'); - priv->id = g_strdup (priv->id_full); - tmp = g_strrstr_len (priv->id, -1, "."); + priv->id_filename = g_strdup (priv->id_full); + g_strdelimit (priv->id_filename, "&<>", '-'); + tmp = g_strrstr_len (priv->id_filename, -1, "."); if (tmp != NULL) *tmp = '\0'; } @@ -3556,8 +3557,8 @@ as_app_create_token_cache_target (AsApp *app, AsApp *donor) guint j; /* add all the data we have */ - if (priv->id != NULL) - as_app_add_tokens (app, priv->id, "C", 100); + if (priv->id_full != NULL) + as_app_add_tokens (app, priv->id_full, "C", 100); locales = g_get_language_names (); for (i = 0; locales[i] != NULL; i++) { if (g_str_has_suffix (locales[i], ".UTF-8")) diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h index b554814..32bcc4f 100644 --- a/libappstream-glib/as-app.h +++ b/libappstream-glib/as-app.h @@ -239,7 +239,7 @@ GHashTable *as_app_get_urls (AsApp *app); GPtrArray *as_app_get_vetos (AsApp *app); const gchar *as_app_get_icon (AsApp *app); const gchar *as_app_get_icon_path (AsApp *app); -const gchar *as_app_get_id (AsApp *app); +const gchar *as_app_get_id_filename (AsApp *app); const gchar *as_app_get_id_full (AsApp *app); const gchar *as_app_get_pkgname_default (AsApp *app); const gchar *as_app_get_source_pkgname (AsApp *app); diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 52813e3..7c31a6f 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -591,7 +591,7 @@ as_test_app_func (void) /* verify */ g_assert_cmpstr (as_app_get_id_full (app), ==, "org.gnome.Software.desktop"); - g_assert_cmpstr (as_app_get_id (app), ==, "org.gnome.Software"); + g_assert_cmpstr (as_app_get_id_filename (app), ==, "org.gnome.Software"); g_assert_cmpstr (as_app_get_name (app, "pl"), ==, "Oprogramowanie"); g_assert_cmpstr (as_app_get_comment (app, NULL), ==, "Application manager"); g_assert_cmpstr (as_app_get_developer_name (app, NULL), ==, "GNOME Foundation"); |