From 37fa6775488ab237a4537d49b92a8d52b0497b98 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 21 Jan 2009 21:14:17 +0000
Subject: * refactor: Extract caps related code from scene and put into a
region module * No functional changes in this revision
---
.../Hypergrid/HGSceneCommunicationService.cs | 2 +-
.../Region/Environment/Scenes/Scene.Inventory.cs | 4 +-
OpenSim/Region/Environment/Scenes/Scene.cs | 105 ++-------------------
OpenSim/Region/Environment/Scenes/SceneBase.cs | 61 ------------
.../Scenes/SceneCommunicationService.cs | 13 ++-
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 13 ++-
.../Environment/Scenes/Tests/SceneTestUtils.cs | 7 ++
.../Scenes/Tests/StandaloneTeleportTests.cs | 4 +-
8 files changed, 35 insertions(+), 174 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
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
else
{
// child agent already there
- agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle);
+ agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + agentCircuit.CapsPath + "0000/";
}
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
///
/// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])
///
- private UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
+ public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
{
ScenePresence avatar;
@@ -305,7 +305,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[])
///
- private void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
+ public void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
UUID primId, bool isScriptRunning, byte[] data)
{
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
get { return m_sceneGridService; }
}
- ///
- /// Each agent has its own capabilities handler.
- ///
- protected Dictionary m_capsHandlers = new Dictionary();
-
///
/// All the region modules attached to this scene.
///
@@ -147,7 +142,8 @@ namespace OpenSim.Region.Environment.Scenes
protected IInterregionCommsOut m_interregionCommsOut;
protected IInterregionCommsIn m_interregionCommsIn;
protected IDialogModule m_dialogModule;
-
+ protected internal ICapabilitiesModule CapsModule;
+
// Central Update Loop
protected int m_fps = 10;
@@ -342,7 +338,7 @@ namespace OpenSim.Region.Environment.Scenes
RegisterDefaultSceneEvents();
- m_dumpAssetsToFile = dumpAssetsToFile;
+ DumpAssetsToFile = dumpAssetsToFile;
m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
@@ -780,6 +776,7 @@ namespace OpenSim.Region.Environment.Scenes
m_interregionCommsOut = RequestModuleInterface();
m_interregionCommsIn = RequestModuleInterface();
m_dialogModule = RequestModuleInterface();
+ CapsModule = RequestModuleInterface();
}
#endregion
@@ -2578,7 +2575,7 @@ namespace OpenSim.Region.Environment.Scenes
(childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
m_sceneGraph.removeUserCount(!childagentYN);
- RemoveCapsHandler(agentID);
+ CapsModule.RemoveCapsHandler(agentID);
if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
{
@@ -2759,9 +2756,7 @@ namespace OpenSim.Region.Environment.Scenes
///
public void NewUserConnection(AgentCircuitData agent)
{
- /// Diva: Horrible stuff!
- capsPaths[agent.AgentID] = agent.CapsPath;
- childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary() : agent.ChildrenCapSeeds);
+ CapsModule.NewUserConnection(agent);
ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
if (sp != null)
@@ -2786,8 +2781,8 @@ namespace OpenSim.Region.Environment.Scenes
"[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the region banlist",
agent.AgentID, RegionInfo.RegionName);
}
-
- AddCapsHandler(agent.AgentID);
+
+ CapsModule.AddCapsHandler(agent.AgentID);
if (!agent.child)
{
@@ -2860,88 +2855,6 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
- /// then it is replaced by a new CAPS handler.
- ///
- /// FIXME: On login this is called twice, once for the login and once when the connection is made.
- /// This is somewhat innefficient and should be fixed. The initial login creation is necessary
- /// since the client asks for capabilities immediately after being informed of the seed.
- ///
- ///
- ///
- public void AddCapsHandler(UUID agentId)
- {
- if (RegionInfo.EstateSettings.IsBanned(agentId))
- return;
-
- String capsObjectPath = GetCapsPath(agentId);
-
- Caps cap = null;
- if (m_capsHandlers.TryGetValue(agentId, out cap))
- {
- m_log.DebugFormat("[CAPS] Attempt at registering twice for the same agent {0}. {1}. Ignoring.", agentId, capsObjectPath);
- //return;
- }
-
- cap
- = new Caps(
- AssetCache, CommsManager.HttpServer, m_regInfo.ExternalHostName, CommsManager.HttpServer.Port,
- capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
-
- cap.RegisterHandlers();
-
- EventManager.TriggerOnRegisterCaps(agentId, cap);
-
- cap.AddNewInventoryItem = AddUploadedInventoryItem;
- cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
- cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset;
- cap.CAPSFetchInventoryDescendents = HandleFetchInventoryDescendentsCAPS;
- cap.GetClient = m_sceneGraph.GetControllingClient;
- m_capsHandlers[agentId] = cap;
- }
-
- public Caps GetCapsHandlerForUser(UUID agentId)
- {
- lock (m_capsHandlers)
- {
- if (m_capsHandlers.ContainsKey(agentId))
- {
- return m_capsHandlers[agentId];
- }
- }
- return null;
- }
-
- ///
- /// Remove the caps handler for a given agent.
- ///
- ///
- public void RemoveCapsHandler(UUID agentId)
- {
- if (childrenSeeds.ContainsKey(agentId))
- {
- childrenSeeds.Remove(agentId);
- }
-
- lock (m_capsHandlers)
- {
- if (m_capsHandlers.ContainsKey(agentId))
- {
- m_capsHandlers[agentId].DeregisterHandlers();
- EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
-
- m_capsHandlers.Remove(agentId);
- }
- else
- {
- m_log.WarnFormat(
- "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!",
- agentId, RegionInfo.RegionName);
- }
- }
- }
-
- ///
/// Triggered when an agent crosses into this sim. Also happens on initial login.
///
///
@@ -3740,7 +3653,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Script Engine
private List ScriptEngines = new List();
- private bool m_dumpAssetsToFile;
+ public bool DumpAssetsToFile;
///
///
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
#endregion
///
- /// XXX These two methods are very temporary
- /// XXX Diva: this is really truly horrible; must...move...to...LL client...stack...
- ///
- protected Dictionary capsPaths = new Dictionary();
- protected Dictionary> childrenSeeds = new Dictionary>();
- public string GetCapsPath(UUID agentId)
- {
- if (capsPaths.ContainsKey(agentId))
- {
- return capsPaths[agentId];
- }
-
- return null;
- }
- public Dictionary GetChildrenSeeds(UUID agentID)
- {
- Dictionary seeds = null;
- if (childrenSeeds.TryGetValue(agentID, out seeds))
- return seeds;
- return new Dictionary();
- }
-
- public void DropChildSeed(UUID agentID, ulong handle)
- {
- Dictionary seeds;
- if (childrenSeeds.TryGetValue(agentID, out seeds))
- {
- seeds.Remove(handle);
- }
- }
-
- public string GetChildSeed(UUID agentID, ulong handle)
- {
- Dictionary seeds;
- if (childrenSeeds.TryGetValue(agentID, out seeds))
- {
- return seeds[handle];
- }
- return null;
- }
-
- public void SetChildrenSeed(UUID agentID, Dictionary value)
- {
- //Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count);
- childrenSeeds[agentID] = value;
- }
-
- public void DumpChildrenSeeds(UUID agentID)
- {
- Console.WriteLine("================ ChildrenSeed {0} ================", RegionInfo.RegionName);
- foreach (KeyValuePair kvp in childrenSeeds[agentID])
- {
- uint x, y;
- Utils.LongToUInts(kvp.Key, out x, out y);
- x = x / Constants.RegionSize;
- y = y / Constants.RegionSize;
- Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value);
- }
- }
-
- ///
/// Returns a new unallocated local ID
///
/// A brand new local ID
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
/// and the regions where there are already child agents. We only send notification to the former.
List neighbourHandles = NeighbourHandles(neighbours); // on this region
neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
- List previousRegionNeighbourHandles = new List(avatar.Scene.GetChildrenSeeds(avatar.UUID).Keys);
+ List previousRegionNeighbourHandles
+ = new List(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
List newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
List oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
@@ -372,7 +373,9 @@ namespace OpenSim.Region.Environment.Scenes
avatar.DropOldNeighbours(oldRegions);
/// Collect as many seeds as possible
- Dictionary seeds = new Dictionary(avatar.Scene.GetChildrenSeeds(avatar.UUID));
+ Dictionary seeds
+ = new Dictionary(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
+
//Console.WriteLine(" !!! No. of seeds: " + seeds.Count);
if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
@@ -397,7 +400,7 @@ namespace OpenSim.Region.Environment.Scenes
seeds.Add(neighbour.RegionHandle, agent.CapsPath);
}
else
- agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
+ agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
cagents.Add(agent);
}
@@ -409,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes
a.ChildrenCapSeeds = new Dictionary(seeds);
}
// These two are the same thing!
- avatar.Scene.SetChildrenSeed(avatar.UUID, seeds);
+ avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
avatar.KnownRegions = seeds;
//avatar.Scene.DumpChildrenSeeds(avatar.UUID);
//avatar.DumpKnownRegions();
@@ -821,7 +824,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
- agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle);
+ agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + agentCircuit.CapsPath + "0000/";
}
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
public void AdjustKnownSeeds()
{
- Dictionary seeds = Scene.GetChildrenSeeds(UUID);
+ Dictionary seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
List old = new List();
foreach (ulong handle in seeds.Keys)
{
@@ -524,7 +524,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
DropOldNeighbours(old);
- Scene.SetChildrenSeed(UUID, seeds);
+ Scene.CapsModule.SetChildrenSeed(UUID, seeds);
KnownRegions = seeds;
//Console.WriteLine(" ++++++++++AFTER+++++++++++++ ");
//DumpKnownRegions();
@@ -848,8 +848,8 @@ namespace OpenSim.Region.Environment.Scenes
//SendAnimPack();
m_scene.SwapRootAgentCount(false);
- m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid);
- m_scene.AddCapsHandler(m_uuid);
+ m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid);
+ m_scene.CapsModule.AddCapsHandler(m_uuid);
// On the next prim update, all objects will be sent
//
@@ -969,7 +969,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (ulong handle in oldRegions)
{
RemoveNeighbourRegion(handle);
- Scene.DropChildSeed(UUID, handle);
+ Scene.CapsModule.DropChildSeed(UUID, handle);
}
}
@@ -2494,14 +2494,13 @@ namespace OpenSim.Region.Environment.Scenes
{
// Restore the user structures that we needed to delete before asking the receiving region to complete the crossing
m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(UUID);
- m_scene.AddCapsHandler(UUID);
+ m_scene.CapsModule.AddCapsHandler(UUID);
}
}
//Console.WriteLine("AFTER CROSS");
//Scene.DumpChildrenSeeds(UUID);
//DumpKnownRegions();
-
}
///
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;
using OpenSim.Framework.Servers;
using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Environment;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Modules.Agent.Capabilities;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Tests.Common.Mock;
@@ -79,6 +81,11 @@ namespace OpenSim.Region.Environment.Scenes.Tests
TestScene testScene = new TestScene(
regInfo, acm, cm, scs, ac, sm, null, false, false, false, configSource, null);
+
+ IRegionModule capsModule = new CapabilitiesModule();
+ capsModule.Initialise(testScene, new IniConfigSource());
+ testScene.AddModule(capsModule.Name, capsModule);
+ testScene.SetModuleInterfaces();
testScene.LandChannel = new TestLandChannel();
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
// TODO: Clean this up
Scene sceneA = SceneTestUtils.SetupScene("sceneA", sceneAId, 1000, 1000, cm);
interregionComms.Initialise(sceneA, new IniConfigSource());
- sceneA.AddModule(interregionComms.Name, interregionComms);
+ sceneA.AddModule(interregionComms.Name, interregionComms);
sceneA.SetModuleInterfaces();
sceneA.RegisterRegionWithGrid();
// TODO: Clean this up
Scene sceneB = SceneTestUtils.SetupScene("sceneB", sceneBId, 1010, 1010, cm);
- interregionComms.Initialise(sceneB, new IniConfigSource());
+ interregionComms.Initialise(sceneB, new IniConfigSource());
sceneB.AddModule(interregionComms.Name, interregionComms);
sceneB.SetModuleInterfaces();
sceneB.RegisterRegionWithGrid();
--
cgit v1.1