Is there a Konqueror mimetype drop handler?

David Faure faure at kde.org
Mon Mar 29 22:22:51 BST 2004


On Friday 27 February 2004 15:20, James Marsh wrote:
> 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.

Hi, did you ever got any answer on this?

There is no such mechanism in KDE right now, but one could imagine adding
an X-KDE-DropAction field to a mimetype description file, where that script 
would be executed when files are being dropped onto a file of that type.

The code for this could be added to KonqOperations::doDrop() in kdebase/libkonq
(this is used by both kdesktop and konqueror).

For the mimetype property to work you have to use the 3-lines syntax like this:
[Property::X-KDE-DropAction]
Type=String
Value=somescript.sh

then you can query for it using mime->property("X-KDE-DropAction").toString() or so.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kfm-devel mailing list