aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2012-03-11 00:53:53 +0000
committerUbitUmarov2012-03-11 00:53:53 +0000
commite4e6f781a61b1b7a7462a39e28e0a85f0fabaab5 (patch)
tree04f25af9832347f1a88890f9d8067f6f0e2155c9 /OpenSim
parent Changed undo redo internals. moved exec code to UndoState.cs from sop that n... (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC_OLD-e4e6f781a61b1b7a7462a39e28e0a85f0fabaab5.zip
opensim-SC_OLD-e4e6f781a61b1b7a7462a39e28e0a85f0fabaab5.tar.gz
opensim-SC_OLD-e4e6f781a61b1b7a7462a39e28e0a85f0fabaab5.tar.bz2
opensim-SC_OLD-e4e6f781a61b1b7a7462a39e28e0a85f0fabaab5.tar.xz
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs20
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs59
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs37
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs10
5 files changed, 121 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index b5c0af6..4be3804 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -58,6 +58,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
58 58
59 private List<Scene> m_Scenes = new List<Scene>(); 59 private List<Scene> m_Scenes = new List<Scene>();
60 60
61 private InventoryCache m_Cache = new InventoryCache();
62
61 protected IUserManagement m_UserManagement; 63 protected IUserManagement m_UserManagement;
62 protected IUserManagement UserManagementModule 64 protected IUserManagement UserManagementModule
63 { 65 {
@@ -312,6 +314,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
312 public InventoryFolderBase GetRootFolder(UUID userID) 314 public InventoryFolderBase GetRootFolder(UUID userID)
313 { 315 {
314 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); 316 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID);
317 InventoryFolderBase root = m_Cache.GetRootFolder(userID);
318 if (root != null)
319 return root;
315 320
316 string invURL = GetInventoryServiceURL(userID); 321 string invURL = GetInventoryServiceURL(userID);
317 322
@@ -320,12 +325,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
320 325
321 IInventoryService connector = GetConnector(invURL); 326 IInventoryService connector = GetConnector(invURL);
322 327
323 return connector.GetRootFolder(userID); 328 root = connector.GetRootFolder(userID);
329
330 m_Cache.Cache(userID, root);
331
332 return root;
324 } 333 }
325 334
326 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 335 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
327 { 336 {
328 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); 337 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type);
338 InventoryFolderBase f = m_Cache.GetFolderForType(userID, type);
339 if (f != null)
340 return f;
329 341
330 string invURL = GetInventoryServiceURL(userID); 342 string invURL = GetInventoryServiceURL(userID);
331 343
@@ -334,7 +346,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
334 346
335 IInventoryService connector = GetConnector(invURL); 347 IInventoryService connector = GetConnector(invURL);
336 348
337 return connector.GetFolderForType(userID, type); 349 f = connector.GetFolderForType(userID, type);
350
351 m_Cache.Cache(userID, type, f);
352
353 return f;
338 } 354 }
339 355
340 public InventoryCollection GetFolderContent(UUID userID, UUID folderID) 356 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
new file mode 100644
index 0000000..0fe778d
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -0,0 +1,59 @@
1using System;
2using System.Collections.Generic;
3
4using OpenSim.Framework;
5using OpenMetaverse;
6
7namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
8{
9 public class InventoryCache
10 {
11 private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour
12
13 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
14 private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>();
15
16 public void Cache(UUID userID, InventoryFolderBase root)
17 {
18 lock (m_RootFolders)
19 m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS);
20 }
21
22 public InventoryFolderBase GetRootFolder(UUID userID)
23 {
24 InventoryFolderBase root = null;
25 if (m_RootFolders.TryGetValue(userID, out root))
26 return root;
27
28 return null;
29 }
30
31 public void Cache(UUID userID, AssetType type, InventoryFolderBase folder)
32 {
33 lock (m_FolderTypes)
34 {
35 Dictionary<AssetType, InventoryFolderBase> ff = null;
36 if (!m_FolderTypes.TryGetValue(userID, out ff))
37 {
38 ff = new Dictionary<AssetType, InventoryFolderBase>();
39 m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS);
40 }
41 if (!ff.ContainsKey(type))
42 ff.Add(type, folder);
43 }
44 }
45
46 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
47 {
48 Dictionary<AssetType, InventoryFolderBase> ff = null;
49 if (m_FolderTypes.TryGetValue(userID, out ff))
50 {
51 InventoryFolderBase f = null;
52 if (ff.TryGetValue(type, out f))
53 return f;
54 }
55
56 return null;
57 }
58 }
59}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 719c300..d1739de 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -616,7 +616,7 @@ namespace OpenSim.Region.Framework.Scenes
616 { 616 {
617 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 617 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
618 if (invAccess != null) 618 if (invAccess != null)
619 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); 619 Util.FireAndForget(delegate { invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); });
620 } 620 }
621 621
622 if (!Permissions.BypassPermissions()) 622 if (!Permissions.BypassPermissions())
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 96f33a5..cdb6efe 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -34,13 +34,17 @@ using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.CoreModules.World.Estate; 36using OpenSim.Region.CoreModules.World.Estate;
37using log4net;
38using System.Reflection;
39using System.Xml;
37 40
38namespace OpenSim.Region.OptionalModules.World.NPC 41namespace OpenSim.Region.OptionalModules.World.NPC
39{ 42{
40 public class NPCAvatar : IClientAPI, INPC 43 public class NPCAvatar : IClientAPI, INPC
41 { 44 {
42 public bool SenseAsAgent { get; set; } 45 private static readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
43 46
47 public bool SenseAsAgent { get; set; }
44 private readonly string m_firstname; 48 private readonly string m_firstname;
45 private readonly string m_lastname; 49 private readonly string m_lastname;
46 private readonly Vector3 m_startPos; 50 private readonly Vector3 m_startPos;
@@ -57,8 +61,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
57 m_scene = scene; 61 m_scene = scene;
58 m_ownerID = ownerID; 62 m_ownerID = ownerID;
59 SenseAsAgent = senseAsAgent; 63 SenseAsAgent = senseAsAgent;
64
60 } 65 }
61 66
67 static NPCAvatar()
68 {
69 InitDefaultAnimations();
70 }
71
72
73
62 public IScene Scene 74 public IScene Scene
63 { 75 {
64 get { return m_scene; } 76 get { return m_scene; }
@@ -130,8 +142,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC
130 142
131 } 143 }
132 144
145 private static void InitDefaultAnimations()
146 {
147 using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
148 {
149 XmlDocument doc = new XmlDocument();
150 doc.Load(reader);
151 if (doc.DocumentElement != null)
152 foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
153 {
154 if (nod.Attributes["name"] != null)
155 {
156 string name = nod.Attributes["name"].Value.ToLower();
157 string id = nod.InnerText;
158 m_defaultAnimations.Add(name, (UUID)id);
159 }
160 }
161 }
162 }
163
133 public UUID GetDefaultAnimation(string name) 164 public UUID GetDefaultAnimation(string name)
134 { 165 {
166 if (m_defaultAnimations.ContainsKey(name))
167 {
168 return m_defaultAnimations[name];
169 }
135 return UUID.Zero; 170 return UUID.Zero;
136 } 171 }
137 172
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
index a662abb..39e983b 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
@@ -48,6 +48,8 @@ namespace OpenSim.Services.Connectors
48 48
49 private string m_ServerURI = String.Empty; 49 private string m_ServerURI = String.Empty;
50 50
51 private object m_Lock = new object();
52
51 public XInventoryServicesConnector() 53 public XInventoryServicesConnector()
52 { 54 {
53 } 55 }
@@ -514,9 +516,11 @@ namespace OpenSim.Services.Connectors
514 { 516 {
515 sendData["METHOD"] = method; 517 sendData["METHOD"] = method;
516 518
517 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 519 string reply = string.Empty;
518 m_ServerURI + "/xinventory", 520 lock (m_Lock)
519 ServerUtils.BuildQueryString(sendData)); 521 reply = SynchronousRestFormsRequester.MakeRequest("POST",
522 m_ServerURI + "/xinventory",
523 ServerUtils.BuildQueryString(sendData));
520 524
521 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 525 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
522 reply); 526 reply);