After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 171595 - MIME subclassing implementation unusable
MIME subclassing implementation unusable
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: MIME and file/program mapping
2.10.x
Other Linux
: Normal major
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
Depends on:
Blocks:
 
 
Reported: 2005-03-25 15:09 UTC by Stanislav Brabec
Modified: 2005-08-09 22:43 UTC
See Also:
GNOME target: 2.10.0
GNOME version: ---


Attachments
My solution :) (2.71 KB, patch)
2005-05-12 16:17 UTC, Christian Kellner
none Details | Review
Updated version (3.11 KB, patch)
2005-05-12 16:36 UTC, Christian Kellner
committed Details | Review

Description Stanislav Brabec 2005-03-25 15:09:49 UTC
Suppose you have installed CVS version of shared-mime-info and files
dsc_0001.nef (camera raw file in TIFF container) and pict0001.mrw (camera raw
file in non-standard container) and you will install GNOME RAW integration
files: http://www.penguin.cz/~utx/gnome-dcraw

Now you want to open these files using GNOME MIME system in nautilus. mrw file
is opened correctly by GIMP, opening of nef file displays MIME conflict warning
(which is correct, too). Up to this moment, everything is correct.

Because you know, that raw files can be integrated into TIFF and JPEG
containers, you will add two lines into /usr/share/mime/packages/dcraw.xml,
re-run update-mime-database /usr/share/mime and update-desktop-database.

One could expect, that nautilus will now open both mrw and nef without any
problems. But what really happens: Nautilus will now open both files, but in
gqview, which can open JPEG and TIFF, but not raw files.

Using exactly the same scheme, Nautilus offers opening SVG files in Bluefish
HTML editor (because SVG is subclass of XML and Bluefish can open XML).

To block this behavior, I have tried to comment out xdg_mime_get_mime_parents()
in get_all_parent_types().

This gives better results, but still recognizes nef file as TIFF. I think, that
MIME type guessing should be reversed for subclasses. Example: File has suffix
nef, which is registered for image/x-dcraw. The same file has contents
image/tiff. But because image/x-dcraw contains sub-class-of image/tiff, the file
should be recognized as image/x-dcraw, not image/tiff.

Current implementation can be kept, but only as addition to fixed
implementation, to find "potentially related applications".

Nautilus then can offer for SVG "Potential application" (fixed implementation;
applications, which declare to open SVG), "Related applications" (old
implementation; applications, which declare to open any parent class, e. g. XML)
and "All applications" (the rest).

How to repeat it: Install RAW integration kit (including gimp-2.2.desktop
editing), add upper mentioned lines. Create any TIFF file, rename it as
image.nef. MIME subsystem MUST think, that it is image/x-dcraw and MUST open it
by GIMP, the only registered application, which can open image/x-dcraw.
Comment 1 Stanislav Brabec 2005-03-25 16:42:23 UTC
Lines added to dcraw.xml for testing subclasses:

    <sub-class-of type="image/tiff"/>
    <sub-class-of type="image/jpeg"/>
Comment 2 Christian Neumair 2005-05-09 19:40:35 UTC
Thanks for your bug report!
gnome-vfs has been recently synced with xdgmime (2005-04-17). Maybe you could
try to checkout a CVS HEAD version of gnome-vfs and try out whether this works
for you now? There seems to have been some progress in xdgmime wrt MIME subclassing.
Comment 3 Stanislav Brabec 2005-05-10 13:16:16 UTC
It does not offer Bluefish HTML Editor as default for opening SVG (but still
lists it), even after removing defaults.list.


But something is still bad:

Suppose you have Digital Camera RAW file (suffix .nef) resp. Video Microsoft WMV
file (suffix .wmv). Open the directory in Nautilus, view as list - you see
correct MIME types for both. But if you click to file (by left or right button),
Nautilus will change its MIME type to Image TIFF resp. Video Microsoft ASF.

IMHO there is missing this rule for context based guesses:

if ( (Suffix says type A) and (Contents says type B) and (A has type B in
sub-class-of list) ) then type is A

In other works: B is legal container type for A.

Note that some MIME types can have more container types, so A can be
sub-class-of more MIME types.

Note that my system (SuSE Linux 9.3) includes fix for WMV:
http://bugs.freedesktop.org/show_bug.cgi?id=2051
Comment 4 Christian Kellner 2005-05-12 16:17:34 UTC
Created attachment 46373 [details] [review]
My solution :)

That should fix the issue. Would love to see some testing and feedback. Many
thanks for the bug report!
Comment 5 Christian Kellner 2005-05-12 16:36:19 UTC
Created attachment 46374 [details] [review]
Updated version
Comment 6 Christian Kellner 2005-05-12 16:45:01 UTC
Forgot to comment. I commited the above patch to CVS head.  Stanislav could you
confirm it is working? If not please reopen. Sorry for the spam!
Comment 7 Stanislav Brabec 2005-05-12 19:43:23 UTC
Works nice for both NEF and WMV. Thanks.

Two additional notes:

Maybe your new code can replace hardcoded compressed type list in
gnome-vfs-mime.c, if subclassing will be well defined.

I wrote a small patch to Nautilus to allow to open file in case of MIME conflict
(see bug 154074, I have GNOME 2.10 version, too). Maybe better patch can be
created (don't display if both types will be opened by the same application and
offer both suffix and context based applications, if there is a conflict).

Comment 8 Chris Lahey 2005-08-09 20:59:37 UTC
I do like the patch, but the bug is wrong.

    <sub-class-of type="image/tiff"/>
    <sub-class-of type="image/jpeg"/>

These imply that all image/x-dcraw are image/tiff.  It also implies that all
image/x-dcraw are image/jpeg.  This is clearly wrong since tiff files can't be
png files.

The problem is that an object can be of multiple mime types even if neither type
is a subtype of the other.  Perhaps the mime system needs to be modified to
return a list of mime types with priorities.  file extensions should count as a
priority of 80, based on what the standard says.

Maybe globs should be able to have priorities.  Like *.xml should be < 50.

Just some random thoughts.
Comment 9 Stanislav Brabec 2005-08-09 22:43:09 UTC
    <sub-class-of type="image/tiff"/>
    <sub-class-of type="image/jpeg"/>

I don't know, whether it is correct, but it helps a bit - nautilus does not
complain, if it detect raw file with contents looking like TIFF or JPEG.

What exactly I need is to say: "Image with one of the raw suffixes _can_ look
like image/tiff or image/jpeg. This fact should not be considered as MIME type
conflict and such file should be recognized as image/x-dcraw."

As addition to prioritizing of MIME type detection can be transitivity
definition. It can define container type and possible file types inside.

Current MIME standards mixes container MIME types and contents MIME types and
this fact causes problems.

Example:
File with contents type of image/tiff can be image/tiff,
application/x-exif-data, image/x-dcraw,...