PDA

View Full Version : MIME and KDE



fullmetalcoder
1st February 2007, 09:30
AFAIR, KDE doesn't comply with freedesktop.org standards (at least not yet). However there must be a standard way to do some file association... How do :

an app registers itself as an handler for a given filetype?
force the desktop to use one handler by default for a given user? for all users ?

wysota
1st February 2007, 12:05
I'm almost sure there has already been a thread describing this on the forum. Please use search facilities to find it.

fullmetalcoder
1st February 2007, 22:07
There indeed was a thread on that subject (and I started it actually...) but it did not brought me the answers I was looking for... I need pure Qt way to associate, programatically, file extensions (or mime types) with a given application. I know that freedesktop provides some specs (still being worked on) for that but unfortunately, KDE doesn't comply with them, neither do Mac and M$ Window$... (and I'm not sure about gnome). So my point is to get low-level information about key files that need to be edited so as to achieve a proper file registration, without forcing the user to run some commands or edit anything on its own...



hmmm...I took another work around in linux...

for KDE I used "kfmclient"

for GNOME i used "gnome-open"

just pass the --help as an arguement to see how to use the system

Now as for working for associating a file is concerned...you need to do this:

Quote:
1. download the latest freedesktop-mime-database.
2. create your own file following the standard and add it to database
3. run update-mime-database command
4. run update-desktop-database command
so you see there is technically no code snippet ;) just a series of commands...

now re-read the info-spec i pointed out previously....you'll understand more completely...what i just said will act as a glue to merge all the not-so-clear spec ;)

Now for Windows: You'll have to play with MFCs/Win32 API for this...look through the docs...am not very well versed this :( But here is the shortcut....create a custom extension, open it through explorer...and choose app to open that file!!!!....you could also physically do it by setting the "file type" from the tool>options etc....you know the story)

MAC: hmmmm well MAC was a closed source system...they have now started to release out the API, so try getting your hands on it. I haven't used MAC much, but from what i know, it's a harrowing task :eek: to find the API...but i think some googling around would help...

NOTE: The concept of MIME types is present in all systems (i.e. all systems are merging towards this)...try exploiting this...

in one of the threads by munna, he asked how to open a a .swf by using the default app...here's the link....someone put a code snippet that was damn good...it could be of use to you...

here's the link:

http://www.qtcentre.org/forum/showthread.php?t=2029

see how the registry is accesed using Qt and you could use it to your benefit!!

That's what nupul said me the last time I asked the question. As you can see it's not exactly the answer I need... My aim is not to open a file of a given type but to make the desktop open it with my app by default (unless the user doesn't want it of course...). I already grabbed some informations about Window$ registry by investigating it through regedit and Qt examples related to settings but I'm not a specialist of KDE and I must admit I'm a bit puzzled by the different mime-related directories I found in /usr/share... Maybe someone has a more in-depth explanation on how they work and what I shall do to achieve my goal...

jacek
1st February 2007, 22:19
There indeed was a thread on that subject (and I started it actually...) but it did not brought me the answers I was looking for...
Next time, please, continue the old thread instead creating a new one, especially when your problem wasn't solved completely.

fullmetalcoder
2nd February 2007, 21:35
Sir! Yes sir! :)

BTW I found what I was looking for after an in-depth investigation of KDE online manual : http://docs.kde.org/userguide/file-associations.html
Everything relevant (AFAIC) is here, except one small piece of info : the application .desktop files are stored in /usr/share/applications ...

Does anyone know in which version KDE plans to bring support of freedesktop standards???

fullmetalcoder
2nd February 2007, 21:38
edit : browser quirk caused a post duplication...