[maemo-commits] [maemo-commits] r12335 - in projects/haf/trunk/libhildonmime: . debian libhildonmime tests tests/datadir/applications tests/datadir/applications/test

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jun 18 18:27:39 EEST 2007
Author: martyn
Date: 2007-06-18 18:27:27 +0300 (Mon, 18 Jun 2007)
New Revision: 12335

Added:
   projects/haf/trunk/libhildonmime/tests/TESTS
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/datadir/applications/test/mp_ui.desktop
   projects/haf/trunk/libhildonmime/tests/datadir/applications/uri-action-defaults.list
   projects/haf/trunk/libhildonmime/tests/test-uri.c
Log:
	* configure.in:
	* debian/changelog: Bumped version to 1.9.8.

	* libhildonmime/hildon-uri.c: Updated action filter function to
	sort by action type. Fixed hildon_uri_open() to use _by_uri() API
	when getting default action. 

	* tests/TESTS: Added some test scenarios.

	* tests/datadir/applications/test/mp_ui.desktop: Updated according
	to the new media player desktop file sent to us.

	* tests/datadir/applications/uri-action-defaults.list: Added the
	media player as the default handler for audio/x-mp3 mime types.

	* tests/test-uri.c: Fixed the -u option which opens a uri, it was
	using the old API.


Modified: projects/haf/trunk/libhildonmime/ChangeLog
===================================================================
--- projects/haf/trunk/libhildonmime/ChangeLog	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/ChangeLog	2007-06-18 15:27:27 UTC (rev 12335)
@@ -1,3 +1,23 @@
+2007-06-18  Martyn Russell  <martyn at imendio.com>
+
+	* configure.in:
+	* debian/changelog: Bumped version to 1.9.8.
+	
+	* libhildonmime/hildon-uri.c: Updated action filter function to
+	sort by action type. Fixed hildon_uri_open() to use _by_uri() API
+	when getting default action. 
+
+	* tests/TESTS: Added some test scenarios.
+
+	* tests/datadir/applications/test/mp_ui.desktop: Updated according
+	to the new media player desktop file sent to us.
+	
+	* tests/datadir/applications/uri-action-defaults.list: Added the
+	media player as the default handler for audio/x-mp3 mime types.
+	
+	* tests/test-uri.c: Fixed the -u option which opens a uri, it was
+	using the old API.
+
 2007-06-15  Richard Hult  <richard at imendio.com>
 
 	* Release 1.9.7.

Modified: projects/haf/trunk/libhildonmime/configure.in
===================================================================
--- projects/haf/trunk/libhildonmime/configure.in	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/configure.in	2007-06-18 15:27:27 UTC (rev 12335)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.52)
  
-AC_INIT(libhildonmime, 1.9.7)
+AC_INIT(libhildonmime, 1.9.8)
 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-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/debian/changelog	2007-06-18 15:27:27 UTC (rev 12335)
@@ -1,3 +1,12 @@
+libhildonmime (1.9.8-1) unstable; urgency=low
+
+  * UNRELEASED!
+  * Updated action filter function to sort by action type.
+  * Fixed hildon_uri_open() to use _by_uri() API when getting default action.
+  * Fixed test-uri -u option which was using old API.
+
+ -- Martyn Russell <martyn at imendio.com>  Fri, 22 May 2007 17:00:01 +0100
+	
 libhildonmime (1.9.7-2) unstable; urgency=low
 
   * Fixed getting default action when falling back to older method

Modified: projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c
===================================================================
--- projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/libhildonmime/hildon-uri.c	2007-06-18 15:27:27 UTC (rev 12335)
@@ -689,6 +689,27 @@
 	return actions;
 }
 
