How to get a CF_HDROP from javascript

Harry <[email protected]> Mon, 03 Apr 2006 22:34:30 +0200
Newsgroups gmane.comp.mozilla.devel.windows
Message-ID <[email protected]>
I have a variable lf of type nsILocalFile and I want to get the CF_HDROP 
clipboard format (from javascript, latest FF1.5).

My understanding is that I need  to put a "application/x-moz-file" 
flavour in the clipboard, but setTransferData seems to fail.
Somehow there is a CF_HDROP on the clipboard, but seems to be zero data.

I tried many variants of pointers (nsIFile, nsILocalFile, nsISupports), 
also I used nsISupportsString encapsulating nsIFile.path, nsIURI.spec 
but nothing helps.

I'm able to put it there as text as "text/unicode" or 
"application/x-moz-url", but thats not what I want to realize.

Following snipped gives an idea whats not working ...

const CI=Components.interfaces;
  // lf = nsILocalFile
  // uri= nsIURI

var gClipboard = 
Components.classes["@mozilla.org/widget/clipboard;1"].getService(CI.nsIClipboard);
   var trans = 
Components.classes["@mozilla.org/widget/transferable;1"].createInstance(CI.nsITransferable);

var kFileMime="application/x-moz-file";

trans.addDataFlavor(kFileMime);
// trans.setTransferData(kFileMime, lf.QueryInterface(CI.nsISupports), 4);

// trans.setTransferData(kFileMime, lf, 4); // 4=pointer size
// trans.setTransferData(kFileMime, lf, 1);
// trans.setTransferData(kFileMime, lf, lf.path.length);
// trans.setTransferData(kFileMime, lf, lf.path.length*2);
// trans.setTransferData(kFileMime, uri, 4);
// trans.setTransferData(kFileMime, uri, 1);
// trans.setTransferData(kFileMime, uri, uri.spec.length);
// trans.setTransferData(kFileMime, uri, uri.spec.length*2);

var sstr = 
Components.classes["@mozilla.org/supports-string;1"].createInstance(CI.nsISupportsString);
var text=uri.spec;
sstr.data=text;
// trans.setTransferData(kFileMime, sstr, text.length);
// trans.setTransferData(kFileMime, sstr, text.length*2);

Any ideas?
Harry