dfaure at trolltech.com
Sun Jan 28 13:00:45 PST 2007
I'm starting to implement shared-mime-info for KDE4.
I hadn't read the spec for a very long time, so I did it again, and: I still like it very much :)
I just have a few questions.
First question: user overrides.
> This specification uses the XDG Base Directory Specification[BaseDir] to define the prefixes below which the database is stored. In the rest of this document, paths shown with the prefix <MIME> indicate the files should be loaded from the mime subdirectory of every directory in XDG_DATA_HOME:XDG_DATA_DIRS.
> For example, when using the default paths, “Load all the <MIME>/text/html.xml files” means to load /usr/share/mime/text/html.xml, /usr/local/share/mime/text/html.xml, and ~/.local/share/mime/text/html.xml (if they exist).
The first sentence puts XDG_DATA_HOME first; the second sentence puts ~/.local in the directory list; I guess the first sentence should say XDG_DATA_DIRS:XDG_DATA_HOME for clarity?
Of course the idea is that local directories override system ones, nothing new there.
However, how does that allow the user to remove a pattern->mimetype association?
For instance, /usr/share/mime/globs says application/msword:*.doc
but since this gives a wrong mimetype to e.g. /usr/share/doc/cvs/contrib/intro.doc (*)
how can I, as a user, remove the "application/msword:*.doc" association?
A ~/.local/share/mime/globs file can only add new glob entries, but not remove existing ones, right?
The spec mentions Override.xml but this seems to only have an effect on files in the same directory
so if the user has no write access to /usr/share/mime/packages, he has no way of overriding what's
defined there, right? It seems to me that mimetype patterns should definitely be editable by the user...
A solution would be if update-mime-database would put the whole list of globs in ~/.local/share/mime/globs
(from all source files, not just from ~/.local/share/mime/packages), and the spec was modified to say "read the most local globs file only".
(*) This raises a second question, on this particular mimetype. Is it wise to associate
*.doc with msword files, given that on most unix systems there are plain-text .doc files?
In KDE3 we defined application/msword with the magic entries below, which are of course not
msword-specific but match any MSOffice file since they are OLE magic numbers, and
there is no way to be more specific with fixed offsets. However this works, since the
other msoffice files have much more specific extensions (*.xls, *.ppt etc.) which are
registered in the corresponding mimetypes. So we resort to using the "magic entries"
(reading the file) only when the extension isn't one of those, and msword files are
detected as such from their contents rather than from the extension.
0 string \376\067\0\043 application/msword
0 string \320\317\021\340\241\261 application/msword
0 string \333\245-\0\0\0 application/msword
PS: please update my email address to faure at kde.org in the spec, the mandrakesoft
email-address doesn't work anymore.
PS2: see my earlier mail "broken link: shared mime info"
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the xdg