Eric Plaster wrote:

 >
 > How do I write the install.js?  Everything I tried seemed to be wrong.
 >  The document on xpinstall on netscapes site was good at explaining the
 > API, but short on examples.  I've included the install.js for
 > spellviewer.  If someone could tell me how to get it installed in a
 > "dndtools" directory and be able to launch it with "./mozilla -chrome
 > chrome://spellviewer/content", I would be most greatfull.


Assuming your attached install.js works, to put it down a level you need to
change the addFile() command and the registerChrome() commands to point to
the new location.

addFile() you can change by supplying the fourth argument
"dndtools/spellviewer.jar" -- but if you supply anything there it has to be
a relative filename, not just a directory name. A better option might be to
specify a target dir

    var instDir = getFolder("Chrome","dndtools");

then in your addFile replace "getFolder('Chrome')" with "instDir".

Now in your registerChrome you use getFolder(instDir,"spellviewer.jar"), or
my preference, replace the whole thing with a single variable

    var chromeFile = getFolder(instDir, "spellviewer.jar");

and then use that in the three registerChrome calls.

I don't really like the structure of your script -- if the initInstall()
fails you shouldn't bother doing anything else.  But in particular
performInstall() doesn't always return SUCCESS, and if it doesn't you will
then invalidly call cancelInstall().

So at least restructure the last bit
    if ( err == SUCCESS ) {
       performInstall();
     }
     else {
        cancelInstall(err);
     }

One non-error status performInstall() can return is 999, meaning everything
appeared to go OK, but it's not installed until you restart because some
file was in-use that you tried to overwrite. This typically happens on an
upgrade, for instance.

 > BTW, being able to register it as "dndtools/spellviewer" would also be
 > very helpfull to avoid name conflicts.


Oh yeah, your gName sucks ;-)

Let's call it gRegName to drive the point home, and for registry names you
need to try to spread out the namespace. Strongly encouraged are things of
the form [<type>/]<company>/<product>. For example, we install Flash using
the key "Plugins/Macromedia/Shockwave Flash".

If this is a work project I'd recommend
"Chrome/QLogic/dndtools/spellviewer", and if it's personal maybe
"Chrome/Eric Plaster/dndtools/spellviewer"

-Dan Veditz


Reply via email to