GNOME Bugzilla – Bug 121553
GnomeVFS Should Use Mime Types for URI Schemes
Last modified: 2008-09-06 19:17:36 UTC
The gnome-vfs mime system should use mime types for uri schemes, rather than using url handlers gconf keys. Attached is a patch which allows this to happen. Using mime types for uri schemes allows several things to happen. The foremost being that multiple applications can register as handling the mime type, as opposed to having the ability for only one thing to own a gconf key. This patch also fixes what may result in segfaults on Solaris and other similar systems, where printing a NULL string will cause a SEGV, since gnome_vfs_get_mime_type () will return application/octet-stream for things that it can't get a GnomeVFSFileInfo for, such as a mailto: URI, as the default, instead of NULL. However, the patch doesn't break the current behaviour, so it can still use the url-handlers tree in gconf also. It would be very useful if this could go into 2.4 proper.
Created attachment 19770 [details] [review] Patch to Allow Mime Types for URI Schemes
Can you explain more what you mean by "The gnome-vfs mime system should use mime types for uri schemes, rather than using url handlers gconf keys." ? Do you mean that gnome-vfs should mime sniff stuff like http://www.gnome.org to find out it must open it in the text/html handler ?
Yes. But it already does that. I am talking about all URI schemes, not just things where there are gnome-vfs modules, and that have actual data that can be read, aside from the fact that http "sniffing" is just using whatever the server returns in the Content-Type: header, which is very often incorrect. What I mean here is that we should get rid of the url handlers gconf keys, and move everything over to using mime types as representations of URI schemes, such that "mailto:foo@bar.com" would end up being the "text/x-url-mailto" mime type, or something similar, depending on what applications are installed, and what the various RFCs and other documents say about naming these mime types. This patch is just a start in that direction, as it allows mime types to be resolved by the uri scheme, and fixes a small portability issue.
Can I commit this yet?
Imo this patch can't go in, since you want to change the behaviour of a public function. I feel it's up to the app using this API to do whatever they feel appropriate when NULL is returned. As a side note, the current plan is to redesign the mime system during 2.5 development, hopefully your issue will be resolved at the same time
Created attachment 19854 [details] [review] Patch to Only Change URL Showing Code in 2.4
This patch only affects the gnome_vfs_url_show_with_env () function, and allows it to use mime types for URIs, rather than changing all of gnome_vfs_get_mime_type () to behave more sanely. With this patch, the handling of a NULL return from _get_mime_type () is changed to fall back to doing _get_mime_type_internal (), so that URIs that gnome-vfs may not handle, can still be opened with the proper application.
I'm not sure mapping mime types to random pseudo-uri schemes is the way to go. But I think you raised a valid point: you can specify in a .applications file that an app can handle various uri schemes, but the current gnome_vfs_url_show code doesn't seem to take that into account. For example, totem has supported_uri_schemes=rtp,mms,net,http,file,ssh,smb,ftp,nntp but I suspect gnome_open rtp://... won't work This is probably what should be fixed and this would probably also do what you want, but I'm not sure it's really easy to do. How does that sound?
I am not sure that I would call something suggested by the w3c as "random pseudo-uri schemes". And in fact, it would be best to be able to dynamically update the mime database with what protocols a particular application does support. For instance, if you build totem without the xine backend, mms, and net, most likely will not work at all, though they would still be specified in the file. Fixing gnome-open to do some better fallback stuff is trivial, really, but I doubt that it's the best solution, and rather only a temporary workaround. Though, the patch that I made is just a similar temporary workaround. I would love to fix this The Right Way (TM) for 2.6, but it looks like that may also not happen. :-/ I will try to look at the shared mime database stuff as soon as I can, but as far as I can tell from what little I have seen of it, it only handls mime types, and doesn't handle the application registry.
> I would love to fix this The Right Way (TM) for 2.6 Which is ? > it only handls mime types, and doesn't handle the application registry. See http://cfergeau.free.fr/mime-spec-0.2.txt and xdg-list archives for the beginning of a discussion about that.
http://cfergeau.free.fr/mime-spec-0.2.txt yields 404 :/.
gnome-vfs has been deprecated and superseded by gio/gvfs since GNOME 2.22, hence mass-closing many of the gnome-vfs requests/bug reports. This means that gnome-vfs is NOT actively maintained anymore, however patches are still welcome. If your reported issue is still valid for gio/gvfs, please feel free to file a bug report against glib/gio or gvfs. @Bugzilla mail recipients: query for gnome-vfs-mass-close to get rid of these notification emails all together. General further information: http://en.wikipedia.org/wiki/GVFS Reasons behind this decision are listed at http://www.mail-archive.com/gnome-vfs-list@gnome.org/msg00899.html