Broke down Caps.cs into a generic Caps object that simply registers/unregisters capabilities and a specific bunch of capability implementations in Linden space called BunchOfCaps.
Renamed a few methods that were misnomers. Compiles but doesn't work.bulletsim
parent
275046cf02
commit
f79400e94c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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 OpenSimulator 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.Region.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Region.ClientStack.Linden
|
||||
{
|
||||
|
||||
public class BunchOfCapsModule : INonSharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_Scene;
|
||||
|
||||
#region INonSharedRegionModule
|
||||
|
||||
public string Name { get { return "BunchOfCapsModule"; } }
|
||||
|
||||
public Type ReplaceableInterface { get { return null; } }
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
}
|
||||
|
||||
public void Close() { }
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
m_Scene = scene;
|
||||
m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps;
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void PostInitialise() { }
|
||||
#endregion
|
||||
|
||||
private void OnRegisterCaps(UUID agentID, Caps caps)
|
||||
{
|
||||
new BunchOfCaps(m_Scene, caps);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -522,7 +522,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
if (AvatarID != UUID.Zero)
|
||||
{
|
||||
return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID));
|
||||
return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -171,8 +171,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
UUID parentFolder = llsdRequest.folder_id;
|
||||
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/";
|
||||
|
||||
Caps.AssetUploader uploader =
|
||||
new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
||||
AssetUploader uploader =
|
||||
new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
||||
llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile);
|
||||
MainServer.Instance.AddStreamHandler(
|
||||
new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
/// <summary>
|
||||
/// Each agent has its own capabilities handler.
|
||||
/// </summary>
|
||||
protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>();
|
||||
protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>();
|
||||
|
||||
protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
|
||||
protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds
|
||||
|
@ -95,19 +95,19 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
get { return null; }
|
||||
}
|
||||
|
||||
public void AddCapsHandler(UUID agentId)
|
||||
public void CreateCaps(UUID agentId)
|
||||
{
|
||||
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId))
|
||||
return;
|
||||
|
||||
String capsObjectPath = GetCapsPath(agentId);
|
||||
|
||||
if (m_capsHandlers.ContainsKey(agentId))
|
||||
if (m_capsObjects.ContainsKey(agentId))
|
||||
{
|
||||
Caps oldCaps = m_capsHandlers[agentId];
|
||||
Caps oldCaps = m_capsObjects[agentId];
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[CAPS]: Reregistering caps for agent {0}. Old caps path {1}, new caps path {2}. ",
|
||||
"[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
|
||||
agentId, oldCaps.CapsObjectPath, capsObjectPath);
|
||||
// This should not happen. The caller code is confused. We need to fix that.
|
||||
// CAPs can never be reregistered, or the client will be confused.
|
||||
|
@ -115,39 +115,29 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
//return;
|
||||
}
|
||||
|
||||
Caps caps
|
||||
= new Caps(m_scene,
|
||||
m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
|
||||
Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
|
||||
(MainServer.Instance == null) ? 0: MainServer.Instance.Port,
|
||||
capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName);
|
||||
capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
|
||||
|
||||
caps.RegisterHandlers();
|
||||
m_capsObjects[agentId] = caps;
|
||||
|
||||
m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
|
||||
|
||||
caps.AddNewInventoryItem = m_scene.AddUploadedInventoryItem;
|
||||
caps.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset;
|
||||
caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset;
|
||||
caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS;
|
||||
caps.GetClient = m_scene.SceneContents.GetControllingClient;
|
||||
|
||||
m_capsHandlers[agentId] = caps;
|
||||
}
|
||||
|
||||
public void RemoveCapsHandler(UUID agentId)
|
||||
public void RemoveCaps(UUID agentId)
|
||||
{
|
||||
if (childrenSeeds.ContainsKey(agentId))
|
||||
{
|
||||
childrenSeeds.Remove(agentId);
|
||||
}
|
||||
|
||||
lock (m_capsHandlers)
|
||||
lock (m_capsObjects)
|
||||
{
|
||||
if (m_capsHandlers.ContainsKey(agentId))
|
||||
if (m_capsObjects.ContainsKey(agentId))
|
||||
{
|
||||
m_capsHandlers[agentId].DeregisterHandlers();
|
||||
m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
|
||||
m_capsHandlers.Remove(agentId);
|
||||
m_capsObjects[agentId].DeregisterHandlers();
|
||||
m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[agentId]);
|
||||
m_capsObjects.Remove(agentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -158,20 +148,20 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public Caps GetCapsHandlerForUser(UUID agentId)
|
||||
public Caps GetCapsForUser(UUID agentId)
|
||||
{
|
||||
lock (m_capsHandlers)
|
||||
lock (m_capsObjects)
|
||||
{
|
||||
if (m_capsHandlers.ContainsKey(agentId))
|
||||
if (m_capsObjects.ContainsKey(agentId))
|
||||
{
|
||||
return m_capsHandlers[agentId];
|
||||
return m_capsObjects[agentId];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void NewUserConnection(AgentCircuitData agent)
|
||||
public void SetAgentCapsSeeds(AgentCircuitData agent)
|
||||
{
|
||||
capsPaths[agent.AgentID] = agent.CapsPath;
|
||||
childrenSeeds[agent.AgentID]
|
||||
|
@ -241,7 +231,7 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
System.Text.StringBuilder caps = new System.Text.StringBuilder();
|
||||
caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
|
||||
|
||||
foreach (KeyValuePair<UUID, Caps> kvp in m_capsHandlers)
|
||||
foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects)
|
||||
{
|
||||
caps.AppendFormat("** User {0}:\n", kvp.Key);
|
||||
for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); )
|
||||
|
|
|
@ -575,7 +575,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
|
|||
string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez";
|
||||
// Get a reference to the user's cap so we can pull out the Caps Object Path
|
||||
Caps userCap
|
||||
= homeScene.CapsModule.GetCapsHandlerForUser(agentData.AgentID);
|
||||
= homeScene.CapsModule.GetCapsForUser(agentData.AgentID);
|
||||
|
||||
string rezHttpProtocol = "http://";
|
||||
string regionCapsHttpProtocol = "http://";
|
||||
|
@ -700,7 +700,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
|
|||
{
|
||||
// Get a referenceokay - to their Cap object so we can pull out the capobjectroot
|
||||
Caps userCap
|
||||
= homeScene.CapsModule.GetCapsHandlerForUser(userData.AgentID);
|
||||
= homeScene.CapsModule.GetCapsForUser(userData.AgentID);
|
||||
|
||||
//Update the circuit data in the region so this user is authorized
|
||||
homeScene.UpdateCircuitData(userData);
|
||||
|
|
|
@ -34,31 +34,27 @@ namespace OpenSim.Region.Framework.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);
|
||||
void CreateCaps(UUID agentId);
|
||||
|
||||
/// <summary>
|
||||
/// Remove the caps handler for a given agent.
|
||||
/// </summary>
|
||||
/// <param name="agentId"></param>
|
||||
void RemoveCapsHandler(UUID agentId);
|
||||
void RemoveCaps(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);
|
||||
Caps GetCapsForUser(UUID agentId);
|
||||
|
||||
void SetAgentCapsSeeds(AgentCircuitData agent);
|
||||
|
||||
Dictionary<ulong, string> GetChildrenSeeds(UUID agentID);
|
||||
|
||||
|
|
|
@ -3033,7 +3033,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_sceneGraph.removeUserCount(!childagentYN);
|
||||
|
||||
if (CapsModule != null)
|
||||
CapsModule.RemoveCapsHandler(agentID);
|
||||
CapsModule.RemoveCaps(agentID);
|
||||
|
||||
// REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
|
||||
// this method is doing is HORRIBLE!!!
|
||||
|
@ -3290,8 +3290,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
if (CapsModule != null)
|
||||
{
|
||||
CapsModule.NewUserConnection(agent);
|
||||
CapsModule.AddCapsHandler(agent.AgentID);
|
||||
CapsModule.SetAgentCapsSeeds(agent);
|
||||
CapsModule.CreateCaps(agent.AgentID);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3309,7 +3309,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
sp.AdjustKnownSeeds();
|
||||
|
||||
if (CapsModule != null)
|
||||
CapsModule.NewUserConnection(agent);
|
||||
CapsModule.SetAgentCapsSeeds(agent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue