The preferences server is an app launched at startup, this app is responsible of storing and retrieving the preferences of the BeOS applications (and may be the system).
The preferences server features are:
- Easy access from applications
- Support for shared preferences
- Support for multiple users
- Support for inheritance
- Support for changes notification
There is no installer available yet; you have to copy the files "by hand" see the Installing the preferences server section for details.
To manage them easily preferences are stored in sections, and because sections can contains sections you can compare the preferences storage model with a hierarchic file system where a "section" is a folder and an "entry" a file. We call an "entry" an atomic preference that is basically a name, a type, and a value.
An entry (i.e. preference) can be shared by any application as soon as you change the value of an entry every other application will be able to read the new value (no need to save a section...).
That is cool because two web browser from two different brands will be able to share the same bookmarks. But the counterpart is that we have to find some strict rules about where to store what.
Read the Preferences Tree GuideLines document to know where to store your preferences.
Because entries can be shared by applications, it can be useful for an app to be notified that the content of a section was modified. The preferences server provide a mechanism for it (see the PrefsSection)
The preferences server supports multiple users, it means that at startup a dialog can prompt you for a user name, the preferences can be specific to a user. So if you log on as "Jeff" your preferences won't be the same than the one you will get if you connect has "Jim".
If you are lucky enough to never share your computer the logging dialog can be disabled, you don't even need to create a user as soon as an "anonymous" always exists and can not be removed.
Because some application preferences should not change when you log as different users, the preferences server provides two different places where you can store your preferences. You can store them at the system level or at the user level.
When you store a preference at the system level, its value will be the same whoever will log on, and if a user modify this value, all the other users will get the new value.
A cool feature of the preferences server is inheritance. The way it works is really simple: when you look for a preference at the user level and if the preference doesn't exist, the preferences server will automatically look for this preference in the system level. Inheritance is really useful for installers, because the first time you install a software you want to have the same settings for all the users, so the installer just have to store the settings at the system level even if the software gets them at the user level.
To call the preferences server from your application just include "PrefsSection.cpp" file in your project. The PrefsSection class is documented and really simple to use.
3 applications are available to manage the preferences server:
StartupUser will let you choose the startup user.
UsersEdit will let you create, rename and delete users
PrefsEdit will let you create, modify and delete entries and sections.