+static gint 
+uri_get_desktop_file_actions_sort_cb (gconstpointer a,
+				      gconstpointer b)
+{
+	HildonURIAction *action_a;
+	HildonURIAction *action_b;
+	gint             diff;
+	      
+	g_return_val_if_fail (a != NULL, 0);
+	g_return_val_if_fail (b != NULL, 0);
+
+	action_a = (HildonURIAction*) a;
+	action_b = (HildonURIAction*) b;
+
+	/* Sort by Normal, Neutral then Fallback */
+	diff = action_a->type - action_b->type;
+	diff = CLAMP (diff, -1, +1);
+
+	return diff;
+}
+
 static GSList *
 uri_get_desktop_file_actions_filtered (GSList              *actions,
 				       HildonURIActionType  filter_action_type,
@@ -754,8 +775,10 @@
 			continue;
 		}
 
-		actions_filtered = g_slist_append (actions_filtered, 
-						   hildon_uri_action_ref (action));
+		actions_filtered = g_slist_insert_sorted (actions_filtered, 
+							  hildon_uri_action_ref (action),
+							  (GCompareFunc)
+							  uri_get_desktop_file_actions_sort_cb);
 	}
 
 	DEBUG_MSG (("URI: Filtering %d actions by mime type:'%s' and "
@@ -1758,10 +1781,11 @@
 
 	default_action = hildon_uri_get_default_action_by_uri (uri, error);
 
-	DEBUG_MSG (("URI: Checking desktop file is default for scheme:'%s':\n"
+	DEBUG_MSG (("URI: Checking desktop file is default by uri:'%s' for scheme:'%s':\n"
 		    "\tdefault_action:%p\n"
 		    "\tdefault_action->desktop_file:'%s'\n"
 		    "\taction->desktop_file:'%s'",
+		    uri,
 		    action->scheme,
 		    default_action,
 		    default_action ? default_action->desktop_file : "",
@@ -1794,7 +1818,7 @@
 			equal = TRUE;
 		}
 		
-		DEBUG_MSG (("URI: Checking desktop file is default:\n"
+		DEBUG_MSG (("URI: Checking desktop file is default by uri:'%s':\n"
 			    "\tfile1:'%s'\n"
 			    "\tfile2:'%s'\n"
 			    "\tname1:'%s'\n"
@@ -1802,6 +1826,7 @@
 			    "\tmethod1:'%s'\n"
 			    "\tmethod2:'%s'\n"
 			    "\tEQUAL = %s",
+			    uri,
 			    desktop_file1, desktop_file2,
 			    default_action->name, action->name,
 			    default_action->method, action->method,
@@ -1990,7 +2015,11 @@
 
 			group = g_strdup_printf (HILDON_URI_DEFAULTS_GROUP_FORMAT, scheme);
 			str = g_key_file_get_string (key_file, group, mime_type_dup, NULL);
-			DEBUG_MSG (("URI: Found string:'%s' in group:'%s'", str, group));
+			DEBUG_MSG (("URI: %s string:'%s' in group:'%s' with key:'%s'", 
+				    str ? "Found" : "Didn't find", 
+				    str, 
+				    group,
+				    mime_type_dup));
 			g_free (group);
 
 			if (str) {
@@ -2206,6 +2235,9 @@
 	gboolean          ok;
 	gboolean          cleanup_action = FALSE;
 
+	DEBUG_MSG (("URI: Attempting to open URI:'%s' with %s action specified",
+		    uri, action_to_try ? "an" : "no"));
+
 	connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
 	if (!connection) {
 		str = "Could not get DBus connection";
@@ -2230,16 +2262,7 @@
 			    "since no action was given.",
 			    uri));
 		
-		/* TODO: Fix this, what was the idea here */
-/*
-		if (action->id) {
-			action = hildon_uri_get_default_action_by_uri (uri, error);
-		} else {
-*/
-		action = hildon_uri_get_default_action (scheme, error);
-
-/*		}
- */
+		action = hildon_uri_get_default_action_by_uri (uri, error);
 		cleanup_action = TRUE;
 
 		if (!action) {
@@ -2251,7 +2274,7 @@
 			 * an error further down, we want to use it
 			 * for that.
 			 */
-			actions = hildon_uri_get_actions (scheme, NULL);
+			actions = hildon_uri_get_actions_by_uri (scheme, -1, NULL);
 
 			/* At this stage we choose the first action
 			 * available from the long list picked up in

Added: projects/haf/trunk/libhildonmime/tests/TESTS
===================================================================
--- projects/haf/trunk/libhildonmime/tests/TESTS	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/tests/TESTS	2007-06-18 15:27:27 UTC (rev 12335)
@@ -0,0 +1,62 @@
+Tests to carry out and expected results:
+========================================
+
+For these tests, you will need to set up your environment first.
+If running in scratchbox, you need to make sure your DBus session is running:
+	
+	$ export DISPLAY=127.0.0.1:2
+	$ af-sb-init.sh start
+
+Then 
+
+	$ source /etc/osso-af-init/af-defines.sh
+
+When this is done, you will need to make sure your environment points to the test data:
+
+	$ export XDG_DATA_HOME="/home/martyn/Source/libhildonmime/tests/datadir-local"	
+	$ export XDG_DATA_DIRS="/home/martyn/Source/libhildonmime/tests/datadir"
+
+For the test-all test, this is set up automatically, for all others, you will need this.	
+
+----
+
+TEST: 
+	Opening a uri of .html mime type should open in browser.
+COMMAND:
+	./test-uri -u http://www.foo.com/bar.html
+EXPECTED: 
+	Using default action:'uri_link_open_link' to open URI:'http://www.foo.com/bar.html'...
+	Opened URI:'http://www.foo.com/bar.html' successfully
+
+----
+
+TEST: 
+	Opening a uri of .mp3 mime type should open in media player.
+COMMAND:
+	./test-uri -u http://www.foo.com/bar.mp3
+EXPECTED:
+	Using default action:'uri_link_play' to open URI:'http://www.foo.com/bar.mp3'...
+	Opened URI:'http://www.foo.com/bar.mp3' successfully
+
+----
+
+TEST:
+	Getting a list of actions for an .mp3 mime type:
+COMMAND:
+	./test-uri -a http://www.foo.com/bar.mp3	
+EXPECTED:
+	Actions for uri:'http://www.foo.com/bar.mp3' are:
+	        uri_link_play
+        	uri_link_save_link
+	        image_viewer_open
+ 
+----
+
+TEST: 
+	Getting a list of actions for 'testplugin' scheme:
+COMMAND:
+	./test-uri -a testplugin://www.foo.com/bar.baz
+EXPECTED:
+	Actions for uri:'testplugin://www.foo.com/bar.baz' are:
+	        test-plugin-method
+

Modified: projects/haf/trunk/libhildonmime/tests/datadir/applications/test/mp_ui.desktop
===================================================================
--- projects/haf/trunk/libhildonmime/tests/datadir/applications/test/mp_ui.desktop	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/tests/datadir/applications/test/mp_ui.desktop	2007-06-18 15:27:27 UTC (rev 12335)
@@ -1,22 +1,28 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Name=medi_ap_mediaplayer_name
-Exec=/usr/bin/mediaplayer-ui
-Icon=qgn_list_medi
-X-Icon-path=/usr/share/pixmaps/
-X-Window-Icon=tn-bookmarks-link
-X-Window-Icon-Dimmed=tn-bookmarks-link-dimmed
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Service=mediaplayer
-X-Osso-Type=application/x-executable
-X-Osso-URI-Actions=rtsp
-MimeType=video/x-msvideo;audio/x-mp3;video/mpeg;audio/x-wav;audio/x-real;video/x-real;audio/x-m4a;audio/x-amr;video/x-mp4;video/3gpp;audio/x-mp2;audio/x-ms-wma;audio/x-mpegurl;audio/x-scpls;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;video/x-ms-asf;audio/x-ms-wax;video/x-ms-wvx;application/vnd.ms-wpl;audio/mp3;video/avi;audio/wav;audio/mpeg
-Comment=medi_ap_mediaplayer_name_thumb
-
-[X-Osso-URI-Action Handler rtsp]
-Method=mime_open
-Name=medi_ap_mediaplayer_name
-TranslationDomain=mediaplayer
-
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Name=medi_ap_mediaplayer_name
+Exec=/usr/bin/mediaplayer-ui
+Icon=qgn_list_medi
+X-Icon-path=/usr/share/pixmaps/
+X-Window-Icon=tn-bookmarks-link
+X-Window-Icon-Dimmed=tn-bookmarks-link-dimmed
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Service=mediaplayer
+X-Osso-Type=application/x-executable
+MimeType=video/x-msvideo;audio/x-mp3;video/mpeg;audio/x-wav;audio/x-real;video/x-real;audio/x-m4a;audio/x-amr;video/x-mp4;video/3gpp;audio/x-mp2;audio/x-ms-wma;video/x-ms-wmv;video/x-ms-wm;audio/x-mpegurl;audio/x-scpls;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;video/x-ms-asf;application/x-ms-asx;audio/x-ms-wax;video/x-ms-wvx;video/x-ms-wmx;application/vnd.ms-wpl;audio/mp3;video/avi;audio/wav;audio/mpeg
+Comment=medi_ap_mediaplayer_name_thumb
+
+[X-Osso-URI-Actions]
+rtsp=X-Osso-URI-Action-Open;
+mms=X-Osso-URI-Action-Open;
+http=X-Osso-URI-Action-Open;
+
+
+[X-Osso-URI-Action-Open]
+Method=mime_open
+Name=uri_link_play
+TranslationDomain=osso-uri
+
+

Modified: projects/haf/trunk/libhildonmime/tests/datadir/applications/uri-action-defaults.list
===================================================================
--- projects/haf/trunk/libhildonmime/tests/datadir/applications/uri-action-defaults.list	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/tests/datadir/applications/uri-action-defaults.list	2007-06-18 15:27:27 UTC (rev 12335)
@@ -11,3 +11,4 @@
 # For new actions
 [X-Osso-URI-Scheme http]
 text-html=test-browser.desktop:X-Osso-URI-Action-Open
+audio-x-mp3=test-mp_ui.desktop:X-Osso-URI-Action-Open

Modified: projects/haf/trunk/libhildonmime/tests/test-uri.c
===================================================================
--- projects/haf/trunk/libhildonmime/tests/test-uri.c	2007-06-18 15:10:14 UTC (rev 12334)
+++ projects/haf/trunk/libhildonmime/tests/test-uri.c	2007-06-18 15:27:27 UTC (rev 12335)
@@ -251,8 +251,8 @@
 
 		if (actions) {
 			HildonURIAction *action;
-			const gchar   *name = NULL;
-			gboolean       found = FALSE;
+			const gchar     *name = NULL;
+			gboolean         found = FALSE;
 
 			for (l = actions; l && !found; l = l->next) {
 				action = l->data;
@@ -266,7 +266,7 @@
 			if (found) {
 				gboolean is_default_action;
 
-				is_default_action = hildon_uri_is_default_action (action, NULL);
+				is_default_action = hildon_uri_is_default_action_by_uri (get_actions_by_uri, action, NULL);
 
 				g_print ("Action:'%s' %s the default action\n", 
 					 is_default, is_default_action ? "is" : "is NOT");
@@ -430,13 +430,13 @@
 		
 		while ((uri = open_uris[i++]) != NULL) {
 		       HildonURIAction *default_action = NULL;
-		       gboolean       success;
-
+		       gboolean         success;
+ 
 		       if (!use_default) {
 			       gchar *scheme;
 
 			       scheme = hildon_uri_get_scheme_from_uri (uri, NULL);
-			       default_action = hildon_uri_get_default_action (scheme, NULL);
+			       default_action = hildon_uri_get_default_action_by_uri (uri, NULL);
 			       
 			       if (default_action) {
 				       g_print ("Using default action:'%s' to open URI:'%s'...\n", 


More information about the maemo-commits mailing list