29 using System.Reflection;
31 using OpenSim.Framework;
32 using OpenSim.Framework.Capabilities;
33 using OpenSim.Framework.Servers.HttpServer;
34 using OpenSim.Region.Framework.Interfaces;
35 using OpenSim.Region.Framework.Scenes;
45 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"EnvironmentModule")]
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private Scene m_scene = null;
52 private UUID regionID = UUID.Zero;
53 private static bool Enabled =
false;
55 private static readonly
string capsName =
"EnvironmentSettings";
56 private static readonly
string capsBase =
"/CAPS/0020/";
60 #region INonSharedRegionModule
63 IConfig config = source.Configs[
"ClientStack.LindenCaps"];
68 if (config.GetString(
"Cap_EnvironmentSettings",
String.Empty) !=
"localhost")
70 m_log.InfoFormat(
"[{0}]: Module is disabled.", Name);
76 m_log.InfoFormat(
"[{0}]: Module is enabled.", Name);
85 get {
return "EnvironmentModule"; }
88 public Type ReplaceableInterface
100 regionID = scene.RegionInfo.RegionID;
109 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
117 scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
122 #region IEnvironmentModule
128 m_scene.SimulationDataService.RemoveRegionEnvironmentSettings(regionUUID);
133 private void OnRegisterCaps(UUID agentID,
Caps caps)
138 string capsPath = capsBase + UUID.Random();
141 caps.RegisterHandler(
146 (request, path, param, httpRequest, httpResponse)
147 => GetEnvironmentSettings(request, path, param, agentID, caps),
149 agentID.ToString()));
152 caps.HttpListener.AddStreamHandler(
156 (request, path, param, httpRequest, httpResponse)
157 => SetEnvironmentSettings(request, path, param, agentID, caps),
159 agentID.ToString()));
163 private string GetEnvironmentSettings(
string request,
string path,
string param,
164 UUID agentID,
Caps caps)
169 string env = String.Empty;
173 env = m_scene.SimulationDataService.LoadRegionEnvironmentSettings(regionID);
177 m_log.ErrorFormat(
"[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}",
178 Name, caps.RegionName, e.Message, e.StackTrace);
181 if (
String.IsNullOrEmpty(env))
187 private string SetEnvironmentSettings(
string request,
string path,
string param,
188 UUID agentID,
Caps caps)
194 setResponse.regionID = regionID;
195 setResponse.success =
false;
197 if (!m_scene.Permissions.CanIssueEstateCommand(agentID,
false))
199 setResponse.fail_reason =
"Insufficient estate permissions, settings has not been saved.";
200 return LLSDHelpers.SerialiseLLSDReply(setResponse);
205 m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request);
206 setResponse.success =
true;
208 m_log.InfoFormat(
"[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
209 Name, agentID, caps.RegionName);
213 m_log.ErrorFormat(
"[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
214 Name, caps.RegionName, e.Message, e.StackTrace);
216 setResponse.success =
false;
217 setResponse.fail_reason = String.Format(
"Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName);
220 return LLSDHelpers.SerialiseLLSDReply(setResponse);
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
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 ResetEnvironmentSettings(UUID regionUUID)
Interactive OpenSim region server
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
OpenSim.Framework.Capabilities.Caps Caps
static string EmptySettings(UUID messageID, UUID regionID)
generates a empty llsd settings response for viewer