On this page http://www.mozilla.org/xpfe/ we have an overview of XPToolkit, or the "Cross Platform Toolkit" which is the module that allows Mozilla applications to be cross-platform.
Notice towards the bottom a link for the clipboard service. The clipboard is the facility through which drag and drop and other style of datatransfer between applications occurs. The link refers to this page:
http://www.mozilla.org/xpfe/xptoolkit/clipboard.html
Towards the end of that page there is an example of using the clipboard. As a code sample it is pretty nice, simple, easy to understand, and I value having it there. However ...
Let's back up a little and talk about the Mozilla architecture a bit. The design is to have a pile of loosely coupled components or modules. The name is "XPCOM" or cross-platform common-object-module. Any service you use in Mozilla, you first must get an XPCOM style handle onto the service. The XPCOM layering allows XPCOM modules to be used from "any" programming language (for which XPCOM bindings have been created). The list includes javascript, C++, python, Java, perl, etc (the usual suspects).
From Javascript the idiom is:
var xyz = Components.classes[class-id].getService(); xyz = xyz.QueryInterface(Components.interfaces.nsIXyz);
The "class-id" is a string with a form like: "@mozilla.org/network/server-socket;1". The "nsIxyz" identifier refers to the interface description (by convention) stored somewhere as a file named nsIxyz.idl. This is nice and loosely structured allowing a great deal of flexibility in bringing pieces and parts together to make an application.
HOWEVER ... If you look at the example you see:
var clipboard = Components.classes["component://netscape/widget/clipboard"].getService(); ... var trans = Components.classes["component://netscape/widget/transferable"].createInstance(); ...
When I copied that code into my application it failed. Why? Because it didn't recognize the class-id string. Why? Well, probably the documentation is out of date. Why? HeckifIknow, I sure don't know why the mozilla.org team is presenting bad or wrong documentation as the way to do things.
Here's the problem -- it's not at all obvious what the class-id string for a given IDL interface is. The class-id string is not given in the IDL file, but is stored elsewhere. Where? I haven't been able to determine a search pattern which will always result in finding the class-id string. Sometimes it is located in a ".h" (header) file related to the class, but not always.
In the case of the clipboard and transferable objects they ended up located here:
http://lxr.mozilla.org/seamonkey/source/xpfe/global/resources/content/nsClipboard.js
http://lxr.mozilla.org/seamonkey/source/xpfe/global/resources/content/nsTransferable.js
It was nice to be able to find this - however, these class-id strings are such a crucial part of writing code for Mozilla that it's absolutely outrageous that it is so difficult to find them.
(2004-08-04 10:41:39.0) Permalink Comments [2]

Posted by Martin Enlund on August 04, 2004 at 02:59 PM PDT #
As we continue to see rich-GUI Web software slide into proprietary formats, and the pressure on Microsoft to play nicely from legal battles ease, the time is right to address the future of the Web.� I would like to invite you to come to a speaker panel at <a href="http://west.cmu.edu/" target="_blank">Carnegie-Mellon University's West Coast Campus, at Moffett Field (45 minutes south of San Francisco), entitled, "Back to Proprietary Client-Server, or Web Renaissance?", on November 10th, 2004, at 6:30pm.�
Every single person I know who has spent one year or more of full-time work doing intensive JavaScript/DOM by the w3c standards (including myself) feels that Mozilla, and especially Safari, are blights and should be released as "experimental" browsers until their bugs are fixed. I'm looking for more panelists who can speak to this "controversial" issue. Please contact me at cbalz at andrew.cmu.edu if you have suggestions for panelists. So far, I have some very good speakers signed up for the panel.
Details:
In this panel, I would like to have the panelists speak to the following questions:</div>
Posted by Christopher M. Balz on September 29, 2004 at 04:51 PM PDT #