aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2013-02-14 08:40:15 +0100
committerMelanie2013-02-14 08:40:15 +0100
commit32c4e1a850fc271808f2e80c79c628ddc82e0206 (patch)
tree616c5ee88d807712d832c08cdc8b9cc0d0341980
parentSmall fix to sim features module (diff)
downloadopensim-SC_OLD-32c4e1a850fc271808f2e80c79c628ddc82e0206.zip
opensim-SC_OLD-32c4e1a850fc271808f2e80c79c628ddc82e0206.tar.gz
opensim-SC_OLD-32c4e1a850fc271808f2e80c79c628ddc82e0206.tar.bz2
opensim-SC_OLD-32c4e1a850fc271808f2e80c79c628ddc82e0206.tar.xz
Add an event and some logic to allow customizing Simulator Features by avatar
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs25
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs6
2 files changed, 26 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
index 8f38737..6ef8815 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
@@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.Linden
59// private static readonly ILog m_log = 59// private static readonly ILog m_log =
60// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 60// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 61
62 public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
63
62 private Scene m_scene; 64 private Scene m_scene;
63 65
64 /// <summary> 66 /// <summary>
@@ -158,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden
158 IRequestHandler reqHandler 160 IRequestHandler reqHandler
159 = new RestHTTPHandler( 161 = new RestHTTPHandler(
160 "GET", "/CAPS/" + UUID.Random(), 162 "GET", "/CAPS/" + UUID.Random(),
161 HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString()); 163 x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString());
162 164
163 caps.RegisterHandler("SimulatorFeatures", reqHandler); 165 caps.RegisterHandler("SimulatorFeatures", reqHandler);
164 } 166 }
@@ -187,18 +189,33 @@ namespace OpenSim.Region.ClientStack.Linden
187 return new OSDMap(m_features); 189 return new OSDMap(m_features);
188 } 190 }
189 191
190 private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) 192 private OSDMap DeepCopy()
193 {
194 // This isn't the cheapest way of doing this but the rate
195 // of occurrence is low (on sim entry only) and it's a sure
196 // way to get a true deep copy.
197 OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features));
198
199 return (OSDMap)copy;
200 }
201
202 private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID)
191 { 203 {
192// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); 204// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request");
193 205
206 OSDMap copy = DeepCopy();
207
208 SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest;
209 if (handlerOnSimulatorFeaturesRequest != null)
210 handlerOnSimulatorFeaturesRequest(agentID, ref copy);
211
194 //Send back data 212 //Send back data
195 Hashtable responsedata = new Hashtable(); 213 Hashtable responsedata = new Hashtable();
196 responsedata["int_response_code"] = 200; 214 responsedata["int_response_code"] = 200;
197 responsedata["content_type"] = "text/plain"; 215 responsedata["content_type"] = "text/plain";
198 responsedata["keepalive"] = false; 216 responsedata["keepalive"] = false;
199 217
200 lock (m_features) 218 responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy);
201 responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features);
202 219
203 return responsedata; 220 return responsedata;
204 } 221 }
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs
index 8cef14e..6effcc1 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs
@@ -26,18 +26,22 @@
26 */ 26 */
27 27
28using System; 28using System;
29using OpenMetaverse;
29using OpenMetaverse.StructuredData; 30using OpenMetaverse.StructuredData;
30 31
31namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
32{ 33{
34 public delegate void SimulatorFeaturesRequestDelegate(UUID agentID, ref OSDMap features);
35
33 /// <summary> 36 /// <summary>
34 /// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability. 37 /// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability.
35 /// </summary> 38 /// </summary>
36 public interface ISimulatorFeaturesModule 39 public interface ISimulatorFeaturesModule
37 { 40 {
41 event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
38 void AddFeature(string name, OSD value); 42 void AddFeature(string name, OSD value);
39 bool RemoveFeature(string name); 43 bool RemoveFeature(string name);
40 bool TryGetFeature(string name, out OSD value); 44 bool TryGetFeature(string name, out OSD value);
41 OSDMap GetFeatures(); 45 OSDMap GetFeatures();
42 } 46 }
43} \ No newline at end of file 47}