29 using System.Collections.Generic;
30 using System.Reflection;
36 using OpenMetaverse.StructuredData;
37 using OpenSim.Framework.Console;
38 using OpenSim.Framework.Servers;
39 using OpenSim.Framework.Servers.HttpServer;
40 using OpenSim.Region.Framework.Interfaces;
41 using OpenSim.Region.Framework.Scenes;
42 using OpenSim.Services.Interfaces;
44 using OpenSim.Capabilities.Handlers;
46 namespace OpenSim.Region.ClientStack.LindenCaps
48 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"AgentPreferencesModule")]
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private List<Scene> m_scenes =
new List<Scene>();
64 lock (m_scenes) m_scenes.Add(scene);
69 lock (m_scenes) m_scenes.Remove(scene);
70 scene.EventManager.OnRegisterCaps -= RegisterCaps;
76 scene.EventManager.OnRegisterCaps += delegate(
UUID agentID,
OpenSim.Framework.Capabilities.Caps caps)
78 RegisterCaps(agentID, caps);
86 public string Name {
get {
return "AgentPreferencesModule"; } }
88 public Type ReplaceableInterface
95 UUID capId = UUID.Random();
96 caps.RegisterHandler(
"AgentPreferences",
98 delegate(
string request,
string path,
string param,
101 return UpdateAgentPreferences(request, path, param, agent);
103 caps.RegisterHandler(
"UpdateAgentLanguage",
105 delegate(
string request,
string path,
string param,
108 return UpdateAgentPreferences(request, path, param, agent);
110 caps.RegisterHandler(
"UpdateAgentInformation",
112 delegate(
string request,
string path,
string param,
115 return UpdateAgentPreferences(request, path, param, agent);
125 if (m_scenes[0].AgentPreferencesService == null)
127 return OSDParser.SerializeLLSDXmlString(resp);
129 m_log.DebugFormat(
"[AgentPrefs]: UpdateAgentPreferences for {0}", agent.ToString());
130 OSDMap req = (
OSDMap)OSDParser.DeserializeLLSDXml(request);
131 AgentPrefs data = m_scenes[0].AgentPreferencesService.GetAgentPreferences(agent);
137 if (req.ContainsKey(
"access_prefs"))
140 data.AccessPrefs = accessPrefs[
"max"].AsString();
142 if (req.ContainsKey(
"default_object_perm_masks"))
144 OSDMap permsMap = (
OSDMap)req[
"default_object_perm_masks"];
145 data.PermEveryone = permsMap[
"Everyone"].AsInteger();
146 data.PermGroup = permsMap[
"Group"].AsInteger();
147 data.PermNextOwner = permsMap[
"NextOwner"].AsInteger();
149 if (req.ContainsKey(
"hover_height"))
151 data.HoverHeight = req[
"hover_height"].AsReal();
153 if (req.ContainsKey(
"language"))
155 data.Language = req[
"language"].AsString();
157 if (req.ContainsKey(
"language_is_public"))
159 data.LanguageIsPublic = req[
"language_is_public"].AsBoolean();
161 m_scenes[0].AgentPreferencesService.StoreAgentPreferences(data);
163 respAccessPrefs[
"max"] = data.AccessPrefs;
164 resp[
"access_prefs"] = respAccessPrefs;
166 respDefaultPerms[
"Everyone"] = data.PermEveryone;
167 respDefaultPerms[
"Group"] = data.PermGroup;
168 respDefaultPerms[
"NextOwner"] = data.PermNextOwner;
169 resp[
"default_object_perm_masks"] = respDefaultPerms;
170 resp[
"god_level"] = 0;
171 resp[
"hover_height"] = data.HoverHeight;
172 resp[
"language"] = data.Language;
173 resp[
"language_is_public"] = data.LanguageIsPublic;
175 string response = OSDParser.SerializeLLSDXmlString(resp);
179 #endregion Region module
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
string UpdateAgentPreferences(string request, string path, string param, UUID agent)
OpenSim.Framework.Capabilities.Caps Caps
OpenMetaverse.StructuredData.OSDMap OSDMap
OpenSim.Framework.Capabilities.Caps Caps
void RegisterCaps(UUID agent, Caps caps)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Interactive OpenSim region server
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...