Merge branch 'master' into careminster
commit
3dbf754651
|
@ -58,6 +58,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
|
||||
private List<Scene> m_Scenes = new List<Scene>();
|
||||
|
||||
private InventoryCache m_Cache = new InventoryCache();
|
||||
|
||||
protected IUserManagement m_UserManagement;
|
||||
protected IUserManagement UserManagementModule
|
||||
{
|
||||
|
@ -312,6 +314,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
public InventoryFolderBase GetRootFolder(UUID userID)
|
||||
{
|
||||
//m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID);
|
||||
InventoryFolderBase root = m_Cache.GetRootFolder(userID);
|
||||
if (root != null)
|
||||
return root;
|
||||
|
||||
string invURL = GetInventoryServiceURL(userID);
|
||||
|
||||
|
@ -320,12 +325,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
|
||||
IInventoryService connector = GetConnector(invURL);
|
||||
|
||||
return connector.GetRootFolder(userID);
|
||||
root = connector.GetRootFolder(userID);
|
||||
|
||||
m_Cache.Cache(userID, root);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
|
||||
{
|
||||
//m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type);
|
||||
InventoryFolderBase f = m_Cache.GetFolderForType(userID, type);
|
||||
if (f != null)
|
||||
return f;
|
||||
|
||||
string invURL = GetInventoryServiceURL(userID);
|
||||
|
||||
|
@ -334,7 +346,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
|
||||
IInventoryService connector = GetConnector(invURL);
|
||||
|
||||
return connector.GetFolderForType(userID, type);
|
||||
f = connector.GetFolderForType(userID, type);
|
||||
|
||||
m_Cache.Cache(userID, type, f);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||
{
|
||||
public class InventoryCache
|
||||
{
|
||||
private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour
|
||||
|
||||
private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
|
||||
private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>();
|
||||
|
||||
public void Cache(UUID userID, InventoryFolderBase root)
|
||||
{
|
||||
lock (m_RootFolders)
|
||||
m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS);
|
||||
}
|
||||
|
||||
public InventoryFolderBase GetRootFolder(UUID userID)
|
||||
{
|
||||
InventoryFolderBase root = null;
|
||||
if (m_RootFolders.TryGetValue(userID, out root))
|
||||
return root;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Cache(UUID userID, AssetType type, InventoryFolderBase folder)
|
||||
{
|
||||
lock (m_FolderTypes)
|
||||
{
|
||||
Dictionary<AssetType, InventoryFolderBase> ff = null;
|
||||
if (!m_FolderTypes.TryGetValue(userID, out ff))
|
||||
{
|
||||
ff = new Dictionary<AssetType, InventoryFolderBase>();
|
||||
m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS);
|
||||
}
|
||||
if (!ff.ContainsKey(type))
|
||||
ff.Add(type, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
|
||||
{
|
||||
Dictionary<AssetType, InventoryFolderBase> ff = null;
|
||||
if (m_FolderTypes.TryGetValue(userID, out ff))
|
||||
{
|
||||
InventoryFolderBase f = null;
|
||||
if (ff.TryGetValue(type, out f))
|
||||
return f;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -616,7 +616,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||
if (invAccess != null)
|
||||
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
|
||||
Util.FireAndForget(delegate { invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); });
|
||||
}
|
||||
|
||||
if (!Permissions.BypassPermissions())
|
||||
|
|
|
@ -34,13 +34,17 @@ using OpenSim.Framework;
|
|||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.CoreModules.World.Estate;
|
||||
using log4net;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
{
|
||||
public class NPCAvatar : IClientAPI, INPC
|
||||
{
|
||||
public bool SenseAsAgent { get; set; }
|
||||
private static readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
|
||||
|
||||
public bool SenseAsAgent { get; set; }
|
||||
private readonly string m_firstname;
|
||||
private readonly string m_lastname;
|
||||
private readonly Vector3 m_startPos;
|
||||
|
@ -57,8 +61,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
|||
m_scene = scene;
|
||||
m_ownerID = ownerID;
|
||||
SenseAsAgent = senseAsAgent;
|
||||
|
||||
}
|
||||
|
||||
static NPCAvatar()
|
||||
{
|
||||
InitDefaultAnimations();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IScene Scene
|
||||
{
|
||||
get { return m_scene; }
|
||||
|
@ -130,8 +142,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
|||
|
||||
}
|
||||
|
||||
private static void InitDefaultAnimations()
|
||||
{
|
||||
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(reader);
|
||||
if (doc.DocumentElement != null)
|
||||
foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
|
||||
{
|
||||
if (nod.Attributes["name"] != null)
|
||||
{
|
||||
string name = nod.Attributes["name"].Value.ToLower();
|
||||
string id = nod.InnerText;
|
||||
m_defaultAnimations.Add(name, (UUID)id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UUID GetDefaultAnimation(string name)
|
||||
{
|
||||
if (m_defaultAnimations.ContainsKey(name))
|
||||
{
|
||||
return m_defaultAnimations[name];
|
||||
}
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace OpenSim.Services.Connectors
|
|||
|
||||
private string m_ServerURI = String.Empty;
|
||||
|
||||
private object m_Lock = new object();
|
||||
|
||||
public XInventoryServicesConnector()
|
||||
{
|
||||
}
|
||||
|
@ -514,9 +516,11 @@ namespace OpenSim.Services.Connectors
|
|||
{
|
||||
sendData["METHOD"] = method;
|
||||
|
||||
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
|
||||
m_ServerURI + "/xinventory",
|
||||
ServerUtils.BuildQueryString(sendData));
|
||||
string reply = string.Empty;
|
||||
lock (m_Lock)
|
||||
reply = SynchronousRestFormsRequester.MakeRequest("POST",
|
||||
m_ServerURI + "/xinventory",
|
||||
ServerUtils.BuildQueryString(sendData));
|
||||
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
|
||||
reply);
|
||||
|
|
Loading…
Reference in New Issue