* refactor: Extract caps related code from scene and put into a region module
* No functional changes in this revision0.6.3-post-fixes
parent
2921729bf2
commit
37fa677548
|
@ -158,7 +158,7 @@ namespace OpenSim.Framework.Communications.Capabilities
|
|||
// the root of all evil
|
||||
m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest);
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Registering seed capability {0} for {1}", capsBase + m_requestPath, m_agentID);
|
||||
"[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_agentID);
|
||||
|
||||
//m_capsHandlers["MapLayer"] =
|
||||
// new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST",
|
||||
|
|
|
@ -86,10 +86,6 @@ namespace OpenSim.Framework
|
|||
/// </exception>
|
||||
bool PresenceChildStatus(UUID agentId);
|
||||
|
||||
// Diva: get this out of here!!!
|
||||
string GetCapsPath(UUID agentId);
|
||||
Dictionary<ulong, string> GetChildrenSeeds(UUID agentId);
|
||||
|
||||
T RequestModuleInterface<T>();
|
||||
T[] RequestModuleInterfaces<T>();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ using OpenSim.Framework.Client;
|
|||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Region.Interfaces;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
|
@ -1382,8 +1383,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
agentData.child = false;
|
||||
agentData.firstname = m_firstName;
|
||||
agentData.lastname = m_lastName;
|
||||
agentData.CapsPath = m_scene.GetCapsPath(m_agentId);
|
||||
agentData.ChildrenCapSeeds = new Dictionary<ulong,string>(m_scene.GetChildrenSeeds(m_agentId));
|
||||
|
||||
ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
|
||||
agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
|
||||
agentData.ChildrenCapSeeds = new Dictionary<ulong,string>(capsModule.GetChildrenSeeds(m_agentId));
|
||||
|
||||
return agentData;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Region.Environment.Interfaces
|
||||
{
|
||||
public interface ICapabilitiesModule
|
||||
{
|
||||
void NewUserConnection(AgentCircuitData agent);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
/// <param name="capsObjectPath"></param>
|
||||
void AddCapsHandler(UUID agentId);
|
||||
|
||||
/// <summary>
|
||||
/// Remove the caps handler for a given agent.
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
void RemoveCapsHandler(UUID agentId);
|
||||
|
||||
/// <summary>
|
||||
/// Will return null if the agent doesn't have a caps handler registered
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
Caps GetCapsHandlerForUser(UUID agentId);
|
||||
|
||||
Dictionary<ulong, string> GetChildrenSeeds(UUID agentID);
|
||||
|
||||
string GetChildSeed(UUID agentID, ulong handle);
|
||||
|
||||
void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds);
|
||||
|
||||
void DropChildSeed(UUID agentID, ulong handle);
|
||||
|
||||
string GetCapsPath(UUID agentId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyrightD
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Communications.Capabilities;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.Agent.Capabilities
|
||||
{
|
||||
public class CapabilitiesModule : IRegionModule, ICapabilitiesModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected Scene m_scene;
|
||||
|
||||
/// <summary>
|
||||
/// Each agent has its own capabilities handler.
|
||||
/// </summary>
|
||||
protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>();
|
||||
|
||||
protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
|
||||
protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds
|
||||
= new Dictionary<UUID, Dictionary<ulong, string>>();
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
|
||||
}
|
||||
|
||||
public void PostInitialise() {}
|
||||
public void Close() {}
|
||||
public string Name { get { return "Capabilities Module"; } }
|
||||
public bool IsSharedModule { get { return false; } }
|
||||
|
||||
public void AddCapsHandler(UUID agentId)
|
||||
{
|
||||
if (m_scene.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(
|
||||
m_scene.AssetCache, m_scene.CommsManager.HttpServer, m_scene.RegionInfo.ExternalHostName,
|
||||
m_scene.CommsManager.HttpServer.Port,
|
||||
capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName);
|
||||
|
||||
cap.RegisterHandlers();
|
||||
|
||||
m_scene.EventManager.TriggerOnRegisterCaps(agentId, cap);
|
||||
|
||||
cap.AddNewInventoryItem = m_scene.AddUploadedInventoryItem;
|
||||
cap.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset;
|
||||
cap.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset;
|
||||
cap.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS;
|
||||
cap.GetClient = m_scene.m_sceneGraph.GetControllingClient;
|
||||
|
||||
m_capsHandlers[agentId] = cap;
|
||||
}
|
||||
|
||||
public void RemoveCapsHandler(UUID agentId)
|
||||
{
|
||||
if (childrenSeeds.ContainsKey(agentId))
|
||||
{
|
||||
childrenSeeds.Remove(agentId);
|
||||
}
|
||||
|
||||
lock (m_capsHandlers)
|
||||
{
|
||||
if (m_capsHandlers.ContainsKey(agentId))
|
||||
{
|
||||
m_capsHandlers[agentId].DeregisterHandlers();
|
||||
m_scene.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, m_scene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Caps GetCapsHandlerForUser(UUID agentId)
|
||||
{
|
||||
lock (m_capsHandlers)
|
||||
{
|
||||
if (m_capsHandlers.ContainsKey(agentId))
|
||||
{
|
||||
return m_capsHandlers[agentId];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void NewUserConnection(AgentCircuitData agent)
|
||||
{
|
||||
capsPaths[agent.AgentID] = agent.CapsPath;
|
||||
childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
|
||||
}
|
||||
|
||||
public string GetCapsPath(UUID agentId)
|
||||
{
|
||||
if (capsPaths.ContainsKey(agentId))
|
||||
{
|
||||
return capsPaths[agentId];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
|
||||
{
|
||||
Dictionary<ulong, string> seeds = null;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
return seeds;
|
||||
return new Dictionary<ulong, string>();
|
||||
}
|
||||
|
||||
public void DropChildSeed(UUID agentID, ulong handle)
|
||||
{
|
||||
Dictionary<ulong, string> seeds;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
{
|
||||
seeds.Remove(handle);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetChildSeed(UUID agentID, ulong handle)
|
||||
{
|
||||
Dictionary<ulong, string> seeds;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
{
|
||||
return seeds[handle];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
|
||||
{
|
||||
//Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count);
|
||||
childrenSeeds[agentID] = seeds;
|
||||
}
|
||||
|
||||
public void DumpChildrenSeeds(UUID agentID)
|
||||
{
|
||||
Console.WriteLine("================ ChildrenSeed {0} ================", m_scene.RegionInfo.RegionName);
|
||||
foreach (KeyValuePair<ulong, string> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -436,9 +436,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.EventQueue
|
|||
}
|
||||
if (AvatarID != UUID.Zero)
|
||||
{
|
||||
// m_scene.GetCapsHandlerForUser will return null if the agent doesn't have a caps handler
|
||||
// registered
|
||||
return ProcessQueue(request, AvatarID, m_scene.GetCapsHandlerForUser(AvatarID));
|
||||
return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -558,7 +558,8 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
|
|||
string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez";
|
||||
string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez";
|
||||
// Get a reference to the user's cap so we can pull out the Caps Object Path
|
||||
OpenSim.Framework.Communications.Capabilities.Caps userCap = homeScene.GetCapsHandlerForUser(agentData.AgentID);
|
||||
OpenSim.Framework.Communications.Capabilities.Caps userCap
|
||||
= homeScene.CapsModule.GetCapsHandlerForUser(agentData.AgentID);
|
||||
|
||||
string rezHttpProtocol = "http://";
|
||||
string regionCapsHttpProtocol = "http://";
|
||||
|
@ -681,9 +682,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
|
|||
|
||||
if (homeScene != null)
|
||||
{
|
||||
// Get a reference to their Cap object so we can pull out the capobjectroot
|
||||
OpenSim.Framework.Communications.Capabilities.Caps userCap =
|
||||
homeScene.GetCapsHandlerForUser(userData.AgentID);
|
||||
// Get a referenceokay - to their Cap object so we can pull out the capobjectroot
|
||||
OpenSim.Framework.Communications.Capabilities.Caps userCap
|
||||
= homeScene.CapsModule.GetCapsHandlerForUser(userData.AgentID);
|
||||
|
||||
//Update the circuit data in the region so this user is authorized
|
||||
homeScene.UpdateCircuitData(userData);
|
||||
|
|
|
@ -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/";
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// <summary>
|
||||
/// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
|
||||
/// </summary>
|
||||
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
|
|||
/// <summary>
|
||||
/// <see>CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[])</see>
|
||||
/// </summary>
|
||||
private void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
|
||||
public void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId,
|
||||
UUID primId, bool isScriptRunning, byte[] data)
|
||||
{
|
||||
ScenePresence avatar;
|
||||
|
|
|
@ -113,11 +113,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
get { return m_sceneGridService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Each agent has its own capabilities handler.
|
||||
/// </summary>
|
||||
protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>();
|
||||
|
||||
/// <value>
|
||||
/// All the region modules attached to this scene.
|
||||
/// </value>
|
||||
|
@ -147,6 +142,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
protected IInterregionCommsOut m_interregionCommsOut;
|
||||
protected IInterregionCommsIn m_interregionCommsIn;
|
||||
protected IDialogModule m_dialogModule;
|
||||
protected internal ICapabilitiesModule CapsModule;
|
||||
|
||||
// Central Update Loop
|
||||
|
||||
|
@ -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<IInterregionCommsOut>();
|
||||
m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
|
||||
m_dialogModule = RequestModuleInterface<IDialogModule>();
|
||||
CapsModule = RequestModuleInterface<ICapabilitiesModule>();
|
||||
}
|
||||
|
||||
#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
|
|||
/// <param name="agent"></param>
|
||||
public void NewUserConnection(AgentCircuitData agent)
|
||||
{
|
||||
/// Diva: Horrible stuff!
|
||||
capsPaths[agent.AgentID] = agent.CapsPath;
|
||||
childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
|
||||
CapsModule.NewUserConnection(agent);
|
||||
|
||||
ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
|
||||
if (sp != null)
|
||||
|
@ -2787,7 +2782,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
agent.AgentID, RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
AddCapsHandler(agent.AgentID);
|
||||
CapsModule.AddCapsHandler(agent.AgentID);
|
||||
|
||||
if (!agent.child)
|
||||
{
|
||||
|
@ -2859,88 +2854,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
/// <param name="capsObjectPath"></param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the caps handler for a given agent.
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an agent crosses into this sim. Also happens on initial login.
|
||||
/// </summary>
|
||||
|
@ -3740,7 +3653,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
#region Script Engine
|
||||
|
||||
private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
|
||||
private bool m_dumpAssetsToFile;
|
||||
public bool DumpAssetsToFile;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -214,67 +214,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// XXX These two methods are very temporary
|
||||
/// XXX Diva: this is really truly horrible; must...move...to...LL client...stack...
|
||||
/// </summary>
|
||||
protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
|
||||
protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds = new Dictionary<UUID, Dictionary<ulong, string>>();
|
||||
public string GetCapsPath(UUID agentId)
|
||||
{
|
||||
if (capsPaths.ContainsKey(agentId))
|
||||
{
|
||||
return capsPaths[agentId];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
|
||||
{
|
||||
Dictionary<ulong, string> seeds = null;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
return seeds;
|
||||
return new Dictionary<ulong, string>();
|
||||
}
|
||||
|
||||
public void DropChildSeed(UUID agentID, ulong handle)
|
||||
{
|
||||
Dictionary<ulong, string> seeds;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
{
|
||||
seeds.Remove(handle);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetChildSeed(UUID agentID, ulong handle)
|
||||
{
|
||||
Dictionary<ulong, string> seeds;
|
||||
if (childrenSeeds.TryGetValue(agentID, out seeds))
|
||||
{
|
||||
return seeds[handle];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> 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<ulong, string> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new unallocated local ID
|
||||
/// </summary>
|
||||
|
|
|
@ -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<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
|
||||
neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
|
||||
List<ulong> previousRegionNeighbourHandles = new List<ulong>(avatar.Scene.GetChildrenSeeds(avatar.UUID).Keys);
|
||||
List<ulong> previousRegionNeighbourHandles
|
||||
= new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
|
||||
List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
|
||||
List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
|
||||
|
||||
|
@ -372,7 +373,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
avatar.DropOldNeighbours(oldRegions);
|
||||
|
||||
/// Collect as many seeds as possible
|
||||
Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(avatar.Scene.GetChildrenSeeds(avatar.UUID));
|
||||
Dictionary<ulong, string> seeds
|
||||
= new Dictionary<ulong, string>(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<ulong, string>(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/";
|
||||
}
|
||||
|
|
|
@ -510,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
public void AdjustKnownSeeds()
|
||||
{
|
||||
Dictionary<ulong, string> seeds = Scene.GetChildrenSeeds(UUID);
|
||||
Dictionary<ulong, string> seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
|
||||
List<ulong> old = new List<ulong>();
|
||||
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();
|
||||
|
@ -849,7 +849,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
m_scene.SwapRootAgentCount(false);
|
||||
m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid);
|
||||
m_scene.AddCapsHandler(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();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -80,6 +82,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();
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ using log4net;
|
|||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
namespace OpenSim.Tests.Common.Mock
|
||||
|
@ -492,8 +493,10 @@ namespace OpenSim.Tests.Common.Mock
|
|||
agentData.child = false;
|
||||
agentData.firstname = m_firstName;
|
||||
agentData.lastname = m_lastName;
|
||||
agentData.CapsPath = m_scene.GetCapsPath(m_agentId);
|
||||
agentData.ChildrenCapSeeds = new Dictionary<ulong,string>(m_scene.GetChildrenSeeds(m_agentId));
|
||||
|
||||
ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
|
||||
agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
|
||||
agentData.ChildrenCapSeeds = new Dictionary<ulong,string>(capsModule.GetChildrenSeeds(m_agentId));
|
||||
|
||||
return agentData;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue