Is there a Konqueror mimetype drop handler?

James Marsh james at snoopy.freeserve.co.uk
Fri Feb 27 14:20:57 GMT 2004


Hi all,

I'm currently writing a KDE program for handling remote batch job
submission using Globus/The Grid. While I'm familiar with Qt, this is
my first proper KDE program.

What I should like to be able to do is have a new mimetype
representing a "destination host" execute a submission program when
"job description" files are dropped on it. The host file then also
needs to be able to be opened in a graphical viewer/editor by clicking
on it to change the various parameters.

On Windows I had to use a horrible Drop Handler Explorer COM extension
to handle being able to drop icons on my filetype. (This is the same
mechanism used by WinZip to allow you to add files to zip archives
without opening them.) I'm not sure how this is best done in KDE
though.

Is there a correct way I can treat my arbitrary file type in a similar
manner to a standard device? From what I could find in the source code
it looks like devices are special cases, however it's likely I wasn't 
looking in the right place! 

I've a couple of ideas for workarounds, but I was hoping I could get
some advice.

The first approach is an awful hack:

Make the first three lines of the file:

  #! /bin/sh
  Handle_dropped_files_executable $0 $*
  exit 0

... with the rest of the file containing the real content such as host
location, prefered credentials etc. Make this file executable and the
file extension seems to be used by Konqueror to decide on the icon and
what to open the file with when clicked normally, but when an icon is
dropped on it, the script itself gets run. Since these files are
likely to be passed between users, this is at best a potential
security problem!

The second idea is slightly better, but seems more complex to
implement: create a new kio protocol and use standard kde URL links to
encode the parameters in a URL using this protocol. The drop action is
then presumably the same as a file getting copied to this URL and
would be handled by the kio slave. Unfortunately this presumably would
require the filetype to use the .desktop extension which seems
inappropriate for my filetype on Windows. I would also have to return
my own mimetype if the URL is clicked directly (read from) in order to
cause my editor/viewer to load, but I'm not sure then how to get back
to the original .desktop file if the parameters are changed.

Ideas/RTFM pointers?

Many thanks,
James.

(I previously emailed this to kde-devel but didn't receive a response.)





More information about the kfm-devel mailing list