Skip to content

Freedesktop share-mime-info in KDE

Sunday, 4 March 2007  |  David Faure

I started a few weeks ago to port the mimetype support in KDE to the "share mime info" standard from ( There are a number of reasons for doing that:

  • Improving compatibility with other free desktops (e.g. when sending a file over email the receiver will get a mimetype his system understands)
  • Improving compatibility with web servers (I think Apache already implements, or will implement, support for shared-mime-info instead of having its own mimetype database too).
  • A bit less maintainance on our side (but a bit more trouble getting changes made...)
  • And the most important benefit is for third-party application makers (is ISV the term? I'm confused with all the TLAs :). They will be able to install a single mimetype file to define the mimetype(s) specific to their application, instead of having to install one file per desktop as is the case currently.

Technically we also gain support for mimetype aliases. We lose a bit of user-configurability though, there is no way to remove an extension associated with a system-defined mimetype, as I explained on the xdg list, but I admit that it was in previous kde versions because we could easily offer it, I don't know if any user actually needed that. Editing mimetypes defined by the user is still (will still be) possible, but not editing system-defined mimetypes [except adding things to them].

So what's the current status? I implemented

  • Support for finding the xdg mime directory (committed to KStandardDirs)
  • Parsing of mimetype-definition xml files by kmimetype (the files generated by update-mime-database)
  • Parsing of the globs file by kbuildsycoca (that file that associates *.txt to text/plain)
  • Parsing of the subclasses file by kbuildsycoca (the one that defines mimetype inheritance)
  • Support for mimetype aliases, including in trader queries. With unit tests.
  • The beginning of the storing of magic rules inside kmimetype, but the parsing isn't finished. It's a tricky mix of binary and text format, and I haven't had time to finish writing the parser yet. The problem is, there's no way to do incremental commits with this stuff, keeping support for the current desktop files in parallel makes no sense, mimetypes would be defined twice. So I can't commit until
  • the magic-file parsing is finished

  • most of the mimetypes we need for kde are defined in the shared-mime database. Pino Toscano has been doing great work on this, filing bug reports about the mimetypes that are missing in shared-mime, and keeping the list of the renamings we need to do, etc. I suppose we'll probably have a kde-specific xml file at least temporarily, I'm letting Pino take care of that (although I'll have to check that my code finds it and parses it ;)

  • the icons are renamed to follow the mimetype names. In KDE3 we had Icon=foo in the mimetype desktop file, but with shared-mime there is no such field, the icon for a mimetype is supposed to have the name of the mimetype. Pino and I (well, mostly him ;) ) made up the list of icon renamings that must happen, and Jonathan Riddell will make those renamings. So we need to coordinate the committing of all that at the same time :)

But meanwhile I'm going to go on vacation for a week, skiing. So it will have to wait until the week after.

So I can't commit yet, but in case anyone wants to see the code, or in case I lose my laptop, I uploaded the current diff to