diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 122 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs | 43 |
2 files changed, 129 insertions, 36 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 9f78948..b531c1f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |||
@@ -43,21 +43,29 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
43 | namespace OpenSim.Region.ClientStack.Linden | 43 | namespace OpenSim.Region.ClientStack.Linden |
44 | { | 44 | { |
45 | /// <summary> | 45 | /// <summary> |
46 | /// SimulatorFeatures capability. This is required for uploading Mesh. | 46 | /// SimulatorFeatures capability. |
47 | /// </summary> | ||
48 | /// <remarks> | ||
49 | /// This is required for uploading Mesh. | ||
47 | /// Since is accepts an open-ended response, we also send more information | 50 | /// Since is accepts an open-ended response, we also send more information |
48 | /// for viewers that care to interpret it. | 51 | /// for viewers that care to interpret it. |
49 | /// | 52 | /// |
50 | /// NOTE: Part of this code was adapted from the Aurora project, specifically | 53 | /// NOTE: Part of this code was adapted from the Aurora project, specifically |
51 | /// the normal part of the response in the capability handler. | 54 | /// the normal part of the response in the capability handler. |
52 | /// </summary> | 55 | /// </remarks> |
53 | /// | ||
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
55 | public class SimulatorFeaturesModule : ISharedRegionModule | 57 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule |
56 | { | 58 | { |
57 | private static readonly ILog m_log = | 59 | private static readonly ILog m_log = |
58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
61 | |||
59 | private Scene m_scene; | 62 | private Scene m_scene; |
60 | 63 | ||
64 | /// <summary> | ||
65 | /// Simulator features | ||
66 | /// </summary> | ||
67 | private OSDMap m_features = new OSDMap(); | ||
68 | |||
61 | private string m_MapImageServerURL = string.Empty; | 69 | private string m_MapImageServerURL = string.Empty; |
62 | private string m_SearchURL = string.Empty; | 70 | private string m_SearchURL = string.Empty; |
63 | 71 | ||
@@ -66,18 +74,20 @@ namespace OpenSim.Region.ClientStack.Linden | |||
66 | public void Initialise(IConfigSource source) | 74 | public void Initialise(IConfigSource source) |
67 | { | 75 | { |
68 | IConfig config = source.Configs["SimulatorFeatures"]; | 76 | IConfig config = source.Configs["SimulatorFeatures"]; |
69 | if (config == null) | 77 | if (config != null) |
70 | return; | ||
71 | |||
72 | m_MapImageServerURL = config.GetString("MapImageServerURI", string.Empty); | ||
73 | if (m_MapImageServerURL != string.Empty) | ||
74 | { | 78 | { |
75 | m_MapImageServerURL = m_MapImageServerURL.Trim(); | 79 | m_MapImageServerURL = config.GetString("MapImageServerURI", string.Empty); |
76 | if (!m_MapImageServerURL.EndsWith("/")) | 80 | if (m_MapImageServerURL != string.Empty) |
77 | m_MapImageServerURL = m_MapImageServerURL + "/"; | 81 | { |
82 | m_MapImageServerURL = m_MapImageServerURL.Trim(); | ||
83 | if (!m_MapImageServerURL.EndsWith("/")) | ||
84 | m_MapImageServerURL = m_MapImageServerURL + "/"; | ||
85 | } | ||
86 | |||
87 | m_SearchURL = config.GetString("SearchServerURI", string.Empty); | ||
78 | } | 88 | } |
79 | 89 | ||
80 | m_SearchURL = config.GetString("SearchServerURI", string.Empty); | 90 | AddDefaultFeatures(); |
81 | } | 91 | } |
82 | 92 | ||
83 | public void AddRegion(Scene s) | 93 | public void AddRegion(Scene s) |
@@ -110,43 +120,83 @@ namespace OpenSim.Region.ClientStack.Linden | |||
110 | 120 | ||
111 | #endregion | 121 | #endregion |
112 | 122 | ||
123 | /// <summary> | ||
124 | /// Add default features | ||
125 | /// </summary> | ||
126 | /// <remarks> | ||
127 | /// TODO: These should be added from other modules rather than hardcoded. | ||
128 | /// </remarks> | ||
129 | private void AddDefaultFeatures() | ||
130 | { | ||
131 | lock (m_features) | ||
132 | { | ||
133 | m_features["MeshRezEnabled"] = true; | ||
134 | m_features["MeshUploadEnabled"] = true; | ||
135 | m_features["MeshXferEnabled"] = true; | ||
136 | m_features["PhysicsMaterialsEnabled"] = true; | ||
137 | |||
138 | OSDMap typesMap = new OSDMap(); | ||
139 | typesMap["convex"] = true; | ||
140 | typesMap["none"] = true; | ||
141 | typesMap["prim"] = true; | ||
142 | m_features["PhysicsShapeTypes"] = typesMap; | ||
143 | |||
144 | // Extra information for viewers that want to use it | ||
145 | OSDMap gridServicesMap = new OSDMap(); | ||
146 | if (m_MapImageServerURL != string.Empty) | ||
147 | gridServicesMap["map-server-url"] = m_MapImageServerURL; | ||
148 | if (m_SearchURL != string.Empty) | ||
149 | gridServicesMap["search"] = m_SearchURL; | ||
150 | m_features["GridServices"] = gridServicesMap; | ||
151 | } | ||
152 | } | ||
153 | |||
113 | public void RegisterCaps(UUID agentID, Caps caps) | 154 | public void RegisterCaps(UUID agentID, Caps caps) |
114 | { | 155 | { |
115 | IRequestHandler reqHandler = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), SimulatorFeatures); | 156 | IRequestHandler reqHandler |
157 | = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), HandleSimulatorFeaturesRequest); | ||
158 | |||
116 | caps.RegisterHandler("SimulatorFeatures", reqHandler); | 159 | caps.RegisterHandler("SimulatorFeatures", reqHandler); |
117 | } | 160 | } |
118 | 161 | ||
119 | private Hashtable SimulatorFeatures(Hashtable mDhttpMethod) | 162 | public void AddFeature(string name, OSD value) |
163 | { | ||
164 | lock (m_features) | ||
165 | m_features[name] = value; | ||
166 | } | ||
167 | |||
168 | public bool RemoveFeature(string name) | ||
169 | { | ||
170 | lock (m_features) | ||
171 | return m_features.Remove(name); | ||
172 | } | ||
173 | |||
174 | public bool TryGetFeature(string name, out OSD value) | ||
175 | { | ||
176 | lock (m_features) | ||
177 | return m_features.TryGetValue(name, out value); | ||
178 | } | ||
179 | |||
180 | public OSDMap GetFeatures() | ||
181 | { | ||
182 | lock (m_features) | ||
183 | return new OSDMap(m_features); | ||
184 | } | ||
185 | |||
186 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) | ||
120 | { | 187 | { |
121 | m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); | 188 | m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); |
122 | OSDMap data = new OSDMap(); | ||
123 | data["MeshRezEnabled"] = true; | ||
124 | data["MeshUploadEnabled"] = true; | ||
125 | data["MeshXferEnabled"] = true; | ||
126 | data["PhysicsMaterialsEnabled"] = true; | ||
127 | |||
128 | OSDMap typesMap = new OSDMap(); | ||
129 | typesMap["convex"] = true; | ||
130 | typesMap["none"] = true; | ||
131 | typesMap["prim"] = true; | ||
132 | data["PhysicsShapeTypes"] = typesMap; | ||
133 | |||
134 | // Extra information for viewers that want to use it | ||
135 | OSDMap gridServicesMap = new OSDMap(); | ||
136 | if (m_MapImageServerURL != string.Empty) | ||
137 | gridServicesMap["map-server-url"] = m_MapImageServerURL; | ||
138 | if (m_SearchURL != string.Empty) | ||
139 | gridServicesMap["search"] = m_SearchURL; | ||
140 | data["GridServices"] = gridServicesMap; | ||
141 | 189 | ||
142 | //Send back data | 190 | //Send back data |
143 | Hashtable responsedata = new Hashtable(); | 191 | Hashtable responsedata = new Hashtable(); |
144 | responsedata["int_response_code"] = 200; | 192 | responsedata["int_response_code"] = 200; |
145 | responsedata["content_type"] = "text/plain"; | 193 | responsedata["content_type"] = "text/plain"; |
146 | responsedata["keepalive"] = false; | 194 | responsedata["keepalive"] = false; |
147 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(data); | 195 | |
196 | lock (m_features) | ||
197 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); | ||
198 | |||
148 | return responsedata; | 199 | return responsedata; |
149 | } | 200 | } |
150 | |||
151 | } | 201 | } |
152 | } | 202 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs new file mode 100644 index 0000000..8cef14e --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using OpenMetaverse.StructuredData; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability. | ||
35 | /// </summary> | ||
36 | public interface ISimulatorFeaturesModule | ||
37 | { | ||
38 | void AddFeature(string name, OSD value); | ||
39 | bool RemoveFeature(string name); | ||
40 | bool TryGetFeature(string name, out OSD value); | ||
41 | OSDMap GetFeatures(); | ||
42 | } | ||
43 | } \ No newline at end of file | ||