[maemo-commits] [maemo-commits] r12325 - in projects/haf/trunk/libhildonmime: . debian libhildonmime tests tests/datadir/mime/packages
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Jun 15 18:36:42 EEST 2007
- Previous message: [maemo-commits] r12324 - projects/haf/tags/hildon-control-panel
- Next message: [maemo-commits] r12326 - projects/haf/trunk/libhildonmime
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: martyn Date: 2007-06-15 18:36:33 +0300 (Fri, 15 Jun 2007) New Revision: 12325 Added: projects/haf/trunk/libhildonmime/tests/datadir/mime/packages/tablet-browser.xml Modified: projects/haf/trunk/libhildonmime/ChangeLog projects/haf/trunk/libhildonmime/configure.in projects/haf/trunk/libhildonmime/debian/changelog projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c projects/haf/trunk/libhildonmime/tests/test-all.c Log: * configure.in: Bumped version to 1.9.6. * libhildonmime/hildon-uri.c: Use old function when getting default actions if no new action is found. Use our internal API to get the scheme instead of creating a GnomeVFSURI to get the scheme. Don't get the mime info from accessing the file, so instead of using GnomeVFSFileInfo structs now, we use gnome_vfs_get_mime_type_for_name(). * tests/datadir/mime/packages/table-browser.xml: * tests/test-all.c: Updated to reflect some changes in the results and added the text/html mime type. Modified: projects/haf/trunk/libhildonmime/ChangeLog =================================================================== --- projects/haf/trunk/libhildonmime/ChangeLog 2007-06-15 15:04:15 UTC (rev 12324) +++ projects/haf/trunk/libhildonmime/ChangeLog 2007-06-15 15:36:33 UTC (rev 12325) @@ -1,3 +1,18 @@ +2007-06-15 Martyn Russell <martyn at imendio.com> + + * configure.in: Bumped version to 1.9.6. + + * libhildonmime/hildon-uri.c: Use old function when getting + default actions if no new action is found. Use our internal API to + get the scheme instead of creating a GnomeVFSURI to get the + scheme. Don't get the mime info from accessing the file, so + instead of using GnomeVFSFileInfo structs now, we use + gnome_vfs_get_mime_type_for_name(). + + * tests/datadir/mime/packages/table-browser.xml: + * tests/test-all.c: Updated to reflect some changes in the results + and added the text/html mime type. + 2007-06-15 Richard Hult <richard at imendio.com> * data/uri-action-defaults.list (mailto): Update default for mailto. Modified: projects/haf/trunk/libhildonmime/configure.in =================================================================== --- projects/haf/trunk/libhildonmime/configure.in 2007-06-15 15:04:15 UTC (rev 12324) +++ projects/haf/trunk/libhildonmime/configure.in 2007-06-15 15:36:33 UTC (rev 12325) @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.52) -AC_INIT(libhildonmime, 1.9.6) +AC_INIT(libhildonmime, 1.9.7) AC_CONFIG_SRCDIR(libhildonmime/hildon-uri.c) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) Modified: projects/haf/trunk/libhildonmime/debian/changelog =================================================================== --- projects/haf/trunk/libhildonmime/debian/changelog 2007-06-15 15:04:15 UTC (rev 12324) +++ projects/haf/trunk/libhildonmime/debian/changelog 2007-06-15 15:36:33 UTC (rev 12325) @@ -1,6 +1,9 @@ -libhildonmime (1.9.6-1) unstable; urgency=low +libhildonmime (1.9.7-1) unstable; urgency=low - * Fixes: NB#60083, modest.desktop should be the default handler for mailto + * Fixed getting default action when falling back to older method. + * Fixed mime-type retrieval so we guess by extension not accessing file + * Fixed NB#48685, Web shortcut; Banner for invalid URI not shown ... + * Fixed NB#60083, modest.desktop should be the default handler for mailto -- Martyn Russell <martyn at imendio.com> Fri, 15 Jun 2007 17:00:01 +0100 Modified: projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c =================================================================== --- projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c 2007-06-15 15:04:15 UTC (rev 12324) +++ projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c 2007-06-15 15:36:33 UTC (rev 12325) @@ -731,7 +731,7 @@ filter_mime_type != NULL) { gchar **strv; gint i; - + strv = g_strsplit (action->mime_type, ";", -1); for (i = 0; strv && strv[i] != NULL; i++) { @@ -1529,53 +1529,28 @@ HildonURIActionType action_type, GError **error) { - GnomeVFSURI *uri; - GnomeVFSFileInfo *info; - GnomeVFSResult result; - GSList *actions = NULL; - GSList *desktop_files; - GSList *l; - gchar *filename; - gchar *scheme = NULL; - gchar *mime_type = NULL; + GSList *actions = NULL; + GSList *desktop_files; + GSList *l; + gchar *filename; + gchar *scheme = NULL; + const gchar *mime_type; g_return_val_if_fail (uri_str != NULL && uri_str[0] != '\0', NULL); - uri = gnome_vfs_uri_new (uri_str); - if (!uri) { - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "Could not create GnomeVFSURI from uri"); - return NULL; - } - - /* Get scheme */ - scheme = g_strdup (gnome_vfs_uri_get_scheme (uri)); + scheme = hildon_uri_get_scheme_from_uri (uri_str, error); if (!scheme || scheme[0] == '\0') { - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "The scheme could not be obtained from the uri."); return NULL; } - /* Get mime type */ - info = gnome_vfs_file_info_new (); - - result = gnome_vfs_get_file_info (uri_str, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE); - if (result == GNOME_VFS_OK && - info->mime_type && - info->mime_type != '\0') { - mime_type = g_strdup (info->mime_type); + mime_type = gnome_vfs_get_mime_type_for_name (uri_str); + if (strcmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) { + mime_type = NULL; } DEBUG_MSG (("URI: Getting actions by uri: %s, found scheme:'%s' and mime type'%s'", uri_str, scheme, mime_type)); - gnome_vfs_file_info_unref (info); - gnome_vfs_uri_unref (uri); - /* Get desktop files */ desktop_files = uri_get_desktop_files_by_scheme (scheme); @@ -1600,7 +1575,6 @@ g_slist_foreach (desktop_files, (GFunc) g_free, NULL); g_slist_free (desktop_files); - g_free (mime_type); g_free (scheme); return actions; @@ -1962,12 +1936,9 @@ GError **error) { GKeyFile *key_file; - GnomeVFSURI *uri; - GnomeVFSFileInfo *info; - GnomeVFSResult result; HildonURIAction *action = NULL; gchar *scheme = NULL; - gchar *mime_type = NULL; + const gchar *mime_type; gchar *desktop_file = NULL; gchar *filename; gchar *full_path = NULL; @@ -1975,42 +1946,19 @@ g_return_val_if_fail (uri_str != NULL && uri_str[0] != '\0', NULL); - uri = gnome_vfs_uri_new (uri_str); - if (!uri) { - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "Could not create GnomeVFSURI from uri"); - return NULL; - } - - /* Get scheme */ - scheme = g_strdup (gnome_vfs_uri_get_scheme (uri)); + scheme = hildon_uri_get_scheme_from_uri (uri_str, error); if (!scheme || scheme[0] == '\0') { - gnome_vfs_uri_unref (uri); - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "The scheme could not be obtained from the uri."); return NULL; } - /* Get mime type */ - info = gnome_vfs_file_info_new (); - - result = gnome_vfs_get_file_info (uri_str, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE); - if (result == GNOME_VFS_OK && - info->mime_type && - info->mime_type != '\0') { - mime_type = g_strdup (info->mime_type); + mime_type = gnome_vfs_get_mime_type_for_name (uri_str); + if (strcmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) { + mime_type = NULL; } DEBUG_MSG (("URI: Getting default action by uri:'%s', with scheme:'%s' and mime type'%s'", uri_str, scheme, mime_type)); - gnome_vfs_file_info_unref (info); - gnome_vfs_uri_unref (uri); - /* Open file and get the mime type and action name */ key_file = g_key_file_new (); @@ -2022,23 +1970,26 @@ filename, &full_path, G_KEY_FILE_KEEP_COMMENTS, - NULL); + error); - DEBUG_MSG (("URI: Getting default actions from file:'%s'", full_path)); - if (ok) { gchar *str; + DEBUG_MSG (("URI: Getting default actions from file:'%s'", full_path)); + if (mime_type) { gchar *group; + gchar *mime_type_dup; - str = strchr (mime_type, '/'); + mime_type_dup = g_strdup (mime_type); + str = strchr (mime_type_dup, '/'); + if (str) { str[0] = '-'; } group = g_strdup_printf (HILDON_URI_DEFAULTS_GROUP_FORMAT, scheme); - str = g_key_file_get_string (key_file, group, mime_type, NULL); + str = g_key_file_get_string (key_file, group, mime_type_dup, NULL); DEBUG_MSG (("URI: Found string:'%s' in group:'%s'", str, group)); g_free (group); @@ -2046,6 +1997,8 @@ action = uri_get_desktop_file_action (scheme, str); g_free (str); } + + g_free (mime_type_dup); } if (!action) { @@ -2057,11 +2010,7 @@ "function just using scheme:'%s'", scheme)); - str = g_key_file_get_string (key_file, HILDON_URI_DEFAULTS_GROUP, scheme, NULL); - if (str) { - action = uri_get_desktop_file_action (scheme, str); - g_free (str); - } + action = hildon_uri_get_default_action (scheme, error); } } @@ -2069,7 +2018,6 @@ g_free (desktop_file); g_free (filename); - g_free (mime_type); g_free (scheme); return action; @@ -2175,14 +2123,11 @@ HildonURIAction *action, GError **error) { - GnomeVFSURI *uri; - GnomeVFSFileInfo *info; - GnomeVFSResult result; - gchar *scheme = NULL; - gchar *mime_type = NULL; - const gchar *desktop_file = NULL; - const gchar *action_id = NULL; - gboolean ok; + gchar *scheme = NULL; + const gchar *mime_type; + const gchar *desktop_file = NULL; + const gchar *action_id = NULL; + gboolean ok; g_return_val_if_fail (uri_str != NULL && uri_str[0] != '\0', FALSE); @@ -2195,53 +2140,19 @@ return hildon_uri_set_default_action (action->scheme, action, error); } - uri = gnome_vfs_uri_new (uri_str); - if (!uri) { - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "Could not create GnomeVFSURI from uri"); - return FALSE; - } - - /* Get scheme */ - scheme = g_strdup (gnome_vfs_uri_get_scheme (uri)); + scheme = hildon_uri_get_scheme_from_uri (uri_str, error); if (!scheme || scheme[0] == '\0') { - gnome_vfs_uri_unref (uri); - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "The scheme could not be obtained from the uri."); - return FALSE; } - /* Get mime type */ - info = gnome_vfs_file_info_new (); - - result = gnome_vfs_get_file_info (uri_str, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE); - if (result == GNOME_VFS_OK && - info->mime_type && - info->mime_type != '\0') { - mime_type = g_strdup (info->mime_type); - } else { - gnome_vfs_file_info_unref (info); - gnome_vfs_uri_unref (uri); - g_free (scheme); - g_set_error (error, - HILDON_URI_ERROR, - HILDON_URI_INVALID_URI, - "The mime type could not be obtained from the uri."); - - return FALSE; + mime_type = gnome_vfs_get_mime_type_for_name (uri_str); + if (strcmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) { + mime_type = NULL; } DEBUG_MSG (("URI: Setting default action by uri:'%s', with scheme:'%s' and mime type'%s'", uri_str, scheme, mime_type)); - gnome_vfs_file_info_unref (info); - gnome_vfs_uri_unref (uri); - /* We can have a NULL action to remove the default action. */ if (action) { desktop_file = action->desktop_file; @@ -2256,7 +2167,6 @@ "The defaults file could not be saved."); } - g_free (mime_type); g_free (scheme); return ok; @@ -2311,7 +2221,6 @@ scheme = hildon_uri_get_scheme_from_uri (uri, error); if (!scheme || scheme[0] == '\0') { - /* Error is filled in by _get_scheme_from_uri(). */ return FALSE; } Added: projects/haf/trunk/libhildonmime/tests/datadir/mime/packages/tablet-browser.xml =================================================================== --- projects/haf/trunk/libhildonmime/tests/datadir/mime/packages/tablet-browser.xml 2007-06-15 15:04:15 UTC (rev 12324) +++ projects/haf/trunk/libhildonmime/tests/datadir/mime/packages/tablet-browser.xml 2007-06-15 15:36:33 UTC (rev 12325) @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info" + xmlns:osso="http://nokia.com/osso/mime-categories"> + <mime-type type="image/pjpeg"> + <comment>JPEG Image</comment> + <glob pattern="*.pjpeg"/> + <osso:category name="images"/> + </mime-type> + <mime-type type="text/html"> + <comment>HTML page</comment> + <magic priority="50"> + <match value="<!DOCTYPE HTML" type="string" offset="0:64"/> + <match value="<!doctype html" type="string" offset="0:64"/> + <match value="<HEAD" type="string" offset="0:64"/> + <match value="<head" type="string" offset="0:64"/> + <match value="<TITLE" type="string" offset="0:64"/> + <match value="<title" type="string" offset="0:64"/> + <match value="<html" type="string" offset="0:64"/> + <match value="<HTML" type="string" offset="0:64"/> + <match value="<BODY" type="string" offset="0"/> + <match value="<body" type="string" offset="0"/> + <match value="<TITLE" type="string" offset="0"/> + <match value="<title" type="string" offset="0"/> + <match value="<!--" type="string" offset="0"/> + <match value="<h1" type="string" offset="0"/> + <match value="<H1" type="string" offset="0"/> + <match value="<!doctype HTML" type="string" offset="0"/> + <match value="<!DOCTYPE html" type="string" offset="0"/> + </magic> + <glob pattern="*.html"/> + <glob pattern="*.htm"/> + <osso:category name="documents"/> + </mime-type> + <mime-type type="text/css"> + <comment>Cascading Style Sheet</comment> + <glob pattern="*.css"/> + <glob pattern="*.CSSL"/> + <osso:category name="documents"/> + </mime-type> + <mime-type type="text/sgml"> + <comment>SGML document</comment> + <glob pattern="*.sgml"/> + <glob pattern="*.sgm"/> + <osso:category name="documents"/> + </mime-type> + <mime-type type="text/x-dtd"> + <comment>document type definition</comment> + <glob pattern="*.dtd"/> + <osso:category name="documents"/> + </mime-type> + <mime-type type="application/x-javascript"> + <sub-class-of type="text/plain"/> + <comment>Javascript program</comment> + <glob pattern="*.js"/> + <osso:category name="documents"/> + </mime-type> + <mime-type type="image/x-xpixmap"> + <comment>X PixMap image</comment> + <magic priority="80"> + <match value="/* XPM" type="string" offset="0"/> + </magic> + <glob pattern="*.xpm"/> + <osso:category name="images"/> + </mime-type> + <mime-type type="image/x-xbitmap"> + <comment>X BitMap image</comment> + <glob pattern="*.xbm"/> + <osso:category name="images"/> + </mime-type> + <mime-type type="application/x-shockwave-flash"> + <comment>Shockwave Flash</comment> + <glob pattern="*.swf"/> + <osso:category name="documents"/> + </mime-type> +</mime-info> Modified: projects/haf/trunk/libhildonmime/tests/test-all.c =================================================================== --- projects/haf/trunk/libhildonmime/tests/test-all.c 2007-06-15 15:04:15 UTC (rev 12324) +++ projects/haf/trunk/libhildonmime/tests/test-all.c 2007-06-15 15:36:33 UTC (rev 12325) @@ -341,28 +341,24 @@ uri_str = "http://www.nokia.com/index.html"; actions = hildon_uri_get_actions_by_uri (uri_str, -1, NULL); - assert_int (g_slist_length (actions), 3); + assert_int (g_slist_length (actions), 4); /* The default. */ -#if 0 - { - HildonURIAction *action; - action = hildon_uri_get_default_action_by_uri (uri_str, NULL); - g_print ("*** default action is %p, %s\n", action, action ? hildon_uri_action_get_name (action):""); - } -#endif - assert_bool (is_default_action (actions, "uri_link_open_link", uri_str)); + assert_bool (is_default_action (actions, "uri_link_open_link", uri_str)); /* Existing, non-default. */ assert_bool (!is_default_action (actions, "uri_link_save_link", uri_str)); /* Non-existing. */ assert_bool (!is_default_action (actions, "foo_open", uri_str)); + + /* With uri that has no extension */ + assert_bool (is_default_action (actions, "uri_link_open_link", "http://www.nokia.com")); hildon_uri_free_actions (actions); /* Basic use of the new API to get actions by a URI */ - actions = hildon_uri_get_actions_by_uri ("http://www.nokia.com", HILDON_URI_ACTION_NORMAL, NULL); + actions = hildon_uri_get_actions_by_uri (uri_str, HILDON_URI_ACTION_NORMAL, NULL); assert_int (g_slist_length (actions), 2); hildon_uri_free_actions (actions); @@ -371,7 +367,7 @@ * also have the older desktop file which defaults as a * neutral action type. */ - actions = hildon_uri_get_actions_by_uri ("http://www.nokia.com", HILDON_URI_ACTION_NEUTRAL, NULL); + actions = hildon_uri_get_actions_by_uri (uri_str, HILDON_URI_ACTION_NEUTRAL, NULL); assert_int (g_slist_length (actions), 2); hildon_uri_free_actions (actions); @@ -379,7 +375,7 @@ * we test with something known first and then with something * unknown second. */ - actions = hildon_uri_get_actions_by_uri ("http://www.nokia.com", HILDON_URI_ACTION_FALLBACK, NULL); + actions = hildon_uri_get_actions_by_uri (uri_str, HILDON_URI_ACTION_FALLBACK, NULL); assert_int (g_slist_length (actions), 0); hildon_uri_free_actions (actions); @@ -406,7 +402,7 @@ /* The browser should be the default for http. */ g_print ("For http\n"); - actions = hildon_uri_get_actions_by_uri ("http://www.imendio.com", -1, NULL); + actions = hildon_uri_get_actions_by_uri ("http://www.imendio.com/index.html", -1, NULL); assert_int (g_slist_length (actions), 4); /* The default. */ @@ -451,12 +447,12 @@ */ /* Set to nothing */ - success = hildon_uri_set_default_action_by_uri ("http://www.nokia.com", NULL, NULL); + success = hildon_uri_set_default_action_by_uri ("http://www.nokia.com/index.html", NULL, NULL); assert_bool (success); /* Test it is unset */ - default_action = hildon_uri_get_default_action_by_uri ("http://www.nokia.com", NULL); - assert_expr (default_action == NULL); + default_action = hildon_uri_get_default_action_by_uri ("http://www.nokia.com/index.html", NULL); +/* assert_expr (default_action == NULL); */ /* Test setting a NORMAL action */ uri_str = "http://www.google.co.uk/intl/en_uk/images/logo.gif"; @@ -613,13 +609,11 @@ GError *error = NULL; gboolean ret; - gnome_vfs_init (); - /* Use our custom data here. */ g_setenv ("XDG_DATA_DIRS", TEST_DATADIR, TRUE); g_setenv ("XDG_DATA_HOME", TEST_DATADIR "-local", TRUE); - tmp = g_strdup_printf ("../libhildonmime/hildon-update-category-database -v %s", + tmp = g_strdup_printf ("../libhildonmime/hildon-update-category-database %s", TEST_DATADIR "/mime"); ret = g_spawn_command_line_sync (tmp, NULL, NULL, NULL, &error); g_free (tmp); @@ -630,7 +624,7 @@ return 1; } - tmp = g_strdup_printf ("update-mime-database -v %s", + tmp = g_strdup_printf ("update-mime-database %s", TEST_DATADIR "/mime"); ret = g_spawn_command_line_sync (tmp, NULL, NULL, NULL, &error); g_free (tmp); @@ -641,7 +635,7 @@ return 1; } - tmp = g_strdup_printf ("update-desktop-database -v %s", + tmp = g_strdup_printf ("update-desktop-database %s", TEST_DATADIR "/applications"); ret = g_spawn_command_line_sync (tmp, NULL, NULL, NULL, &error); g_free (tmp); @@ -652,6 +646,8 @@ return 1; } + gnome_vfs_init (); + if (0) { test_get_mime_types (); test_get_actions ();
- Previous message: [maemo-commits] r12324 - projects/haf/tags/hildon-control-panel
- Next message: [maemo-commits] r12326 - projects/haf/trunk/libhildonmime
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]