Re: A patch for uniform mime handling



On Wed, 2003-09-10 at 18:48, Rodney Dawes wrote:
> On Wed, 2003-09-10 at 05:06, Alexander Larsson wrote:
> > On Wed, 2003-09-10 at 06:54, Bryan Forbes wrote:
> > > Hello,
> > >     I am emailing this list to propose a patch to gnome_vfs_get_mime_type to return
> > > GNOME_VFS_MIME_TYPE_UNKNOWN instead of NULL as it does now.  The patch on bug 121553
> > > (http://bugzilla.gnome.org/show_bug.cgi?id=121553) fixes this issue and also handles it
> > > the way gnome_vfs_get_mime_type_common, gnome_vfs_get_file_mime_type,
> > > gnome_vfs_get_mime_type_for_data, and gnome_vfs_get_mime_type_from_file_data (by using
> > > _gnome_vfs_get_mime_type_internal instead of returning NULL).  Not only does it make the
> > > function more uniform to the other 4 functions, but it also fixes a crash on Solaris when
> > > the function returns NULL (because you can't do printf("%s\n", NULL);).
> > >     You may be saying to yourself, "This breaks API", but I would say to you that all
> > > apps that use this function have to handle this anyway, and most set the mime-type to
> > > GNOME_VFS_MIME_TYPE_UNKNOWN themselves. For example:
> > 
> > I don't like the patch as it stands. The call is documented to do the
> > same thing as gnome_vfs_get_file_info(), and it is my opinion that if
> > you pass GNOME_VFS_FILE_INFO_GET_MIME_TYPE to get_file_info the module
> > should *always* put something in the mime field, even if it is only
> > GNOME_VFS_MIME_TYPE_UNKNOWN. If some module is not doing this we should
> > fix that. The file method internally calls
> > gnome_vfs_get_file_mime_type() which ends up calling 
> > _gnome_vfs_get_mime_type_internal() already, so its ok.
> 
> But what about for URIs of types where there is no module installed. It
> would still be nice to know the mime type, so that we could open the
> correct application, even if it's on a URI that gnome-vfs can't handle,
> such as mms:// or rtsp://, where these would make sense to launch
> mplayer, xine, realplayer, windows media player, or something else.

You mean mimetypes like x-uri/mailto or something? I'm not sure what I
think about that. I don't like extending the mimetype specification in a
not-entierly-standard way (this isn't really a file type like other mime
types). Furthermore I think its a bit dangerous to assume gnome-vfs
handles all types of URIs, since it generally doesn't (it will generate
NULL GnomeVFSURIs for them), and since it propagates the idea that
gnome-vfs is a good library to use when you want to e.g. write a web
browser (we don't support things like forms and cookies, and I don't
think we want, gnome-vfs is for reading and writing files).

However, the idea has some merit in that it gives a way of handling some
types of uris (mailto:, mms:, rtsp:, callto: and maybe some more) in a
way that is consistant with how file types are handled. Although it
doesn't work for everything, for instance http uris, and it might not
make much usability sense to have e.g. the mailto handler specified in
the same UI that lists filetypes, extensions and their handlers.

Anyway, I don't want to change how this is done now, because the whole
mimetype system and UI is scheduled for a complete overhaul in 2.6 (I
hope), but I think we should take this idea into account when designing
the new system.

> > > At line 97 of src/egg-recent-item.c in totem cvs HEAD:
> > > 	item->mime_type = gnome_vfs_get_mime_type (item->uri);
> > > 
> > > 	if (!item->mime_type)
> > > 		item->mime_type = g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN);
> > > 
> > > As you can see, this code just works around the NULL return and wouldn't break with the
> > > new patch. EOG, File-Roller, gedit, gpdf, nautilus
> > 
> > This would be fixed by passing GNOME_VFS_MIME_TYPE_UNKNOWN if the
> > get_file_info fails.
> 
> Which is basically exactly what this patch does. However, it also
> resorts to getting the mime type from the filename first.

Well, not the filename as such, but rather the whole encoded uri as a
filename. But I understand your point, and why you did this.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a time-tossed small-town cowboy from the 'hood. She's a sarcastic 
green-skinned widow living on borrowed time. They fight crime! 




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