ExtensionUninstaller API Technical Documentation
Optimizing Your XUL Application for Uninstall
Sometimes XUL applications create new preferences or add entries to the local.rdf or create new files on the users system. If you are the creator of such applications, it's good practice to optimize it for uninstallation. If you don't, the user will end up with useless junk on their computer long after your application has been uninstalled.
Below I'll show you a few simple entries to add to your contents.rdf to optimize your application.
#uninstallInfoThe #uninstallInfo entry should contain a sequence of files to be removed from the users system. Here's an example:
The above example has two files to be removed when the application is uninstalled; "datasources/myapp.rdf" and "ComsD:mycomponent.xpt". The first is a relative path from the Mozilla installation directory, the second uses the Mozilla Directory Service Key to define where "mycomponent.xpt" lives. In this case, "ComsD" is the Mozilla component directory.
You can find a list of keys from:
http://www.mozdev.org/lxr/http/source/jslib/libraries/io/dirUtils.js#L47
http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsDirectoryServiceDefs.h
http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsAppDirectoryServiceDefs.h
Please note: You cannot use the following keys:
appdata, appregf or wind.
You also cannot have ".." in the path.
The #uninstallFunc entry specifies the name of a function to be called durring the uninstall process. This function should take care of removing application specific preferences, entries in local.rdf and anything else your it might have done after installation. The function needs to be included in your application's overlay file so that the API has access to it. The ExtensionUninstaller API will pass this function two arguments:
1) A reference to the current ExtUninstallLogger object.
2) A boolean "test" flag. TRUE = Uninstallation is testing, no real actions should be taken (removing, etc). FALSE = Uninstalling
You will use the ExtUninstallLogger object to log your uninstall activities. If the boolean flag is set to true, your function should log everything as normal, except no uninstall action should be taken.
Here's an example of the entry in the contents.rdf:
In the above example you defined "myapp_uninstall" as your uninstall function.
You function should add log items to the ExtUninstallLogger object as it completes it's tasks.
If an error occurs in your function, it should be logged as either an error or warning, with the
error code being any number between 1000 - 1099. If it's logged as an error, the entire uninstall will fail, and the
API will not continue with any of the other tasks. Logging it as warning will allow the rest of the unintall to continue, but
will relected the warning in the logs.
Learn more about logging
