Hello! I've developed a kdelibs addon that is capable of converting information on file extensions and the contents of the native start menu on the Windows platform, and am now at a stage where I need answers to a few questions related to the priority and handling of MIME type information by KMimeTypeTrader and related classes in kdelibs.
Suppose I have two different MIME type definitions (as an example for Word documents (.doc)): * One defined as "application/msword" (as shipped with KDE, defined in $KDE_INSTALL_PREFIX/share/mime/packages/freedesktop.org.xml) * The other defined as "application/vnd.kde.windows.doc", defined in the user's home directory (under $HOME/.kde/share/mime/packages/application_vnd_kde_windows_doc.xml). Here the abbreviated definition as shipped with KDE: ==================================================== <mime-type type="application/msword"> <comment>Word document</comment> <sub-class-of type="application/x-ole-storage"/> <generic-icon name="x-office-document"/> <magic priority="60"> <match value="\x31\xbe\x00\x00" type="string" offset="0"/> <match value="PO^Q`" type="string" offset="0"/> <match value="\376\067\0\043" type="string" offset="0"/> <match value="\333\245-\0\0\0" type="string" offset="0"/> <match value="MSWordDoc" type="string" offset="2112"/> <match value="MSWordDoc" type="string" offset="2108"/> <match value="Microsoft Word document data" type="string" offset="2112"/> <match value="bjbj" type="string" offset="546"/> <match value="jbjb" type="string" offset="546"/> </magic> <glob pattern="*.doc"/> <alias type="application/vnd.ms-word"/> <alias type="application/x-msword"/> </mime-type> ==================================================== And here my custom definition: ==================================================== <mime-type type="application/vnd.kde.windows.doc"> <comment>Microsoft Word-Dokument</comment> <glob pattern="*.doc"/> </mime-type> ==================================================== The latter only contains the glob pattern, since this actually is all that is relevant on the Windows platform to determine a file's type. Here, KDE's method of determining a file's true type using the "magic pattern" given in the first of the two MIME type definitions is way smarter than Windows' own one, which is a good thing. On the other hand, I also extract the corresponding icons used by Windows Explorer for file extensions, which are tied to the MIME type definition I give in my custom-generated MIME type. Here, it seems the "closer match" is winning, i. e. a .doc file is determined to be "application/msword" instead of "application/vnd.kde.windows.doc". Now the trouble starts: If I don't put "application/msword" as MIME type into the .desktop file that defines the program to handle .doc files: [Desktop Entry] Type=Application Name=Microsoft Office Word GenericName=Microsoft Office Word Comment=Microsoft Word-Dokument Exec=classexec "%f" --action Open --class Word.Document.8 Icon=application-vnd.kde.windows.doc MimeType=application/vnd.kde.windows.doc;application/msword InitialPreference=99 Konqueror/Dolphin don't "detect" the fact that MS Word is available to handle .doc files, and instead still present me with the native Windows "Select program to open" dialog. Additionally, the icon displayed for .doc is that shipped with KDE, not the one I've converted from the native platform. Hence my question: Is it possible to override the MIME type priorities so that my custom-generated MIME types are used instead of those KMimeTypeTrader would select by default (even if that selection is a better match than solely by the file extension given)? If yes, how do I accomplish that? If no, what would be alternative suggestions instead? With best regards, Fabian Aichele