aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-01-21 21:14:17 +0000
committerJustin Clarke Casey2009-01-21 21:14:17 +0000
commit37fa6775488ab237a4537d49b92a8d52b0497b98 (patch)
tree805183f2f807a8a051ba64878c079fb0a8c7fe17 /OpenSim/Region/Environment
parent* Restore commented out isdone assertions in TextureSendTests.T010_SendPkg() (diff)
downloadopensim-SC_OLD-37fa6775488ab237a4537d49b92a8d52b0497b98.zip
opensim-SC_OLD-37fa6775488ab237a4537d49b92a8d52b0497b98.tar.gz
opensim-SC_OLD-37fa6775488ab237a4537d49b92a8d52b0497b98.tar.bz2
opensim-SC_OLD-37fa6775488ab237a4537d49b92a8d52b0497b98.tar.xz
* refactor: Extract caps related code from scene and put into a region module
* No functional changes in this revision
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs74
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs204
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs9
-rw-r--r--OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs105
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs61
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs7
-rw-r--r--OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs4
12 files changed, 319 insertions, 181 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs b/OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs
new file mode 100644
index 0000000..8a2c549
--- /dev/null
+++ b/OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs
@@ -0,0 +1,74 @@
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 OpenSim 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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
33
34namespace OpenSim.Region.Environment.Interfaces
35{
36 public interface ICapabilitiesModule
37 {
38 void NewUserConnection(AgentCircuitData agent);
39
40 /// <summary>
41 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
42 /// then it is replaced by a new CAPS handler.
43 ///
44 /// FIXME: On login this is called twice, once for the login and once when the connection is made.
45 /// This is somewhat innefficient and should be fixed. The initial login creation is necessary
46 /// since the client asks for capabilities immediately after being informed of the seed.
47 /// </summary>
48 /// <param name="agentId"></param>
49 /// <param name="capsObjectPath"></param>
50 void AddCapsHandler(UUID agentId);
51
52 /// <summary>
53 /// Remove the caps handler for a given agent.
54 /// </summary>
55 /// <param name="agentId"></param>
56 void RemoveCapsHandler(UUID agentId);
57
58 /// <summary>
59 /// Will return null if the agent doesn't have a caps handler registered
60 /// </summary>
61 /// <param name="agentId"></param>
62 Caps GetCapsHandlerForUser(UUID agentId);
63
64 Dictionary<ulong, string> GetChildrenSeeds(UUID agentID);
65
66 string GetChildSeed(UUID agentID, ulong handle);
67
68 void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds);
69
70 void DropChildSeed(UUID agentID, ulong handle);
71
72 string GetCapsPath(UUID agentId);
73 }
74}
diff --git a/OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs
new file mode 100644
index 0000000..9fa6d7d
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs
@@ -0,0 +1,204 @@
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 copyrightD
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 OpenSim 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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Capabilities;
37using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Scenes;
39using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
40
41namespace OpenSim.Region.Environment.Modules.Agent.Capabilities
42{
43 public class CapabilitiesModule : IRegionModule, ICapabilitiesModule
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 protected Scene m_scene;
48
49 /// <summary>
50 /// Each agent has its own capabilities handler.
51 /// </summary>
52 protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>();
53
54 protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
55 protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds
56 = new Dictionary<UUID, Dictionary<ulong, string>>();
57
58 public void Initialise(Scene scene, IConfigSource source)
59 {
60 m_scene = scene;
61 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
62 }
63
64 public void PostInitialise() {}
65 public void Close() {}
66 public string Name { get { return "Capabilities Module"; } }
67 public bool IsSharedModule { get { return false; } }
68
69 public void AddCapsHandler(UUID agentId)
70 {
71 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId))
72 return;
73
74 String capsObjectPath = GetCapsPath(agentId);
75
76 Caps cap = null;
77 if (m_capsHandlers.TryGetValue(agentId, out cap))
78 {
79 m_log.DebugFormat(
80 "[CAPS]: Attempt at registering twice for the same agent {0}. {1}. Ignoring.",
81 agentId, capsObjectPath);
82 //return;
83 }
84
85 cap
86 = new Caps(
87 m_scene.AssetCache, m_scene.CommsManager.HttpServer, m_scene.RegionInfo.ExternalHostName,
88 m_scene.CommsManager.HttpServer.Port,
89 capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName);
90
91 cap.RegisterHandlers();
92
93 m_scene.EventManager.TriggerOnRegisterCaps(agentId, cap);
94
95 cap.AddNewInventoryItem = m_scene.AddUploadedInventoryItem;
96 cap.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset;
97 cap.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset;
98 cap.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS;
99 cap.GetClient = m_scene.m_sceneGraph.GetControllingClient;
100
101 m_capsHandlers[agentId] = cap;
102 }
103
104 public void RemoveCapsHandler(UUID agentId)
105 {
106 if (childrenSeeds.ContainsKey(agentId))
107 {
108 childrenSeeds.Remove(agentId);
109 }
110
111 lock (m_capsHandlers)
112 {
113 if (m_capsHandlers.ContainsKey(agentId))
114 {
115 m_capsHandlers[agentId].DeregisterHandlers();
116 m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
117
118 m_capsHandlers.Remove(agentId);
119 }
120 else
121 {
122 m_log.WarnFormat(
123 "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!",
124 agentId, m_scene.RegionInfo.RegionName);
125 }
126 }
127 }
128
129 public Caps GetCapsHandlerForUser(UUID agentId)
130 {
131 lock (m_capsHandlers)
132 {
133 if (m_capsHandlers.ContainsKey(agentId))
134 {
135 return m_capsHandlers[agentId];
136 }
137 }
138
139 return null;
140 }
141
142 public void NewUserConnection(AgentCircuitData agent)
143 {
144 capsPaths[agent.AgentID] = agent.CapsPath;
145 childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
146 }
147
148 public string GetCapsPath(UUID agentId)
149 {
150 if (capsPaths.ContainsKey(agentId))
151 {
152 return capsPaths[agentId];
153 }
154
155 return null;
156 }
157
158 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
159 {
160 Dictionary<ulong, string> seeds = null;
161 if (childrenSeeds.TryGetValue(agentID, out seeds))
162 return seeds;
163 return new Dictionary<ulong, string>();
164 }
165
166 public void DropChildSeed(UUID agentID, ulong handle)
167 {
168 Dictionary<ulong, string> seeds;
169 if (childrenSeeds.TryGetValue(agentID, out seeds))
170 {
171 seeds.Remove(handle);
172 }
173 }
174
175 public string GetChildSeed(UUID agentID, ulong handle)
176 {
177 Dictionary<ulong, string> seeds;
178 if (childrenSeeds.TryGetValue(agentID, out seeds))
179 {
180 return seeds[handle];
181 }
182 return null;
183 }
184
185 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
186 {
187 //Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count);
188 childrenSeeds[agentID] = seeds;
189 }
190
191 public void DumpChildrenSeeds(UUID agentID)
192 {
193 Console.WriteLine("================ ChildrenSeed {0} ================", m_scene.RegionInfo.RegionName);
194 foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID])
195 {
196 uint x, y;
197 Utils.LongToUInts(kvp.Key, out x, out y);
198 x = x / Constants.RegionSize;
199 y = y / Constants.RegionSize;
200 Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value);
201 }
202 }
203 }
204} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs
index 3f46e95..bc4c5b9 100644
--- a/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs
@@ -436,9 +436,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.EventQueue
436 } 436 }
437 if (AvatarID != UUID.Zero) 437 if (AvatarID != UUID.Zero)
438 { 438 {
439 // m_scene.GetCapsHandlerForUser will return null if the agent doesn't have a caps handler 439 return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID));
440 // registered
441 return ProcessQueue(request, AvatarID, m_scene.GetCapsHandlerForUser(AvatarID));
442 } 440 }
443 else 441 else
444 { 442 {
diff --git a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
index a493117..f5b2823 100644
--- a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs
@@ -558,7 +558,8 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
558 string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez"; 558 string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez";
559 string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez"; 559 string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez";
560 // Get a reference to the user's cap so we can pull out the Caps Object Path 560 // Get a reference to the user's cap so we can pull out the Caps Object Path
561 OpenSim.Framework.Communications.Capabilities.Caps userCap = homeScene.GetCapsHandlerForUser(agentData.AgentID); 561 OpenSim.Framework.Communications.Capabilities.Caps userCap
562 = homeScene.CapsModule.GetCapsHandlerForUser(agentData.AgentID);
562 563
563 string rezHttpProtocol = "http://"; 564 string rezHttpProtocol = "http://";
564 string regionCapsHttpProtocol = "http://"; 565 string regionCapsHttpProtocol = "http://";
@@ -681,9 +682,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
681 682
682 if (homeScene != null) 683 if (homeScene != null)
683 { 684 {
684 // Get a reference to their Cap object so we can pull out the capobjectroot 685 // Get a referenceokay - to their Cap object so we can pull out the capobjectroot
685 OpenSim.Framework.Communications.Capabilities.Caps userCap = 686 OpenSim.Framework.Communications.Capabilities.Caps userCap
686 homeScene.GetCapsHandlerForUser(userData.AgentID); 687 = homeScene.CapsModule.GetCapsHandlerForUser(userData.AgentID);
687 688
688 //Update the circuit data in the region so this user is authorized 689 //Update the circuit data in the region so this user is authorized
689 homeScene.UpdateCircuitData(userData); 690 homeScene.UpdateCircuitData(userData);
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs
index a652609..76d1cba 100644
--- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -228,7 +228,7 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
228 else 228 else
229 { 229 {
230 // child agent already there 230 // child agent already there
231 agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle); 231 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
232 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 232 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
233 + "/CAPS/" + agentCircuit.CapsPath + "0000/"; 233 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
234 } 234 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 404a7c3..58ab058 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -214,7 +214,7 @@ namespace OpenSim.Region.Environment.Scenes
214 /// <summary> 214 /// <summary>
215 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 215 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
216 /// </summary> 216 /// </summary>
217 private UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 217 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
218 { 218 {
219 ScenePresence avatar; 219 ScenePresence avatar;
220 220
@@ -305,7 +305,7 @@ namespace OpenSim.Region.Environment.Scenes
305 /// <summary> 305 /// <summary>
306 /// <see>CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[])</see> 306 /// <see>CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[])</see>
307 /// </summary> 307 /// </summary>
308 private void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId, 308 public void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
309 UUID primId, bool isScriptRunning, byte[] data) 309 UUID primId, bool isScriptRunning, byte[] data)
310 { 310 {
311 ScenePresence avatar; 311 ScenePresence avatar;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 8a9d295..3a0bbc3 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -113,11 +113,6 @@ namespace OpenSim.Region.Environment.Scenes
113 get { return m_sceneGridService; } 113 get { return m_sceneGridService; }
114 } 114 }
115 115
116 /// <summary>
117 /// Each agent has its own capabilities handler.
118 /// </summary>
119 protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>();
120
121 /// <value> 116 /// <value>
122 /// All the region modules attached to this scene. 117 /// All the region modules attached to this scene.
123 /// </value> 118 /// </value>
@@ -147,7 +142,8 @@ namespace OpenSim.Region.Environment.Scenes
147 protected IInterregionCommsOut m_interregionCommsOut; 142 protected IInterregionCommsOut m_interregionCommsOut;
148 protected IInterregionCommsIn m_interregionCommsIn; 143 protected IInterregionCommsIn m_interregionCommsIn;
149 protected IDialogModule m_dialogModule; 144 protected IDialogModule m_dialogModule;
150 145 protected internal ICapabilitiesModule CapsModule;
146
151 // Central Update Loop 147 // Central Update Loop
152 148
153 protected int m_fps = 10; 149 protected int m_fps = 10;
@@ -342,7 +338,7 @@ namespace OpenSim.Region.Environment.Scenes
342 338
343 RegisterDefaultSceneEvents(); 339 RegisterDefaultSceneEvents();
344 340
345 m_dumpAssetsToFile = dumpAssetsToFile; 341 DumpAssetsToFile = dumpAssetsToFile;
346 342
347 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; 343 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
348 344
@@ -780,6 +776,7 @@ namespace OpenSim.Region.Environment.Scenes
780 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>(); 776 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>();
781 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>(); 777 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
782 m_dialogModule = RequestModuleInterface<IDialogModule>(); 778 m_dialogModule = RequestModuleInterface<IDialogModule>();
779 CapsModule = RequestModuleInterface<ICapabilitiesModule>();
783 } 780 }
784 781
785 #endregion 782 #endregion
@@ -2578,7 +2575,7 @@ namespace OpenSim.Region.Environment.Scenes
2578 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); 2575 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
2579 2576
2580 m_sceneGraph.removeUserCount(!childagentYN); 2577 m_sceneGraph.removeUserCount(!childagentYN);
2581 RemoveCapsHandler(agentID); 2578 CapsModule.RemoveCapsHandler(agentID);
2582 2579
2583 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 2580 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
2584 { 2581 {
@@ -2759,9 +2756,7 @@ namespace OpenSim.Region.Environment.Scenes
2759 /// <param name="agent"></param> 2756 /// <param name="agent"></param>
2760 public void NewUserConnection(AgentCircuitData agent) 2757 public void NewUserConnection(AgentCircuitData agent)
2761 { 2758 {
2762 /// Diva: Horrible stuff! 2759 CapsModule.NewUserConnection(agent);
2763 capsPaths[agent.AgentID] = agent.CapsPath;
2764 childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
2765 2760
2766 ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); 2761 ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
2767 if (sp != null) 2762 if (sp != null)
@@ -2786,8 +2781,8 @@ namespace OpenSim.Region.Environment.Scenes
2786 "[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the region banlist", 2781 "[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the region banlist",
2787 agent.AgentID, RegionInfo.RegionName); 2782 agent.AgentID, RegionInfo.RegionName);
2788 } 2783 }
2789 2784
2790 AddCapsHandler(agent.AgentID); 2785 CapsModule.AddCapsHandler(agent.AgentID);
2791 2786
2792 if (!agent.child) 2787 if (!agent.child)
2793 { 2788 {
@@ -2860,88 +2855,6 @@ namespace OpenSim.Region.Environment.Scenes
2860 } 2855 }
2861 2856
2862 /// <summary> 2857 /// <summary>
2863 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
2864 /// then it is replaced by a new CAPS handler.
2865 ///
2866 /// FIXME: On login this is called twice, once for the login and once when the connection is made.
2867 /// This is somewhat innefficient and should be fixed. The initial login creation is necessary
2868 /// since the client asks for capabilities immediately after being informed of the seed.
2869 /// </summary>
2870 /// <param name="agentId"></param>
2871 /// <param name="capsObjectPath"></param>
2872 public void AddCapsHandler(UUID agentId)
2873 {
2874 if (RegionInfo.EstateSettings.IsBanned(agentId))
2875 return;
2876
2877 String capsObjectPath = GetCapsPath(agentId);
2878
2879 Caps cap = null;
2880 if (m_capsHandlers.TryGetValue(agentId, out cap))
2881 {
2882 m_log.DebugFormat("[CAPS] Attempt at registering twice for the same agent {0}. {1}. Ignoring.", agentId, capsObjectPath);
2883 //return;
2884 }
2885
2886 cap
2887 = new Caps(
2888 AssetCache, CommsManager.HttpServer, m_regInfo.ExternalHostName, CommsManager.HttpServer.Port,
2889 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
2890
2891 cap.RegisterHandlers();
2892
2893 EventManager.TriggerOnRegisterCaps(agentId, cap);
2894
2895 cap.AddNewInventoryItem = AddUploadedInventoryItem;
2896 cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
2897 cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset;
2898 cap.CAPSFetchInventoryDescendents = HandleFetchInventoryDescendentsCAPS;
2899 cap.GetClient = m_sceneGraph.GetControllingClient;
2900 m_capsHandlers[agentId] = cap;
2901 }
2902
2903 public Caps GetCapsHandlerForUser(UUID agentId)
2904 {
2905 lock (m_capsHandlers)
2906 {
2907 if (m_capsHandlers.ContainsKey(agentId))
2908 {
2909 return m_capsHandlers[agentId];
2910 }
2911 }
2912 return null;
2913 }
2914
2915 /// <summary>
2916 /// Remove the caps handler for a given agent.
2917 /// </summary>
2918 /// <param name="agentId"></param>
2919 public void RemoveCapsHandler(UUID agentId)
2920 {
2921 if (childrenSeeds.ContainsKey(agentId))
2922 {
2923 childrenSeeds.Remove(agentId);
2924 }
2925
2926 lock (m_capsHandlers)
2927 {
2928 if (m_capsHandlers.ContainsKey(agentId))
2929 {
2930 m_capsHandlers[agentId].DeregisterHandlers();
2931 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
2932
2933 m_capsHandlers.Remove(agentId);
2934 }
2935 else
2936 {
2937 m_log.WarnFormat(
2938 "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!",
2939 agentId, RegionInfo.RegionName);
2940 }
2941 }
2942 }
2943
2944 /// <summary>
2945 /// Triggered when an agent crosses into this sim. Also happens on initial login. 2858 /// Triggered when an agent crosses into this sim. Also happens on initial login.
2946 /// </summary> 2859 /// </summary>
2947 /// <param name="agentID"></param> 2860 /// <param name="agentID"></param>
@@ -3740,7 +3653,7 @@ namespace OpenSim.Region.Environment.Scenes
3740 #region Script Engine 3653 #region Script Engine
3741 3654
3742 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>(); 3655 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
3743 private bool m_dumpAssetsToFile; 3656 public bool DumpAssetsToFile;
3744 3657
3745 /// <summary> 3658 /// <summary>
3746 /// 3659 ///
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index fafa933..e6e2c93 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -215,67 +215,6 @@ namespace OpenSim.Region.Environment.Scenes
215 #endregion 215 #endregion
216 216
217 /// <summary> 217 /// <summary>
218 /// XXX These two methods are very temporary
219 /// XXX Diva: this is really truly horrible; must...move...to...LL client...stack...
220 /// </summary>
221 protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
222 protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds = new Dictionary<UUID, Dictionary<ulong, string>>();
223 public string GetCapsPath(UUID agentId)
224 {
225 if (capsPaths.ContainsKey(agentId))
226 {
227 return capsPaths[agentId];
228 }
229
230 return null;
231 }
232 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
233 {
234 Dictionary<ulong, string> seeds = null;
235 if (childrenSeeds.TryGetValue(agentID, out seeds))
236 return seeds;
237 return new Dictionary<ulong, string>();
238 }
239
240 public void DropChildSeed(UUID agentID, ulong handle)
241 {
242 Dictionary<ulong, string> seeds;
243 if (childrenSeeds.TryGetValue(agentID, out seeds))
244 {
245 seeds.Remove(handle);
246 }
247 }
248
249 public string GetChildSeed(UUID agentID, ulong handle)
250 {
251 Dictionary<ulong, string> seeds;
252 if (childrenSeeds.TryGetValue(agentID, out seeds))
253 {
254 return seeds[handle];
255 }
256 return null;
257 }
258
259 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> value)
260 {
261 //Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count);
262 childrenSeeds[agentID] = value;
263 }
264
265 public void DumpChildrenSeeds(UUID agentID)
266 {
267 Console.WriteLine("================ ChildrenSeed {0} ================", RegionInfo.RegionName);
268 foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID])
269 {
270 uint x, y;
271 Utils.LongToUInts(kvp.Key, out x, out y);
272 x = x / Constants.RegionSize;
273 y = y / Constants.RegionSize;
274 Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value);
275 }
276 }
277
278 /// <summary>
279 /// Returns a new unallocated local ID 218 /// Returns a new unallocated local ID
280 /// </summary> 219 /// </summary>
281 /// <returns>A brand new local ID</returns> 220 /// <returns>A brand new local ID</returns>
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index 596862b..9935512 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -359,7 +359,8 @@ namespace OpenSim.Region.Environment.Scenes
359 /// and the regions where there are already child agents. We only send notification to the former. 359 /// and the regions where there are already child agents. We only send notification to the former.
360 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region 360 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
361 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too 361 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
362 List<ulong> previousRegionNeighbourHandles = new List<ulong>(avatar.Scene.GetChildrenSeeds(avatar.UUID).Keys); 362 List<ulong> previousRegionNeighbourHandles
363 = new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
363 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); 364 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
364 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); 365 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
365 366
@@ -372,7 +373,9 @@ namespace OpenSim.Region.Environment.Scenes
372 avatar.DropOldNeighbours(oldRegions); 373 avatar.DropOldNeighbours(oldRegions);
373 374
374 /// Collect as many seeds as possible 375 /// Collect as many seeds as possible
375 Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(avatar.Scene.GetChildrenSeeds(avatar.UUID)); 376 Dictionary<ulong, string> seeds
377 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
378
376 //Console.WriteLine(" !!! No. of seeds: " + seeds.Count); 379 //Console.WriteLine(" !!! No. of seeds: " + seeds.Count);
377 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle)) 380 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
378 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath); 381 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
@@ -397,7 +400,7 @@ namespace OpenSim.Region.Environment.Scenes
397 seeds.Add(neighbour.RegionHandle, agent.CapsPath); 400 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
398 } 401 }
399 else 402 else
400 agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, neighbour.RegionHandle); 403 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
401 404
402 cagents.Add(agent); 405 cagents.Add(agent);
403 } 406 }
@@ -409,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes
409 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds); 412 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
410 } 413 }
411 // These two are the same thing! 414 // These two are the same thing!
412 avatar.Scene.SetChildrenSeed(avatar.UUID, seeds); 415 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
413 avatar.KnownRegions = seeds; 416 avatar.KnownRegions = seeds;
414 //avatar.Scene.DumpChildrenSeeds(avatar.UUID); 417 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
415 //avatar.DumpKnownRegions(); 418 //avatar.DumpKnownRegions();
@@ -821,7 +824,7 @@ namespace OpenSim.Region.Environment.Scenes
821 } 824 }
822 else 825 else
823 { 826 {
824 agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle); 827 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
825 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 828 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
826 + "/CAPS/" + agentCircuit.CapsPath + "0000/"; 829 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
827 } 830 }
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 2099e9a..02d3642 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -510,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes
510 510
511 public void AdjustKnownSeeds() 511 public void AdjustKnownSeeds()
512 { 512 {
513 Dictionary<ulong, string> seeds = Scene.GetChildrenSeeds(UUID); 513 Dictionary<ulong, string> seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
514 List<ulong> old = new List<ulong>(); 514 List<ulong> old = new List<ulong>();
515 foreach (ulong handle in seeds.Keys) 515 foreach (ulong handle in seeds.Keys)
516 { 516 {
@@ -524,7 +524,7 @@ namespace OpenSim.Region.Environment.Scenes
524 } 524 }
525 } 525 }
526 DropOldNeighbours(old); 526 DropOldNeighbours(old);
527 Scene.SetChildrenSeed(UUID, seeds); 527 Scene.CapsModule.SetChildrenSeed(UUID, seeds);
528 KnownRegions = seeds; 528 KnownRegions = seeds;
529 //Console.WriteLine(" ++++++++++AFTER+++++++++++++ "); 529 //Console.WriteLine(" ++++++++++AFTER+++++++++++++ ");
530 //DumpKnownRegions(); 530 //DumpKnownRegions();
@@ -848,8 +848,8 @@ namespace OpenSim.Region.Environment.Scenes
848 //SendAnimPack(); 848 //SendAnimPack();
849 849
850 m_scene.SwapRootAgentCount(false); 850 m_scene.SwapRootAgentCount(false);
851 m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid); 851 m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid);
852 m_scene.AddCapsHandler(m_uuid); 852 m_scene.CapsModule.AddCapsHandler(m_uuid);
853 853
854 // On the next prim update, all objects will be sent 854 // On the next prim update, all objects will be sent
855 // 855 //
@@ -969,7 +969,7 @@ namespace OpenSim.Region.Environment.Scenes
969 foreach (ulong handle in oldRegions) 969 foreach (ulong handle in oldRegions)
970 { 970 {
971 RemoveNeighbourRegion(handle); 971 RemoveNeighbourRegion(handle);
972 Scene.DropChildSeed(UUID, handle); 972 Scene.CapsModule.DropChildSeed(UUID, handle);
973 } 973 }
974 } 974 }
975 975
@@ -2494,14 +2494,13 @@ namespace OpenSim.Region.Environment.Scenes
2494 { 2494 {
2495 // Restore the user structures that we needed to delete before asking the receiving region to complete the crossing 2495 // Restore the user structures that we needed to delete before asking the receiving region to complete the crossing
2496 m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(UUID); 2496 m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(UUID);
2497 m_scene.AddCapsHandler(UUID); 2497 m_scene.CapsModule.AddCapsHandler(UUID);
2498 } 2498 }
2499 } 2499 }
2500 2500
2501 //Console.WriteLine("AFTER CROSS"); 2501 //Console.WriteLine("AFTER CROSS");
2502 //Scene.DumpChildrenSeeds(UUID); 2502 //Scene.DumpChildrenSeeds(UUID);
2503 //DumpKnownRegions(); 2503 //DumpKnownRegions();
2504
2505 } 2504 }
2506 2505
2507 /// <summary> 2506 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs
index 5fa897c..dee3914 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs
@@ -34,6 +34,8 @@ using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework.Servers; 34using OpenSim.Framework.Servers;
35using OpenSim.Region.Physics.Manager; 35using OpenSim.Region.Physics.Manager;
36using OpenSim.Region.Environment; 36using OpenSim.Region.Environment;
37using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Modules.Agent.Capabilities;
37using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
38using OpenSim.Tests.Common.Mock; 40using OpenSim.Tests.Common.Mock;
39 41
@@ -79,6 +81,11 @@ namespace OpenSim.Region.Environment.Scenes.Tests
79 81
80 TestScene testScene = new TestScene( 82 TestScene testScene = new TestScene(
81 regInfo, acm, cm, scs, ac, sm, null, false, false, false, configSource, null); 83 regInfo, acm, cm, scs, ac, sm, null, false, false, false, configSource, null);
84
85 IRegionModule capsModule = new CapabilitiesModule();
86 capsModule.Initialise(testScene, new IniConfigSource());
87 testScene.AddModule(capsModule.Name, capsModule);
88 testScene.SetModuleInterfaces();
82 89
83 testScene.LandChannel = new TestLandChannel(); 90 testScene.LandChannel = new TestLandChannel();
84 testScene.LoadWorldMap(); 91 testScene.LoadWorldMap();
diff --git a/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs
index d7342de..a61b9c2 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs
@@ -63,13 +63,13 @@ namespace OpenSim.Region.Environment.Scenes.Tests
63 // TODO: Clean this up 63 // TODO: Clean this up
64 Scene sceneA = SceneTestUtils.SetupScene("sceneA", sceneAId, 1000, 1000, cm); 64 Scene sceneA = SceneTestUtils.SetupScene("sceneA", sceneAId, 1000, 1000, cm);
65 interregionComms.Initialise(sceneA, new IniConfigSource()); 65 interregionComms.Initialise(sceneA, new IniConfigSource());
66 sceneA.AddModule(interregionComms.Name, interregionComms); 66 sceneA.AddModule(interregionComms.Name, interregionComms);
67 sceneA.SetModuleInterfaces(); 67 sceneA.SetModuleInterfaces();
68 sceneA.RegisterRegionWithGrid(); 68 sceneA.RegisterRegionWithGrid();
69 69
70 // TODO: Clean this up 70 // TODO: Clean this up
71 Scene sceneB = SceneTestUtils.SetupScene("sceneB", sceneBId, 1010, 1010, cm); 71 Scene sceneB = SceneTestUtils.SetupScene("sceneB", sceneBId, 1010, 1010, cm);
72 interregionComms.Initialise(sceneB, new IniConfigSource()); 72 interregionComms.Initialise(sceneB, new IniConfigSource());
73 sceneB.AddModule(interregionComms.Name, interregionComms); 73 sceneB.AddModule(interregionComms.Name, interregionComms);
74 sceneB.SetModuleInterfaces(); 74 sceneB.SetModuleInterfaces();
75 sceneB.RegisterRegionWithGrid(); 75 sceneB.RegisterRegionWithGrid();