Open Bug 296443 Opened 20 years ago Updated 2 years ago

Mozilla should follow shared mime freedesktop specs (determining MIME type of a file and the default app for it)

Categories

(Firefox :: File Handling, enhancement)

All
Linux
enhancement

Tracking

()

People

(Reporter: tmpfreire, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: helpwanted)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050523 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050523 Firefox/1.0.4

Mozilla/Firefox/NSPR/Toolkit (maybe this bug should be re-categorized) should
follow the freedesktop standards, to have a better integration within the
several desktop environments. IMO this is necessary to have a more integrated
Desktop Environment, with a single place to define actions for each file type.
There is already a bug filed for icon themes, but nothing is spoken about mime
types and default actions. There are two projects at freedesktop developing
those standards. one of them is about the shared mime database itself, along
with common programs to alter it.
The other is about setting default actions for each mimetype, so that file types
are correctly handled. 

http://www.freedesktop.org/wiki/Standards_2fshared_2dmime_2dinfo_2dspec

http://www.freedesktop.org/wiki/Standards_2fmime_2dactions_2dspec



Reproducible: Always
This is not an Extension/Theme Manager bug and I highly doubt it will get any
attention as long as it is filed as such. You should probably attempt to find a
better product / component for it.
Hmm, it's 'OS Integration', I guess. :)  
Component: Extension/Theme Manager → OS Integration
For someone who has not read the freedesktop specs it's not clear what exactly you're asking for. The steps to reproduce / expected results / actual results actually need to be specified when filing bugs.

After a quick glance through the document at the first link, I think the spec defines the way to get a MIME type for a local file. Based on that I'm moving the bug to Core-File Handling. Is my understanding correct?

