diff options
author | Melanie | 2013-04-25 20:47:55 +0100 |
---|---|---|
committer | Melanie | 2013-04-25 20:47:55 +0100 |
commit | c6628b1c769f957d4ac6c0aa71b2e671a34d5ed8 (patch) | |
tree | 7d7326fa9f7b894e5d6f846d477d97693644dc07 | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Recover a lost "virtual". Downstream projects need this. (diff) | |
download | opensim-SC_OLD-c6628b1c769f957d4ac6c0aa71b2e671a34d5ed8.zip opensim-SC_OLD-c6628b1c769f957d4ac6c0aa71b2e671a34d5ed8.tar.gz opensim-SC_OLD-c6628b1c769f957d4ac6c0aa71b2e671a34d5ed8.tar.bz2 opensim-SC_OLD-c6628b1c769f957d4ac6c0aa71b2e671a34d5ed8.tar.xz |
Merge branch 'master' into careminster
4 files changed, 406 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 9fa9be1..89a4d30 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -288,8 +288,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
288 | if (sp.IsChildAgent) | 288 | if (sp.IsChildAgent) |
289 | return; | 289 | return; |
290 | sp.ControllingClient.Kick(reason); | 290 | sp.ControllingClient.Kick(reason); |
291 | sp.MakeChildAgent(); | 291 | sp.Scene.IncomingCloseAgent(sp.UUID, true); |
292 | sp.ControllingClient.Close(); | ||
293 | } | 292 | } |
294 | 293 | ||
295 | private void OnIncomingInstantMessage(GridInstantMessage msg) | 294 | private void OnIncomingInstantMessage(GridInstantMessage msg) |
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs new file mode 100644 index 0000000..08b71e4 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs | |||
@@ -0,0 +1,57 @@ | |||
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.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | public enum InsertLocation : int | ||
35 | { | ||
36 | Agent = 1, | ||
37 | World = 2, | ||
38 | Tools = 3, | ||
39 | Advanced = 4, | ||
40 | Admin = 5 | ||
41 | } | ||
42 | |||
43 | public enum UserMode : int | ||
44 | { | ||
45 | Normal = 0, | ||
46 | God = 3 | ||
47 | } | ||
48 | |||
49 | public delegate void CustomMenuHandler(string action, UUID agentID, List<uint> selection); | ||
50 | |||
51 | public interface IDynamicMenuModule | ||
52 | { | ||
53 | void AddMenuItem(UUID agentID, string title, InsertLocation location, UserMode mode, CustomMenuHandler handler); | ||
54 | void AddMenuItem(string title, InsertLocation location, UserMode mode, CustomMenuHandler handler); | ||
55 | void RemoveMenuItem(string action); | ||
56 | } | ||
57 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index b09ae39..7b47275 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -34,6 +34,7 @@ using System.Threading; | |||
34 | using log4net; | 34 | using log4net; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenMetaverse.Assets; | 36 | using OpenMetaverse.Assets; |
37 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Scenes.Serialization; | 39 | using OpenSim.Region.Framework.Scenes.Serialization; |
39 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
@@ -180,6 +181,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
180 | if (!assetUuids.ContainsKey(tii.AssetID)) | 181 | if (!assetUuids.ContainsKey(tii.AssetID)) |
181 | GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); | 182 | GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); |
182 | } | 183 | } |
184 | |||
185 | // get any texture UUIDs used for materials such as normal and specular maps | ||
186 | GatherMaterialsUuids(part, assetUuids); | ||
183 | } | 187 | } |
184 | catch (Exception e) | 188 | catch (Exception e) |
185 | { | 189 | { |
@@ -204,6 +208,68 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | // } | 208 | // } |
205 | // } | 209 | // } |
206 | 210 | ||
211 | |||
212 | /// <summary> | ||
213 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | ||
214 | /// </summary> | ||
215 | /// <param name="part"></param> | ||
216 | /// <param name="assetUuids"></param> | ||
217 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | ||
218 | { | ||
219 | // scan thru the dynAttrs map of this part for any textures used as materials | ||
220 | OSDMap OSMaterials = null; | ||
221 | |||
222 | lock (part.DynAttrs) | ||
223 | { | ||
224 | if (part.DynAttrs.ContainsKey("OS:Materials")) | ||
225 | OSMaterials = part.DynAttrs["OS:Materials"]; | ||
226 | if (OSMaterials != null && OSMaterials.ContainsKey("Materials")) | ||
227 | { | ||
228 | OSD osd = OSMaterials["Materials"]; | ||
229 | //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); | ||
230 | |||
231 | if (osd is OSDArray) | ||
232 | { | ||
233 | OSDArray matsArr = osd as OSDArray; | ||
234 | foreach (OSDMap matMap in matsArr) | ||
235 | { | ||
236 | try | ||
237 | { | ||
238 | if (matMap.ContainsKey("Material")) | ||
239 | { | ||
240 | OSDMap mat = matMap["Material"] as OSDMap; | ||
241 | if (mat.ContainsKey("NormMap")) | ||
242 | { | ||
243 | UUID normalMapId = mat["NormMap"].AsUUID(); | ||
244 | if (normalMapId != UUID.Zero) | ||
245 | { | ||
246 | assetUuids[normalMapId] = AssetType.Texture; | ||
247 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | ||
248 | } | ||
249 | } | ||
250 | if (mat.ContainsKey("SpecMap")) | ||
251 | { | ||
252 | UUID specularMapId = mat["SpecMap"].AsUUID(); | ||
253 | if (specularMapId != UUID.Zero) | ||
254 | { | ||
255 | assetUuids[specularMapId] = AssetType.Texture; | ||
256 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | |||
261 | } | ||
262 | catch (Exception e) | ||
263 | { | ||
264 | m_log.Warn("[UUID Gatherer]: exception getting materials: " + e.Message); | ||
265 | } | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | |||
272 | |||
207 | /// <summary> | 273 | /// <summary> |
208 | /// Get an asset synchronously, potentially using an asynchronous callback. If the | 274 | /// Get an asset synchronously, potentially using an asynchronous callback. If the |
209 | /// asynchronous callback is used, we will wait for it to complete. | 275 | /// asynchronous callback is used, we will wait for it to complete. |
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs new file mode 100644 index 0000000..917911f --- /dev/null +++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs | |||
@@ -0,0 +1,282 @@ | |||
1 | // ****************************************************************** | ||
2 | // Copyright (c) 2008, 2009 Melanie Thielker | ||
3 | // | ||
4 | // All rights reserved | ||
5 | // | ||
6 | |||
7 | using System; | ||
8 | using System.IO; | ||
9 | using System.Reflection; | ||
10 | using System.Text; | ||
11 | using System.Collections.Generic; | ||
12 | using OpenMetaverse; | ||
13 | using OpenMetaverse.StructuredData; | ||
14 | using OpenSim; | ||
15 | using OpenSim.Region; | ||
16 | using OpenSim.Region.Framework; | ||
17 | using OpenSim.Region.Framework.Scenes; | ||
18 | using OpenSim.Region.Framework.Interfaces; | ||
19 | using OpenSim.Framework; | ||
20 | //using OpenSim.Framework.Capabilities; | ||
21 | using OpenSim.Framework.Servers; | ||
22 | using OpenSim.Framework.Servers.HttpServer; | ||
23 | using Nini.Config; | ||
24 | using log4net; | ||
25 | using Mono.Addins; | ||
26 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
27 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
28 | |||
29 | namespace OpenSim.Region.OptionalModules.ViewerSupport | ||
30 | { | ||
31 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DynamicMenu")] | ||
32 | public class DynamicMenuModule : INonSharedRegionModule, IDynamicMenuModule | ||
33 | { | ||
34 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
35 | |||
36 | private class MenuItemData | ||
37 | { | ||
38 | public string Title; | ||
39 | public UUID AgentID; | ||
40 | public InsertLocation Location; | ||
41 | public UserMode Mode; | ||
42 | public CustomMenuHandler Handler; | ||
43 | } | ||
44 | |||
45 | private Dictionary<UUID, List<MenuItemData>> m_menuItems = | ||
46 | new Dictionary<UUID, List<MenuItemData>>(); | ||
47 | |||
48 | private Scene m_scene; | ||
49 | |||
50 | public string Name | ||
51 | { | ||
52 | get { return "DynamicMenuModule"; } | ||
53 | } | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public void Initialise(IConfigSource config) | ||
61 | { | ||
62 | } | ||
63 | |||
64 | public void Close() | ||
65 | { | ||
66 | } | ||
67 | |||
68 | public void AddRegion(Scene scene) | ||
69 | { | ||
70 | m_scene = scene; | ||
71 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
72 | m_scene.RegisterModuleInterface<IDynamicMenuModule>(this); | ||
73 | } | ||
74 | |||
75 | public void RegionLoaded(Scene scene) | ||
76 | { | ||
77 | ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>(); | ||
78 | |||
79 | if (featuresModule != null) | ||
80 | featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; | ||
81 | } | ||
82 | |||
83 | public void RemoveRegion(Scene scene) | ||
84 | { | ||
85 | } | ||
86 | |||
87 | private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) | ||
88 | { | ||
89 | OSD menus = new OSDMap(); | ||
90 | if (features.ContainsKey("menus")) | ||
91 | menus = features["menus"]; | ||
92 | |||
93 | OSDMap agent = new OSDMap(); | ||
94 | OSDMap world = new OSDMap(); | ||
95 | OSDMap tools = new OSDMap(); | ||
96 | OSDMap advanced = new OSDMap(); | ||
97 | OSDMap admin = new OSDMap(); | ||
98 | if (((OSDMap)menus).ContainsKey("agent")) | ||
99 | agent = (OSDMap)((OSDMap)menus)["agent"]; | ||
100 | if (((OSDMap)menus).ContainsKey("world")) | ||
101 | world = (OSDMap)((OSDMap)menus)["world"]; | ||
102 | if (((OSDMap)menus).ContainsKey("tools")) | ||
103 | tools = (OSDMap)((OSDMap)menus)["tools"]; | ||
104 | if (((OSDMap)menus).ContainsKey("advanced")) | ||
105 | advanced = (OSDMap)((OSDMap)menus)["advanced"]; | ||
106 | if (((OSDMap)menus).ContainsKey("admin")) | ||
107 | admin = (OSDMap)((OSDMap)menus)["admin"]; | ||
108 | |||
109 | if (m_menuItems.ContainsKey(UUID.Zero)) | ||
110 | { | ||
111 | foreach (MenuItemData d in m_menuItems[UUID.Zero]) | ||
112 | { | ||
113 | if (d.Mode == UserMode.God && (!m_scene.Permissions.IsGod(agentID))) | ||
114 | continue; | ||
115 | |||
116 | OSDMap loc = null; | ||
117 | switch (d.Location) | ||
118 | { | ||
119 | case InsertLocation.Agent: | ||
120 | loc = agent; | ||
121 | break; | ||
122 | case InsertLocation.World: | ||
123 | loc = world; | ||
124 | break; | ||
125 | case InsertLocation.Tools: | ||
126 | loc = tools; | ||
127 | break; | ||
128 | case InsertLocation.Advanced: | ||
129 | loc = advanced; | ||
130 | break; | ||
131 | case InsertLocation.Admin: | ||
132 | loc = admin; | ||
133 | break; | ||
134 | } | ||
135 | |||
136 | if (loc == null) | ||
137 | continue; | ||
138 | |||
139 | loc[d.Title] = OSD.FromString(d.Title); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | if (m_menuItems.ContainsKey(agentID)) | ||
144 | { | ||
145 | foreach (MenuItemData d in m_menuItems[agentID]) | ||
146 | { | ||
147 | if (d.Mode == UserMode.God && (!m_scene.Permissions.IsGod(agentID))) | ||
148 | continue; | ||
149 | |||
150 | OSDMap loc = null; | ||
151 | switch (d.Location) | ||
152 | { | ||
153 | case InsertLocation.Agent: | ||
154 | loc = agent; | ||
155 | break; | ||
156 | case InsertLocation.World: | ||
157 | loc = world; | ||
158 | break; | ||
159 | case InsertLocation.Tools: | ||
160 | loc = tools; | ||
161 | break; | ||
162 | case InsertLocation.Advanced: | ||
163 | loc = advanced; | ||
164 | break; | ||
165 | case InsertLocation.Admin: | ||
166 | loc = admin; | ||
167 | break; | ||
168 | } | ||
169 | |||
170 | if (loc == null) | ||
171 | continue; | ||
172 | |||
173 | loc[d.Title] = OSD.FromString(d.Title); | ||
174 | } | ||
175 | } | ||
176 | |||
177 | |||
178 | ((OSDMap)menus)["agent"] = agent; | ||
179 | ((OSDMap)menus)["world"] = world; | ||
180 | ((OSDMap)menus)["tools"] = tools; | ||
181 | ((OSDMap)menus)["advanced"] = advanced; | ||
182 | ((OSDMap)menus)["admin"] = admin; | ||
183 | |||
184 | features["menus"] = menus; | ||
185 | } | ||
186 | |||
187 | private void OnRegisterCaps(UUID agentID, Caps caps) | ||
188 | { | ||
189 | string capUrl = "/CAPS/" + UUID.Random() + "/"; | ||
190 | |||
191 | capUrl = "/CAPS/" + UUID.Random() + "/"; | ||
192 | caps.RegisterHandler("CustomMenuAction", new MenuActionHandler(capUrl, "CustomMenuAction", agentID, this, m_scene)); | ||
193 | } | ||
194 | |||
195 | internal void HandleMenuSelection(string action, UUID agentID, List<uint> selection) | ||
196 | { | ||
197 | if (m_menuItems.ContainsKey(agentID)) | ||
198 | { | ||
199 | foreach (MenuItemData d in m_menuItems[agentID]) | ||
200 | { | ||
201 | if (d.Title == action) | ||
202 | d.Handler(action, agentID, selection); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | if (m_menuItems.ContainsKey(UUID.Zero)) | ||
207 | { | ||
208 | foreach (MenuItemData d in m_menuItems[UUID.Zero]) | ||
209 | { | ||
210 | if (d.Title == action) | ||
211 | d.Handler(action, agentID, selection); | ||
212 | } | ||
213 | } | ||
214 | } | ||
215 | |||
216 | public void AddMenuItem(string title, InsertLocation location, UserMode mode, CustomMenuHandler handler) | ||
217 | { | ||
218 | AddMenuItem(UUID.Zero, title, location, mode, handler); | ||
219 | } | ||
220 | |||
221 | public void AddMenuItem(UUID agentID, string title, InsertLocation location, UserMode mode, CustomMenuHandler handler) | ||
222 | { | ||
223 | if (!m_menuItems.ContainsKey(agentID)) | ||
224 | m_menuItems[agentID] = new List<MenuItemData>(); | ||
225 | |||
226 | m_menuItems[agentID].Add(new MenuItemData() { Title = title, AgentID = agentID, Location = location, Mode = mode, Handler = handler }); | ||
227 | } | ||
228 | |||
229 | public void RemoveMenuItem(string action) | ||
230 | { | ||
231 | foreach (KeyValuePair<UUID,List< MenuItemData>> kvp in m_menuItems) | ||
232 | { | ||
233 | List<MenuItemData> pendingDeletes = new List<MenuItemData>(); | ||
234 | foreach (MenuItemData d in kvp.Value) | ||
235 | { | ||
236 | if (d.Title == action) | ||
237 | pendingDeletes.Add(d); | ||
238 | } | ||
239 | |||
240 | foreach (MenuItemData d in pendingDeletes) | ||
241 | kvp.Value.Remove(d); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
246 | public class MenuActionHandler : BaseStreamHandler | ||
247 | { | ||
248 | private static readonly ILog m_log = | ||
249 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
250 | |||
251 | private UUID m_agentID; | ||
252 | private Scene m_scene; | ||
253 | private DynamicMenuModule m_module; | ||
254 | |||
255 | public MenuActionHandler(string path, string name, UUID agentID, DynamicMenuModule module, Scene scene) | ||
256 | :base("POST", path, name, agentID.ToString()) | ||
257 | { | ||
258 | m_agentID = agentID; | ||
259 | m_scene = scene; | ||
260 | m_module = module; | ||
261 | } | ||
262 | |||
263 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
264 | { | ||
265 | StreamReader reader = new StreamReader(request); | ||
266 | string requestBody = reader.ReadToEnd(); | ||
267 | |||
268 | OSD osd = OSDParser.DeserializeLLSDXml(requestBody); | ||
269 | |||
270 | string action = ((OSDMap)osd)["action"].AsString(); | ||
271 | OSDArray selection = (OSDArray)((OSDMap)osd)["selection"]; | ||
272 | List<uint> sel = new List<uint>(); | ||
273 | for (int i = 0 ; i < selection.Count ; i++) | ||
274 | sel.Add(selection[i].AsUInteger()); | ||
275 | |||
276 | Util.FireAndForget(x => { m_module.HandleMenuSelection(action, m_agentID, sel); }); | ||
277 | |||
278 | Encoding encoding = Encoding.UTF8; | ||
279 | return encoding.GetBytes(OSDParser.SerializeLLSDXmlString(new OSD())); | ||
280 | } | ||
281 | } | ||
282 | } | ||