Creating an XUL App Installer - The Installation Process
(Page 3 of 4 )
To start the installation process, we need to initialize it and provide the chrome registry with the registry key:
initInstall(appName, "/"+author+"/"+chromeName, version);
The initInstall method takes the plain-text, or friendly, name of your application, followed by '/author name/application name/' which should match the information in the main contents.rdf file.
To tell XPInstall where to copy your application files to, you use the getFolder method to obtain the target directory, and the setPackageFolder method to set it as the target directory:
installDir = getFolder("Chrome","");
setPackageFolder(installDir);
The addFile method assigns a source file to be copied to the target directory. It takes just one parameter; the name of the source file:
addFile(file);
You can also use the addFolder method to assign the source files for the installation if your XPI archive contains a directory structure instead of a JAR file.
You now need to specify what information is added to the installed-chrome file, a key element of the chrome-registry. This is done using the registerChrome method which takes three parameters: what to install and how to install it, where the files can be found, and the path to the files:
registerChrome(CONTENT | DELAYED_CHROME, getFolder("Chrome",
file), contentPath);
registerChrome(LOCALE | DELAYED_CHROME, getFolder("Chrome",
file), localePath);
Note that skin packages normally reside within their own JAR archives, which is why I haven't specified a SKIN| DELAYED_CHROME install. DELAYED_CHROME means that the new chrome will be installed once Mozilla has been restarted (when the chrome.rdf file is regenerated).
Finally, the performaInstall method is called, which actually performs the installation. This is the point where the specified files are actually copied, and the necessary file updates occur:
performInstall();
Next: Packaging Your Files >>
More XML Articles
More By Dan Wellman