How to run the code during the "first run" of the Xulrunner application

I am writing a custom xulrunner based application and I want the first time the application is launched the files are deployed to the user profile.

I put the files in the default / application profile directory, but they were not copied to the user profile when the application was first launched.

Do I have to write some additional code, or should this happen automatically? What exactly is copied is the default preferences of the application.

Is there a "standard" way suggested by Firefox or some of Mozilla's many applications? Any link to some reading would be helpful. Any hint is valuable.

Thanks in advance.

+1


a source to share


2 answers


Unfortunately, the standard way to do the first startup code is to use the pref system to determine if you have or haven't done it yet. However, there are a few bugs:



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

  • after running the code and setting the prefix, make sure you clear the prefix as prefs are written to close and will only persist on close.

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

+1


a source


You can also use the settings system in conjunction with a query for the version number of extensions. When the version changes, call your function. This allows you the flexibility to call the function later if you like, but only when the version changes.



+1


a source







All Articles