On Thursday 15 September 2011 23:07:55 Иван Комиссаров wrote:
> 15.09.2011, в 21:12, David Faure написал(а):
> > Well the very first step was to get QStandardPaths into Qt, so that we
> > can locate the files generated by shared-mime-info on disk.
> >
> > It took a long time (due to 3 platforms, due to review process, and due
> > to the refactor branch being merged into master), but it's finally
> > ready. Not merged yet, though.
>
> Ah, i see… Is that means that you want to store same text files (generated
> by update-mime-database command) in windows/mac too?
Store... or generate.
We could provide update-mime-database, it's a very small utility.
> > Also, my first commits to qmime.git were moved to a branch and never
> > merged in, I don't take that as a sign of fruitful collaboration...
>
> I move them to separate branch because when i worked with Konstantin, we
> discussed everything before writing code. If we don't discuss first, we
> need code review instead - that's why i created branches for you and me.
Sure, but the review never happened and the changes were never merged in.
But OK, they were just small steps in the API cleanups, not a complete
"proposal". Catch 22.
> > IMHO the editing of mimetypes in Qt Creator should be removed.
> > I asked danimo and he was very surprised to hear that such a thing
> > existed. But if Qt creator should really allow editing of mimetypes,
> > then it should edit the system mimetypes (I have code for that too...).
> > The concept of per- application mimetypes breaks the concept of
> > shared-mime-info.
>
> Sometimes (quite rare though) application really need it's own format of
> files for its inner purposes. That's why creating of custom mime types can
> be useful sometimes.
Yes, and this can be done by installing an xml file, no api needed.
> > Moving to another public class doesn't change the issue: if it's in the
> > API, it can't be changed later.
> >
> > Same thing with the glob weights -- this shouldn't appear in the API,
> > because that makes it impossible to change if the spec changes. In fact
> > this wasn't in the spec initially... these things -can- change.
>
> I don't believe they (freedesktop.org) will change spec - they have big risk
> to broke something:)
That is definitely not true. New features can always be added, and they have
been, in the (not so long) past.
Initially the spec had no glob weights, for instance.
The earlier version (in kde time) had no range support for magic matching.
Who knows what features might come in, in the future.
And especially if you want to have more backends than shared-mime-info, then
having so many details in the API just won't work. Windows doesn't even have
content matching, I hear.
... But actually that's why I think we would be in a much better position by
using shared-mime-info everywhere. Just yesterday I had the example of someone
on linux sending a PDF file by mail to someone on Windows, and the file had no
extension (openoffice checkbox in file dialog was unchecked for some reason).
As a result, the file was opened in notepad by Windows.
If that application was using shared-mime-info, the content matching would
have immediately detected that it was a PDF file.
And by using shared-mime-info everywhere, we solve the problem of "how does an
app define new mimetypes" : with an xml file. And with the same features
everywhere, as a result.
Think about the typical case of
QMimeType mime = QMimeDatabase::findByName(fileName);
if (mime.inherits("application/xml")) {
// then use an xml viewer, or whatever.
}
If the mimetype name on Windows or mac is not application/xml but something
else, then the application needs to know about that and check for all these
names? That's very fragile and not really what you expect from cross-platform
framework. The advantage of using shared-mime-info everywhere is not only
"same features everywhere", but also and mainly "same mimetype names
everywhere".
The main issue is how to use the mime-apps associations for the existing
Windows or Mac apps, this is where Qt itself might have to do some mapping --
but that's for the separate discussion of mime-apps associations.
> > There is just one xml file to copy. The rest is generated by
> > update-mime-
> > database. But I can see that given Windows's non-existing dependency
> > handling, this might not be a great solution ;)
>
> Is update-mime-database ported to windows? Where does it store files?
Yes, KDE uses it on Windows too.
It stores files in XDG_DATA_DIRS/mime I presume. I'll double-check with the
KDE-on-windows guys. In any case we can set things up so that it uses
QStandardPaths::GenericDataLocation + "/mime" everywhere, which is on Windows
CSIDL_COMMON_APPDATA + "/mime" and CSIDL_LOCAL_APPDATA + "/mime".
> > An alternative could be that Qt ships the files generated from
> > freedesktop.org.xml, and [on any platform] if shared-mime-info is
> > installed we don't use those.
>
> Is it really best way to deploy million of files on windows/mac? Maybe it is
> better to use one huge database file?
With a single file, other apps cannot install their own description files.
This is a very practical need, look at how many apps install additional
mimetype definitions here on linux:
-Asterix.site- dfaure 10:22 /k>ls -l /usr/share/mime/packages
total 1684
-rw-r--r-- 1 root root 1285 Jan 22 2011 akonadi-mime.xml
-rw-r--r-- 1 root root 1264 Feb 1 2011 bluedevil-mime.xml
-rw-r--r-- 1 root root 292 Aug 19 19:58 firefox.xml
-rw-r--r-- 1 root root 1615319 Feb 19 2011 freedesktop.org.xml
-rw-r--r-- 1 root root 749 Jan 18 2011 kdepimlibs-mime.xml
-rw-r--r-- 1 root root 875 Jan 27 2011 kdepim-mime.xml
-rw-r--r-- 1 root root 14314 Jan 19 2011 kde.xml
-rw-r--r-- 1 root root 285 Jan 19 2011 lancelotpart-mime.xml
-rw-r--r-- 1 root root 18361 Jan 19 2011 network.xml
-rw-r--r-- 1 root root 8821 Feb 22 2011 openoffice.xml
-rw-r--r-- 1 root root 2971 May 20 17:37 packagekit-catalog.xml
-rw-r--r-- 1 root root 3428 May 20 17:37 packagekit-package-list.xml
-rw-r--r-- 1 root root 3345 May 20 17:37 packagekit-servicepack.xml
-rw-r--r-- 1 root root 1857 Jul 19 16:19 vmware-player.xml
-rw-r--r-- 1 root root 283 May 18 21:33 xine-ui.xml
-rw-r--r-- 1 root root 408 Jan 15 2011 x-k3b.xml
-rw-r--r-- 1 root root 225 Jun 19 2008 x-sysinfo.xml
-rw-r--r-- 1 root root 494 Nov 10 2009 yast2-metapackage-handler-
mimetypes.xml
> Shared-mime-info describes one binary
> format for database, but i does not contains strings (descriptions) for
> mime types.
Yes, that is an option I haven't really investigated yet. It should be faster,
but indeed it doesn't solve the whole issue. In order to get something earlier
I have the feeling we should start with the existing code, and later look into
binary parsing. But no strong feelings there.
> Maybe they can change spec to add these strings?
I don't think so. It would bloat the size of the binary file, thus making its
parsing slower (think about translations -> huge amounts of data overall,
compared to the current size). And the mimetype descriptions is something that
is very rarely needed. This is why my code parses them (from the standalone
xml files) only on demand, in most cases the apps don't care for that, they
just want to get the mimetype of a file and check if that mimetype is one that
they support (possibly in order to use the right plugin, etc.).
> (or ids of mime types to load strings from .qm files, for example)
Well the id could be the mimetype name, no? Or does it have to be numerical?
> Btw, i know that my english skills is very bad, so feel free to ask if
> something is not clear:)
Your english is perfectly fine, don't worry.
--
David Faure, ***@kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).