gnome_vfs_mime_get_short_list_componentsgnome_vfs_mime_get_short_list_components



Hi,

When the new MIME system was written, the concept of short lists were
removed and the functions that returned short lists previously were
changed to return complete lists.  The problem is there is code out
there that expects components listed in the short list to be ideal for a
given mime type.  In particular, gnome_vfs_mime_get_default_component
relies on the short list to prioritize which component to return. 

This causes unusual bugs to popup like vcard source being shown in an
embedded abiword control in evolution instead of a vcard and the wrong
view to pop up in nautilus.

The fix is two parts:

1) Remove the code that uses the short list from get_default_component.
2) Reorder the shortlist so that controls that can handle (for instance)
text/vcard will be given higher priority than controls that can just
handle text/plain.

Note I accidentally commited this fix before the weekend without release
team approval and have since reverted it pending release team approval.

--Ray Strode
Index: gnome-vfs-mime-handlers.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-handlers.c,v
retrieving revision 1.108
diff -u -u -p -r1.108 gnome-vfs-mime-handlers.c
--- gnome-vfs-mime-handlers.c	7 Sep 2004 06:44:55 -0000	1.108
+++ gnome-vfs-mime-handlers.c	7 Sep 2004 06:58:38 -0000
@@ -376,10 +376,7 @@ gnome_vfs_mime_get_default_component (co
 	CORBA_Environment ev;
 	char *supertype;
 	char *query;
-	char *sort[6];
-        GList *short_list;
-	GList *p;
-	char *prev;
+	char *sort[5];
 
 	if (mime_type == NULL) {
 		return NULL;
@@ -408,39 +405,15 @@ gnome_vfs_mime_get_default_component (co
 		sort[0] = g_strdup ("true");
 	}
 
-	short_list = gnome_vfs_mime_get_short_list_components (mime_type);
-	short_list = g_list_concat (short_list,
-				    gnome_vfs_mime_get_short_list_components (supertype));
-	if (short_list != NULL) {
-		sort[1] = g_strdup ("prefer_by_list_order(iid, ['");
-
-		for (p = short_list; p != NULL; p = p->next) {
- 			prev = sort[1];
-			
-			if (p->next != NULL) {
-				sort[1] = g_strconcat (prev, ((Bonobo_ServerInfo *) (p->data))->iid, 
-								    "','", NULL);
-			} else {
-				sort[1] = g_strconcat (prev, ((Bonobo_ServerInfo *) (p->data))->iid, 
-								    "'])", NULL);
-			}
-			g_free (prev);
-		}
-		gnome_vfs_mime_component_list_free (short_list);
-	} else {
-		sort[1] = g_strdup ("true");
-	}
-
-
 	/* Prefer something that matches the exact type to something
            that matches the supertype */
-	sort[2] = g_strconcat ("bonobo:supported_mime_types.has ('", mime_type, "')", NULL);
+	sort[1] = g_strconcat ("bonobo:supported_mime_types.has ('", mime_type, "')", NULL);
 
 	/* Prefer something that matches the supertype to something that matches `*' */
-	sort[3] = g_strconcat ("bonobo:supported_mime_types.has ('", supertype, "')", NULL);
+	sort[2] = g_strconcat ("bonobo:supported_mime_types.has ('", supertype, "')", NULL);
 
-	sort[4] = g_strdup ("name");
-	sort[5] = NULL;
+	sort[3] = g_strdup ("name");
+	sort[4] = NULL;
 
 	info_list = bonobo_activation_query (query, sort, &ev);
 	
@@ -458,7 +431,6 @@ gnome_vfs_mime_get_default_component (co
 	g_free (sort[1]);
 	g_free (sort[2]);
 	g_free (sort[3]);
-	g_free (sort[4]);
 
 	CORBA_exception_free (&ev);
 
@@ -502,7 +474,59 @@ gnome_vfs_mime_get_short_list_applicatio
 GList *
 gnome_vfs_mime_get_short_list_components (const char *mime_type)
 {
-	return gnome_vfs_mime_get_all_components (mime_type);
+	Bonobo_ServerInfoList *info_list;
+	GList *components_list;
+	CORBA_Environment ev;
+	char *supertype;
+	char *query;
+	char *sort[4];
+
+	if (mime_type == NULL) {
+		return NULL;
+	}
+
+	CORBA_exception_init (&ev);
+
+	/* Find a component that supports either the exact mime type,
+           the supertype, or all mime types. */
+
+	/* FIXME bugzilla.eazel.com 1142: should probably check for
+           the right interfaces too. Also slightly semantically
+           different from nautilus in other tiny ways.
+	*/
+	supertype = gnome_vfs_get_supertype_from_mime_type (mime_type);
+	query = g_strconcat ("bonobo:supported_mime_types.has_one (['", mime_type, 
+			     "', '", supertype,
+			     "', '*'])", NULL);
+	g_free (supertype);
+	
+        /* Prefer something that matches the exact type to something
+           that matches the supertype */
+	sort[0] = g_strconcat ("bonobo:supported_mime_types.has ('", mime_type, "')", NULL);
+
+	/* Prefer something that matches the supertype to something that matches `*' */
+	sort[1] = g_strconcat ("bonobo:supported_mime_types.has ('", supertype, "')", NULL);
+
+	sort[2] = g_strdup ("name");
+	sort[3] = NULL;
+
+	info_list = bonobo_activation_query (query, sort, &ev);
+	
+	if (ev._major == CORBA_NO_EXCEPTION) {
+		components_list = Bonobo_ServerInfoList_to_ServerInfo_g_list (info_list);
+		CORBA_free (info_list);
+	} else {
+		components_list = NULL;
+	}
+
+	g_free (query);
+	g_free (sort[0]);
+	g_free (sort[1]);
+	g_free (sort[2]);
+
+	CORBA_exception_free (&ev);
+
+	return components_list;
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]