David Illsley wrote:

> Hi, I've been working on a few XUL apps which (unsurprisingly) use
> XPInstall. I want to add default prefs when the package is installed
> so that the app can make reasonable assumptions about the existance of
> prefs. However, when I place my prefs modifying code in install.js it
> doesn't seem to work as the Components object cannot be obtained.
> 
> I was wondering if there is any way I can get to this object, whether
> this is a bug or RFE, known or otherwise?


The Components object is not available in the xpinstall context, and there 
are no plans to expose it (too many deep issues).

If you want to create a true default pref the only way is to add a foo.js 
file to bin/defaults/pref/ -- please pick a unique name giving thought to 
avoiding future clashes with others who want to add default prefs.

The "SetDefault...Pref" functions in nsIPref don't really do what they 
advertise. That's an obsolete interface, for one thing. For another they add 
values to the current in-memory "default pref" structure, but they don't get 
written out to disk. So the unavailability of the Components object isn't 
such a great loss here.

One thing you can't do in an install is set and read prefs for the current 
user. See http://bugzilla.mozilla.org/show_bug.cgi?id=15239

You should be sure to code your app to behave properly in case the default 
prefs are not set, because it's possible that the global directory is not 
writable. If you've got a pure "chrome" app you could write the install 
script to failover to the profile chrome directory, but there's nothing you 
could do for the defaults

-Dan Veditz


Reply via email to