The format of Shared MIME Database magic values

Alexander Kamyshnikov axill777 at gmail.com
Mon Dec 16 01:55:49 PST 2013


Oh thanks, Kevin! This library is exactly i need for.
However, yet-another-implementation-of MIME loader might be useful for
somebody, or i'm just wasted my time? :)
This was funny and interesting quest.


2013/12/16 Kevin Krammer <krammer at kde.org>

> On Monday, 2013-12-16, 12:45:47, Alexander Kamyshnikov wrote:
> > I'm confused a bit.
> > So, you want to say that QMimeDatabase from Qt5 can be separately used in
> > Qt4?
> > I.e. i can just include this code in mine.
>
> Not the Qt5 based code obviously. But Jerome said that there is a Qt4 port
> of
> the Qt5 code.
>
> I guess he is referring to
> https://github.com/pasnox/mimetypes-qt4
>
> Cheers,
> Kevin
>
> > Also, i'm trying to google "qmimedatabase qt4", but find nothing
> > appropriate.
> > A more concrete search direction will be welcome.
> > P.S. Sorry, if i don't understand simple things. My english is not
> perfect
> > yet.
> >
> >
> > 2013/12/16 Kevin Krammer <krammer at kde.org>
> >
> > > On Monday, 2013-12-16, 11:41:34, Alexander Kamyshnikov wrote:
> > > > Hi Kevin. I'm glad to see KDE developer here because i'm KDE fan for
> > > > many
> > > > years :)
> > > > But this KDE MIME-support code hardly depend from other KDE stuff,
> isn't
> > >
> > > it?
> > >
> > > > I need "pure" Qt code - this is our software client requirement :/ So
> > > > i'm
> > > > wrote CMimeDatabase class. And just want to make it fully compliant
> with
> > > > freedesktop standart.
> > >
> > > Just wanted to point out that the Qt5 implementation was contributed by
> > > KDE
> > > developers, so additional to the Qt4 port of that code there is also
> "the
> > > original" Qt4 code available.
> > >
> > > But of course if you need a pure C++ implementation without Qt then
> > > writing a
> > > new one is your only choice.
> > >
> > > Cheers,
> > > Kevin
> > >
> > > > (see
> > >
> > >
> http://api.kde.org/4.0-api/kdelibs-apidocs/kdecore/html/kmimetype_8h_sourc
> > > e
> > > .
> > >
> > > > html -
> > > > KUrl, KServiceType etc.)
> > > >
> > > >
> > > > 2013/12/14 Kevin Krammer <krammer at kde.org>
> > > >
> > > > > On Friday, 2013-12-13, 20:11:34, Jerome Leclanche wrote:
> > > > > > There is a Qt 4 port of this.
> > > > >
> > > > > And there should also be the original Qt4 based code in the kdelibs
> > > > > repository.
> > > > >
> > > > > Cheers,
> > > > > Kevin
> > > > >
> > > > > > As for windows support... I've been down that road, trying to
> > > > > > provide
> > > > > > it. Windows' feature set doesn't even sort of come close; it only
> > > > > > provides real mime types for a limited set of registered
> extensions,
> > > > > > and it doesn't provide any of the very useful features such as
> > > > > > subclassing, etc. In the end, I gave up and am only providing
> > > > > > xdg-based mime types. I think Qt made an excellent choice in
> > >
> > > providing
> > >
> > > > > > the xdg database itself. But if you choose against that, good
> luck.
> > > > > >
> > > > > > Anyway you can have a look at my python-based mimetype lib. Magic
> > > > > > matches are implemented on line 192 onwards.
> > > > > >
> > > > > > https://github.com/Adys/python-xdg/blob/master/xdg/mime.py
> > > > > >
> > > > > > J. Leclanche
> > > > > >
> > > > > >
> > > > > > On Fri, Dec 13, 2013 at 7:56 PM, Alexander Kamyshnikov
> > > > > >
> > > > > > <axill777 at gmail.com> wrote:
> > > > > > > Yes, i had. But i decided to write my own implementation
> because:
> > > > > > > a) my project is forced to use Qt4 only (clients have very old
> > > > >
> > > > > versions of
> > > > >
> > > > > > > modified Red Hat with XDG_DATA_DIRS undefined);
> > > > > > > b) Windows support (through reading registry HKCR/.ext keys) is
> > > > >
> > > > > required;
> > > > >
> > > > > > > c) I'm very curious :)
> > > > > > >
> > > > > > > You think i'm should look deeply at the qmimedatabase.cpp
> however?
> > > > > > >
> > > > > > >
> > > > > > > 2013/12/13 Jerome Leclanche <adys.wh at gmail.com>
> > > > > > >
> > > > > > >> Have you had a look at the Qt 5 mimetype module?
> > > > > > >>
> > > > > > >> http://qt-project.org/doc/qt-5.0/qtcore/qmimedatabase.html
> > > > > > >> J. Leclanche
> > > > > > >>
> > > > > > >>
> > > > > > >> On Fri, Dec 13, 2013 at 7:35 PM, Alexander Kamyshnikov
> > > > > > >>
> > > > > > >> <axill777 at gmail.com> wrote:
> > > > > > >> > Hi all!
> > > > > > >> > I'm developing the implementation of MIME database in C++/Qt
> > > > > > >> > for
> > > > > > >> > one
> > > > > > >> > commercial program (requirement managment tool, if one will
> be
> > > > > > >> > interested).
> > > > > > >> > So my question is: the format of magic values to compare
> file
> > > > > > >> > header
> > > > > > >> > data
> > > > > > >> > with is not specified exactly in the spec. I mean the
> > > > >
> > > > > magic/match/value
> > > > >
> > > > > > >> > attribute.
> > > > > > >> > What exactly mean those magic strings from
> > > > > > >> > /usr/share/mime/packages/freedesktop.org.xml from my
> Kubuntu?
> > > > > > >> > 1) "\1\9"
> > > > > > >> > 2) "\376\067\0\043"
> > > > > > >> > 3) "\x8AMNG\x0D\x0A\x1A\x0A"
> > > > > > >> > Second is looks like octal number in C notation, third -
> > > > >
> > > > > hexadecimal,
> > > > >
> > > > > > >> > but
> > > > > > >> > about first i'm not sure. It is just "usual" decimal value?
> > > > > > >> > What format exactly should use magic values?
> > > > > > >> > Thanks for your help. WBR, Alexander
> > >
> > > > > > >> > P.S. Spec i'm using living here:
> > >
> http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info
> > >
> > > > > > >> > -spec-latest.html#id2661973 P.S. <match> items can be
> nested.
> > >
> > > But i
> > >
> > > > > > >> > can't find yet the clear way to implement their storage
> > > > > > >> > programmatically. Some kind of tree, or reverse polish
> notation
> > > > >
> > > > > should
> > > > >
> > > > > > >> > be used here? nevermind
> > > > > > >> >
> > > > > > >> > _______________________________________________
> > > > > > >> > xdg mailing list
> > > > > > >> > xdg at lists.freedesktop.org
> > > > > > >> > http://lists.freedesktop.org/mailman/listinfo/xdg
> > > > > >
> > > > > > _______________________________________________
> > > > > > xdg mailing list
> > > > > > xdg at lists.freedesktop.org
> > > > > > http://lists.freedesktop.org/mailman/listinfo/xdg
> > > > >
> > > > > --
> > > > > Kevin Krammer, KDE developer, xdg-utils developer
> > > > > KDE user support, developer mentoring
> > > > >
> > > > > _______________________________________________
> > > > > xdg mailing list
> > > > > xdg at lists.freedesktop.org
> > > > > http://lists.freedesktop.org/mailman/listinfo/xdg
> > >
> > > --
> > > Kevin Krammer, KDE developer, xdg-utils developer
> > > KDE user support, developer mentoring
> > >
> > > _______________________________________________
> > > xdg mailing list
> > > xdg at lists.freedesktop.org
> > > http://lists.freedesktop.org/mailman/listinfo/xdg
> --
> Kevin Krammer, KDE developer, xdg-utils developer
> KDE user support, developer mentoring
>
> _______________________________________________
> xdg mailing list
> xdg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xdg
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xdg/attachments/20131216/e295083e/attachment-0001.html>


More information about the xdg mailing list