OpenSimulator Internals/Code Map/ROBUST/AgentPreferencesService
OpenSimulator Internals/Code Map/ROBUST/AgentPreferencesService
[edit]Overview
[edit]AgentPreferencesService stores per-user viewer preferences: language, hover height, access tier, and default creation permissions. It is a thin wrapper over a single database table.
Source files:
OpenSim/Services/UserAccountService/AgentPreferencesService.cs OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs
Note: these files live in the UserAccountService directory, not a separate AgentPreferencesService directory.
Constructor and Config Loading
[edit]AgentPreferencesServiceBase(IConfigSource config)
Config is read in two layers; [AgentPreferencesService] overrides [DatabaseService]. Unlike other services, [AgentPreferencesService] is required -- the constructor throws if the section is absent.
| Section | Key | Default | Notes |
|---|---|---|---|
| [DatabaseService] | StorageProvider | (none) | DLL name -- fallback |
| [DatabaseService] | ConnectionString | (none) | DB connection string -- fallback |
| [AgentPreferencesService] | StorageProvider | (inherited) | Required section; overrides [DatabaseService] |
| [AgentPreferencesService] | ConnectionString | (inherited) | Overrides [DatabaseService] |
| [AgentPreferencesService] | Realm | AgentPrefs | Table name |
Throws if:
- [AgentPreferencesService] section is missing
- StorageProvider is empty after both layers
- Plugin cannot be loaded
The loaded plugin is stored as m_Database (IAgentPreferencesData).
No console commands are registered.
Data Model
[edit]One row per user. Fields stored:
| Field | Type | Notes |
|---|---|---|
| PrincipalID | UUID string | Stored in Data dictionary, not as a separate column in AgentPreferencesData |
| AccessPrefs | string | Access tier preference (e.g. "M" for Mature) |
| HoverHeight | float string | Avatar hover height |
| Language | string | BCP 47 language tag (e.g. "en-us") |
| LanguageIsPublic | "1" / "0" | Whether language preference is visible to others |
| PermEveryone | int string | Default everyone permissions on created objects |
| PermGroup | int string | Default group permissions on created objects |
| PermNextOwner | int string | Default next-owner permissions on created objects |
Conversion between AgentPreferencesData (dictionary) and AgentPrefs (typed object) is handled by the AgentPrefs constructor and StoreAgentPreferences().
GetAgentPreferences
[edit]public AgentPrefs GetAgentPreferences(UUID principalID)
Calls m_Database.GetPrefs(principalID). Returns null if no record exists, otherwise constructs AgentPrefs from the returned data dictionary.
StoreAgentPreferences
[edit]public bool StoreAgentPreferences(AgentPrefs data)
Converts AgentPrefs to AgentPreferencesData dictionary and calls m_Database.Store(). All fields are written on every call -- no partial update. LanguageIsPublic is stored as "1" or "0", not "True"/"False".
Returns the result of m_Database.Store().
GetLang
[edit]public string GetLang(UUID principalID)
Convenience method. Calls GetAgentPreferences(), returns Language if the record exists and LanguageIsPublic is true. Returns "en-us" in all other cases (no record, or language is not public).
Notes
[edit]- [AgentPreferencesService] section is mandatory -- missing it throws at startup, unlike most other services where the section is optional.
- There is no cache in this service.
- No console commands are registered.