tags:

views:

112

answers:

2

I am writing a custom xulrunner-based app and I wish to have some files deployed in the user profile the first time the application is run.

I placed the files in my application's defaults/profile directory but they did not get copied to user's profile during the first run of the application.

Should I write some additional code or this should happen automatically? The thing that gets copied for sure is the application default preferences.

Is there a "standard" way offered by Firefox or some of the many mozilla applications? Any link to some reading will be helpful. Any hint is valuable.

Thanks in advance.

+1  A: 

Unfortunately the standard way of doing first run code is to use the pref system to determine if you have or haven't done something yet. There are a few gotchas though:

  • Make sure this code only runs once. If your firstrun code is in an overlay or main browser window, it can be run multiple times (once per window)

  • after you run the code and set the pref, make sure you flush the prefs, since prefs are written on close and will only be saved when you close.

    Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefService) .savePrefFile(null);

anotherjesse
It turned out that because I was using a "-profile ../../Data" parameter with a predefined folder for where the profile should be. The files from defaults/profile did not get copied.I deleted several times the content of the predefined Profile folder, but yet nothing happenedAfter removing the parameter it worked. However I still needed the hint you provided.Thanks Anotherjesse
Berov
+1  A: 

You could also use the preferences system in concert with querying for an extensions version number. When the version changes, call your function. That would allow you the flexibility to call the function again later if you want - but only at a version change.

pc1oad1etter
Ah this is quite helpful. thanks a lot for the additional hint.
Berov