diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 149 |
1 files changed, 124 insertions, 25 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 191bccf..e258bcb 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using log4net; | 32 | using log4net; |
32 | using Nini.Config; | 33 | using Nini.Config; |
@@ -37,7 +38,7 @@ using OpenSim.Framework; | |||
37 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Services.Interfaces; | 41 | // using OpenSim.Services.Interfaces; |
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | 42 | using Caps = OpenSim.Framework.Capabilities.Caps; |
42 | 43 | ||
43 | namespace OpenSim.Region.ClientStack.Linden | 44 | namespace OpenSim.Region.ClientStack.Linden |
@@ -56,8 +57,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] | 57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] |
57 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule | 58 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule |
58 | { | 59 | { |
59 | // private static readonly ILog m_log = | 60 | private static readonly ILog m_log = |
60 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
62 | |||
63 | public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; | ||
61 | 64 | ||
62 | private Scene m_scene; | 65 | private Scene m_scene; |
63 | 66 | ||
@@ -66,25 +69,40 @@ namespace OpenSim.Region.ClientStack.Linden | |||
66 | /// </summary> | 69 | /// </summary> |
67 | private OSDMap m_features = new OSDMap(); | 70 | private OSDMap m_features = new OSDMap(); |
68 | 71 | ||
69 | private string m_MapImageServerURL = string.Empty; | ||
70 | private string m_SearchURL = string.Empty; | 72 | private string m_SearchURL = string.Empty; |
73 | private string m_DestinationGuideURL = string.Empty; | ||
74 | private bool m_ExportSupported = false; | ||
75 | private string m_GridName = string.Empty; | ||
76 | private string m_GridURL = string.Empty; | ||
71 | 77 | ||
72 | #region ISharedRegionModule Members | 78 | #region ISharedRegionModule Members |
73 | 79 | ||
74 | public void Initialise(IConfigSource source) | 80 | public void Initialise(IConfigSource source) |
75 | { | 81 | { |
76 | IConfig config = source.Configs["SimulatorFeatures"]; | 82 | IConfig config = source.Configs["SimulatorFeatures"]; |
83 | |||
77 | if (config != null) | 84 | if (config != null) |
78 | { | 85 | { |
79 | m_MapImageServerURL = config.GetString("MapImageServerURI", string.Empty); | 86 | // |
80 | if (m_MapImageServerURL != string.Empty) | 87 | // All this is obsolete since getting these features from the grid service!! |
81 | { | 88 | // Will be removed after the next release |
82 | m_MapImageServerURL = m_MapImageServerURL.Trim(); | 89 | // |
83 | if (!m_MapImageServerURL.EndsWith("/")) | 90 | m_SearchURL = config.GetString("SearchServerURI", m_SearchURL); |
84 | m_MapImageServerURL = m_MapImageServerURL + "/"; | 91 | |
85 | } | 92 | m_DestinationGuideURL = config.GetString ("DestinationGuideURI", m_DestinationGuideURL); |
86 | 93 | ||
87 | m_SearchURL = config.GetString("SearchServerURI", string.Empty); | 94 | if (m_DestinationGuideURL == string.Empty) // Make this consistent with the variable in the LoginService config |
95 | m_DestinationGuideURL = config.GetString("DestinationGuide", m_DestinationGuideURL); | ||
96 | |||
97 | m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported); | ||
98 | |||
99 | m_GridURL = Util.GetConfigVarFromSections<string>( | ||
100 | source, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "SimulatorFeatures" }, String.Empty); | ||
101 | |||
102 | m_GridName = config.GetString("GridName", string.Empty); | ||
103 | if (m_GridName == string.Empty) | ||
104 | m_GridName = Util.GetConfigVarFromSections<string>( | ||
105 | source, "gridname", new string[] { "GridInfo", "SimulatorFeatures" }, String.Empty); | ||
88 | } | 106 | } |
89 | 107 | ||
90 | AddDefaultFeatures(); | 108 | AddDefaultFeatures(); |
@@ -94,6 +112,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
94 | { | 112 | { |
95 | m_scene = s; | 113 | m_scene = s; |
96 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 114 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
115 | |||
116 | m_scene.RegisterModuleInterface<ISimulatorFeaturesModule>(this); | ||
97 | } | 117 | } |
98 | 118 | ||
99 | public void RemoveRegion(Scene s) | 119 | public void RemoveRegion(Scene s) |
@@ -103,6 +123,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
103 | 123 | ||
104 | public void RegionLoaded(Scene s) | 124 | public void RegionLoaded(Scene s) |
105 | { | 125 | { |
126 | GetGridExtraFeatures(s); | ||
106 | } | 127 | } |
107 | 128 | ||
108 | public void PostInitialise() | 129 | public void PostInitialise() |
@@ -128,26 +149,43 @@ namespace OpenSim.Region.ClientStack.Linden | |||
128 | /// </remarks> | 149 | /// </remarks> |
129 | private void AddDefaultFeatures() | 150 | private void AddDefaultFeatures() |
130 | { | 151 | { |
152 | |||
131 | lock (m_features) | 153 | lock (m_features) |
132 | { | 154 | { |
133 | m_features["MeshRezEnabled"] = true; | 155 | m_features["MeshRezEnabled"] = true; |
134 | m_features["MeshUploadEnabled"] = true; | 156 | m_features["MeshUploadEnabled"] = true; |
135 | m_features["MeshXferEnabled"] = true; | 157 | m_features["MeshXferEnabled"] = true; |
136 | m_features["PhysicsMaterialsEnabled"] = true; | 158 | m_features["PhysicsMaterialsEnabled"] = true; |
137 | 159 | ||
138 | OSDMap typesMap = new OSDMap(); | 160 | OSDMap typesMap = new OSDMap(); |
139 | typesMap["convex"] = true; | 161 | typesMap["convex"] = true; |
140 | typesMap["none"] = true; | 162 | typesMap["none"] = true; |
141 | typesMap["prim"] = true; | 163 | typesMap["prim"] = true; |
142 | m_features["PhysicsShapeTypes"] = typesMap; | 164 | m_features["PhysicsShapeTypes"] = typesMap; |
143 | 165 | ||
144 | // Extra information for viewers that want to use it | 166 | // Extra information for viewers that want to use it |
145 | OSDMap gridServicesMap = new OSDMap(); | 167 | // TODO: Take these out of here into their respective modules, like map-server-url |
146 | if (m_MapImageServerURL != string.Empty) | 168 | OSDMap extrasMap; |
147 | gridServicesMap["map-server-url"] = m_MapImageServerURL; | 169 | if(m_features.ContainsKey("OpenSimExtras")) |
170 | { | ||
171 | extrasMap = (OSDMap)m_features["OpenSimExtras"]; | ||
172 | } | ||
173 | else | ||
174 | extrasMap = new OSDMap(); | ||
175 | |||
148 | if (m_SearchURL != string.Empty) | 176 | if (m_SearchURL != string.Empty) |
149 | gridServicesMap["search"] = m_SearchURL; | 177 | extrasMap["search-server-url"] = m_SearchURL; |
150 | m_features["GridServices"] = gridServicesMap; | 178 | if (!string.IsNullOrEmpty(m_DestinationGuideURL)) |
179 | extrasMap["destination-guide-url"] = m_DestinationGuideURL; | ||
180 | if (m_ExportSupported) | ||
181 | extrasMap["ExportSupported"] = true; | ||
182 | if (m_GridURL != string.Empty) | ||
183 | extrasMap["GridURL"] = m_GridURL; | ||
184 | if (m_GridName != string.Empty) | ||
185 | extrasMap["GridName"] = m_GridName; | ||
186 | |||
187 | if (extrasMap.Count > 0) | ||
188 | m_features["OpenSimExtras"] = extrasMap; | ||
151 | } | 189 | } |
152 | } | 190 | } |
153 | 191 | ||
@@ -156,7 +194,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
156 | IRequestHandler reqHandler | 194 | IRequestHandler reqHandler |
157 | = new RestHTTPHandler( | 195 | = new RestHTTPHandler( |
158 | "GET", "/CAPS/" + UUID.Random(), | 196 | "GET", "/CAPS/" + UUID.Random(), |
159 | HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString()); | 197 | x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString()); |
160 | 198 | ||
161 | caps.RegisterHandler("SimulatorFeatures", reqHandler); | 199 | caps.RegisterHandler("SimulatorFeatures", reqHandler); |
162 | } | 200 | } |
@@ -185,20 +223,81 @@ namespace OpenSim.Region.ClientStack.Linden | |||
185 | return new OSDMap(m_features); | 223 | return new OSDMap(m_features); |
186 | } | 224 | } |
187 | 225 | ||
188 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) | 226 | private OSDMap DeepCopy() |
227 | { | ||
228 | // This isn't the cheapest way of doing this but the rate | ||
229 | // of occurrence is low (on sim entry only) and it's a sure | ||
230 | // way to get a true deep copy. | ||
231 | OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features)); | ||
232 | |||
233 | return (OSDMap)copy; | ||
234 | } | ||
235 | |||
236 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID) | ||
189 | { | 237 | { |
190 | // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); | 238 | // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); |
191 | 239 | ||
240 | OSDMap copy = DeepCopy(); | ||
241 | |||
242 | // Let's add the agentID to the destination guide, if it is expecting that. | ||
243 | if (copy.ContainsKey("OpenSimExtras") && ((OSDMap)(copy["OpenSimExtras"])).ContainsKey("destination-guide-url")) | ||
244 | ((OSDMap)copy["OpenSimExtras"])["destination-guide-url"] = Replace(((OSDMap)copy["OpenSimExtras"])["destination-guide-url"], "[USERID]", agentID.ToString()); | ||
245 | |||
246 | SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; | ||
247 | |||
248 | if (handlerOnSimulatorFeaturesRequest != null) | ||
249 | handlerOnSimulatorFeaturesRequest(agentID, ref copy); | ||
250 | |||
192 | //Send back data | 251 | //Send back data |
193 | Hashtable responsedata = new Hashtable(); | 252 | Hashtable responsedata = new Hashtable(); |
194 | responsedata["int_response_code"] = 200; | 253 | responsedata["int_response_code"] = 200; |
195 | responsedata["content_type"] = "text/plain"; | 254 | responsedata["content_type"] = "text/plain"; |
196 | responsedata["keepalive"] = false; | 255 | responsedata["keepalive"] = false; |
197 | 256 | ||
198 | lock (m_features) | 257 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy); |
199 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); | ||
200 | 258 | ||
201 | return responsedata; | 259 | return responsedata; |
202 | } | 260 | } |
261 | |||
262 | /// <summary> | ||
263 | /// Gets the grid extra features. | ||
264 | /// </summary> | ||
265 | /// <param name='featuresURI'> | ||
266 | /// The URI Robust uses to handle the get_extra_features request | ||
267 | /// </param> | ||
268 | private void GetGridExtraFeatures(Scene scene) | ||
269 | { | ||
270 | Dictionary<string, object> extraFeatures = scene.GridService.GetExtraFeatures(); | ||
271 | if (extraFeatures.ContainsKey("Result") && extraFeatures["Result"] != null && extraFeatures["Result"].ToString() == "Failure") | ||
272 | { | ||
273 | m_log.WarnFormat("[SIMULATOR FEATURES MODULE]: Unable to retrieve grid-wide features"); | ||
274 | return; | ||
275 | } | ||
276 | |||
277 | lock (m_features) | ||
278 | { | ||
279 | OSDMap extrasMap = new OSDMap(); | ||
280 | |||
281 | foreach(string key in extraFeatures.Keys) | ||
282 | { | ||
283 | extrasMap[key] = (string)extraFeatures[key]; | ||
284 | |||
285 | if (key == "ExportSupported") | ||
286 | { | ||
287 | bool.TryParse(extraFeatures[key].ToString(), out m_ExportSupported); | ||
288 | } | ||
289 | } | ||
290 | m_features["OpenSimExtras"] = extrasMap; | ||
291 | |||
292 | } | ||
293 | } | ||
294 | |||
295 | private string Replace(string url, string substring, string replacement) | ||
296 | { | ||
297 | if (!String.IsNullOrEmpty(url) && url.Contains(substring)) | ||
298 | return url.Replace(substring, replacement); | ||
299 | |||
300 | return url; | ||
301 | } | ||
203 | } | 302 | } |
204 | } | 303 | } |