One issue per bug please, file a different bug on the other spec (although I'm not sure what it is about either).
Assignee: nobody → file-handling
Component: OS Integration → File Handling
Product: Firefox → Core
QA Contact: extension.manager → ian
Version: unspecified → Trunk
I think Core-File handling is good.

Let me try to explain the issue in a clearer way:
I use Linux with KDE as my DE. It has a nice mime handling database, and i have a central management system in which I am able to tell the default actions for each mime type. But when I use Firefox, it does not know anything about it. it has its own mime handling.
OK, if I fire gnome apps, the same happens. they have their own mime.
But things are changing. just like the clipboard had its interoperability problems solved, other aspects of the Desktop environment need to be reviewed, and components/subprojects shared. mime/file handling is one of them.
Freedesktop.org has ongoing projects for unifying the mime databases for gnome/kde, as a spec which should be followed by other OS desktop environments and apps.
My two links are for two different projects, but they are together in this single bug, because they are both needed (imo) to solve this single issue. 

The 'end' (the enhancement this bug proposes) is to 'properly integrate mime/file handling with the rest of the OS/DE'.
It means a few things:
- a freshly installed firefox will instantly pick up the user file handling preferences on the previously installed Desktop Environment.
- changes in the mime preferences will carry on transparently between Fifefox and the DE, without the need of double work.

For that to happen we nned also the 'means to an end', which is the mime database spec. Bute there is little use to integrate it if the mime actions are not shared too.

I hope you agree with me, that it's actually a single 'problem', which is better solved by following these 2 specs. I just jumped ahead of myself, and instead of just reporting 'I want mime actions to be consistent with my desktop preferences', I looked for the possible solutions, which are the specs which make it possible. Hmm, I think I could have explained my self better the first time around.

I think mozilla will have a benefit by participating on the evolution of these specs, and pushing its adoption. And so will the whole FLOSS crowd.

Steps to reproduce:
1. set up some mime handling preference on your favorite Desktop Environment
2. Try to open file of said mime type on firefox
3. Firefox does not transparently inherit DE's mime preference.

What should happen:
 Firefox should use preferred application for handling that mime type, as set up by the DE.
Okay, thanks for explanation. I still think there should be two bugs for two specs, since they can be implemented separately. But I don't particularly care, since I will not be working on this.

My understanding is that the code you need is at:
http://lxr.mozilla.org/seamonkey/source/uriloader/exthandler/
Blocks: 233462
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Mozilla should follow shared mime freedesktop specs → Mozilla should follow shared mime freedesktop specs (determining MIME type of a file and )
Summary: Mozilla should follow shared mime freedesktop specs (determining MIME type of a file and ) → Mozilla should follow shared mime freedesktop specs (determining MIME type of a file and the default app for it)
fwiw, this code currently asks gnome (via gnome-vfs, iirc) for this stuff. isn't it a bug in gnome-vfs if it doesn't use the freedesktop stuff?
The code uses a deprecated function:
http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-20-gnome-vfs-mime.html#gnome-vfs-mime-type-from-name

and they yelled at us because of that:
https://bugs.freedesktop.org/show_bug.cgi?id=2928#c21
i've filled this bug which may be related :
Bug 421914 – [GNOME integration] Choosing from Firefox context menu to view a selected image should open the default GNOME image viewer
I just run into exactly this bug. I am maintaining a local Linux distribution for Swiss schools using KDE. The mime configuration was done according to the freedesktop standard. Because Firefox is much better than Konqueror in many aspects, we added Firefox to the distribution. To our unbelieving amazement Firefox just ignored the mime settings. Maintaining and supporting this setting is a nightmare because now we always have to change the settings in two places and must take great care that both configurations (freedesktop, firefox) stay consistent.
Please support the freedesktop standards instead of poorly reinventing the wheel.
QA Contact: ian → file-handling
This bug is "NEW" since 2005, and is a real blocker for those who use other DEs than Gnome...
I've even written a post on how to hack around it (at http://luisfpg.blogspot.com/2009/04/making-firefox-open-files-honoring-kdes.html), but it's just an ugly hack.
IMHO, integration with KDE should be a major goal. 
Not to mention the KDE open / save dialogs (couldn't find report) and printing (https://bugzilla.mozilla.org/show_bug.cgi?id=228083) integration...
Any news on this bug, my original bug has been removed as duplicate of this bug, so any progress on this bug would be appreciated.
So what GNOME apis would let us do this, exactly?  Comment 7 seems to be about a slightly different issue; that's about file-to-type mapping (where the Unix code just needs to implement GetTypeFromFile instead of falling back on getting from extension).  This bug is about us not getting the right helper application given a type, if I understand correctly...  Or am I misunderstanding?
Please, someone correct me if I'm wrong, but for me, the point is not which GNOME apis would let you do it, because GNOME is in a lower level of the stack... Think this way: The XDG standard provides functions to make it transparent for applications desktop environment details, like file associations. Then, and each desktop environment provides it's own details.
You will never make it work in an standard way by accessing the GNOME api's, because KDE's file associations are not accessible by them. The same applies to XFCE, for example.
The real solution would be to use the XDG apis, not the GNOME apis...
> The real solution would be to use the XDG apis, not the GNOME apis...

Ok, how does one do that?  Can you point me to the documentation for those?
(In reply to comment #16)
> > The real solution would be to use the XDG apis, not the GNOME apis...
> 
> Ok, how does one do that?  Can you point me to the documentation for those?

xdg@lists.freedesktop.org there is a mailing list for the xdg specs. I could point you to a file how to do this, but I will not be 100% sure it will be the right one. Please ask on the mailing list about the mine-type application mapping and I am sure you will receive a lot of help if you indicate its for thunderbird xdg desktop integration. 

(BTW. indeed use the XDG specs, never gnome, kde or xfce api's)
I someone wants to figure out the APIs to use here, that would be very helpful.  I can advise on the relevant parts of the Gecko code, but I don't have the time to go hunting, nor to implement myself...
Keywords: helpwanted
I suggest that rather than trying to implement the XDG spec directly, the now standard xdg-open or xdg-mime command should be queried if it exists before falling back to GnomeVFS.
Depends on: 713802
Since bug 713802, Gecko is using GIO to get the preferred helper app for the MIME type.  GIO should be using the freedesktop mime actions spec to get this info.
http://www.freedesktop.org/wiki/Specifications/mime-actions-spec

Remaining to do here should just be implementing nsExternalHelperAppService::GetTypeFromFile() to use the right APIs to make use of
http://freedesktop.org/wiki/Software/shared-mime-info
Product: Core → Firefox
Version: Trunk → unspecified

So there’s three options, depending on GIO being supposed to behave according to spec or not:

If GIO wants to be spec-compliant, but isn’t, GIO needs to be fixed.
If GIO is spec-compliant, Firefox uses it wrong and needs to be fixed.
If GIO is intentionally not spec-compliant, Firefox needs to start using something compliant instead.

Who is familiar with the code and can answer which one it is?

I don't think there is anyone in particular familiar with both the Firefox-side code and GIO.

Also, it's not clear to me which "spec" is being referenced in comment 21. The freedesktop spec? Web specs? Something else?

I'm unaware of a web spec for opening files, and this ticket literally has in the title "follow shared mime freedesktop specs", so it seems obvious that is the spec being referred to.

exactly.

I investigated a bit: In my case I didn’t set any default application for the .docx mime type.
Firefox opended it with Calibre’s ebook Editor, while everything else agrees to use Libreoffice Writer.

I turned to xdg-mime as a source of truth. It is pretty complex: For my KDE Plasma desktop it internally uses ktraderclient5 which makes it of course act the same as KDE, and gives us Libreoffice Writer for a .docx file:

$ xdg-mime query default application/vnd.openxmlformats-officedocument.wordprocessingml.document
libreoffice-writer.desktop

Firefox starts Calibre’s ebook Editor, which might indicate that its method (GIO?) seems to simply use the first entry in /usr/share/applications/mimeinfo.cache (that file is for knowing what choices are there, not what to use):

$ grep ml.doc /usr/share/applications/mimeinfo.cache
application/vnd.openxmlformats-officedocument.wordprocessingml.document=calibre-ebook-edit.desktop;calibre-ebook-viewer.desktop;calibre-gui.desktop;libreoffice-writer.desktop;

After manually changing the default to Writer manually in ~/.config/mimeapps.list, Firefox agrees with xdg-mime and KDE.

I didn’t figure out what the spec says for choosing the default application if none is set. It might be that Firefox’/GIO’s behavior is therefore already spec compliant here.

In any case we would get better and more expected results if Firefox used xdg-mime if available to determine the default.

Depends on: 1663257

(In reply to Boris Zbarsky [:bzbarsky] from comment #22)

I don't think there is anyone in particular familiar with both the Firefox-side code and GIO.

Also, it's not clear to me which "spec" is being referenced in comment 21. The freedesktop spec? Web specs? Something else?

https://specifications.freedesktop.org/mime-apps-spec/latest/ar01s02.html

Severity: normal → S3

Maybe I am naive, but would it just suffice to have Firefox run xdg-open $fileName for all files for which it is set to use the system default application and when xdg-open is available ?

You need to log in before you can comment on or make changes to this bug.