aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs182
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs125
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs4
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs77
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs9
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs91
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs20
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs144
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs55
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs29
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs111
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs159
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs196
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs148
15 files changed, 1268 insertions, 84 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs
new file mode 100644
index 0000000..aabdb51
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/AgentPreferencesModule.cs
@@ -0,0 +1,182 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.IO;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces;
43using Caps = OpenSim.Framework.Capabilities.Caps;
44using OpenSim.Capabilities.Handlers;
45
46namespace OpenSim.Region.ClientStack.LindenCaps
47{
48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AgentPreferencesModule")]
49 public class AgentPreferencesModule : ISharedRegionModule
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 private List<Scene> m_scenes = new List<Scene>();
54
55 public void Initialise(IConfigSource source)
56 {
57
58 }
59
60 #region Region module
61
62 public void AddRegion(Scene scene)
63 {
64 lock (m_scenes) m_scenes.Add(scene);
65 }
66
67 public void RemoveRegion(Scene scene)
68 {
69 lock (m_scenes) m_scenes.Remove(scene);
70 scene.EventManager.OnRegisterCaps -= RegisterCaps;
71 scene = null;
72 }
73
74 public void RegionLoaded(Scene scene)
75 {
76 scene.EventManager.OnRegisterCaps += delegate(UUID agentID, OpenSim.Framework.Capabilities.Caps caps)
77 {
78 RegisterCaps(agentID, caps);
79 };
80 }
81
82 public void PostInitialise() {}
83
84 public void Close() {}
85
86 public string Name { get { return "AgentPreferencesModule"; } }
87
88 public Type ReplaceableInterface
89 {
90 get { return null; }
91 }
92
93 public void RegisterCaps(UUID agent, Caps caps)
94 {
95 UUID capId = UUID.Random();
96 caps.RegisterHandler("AgentPreferences",
97 new RestStreamHandler("POST", "/CAPS/" + capId,
98 delegate(string request, string path, string param,
99 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
100 {
101 return UpdateAgentPreferences(request, path, param, agent);
102 }));
103 caps.RegisterHandler("UpdateAgentLanguage",
104 new RestStreamHandler("POST", "/CAPS/" + capId,
105 delegate(string request, string path, string param,
106 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
107 {
108 return UpdateAgentPreferences(request, path, param, agent);
109 }));
110 caps.RegisterHandler("UpdateAgentInformation",
111 new RestStreamHandler("POST", "/CAPS/" + capId,
112 delegate(string request, string path, string param,
113 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
114 {
115 return UpdateAgentPreferences(request, path, param, agent);
116 }));
117 }
118
119 public string UpdateAgentPreferences(string request, string path, string param, UUID agent)
120 {
121 OSDMap resp = new OSDMap();
122 // The viewer doesn't do much with the return value, so for now, if there is no preference service,
123 // we'll return a null llsd block for debugging purposes. This may change if someone knows what the
124 // correct server response would be here.
125 if (m_scenes[0].AgentPreferencesService == null)
126 {
127 return OSDParser.SerializeLLSDXmlString(resp);
128 }
129 m_log.DebugFormat("[AgentPrefs]: UpdateAgentPreferences for {0}", agent.ToString());
130 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
131 AgentPrefs data = m_scenes[0].AgentPreferencesService.GetAgentPreferences(agent);
132 if (data == null)
133 {
134 data = new AgentPrefs(agent);
135 }
136
137 if (req.ContainsKey("access_prefs"))
138 {
139 OSDMap accessPrefs = (OSDMap)req["access_prefs"]; // We could check with ContainsKey...
140 data.AccessPrefs = accessPrefs["max"].AsString();
141 }
142 if (req.ContainsKey("default_object_perm_masks"))
143 {
144 OSDMap permsMap = (OSDMap)req["default_object_perm_masks"];
145 data.PermEveryone = permsMap["Everyone"].AsInteger();
146 data.PermGroup = permsMap["Group"].AsInteger();
147 data.PermNextOwner = permsMap["NextOwner"].AsInteger();
148 }
149 if (req.ContainsKey("hover_height"))
150 {
151 data.HoverHeight = req["hover_height"].AsReal();
152 }
153 if (req.ContainsKey("language"))
154 {
155 data.Language = req["language"].AsString();
156 }
157 if (req.ContainsKey("language_is_public"))
158 {
159 data.LanguageIsPublic = req["language_is_public"].AsBoolean();
160 }
161 m_scenes[0].AgentPreferencesService.StoreAgentPreferences(data);
162 OSDMap respAccessPrefs = new OSDMap();
163 respAccessPrefs["max"] = data.AccessPrefs;
164 resp["access_prefs"] = respAccessPrefs;
165 OSDMap respDefaultPerms = new OSDMap();
166 respDefaultPerms["Everyone"] = data.PermEveryone;
167 respDefaultPerms["Group"] = data.PermGroup;
168 respDefaultPerms["NextOwner"] = data.PermNextOwner;
169 resp["default_object_perm_masks"] = respDefaultPerms;
170 resp["god_level"] = 0; // *TODO: Add this
171 resp["hover_height"] = data.HoverHeight;
172 resp["language"] = data.Language;
173 resp["language_is_public"] = data.LanguageIsPublic;
174
175 string response = OSDParser.SerializeLLSDXmlString(resp);
176 return response;
177 }
178
179 #endregion Region module
180 }
181}
182
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index ab8f0c9..4e6d196 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -45,6 +45,7 @@ using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Scenes.Serialization; 45using OpenSim.Region.Framework.Scenes.Serialization;
46using OpenSim.Framework.Servers; 46using OpenSim.Framework.Servers;
47using OpenSim.Framework.Servers.HttpServer; 47using OpenSim.Framework.Servers.HttpServer;
48using OpenSim.Framework.Client;
48using OpenSim.Services.Interfaces; 49using OpenSim.Services.Interfaces;
49 50
50using Caps = OpenSim.Framework.Capabilities.Caps; 51using Caps = OpenSim.Framework.Capabilities.Caps;
@@ -359,8 +360,8 @@ namespace OpenSim.Region.ClientStack.Linden
359 public string SeedCapRequest(string request, string path, string param, 360 public string SeedCapRequest(string request, string path, string param,
360 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 361 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
361 { 362 {
362 m_log.DebugFormat( 363// m_log.DebugFormat(
363 "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID); 364// "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID);
364 365
365 if (!m_HostCapsObj.WaitForActivation()) 366 if (!m_HostCapsObj.WaitForActivation())
366 return string.Empty; 367 return string.Empty;
@@ -788,10 +789,99 @@ namespace OpenSim.Region.ClientStack.Linden
788 } 789 }
789 else if (inventoryType == "object") 790 else if (inventoryType == "object")
790 { 791 {
792<<<<<<< HEAD
793 inType = (sbyte)InventoryType.Object;
794 assType = (sbyte)AssetType.Object;
795
796 List<Vector3> positions = new List<Vector3>();
797 List<Quaternion> rotations = new List<Quaternion>();
798 OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data);
799 OSDArray instance_list = (OSDArray)request["instance_list"];
800 OSDArray mesh_list = (OSDArray)request["mesh_list"];
801 OSDArray texture_list = (OSDArray)request["texture_list"];
802 SceneObjectGroup grp = null;
803
804 InventoryFolderBase textureUploadFolder = null;
805
806 List<InventoryFolderBase> foldersToUpdate = new List<InventoryFolderBase>();
807 List<InventoryItemBase> itemsToUpdate = new List<InventoryItemBase>();
808 IClientInventory clientInv = null;
809
810 if (texture_list.Count > 0)
811 {
812 ScenePresence avatar = null;
813 m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
814
815 if (avatar != null)
816 {
817 IClientCore core = (IClientCore)avatar.ControllingClient;
818
819 if (core.TryGet<IClientInventory>(out clientInv))
820 {
821 var systemTextureFolder = m_Scene.InventoryService.GetFolderForType(m_HostCapsObj.AgentID, FolderType.Texture);
822 textureUploadFolder = new InventoryFolderBase(UUID.Random(), assetName, m_HostCapsObj.AgentID, (short)FolderType.None, systemTextureFolder.ID, 1);
823 if (m_Scene.InventoryService.AddFolder(textureUploadFolder))
824 {
825 foldersToUpdate.Add(textureUploadFolder);
826
827 m_log.DebugFormat(
828 "[BUNCH OF CAPS]: Created new folder '{0}' ({1}) for textures uploaded with mesh object {2}",
829 textureUploadFolder.Name, textureUploadFolder.ID, assetName);
830 }
831 else
832 {
833 textureUploadFolder = null;
834 }
835 }
836 }
837 }
838
839 List<UUID> textures = new List<UUID>();
840 for (int i = 0; i < texture_list.Count; i++)
841 {
842 AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, "");
843 textureAsset.Data = texture_list[i].AsBinary();
844 m_assetService.Store(textureAsset);
845 textures.Add(textureAsset.FullID);
846
847 if (textureUploadFolder != null)
848 {
849 InventoryItemBase textureItem = new InventoryItemBase();
850 textureItem.Owner = m_HostCapsObj.AgentID;
851 textureItem.CreatorId = m_HostCapsObj.AgentID.ToString();
852 textureItem.CreatorData = String.Empty;
853 textureItem.ID = UUID.Random();
854 textureItem.AssetID = textureAsset.FullID;
855 textureItem.Description = assetDescription;
856 textureItem.Name = assetName + " - Texture " + (i + 1).ToString();
857 textureItem.AssetType = (int)AssetType.Texture;
858 textureItem.InvType = (int)InventoryType.Texture;
859 textureItem.Folder = textureUploadFolder.ID;
860 textureItem.CurrentPermissions
861 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export);
862 textureItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
863 textureItem.EveryOnePermissions = 0;
864 textureItem.NextPermissions = (uint)PermissionMask.All;
865 textureItem.CreationDate = Util.UnixTimeSinceEpoch();
866 m_Scene.InventoryService.AddItem(textureItem);
867 itemsToUpdate.Add(textureItem);
868
869 m_log.DebugFormat(
870 "[BUNCH OF CAPS]: Created new inventory item '{0}' ({1}) for texture uploaded with mesh object {2}",
871 textureItem.Name, textureItem.ID, assetName);
872 }
873 }
874
875 if (clientInv != null && (foldersToUpdate.Count > 0 || itemsToUpdate.Count > 0))
876 {
877 clientInv.SendBulkUpdateInventory(foldersToUpdate.ToArray(), itemsToUpdate.ToArray());
878 }
879=======
791 if (assetType == "mesh") // this code for now is for mesh models uploads only 880 if (assetType == "mesh") // this code for now is for mesh models uploads only
792 { 881 {
793 inType = (sbyte)InventoryType.Object; 882 inType = (sbyte)InventoryType.Object;
794 assType = (sbyte)AssetType.Object; 883 assType = (sbyte)AssetType.Object;
884>>>>>>> avn/ubitvar
795 885
796 List<Vector3> positions = new List<Vector3>(); 886 List<Vector3> positions = new List<Vector3>();
797 List<Quaternion> rotations = new List<Quaternion>(); 887 List<Quaternion> rotations = new List<Quaternion>();
@@ -1375,18 +1465,26 @@ namespace OpenSim.Region.ClientStack.Linden
1375 item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); 1465 item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID));
1376 if (item != null) 1466 if (item != null)
1377 { 1467 {
1378 copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); 1468 string message;
1379 if (copyItem != null && client != null) 1469 copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message);
1470 if (client != null)
1380 { 1471 {
1381 m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); 1472 if (copyItem != null)
1382 client.SendBulkUpdateInventory(copyItem); 1473 {
1474 m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
1475 client.SendBulkUpdateInventory(copyItem);
1476 }
1477 else
1478 {
1479 client.SendAgentAlertMessage(message, false);
1480 }
1383 } 1481 }
1384 } 1482 }
1385 else 1483 else
1386 { 1484 {
1387 m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); 1485 m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID);
1388 if (client != null) 1486 if (client != null)
1389 client.SendAlertMessage("Failed to retrieve item"); 1487 client.SendAgentAlertMessage("Failed to retrieve item", false);
1390 } 1488 }
1391 } 1489 }
1392 catch (Exception e) 1490 catch (Exception e)
@@ -1558,13 +1656,14 @@ namespace OpenSim.Region.ClientStack.Linden
1558 string param, IOSHttpRequest httpRequest, 1656 string param, IOSHttpRequest httpRequest,
1559 IOSHttpResponse httpResponse) 1657 IOSHttpResponse httpResponse)
1560 { 1658 {
1561// OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); 1659 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1562 OSDMap resp = new OSDMap(); 1660 OSDMap accessPrefs = (OSDMap)req["access_prefs"];
1563 1661 string desiredMaturity = accessPrefs["max"];
1564 OSDMap accessPrefs = new OSDMap();
1565 accessPrefs["max"] = "A";
1566 1662
1567 resp["access_prefs"] = accessPrefs; 1663 OSDMap resp = new OSDMap();
1664 OSDMap respAccessPrefs = new OSDMap();
1665 respAccessPrefs["max"] = desiredMaturity; // echoing the maturity back means success
1666 resp["access_prefs"] = respAccessPrefs;
1568 1667
1569 string response = OSDParser.SerializeLLSDXmlString(resp); 1668 string response = OSDParser.SerializeLLSDXmlString(resp);
1570 return response; 1669 return response;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs
index b735dfa..c241075 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs
@@ -40,8 +40,8 @@ using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using Caps = OpenSim.Framework.Capabilities.Caps; 41using Caps = OpenSim.Framework.Capabilities.Caps;
42 42
43[assembly: Addin("LindenCaps", "0.1")] 43[assembly: Addin("LindenCaps", OpenSim.VersionInfo.VersionNumber)]
44[assembly: AddinDependency("OpenSim", "0.5")] 44[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
45namespace OpenSim.Region.ClientStack.Linden 45namespace OpenSim.Region.ClientStack.Linden
46{ 46{
47 47
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 51535a6..5fb028c 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.ClientStack.Linden
100 "debug eq [0|1|2]", 100 "debug eq [0|1|2]",
101 "Turn on event queue debugging\n" 101 "Turn on event queue debugging\n"
102 + " <= 0 - turns off all event queue logging\n" 102 + " <= 0 - turns off all event queue logging\n"
103 + " >= 1 - turns on outgoing event logging\n" 103 + " >= 1 - turns on event queue setup and outgoing event logging\n"
104 + " >= 2 - turns on poll notification", 104 + " >= 2 - turns on poll notification",
105 HandleDebugEq); 105 HandleDebugEq);
106 106
@@ -177,6 +177,32 @@ namespace OpenSim.Region.ClientStack.Linden
177 } 177 }
178 178
179 /// <summary> 179 /// <summary>
180<<<<<<< HEAD
181 /// Always returns a valid queue
182 /// </summary>
183 /// <param name="agentId"></param>
184 /// <returns></returns>
185 private Queue<OSD> TryGetQueue(UUID agentId)
186 {
187 lock (queues)
188 {
189 if (!queues.ContainsKey(agentId))
190 {
191 if (DebugLevel > 0)
192 m_log.DebugFormat(
193 "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}",
194 agentId, m_scene.RegionInfo.RegionName);
195
196 queues[agentId] = new Queue<OSD>();
197 }
198
199 return queues[agentId];
200 }
201 }
202
203 /// <summary>
204=======
205>>>>>>> avn/ubitvar
180 /// May return a null queue 206 /// May return a null queue
181 /// </summary> 207 /// </summary>
182 /// <param name="agentId"></param> 208 /// <param name="agentId"></param>
@@ -207,12 +233,18 @@ namespace OpenSim.Region.ClientStack.Linden
207 lock (queue) 233 lock (queue)
208 queue.Enqueue(ev); 234 queue.Enqueue(ev);
209 } 235 }
210 else 236 else if (DebugLevel > 0)
211 { 237 {
212 OSDMap evMap = (OSDMap)ev; 238 ScenePresence sp = m_scene.GetScenePresence(avatarID);
213 m_log.WarnFormat( 239
214 "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", 240 // This assumes that an NPC should never have a queue.
215 avatarID, evMap["message"], m_scene.Name); 241 if (sp != null && sp.PresenceType != PresenceType.Npc)
242 {
243 OSDMap evMap = (OSDMap)ev;
244 m_log.WarnFormat(
245 "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}",
246 sp.Name, sp.UUID, evMap["message"], m_scene.Name);
247 }
216 } 248 }
217 } 249 }
218 catch (NullReferenceException e) 250 catch (NullReferenceException e)
@@ -258,9 +290,17 @@ namespace OpenSim.Region.ClientStack.Linden
258 public void OnRegisterCaps(UUID agentID, Caps caps) 290 public void OnRegisterCaps(UUID agentID, Caps caps)
259 { 291 {
260 // Register an event queue for the client 292 // Register an event queue for the client
293<<<<<<< HEAD
294
295 if (DebugLevel > 0)
296 m_log.DebugFormat(
297 "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
298 agentID, caps, m_scene.RegionInfo.RegionName);
299=======
261 m_log.DebugFormat( 300 m_log.DebugFormat(
262 "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", 301 "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
263 agentID, caps, m_scene.RegionInfo.RegionName); 302 agentID, caps, m_scene.RegionInfo.RegionName);
303>>>>>>> avn/ubitvar
264 304
265 UUID eventQueueGetUUID; 305 UUID eventQueueGetUUID;
266 Queue<OSD> queue; 306 Queue<OSD> queue;
@@ -479,8 +519,14 @@ namespace OpenSim.Region.ClientStack.Linden
479 519
480 public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) 520 public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
481 { 521 {
522<<<<<<< HEAD
523 if (DebugLevel > 0)
524 m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}",
525 LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY);
526=======
482 m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", 527 m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>",
483 LogHeader, handle, avatarID, regionSizeX, regionSizeY); 528 LogHeader, handle, avatarID, regionSizeX, regionSizeY);
529>>>>>>> avn/ubitvar
484 530
485 OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); 531 OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY);
486 Enqueue(item, avatarID); 532 Enqueue(item, avatarID);
@@ -489,8 +535,15 @@ namespace OpenSim.Region.ClientStack.Linden
489 public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, 535 public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath,
490 ulong regionHandle, int regionSizeX, int regionSizeY) 536 ulong regionHandle, int regionSizeX, int regionSizeY)
491 { 537 {
538<<<<<<< HEAD
539 if (DebugLevel > 0)
540 m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}",
541 LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY);
542
543=======
492 m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", 544 m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>",
493 LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); 545 LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY);
546>>>>>>> avn/ubitvar
494 OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); 547 OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY);
495 Enqueue(item, avatarID); 548 Enqueue(item, avatarID);
496 } 549 }
@@ -500,8 +553,14 @@ namespace OpenSim.Region.ClientStack.Linden
500 uint locationID, uint flags, string capsURL, 553 uint locationID, uint flags, string capsURL,
501 UUID avatarID, int regionSizeX, int regionSizeY) 554 UUID avatarID, int regionSizeX, int regionSizeY)
502 { 555 {
556<<<<<<< HEAD
557 if (DebugLevel > 0)
558 m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}",
559 LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY);
560=======
503 m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>", 561 m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>",
504 LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); 562 LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY);
563>>>>>>> avn/ubitvar
505 564
506 OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, 565 OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint,
507 locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); 566 locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY);
@@ -512,8 +571,14 @@ namespace OpenSim.Region.ClientStack.Linden
512 IPEndPoint newRegionExternalEndPoint, 571 IPEndPoint newRegionExternalEndPoint,
513 string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) 572 string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
514 { 573 {
574<<<<<<< HEAD
575 if (DebugLevel > 0)
576 m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>",
577 LogHeader, handle, avatarID, regionSizeX, regionSizeY);
578=======
515 m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", 579 m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>",
516 LogHeader, handle, avatarID, regionSizeX, regionSizeY); 580 LogHeader, handle, avatarID, regionSizeX, regionSizeY);
581>>>>>>> avn/ubitvar
517 582
518 OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, 583 OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint,
519 capsURL, avatarID, sessionID, regionSizeX, regionSizeY); 584 capsURL, avatarID, sessionID, regionSizeX, regionSizeY);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs
index 50e22f5..8b7e4c1 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs
@@ -77,8 +77,13 @@ namespace OpenSim.Region.ClientStack.Linden
77 llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); 77 llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle)));
78 llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); 78 llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes()));
79 llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); 79 llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port));
80<<<<<<< HEAD
81 llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint) regionSizeX));
82 llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint) regionSizeY));
83=======
80 llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); 84 llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
81 llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); 85 llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
86>>>>>>> avn/ubitvar
82 87
83 OSDArray arr = new OSDArray(1); 88 OSDArray arr = new OSDArray(1);
84 arr.Add(llsdSimInfo); 89 arr.Add(llsdSimInfo);
@@ -171,8 +176,12 @@ namespace OpenSim.Region.ClientStack.Linden
171 info.Add("SimAccess", OSD.FromInteger(simAccess)); 176 info.Add("SimAccess", OSD.FromInteger(simAccess));
172 info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); 177 info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes()));
173 info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); 178 info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port));
179<<<<<<< HEAD
180 info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation
181=======
174// info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation 182// info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation
175 info.Add("TeleportFlags", OSD.FromUInteger(flags)); 183 info.Add("TeleportFlags", OSD.FromUInteger(flags));
184>>>>>>> avn/ubitvar
176 info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); 185 info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX));
177 info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); 186 info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY));
178 187
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
index 9e24bce..16a902d 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Net; 31using System.Net;
31using log4net.Config; 32using log4net.Config;
@@ -33,13 +34,15 @@ using Nini.Config;
33using NUnit.Framework; 34using NUnit.Framework;
34using OpenMetaverse; 35using OpenMetaverse;
35using OpenMetaverse.Packets; 36using OpenMetaverse.Packets;
37using OpenMetaverse.StructuredData;
36using OpenSim.Framework; 38using OpenSim.Framework;
37using OpenSim.Framework.Servers; 39using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Region.ClientStack.Linden; 41using OpenSim.Region.ClientStack.Linden;
40using OpenSim.Region.CoreModules.Framework; 42using OpenSim.Region.CoreModules.Framework;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43 46
44namespace OpenSim.Region.ClientStack.Linden.Tests 47namespace OpenSim.Region.ClientStack.Linden.Tests
45{ 48{
@@ -47,6 +50,8 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
47 public class EventQueueTests : OpenSimTestCase 50 public class EventQueueTests : OpenSimTestCase
48 { 51 {
49 private TestScene m_scene; 52 private TestScene m_scene;
53 private EventQueueGetModule m_eqgMod;
54 private NPCModule m_npcMod;
50 55
51 [SetUp] 56 [SetUp]
52 public override void SetUp() 57 public override void SetUp()
@@ -69,10 +74,15 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
69 config.Configs["Startup"].Set("EventQueue", "true"); 74 config.Configs["Startup"].Set("EventQueue", "true");
70 75
71 CapabilitiesModule capsModule = new CapabilitiesModule(); 76 CapabilitiesModule capsModule = new CapabilitiesModule();
72 EventQueueGetModule eqgModule = new EventQueueGetModule(); 77 m_eqgMod = new EventQueueGetModule();
78
79 // For NPC test support
80 config.AddConfig("NPC");
81 config.Configs["NPC"].Set("Enabled", "true");
82 m_npcMod = new NPCModule();
73 83
74 m_scene = new SceneHelpers().SetupScene(); 84 m_scene = new SceneHelpers().SetupScene();
75 SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); 85 SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod);
76 } 86 }
77 87
78 [Test] 88 [Test]
@@ -101,5 +111,80 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
101 // TODO: Add more assertions for the other aspects of event queues 111 // TODO: Add more assertions for the other aspects of event queues
102 Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); 112 Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0));
103 } 113 }
114
115 [Test]
116 public void TestEnqueueMessage()
117 {
118 TestHelpers.InMethod();
119// log4net.Config.XmlConfigurator.Configure();
120
121 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
122
123 string messageName = "TestMessage";
124
125 m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), sp.UUID);
126
127 Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID);
128
129 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK));
130
131// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]);
132
133 OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]);
134 OSDArray eventsOsd = (OSDArray)rawOsd["events"];
135
136 bool foundUpdate = false;
137 foreach (OSD osd in eventsOsd)
138 {
139 OSDMap eventOsd = (OSDMap)osd;
140
141 if (eventOsd["message"] == messageName)
142 foundUpdate = true;
143 }
144
145 Assert.That(foundUpdate, Is.True, string.Format("Did not find {0} in response", messageName));
146 }
147
148 /// <summary>
149 /// Test an attempt to put a message on the queue of a user that is not in the region.
150 /// </summary>
151 [Test]
152 public void TestEnqueueMessageNoUser()
153 {
154 TestHelpers.InMethod();
155 TestHelpers.EnableLogging();
156
157 string messageName = "TestMessage";
158
159 m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), TestHelpers.ParseTail(0x1));
160
161 Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, TestHelpers.ParseTail(0x1));
162
163 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway));
164 }
165
166 /// <summary>
167 /// NPCs do not currently have an event queue but a caller may try to send a message anyway, so check behaviour.
168 /// </summary>
169 [Test]
170 public void TestEnqueueMessageToNpc()
171 {
172 TestHelpers.InMethod();
173// TestHelpers.EnableLogging();
174
175 UUID npcId
176 = m_npcMod.CreateNPC(
177 "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance());
178
179 ScenePresence npc = m_scene.GetScenePresence(npcId);
180
181 string messageName = "TestMessage";
182
183 m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), npc.UUID);
184
185 Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, npc.UUID);
186
187 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway));
188 }
104 } 189 }
105} \ No newline at end of file 190} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs
index 87d3d1c..e0a11cc 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs
@@ -25,20 +25,16 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using Mono.Addins; 28using Mono.Addins;
29using Nini.Config;
34using OpenMetaverse; 30using OpenMetaverse;
35using OpenSim.Framework; 31using OpenSim.Capabilities.Handlers;
36using OpenSim.Framework.Servers.HttpServer; 32using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using System;
40using Caps = OpenSim.Framework.Capabilities.Caps; 37using Caps = OpenSim.Framework.Capabilities.Caps;
41using OpenSim.Capabilities.Handlers;
42 38
43namespace OpenSim.Region.ClientStack.Linden 39namespace OpenSim.Region.ClientStack.Linden
44{ 40{
@@ -58,8 +54,6 @@ namespace OpenSim.Region.ClientStack.Linden
58 54
59 private string m_fetchInventory2Url; 55 private string m_fetchInventory2Url;
60 56
61 private FetchInventory2Handler m_fetchHandler;
62
63 #region ISharedRegionModule Members 57 #region ISharedRegionModule Members
64 58
65 public void Initialise(IConfigSource source) 59 public void Initialise(IConfigSource source)
@@ -98,10 +92,6 @@ namespace OpenSim.Region.ClientStack.Linden
98 92
99 m_inventoryService = m_scene.InventoryService; 93 m_inventoryService = m_scene.InventoryService;
100 94
101 // We'll reuse the same handler for all requests.
102 if (m_fetchInventory2Url == "localhost")
103 m_fetchHandler = new FetchInventory2Handler(m_inventoryService);
104
105 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 95 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
106 } 96 }
107 97
@@ -131,9 +121,11 @@ namespace OpenSim.Region.ClientStack.Linden
131 { 121 {
132 capUrl = "/CAPS/" + UUID.Random(); 122 capUrl = "/CAPS/" + UUID.Random();
133 123
124 FetchInventory2Handler fetchHandler = new FetchInventory2Handler(m_inventoryService, agentID);
125
134 IRequestHandler reqHandler 126 IRequestHandler reqHandler
135 = new RestStreamHandler( 127 = new RestStreamHandler(
136 "POST", capUrl, m_fetchHandler.FetchInventoryRequest, capName, agentID.ToString()); 128 "POST", capUrl, fetchHandler.FetchInventoryRequest, capName, agentID.ToString());
137 129
138 caps.RegisterHandler(capName, reqHandler); 130 caps.RegisterHandler(capName, reqHandler);
139 } 131 }
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs
new file mode 100644
index 0000000..6617bbc
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs
@@ -0,0 +1,144 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
33using System.Reflection;
34using System.IO;
35using System.Web;
36using log4net;
37using Nini.Config;
38using Mono.Addins;
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41using OpenMetaverse.Imaging;
42using OpenSim.Framework;
43using OpenSim.Framework.Servers;
44using OpenSim.Framework.Servers.HttpServer;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Services.Interfaces;
48using Caps = OpenSim.Framework.Capabilities.Caps;
49using OpenSim.Capabilities.Handlers;
50
51namespace OpenSim.Region.ClientStack.Linden
52{
53
54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetDisplayNamesModule")]
55 public class GetDisplayNamesModule : INonSharedRegionModule
56 {
57 private static readonly ILog m_log =
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59
60 private Scene m_scene;
61 private IUserManagement m_UserManager;
62
63 private bool m_Enabled = false;
64
65 private string m_URL;
66
67 #region ISharedRegionModule Members
68
69 public void Initialise(IConfigSource source)
70 {
71 IConfig config = source.Configs["ClientStack.LindenCaps"];
72 if (config == null)
73 return;
74
75 m_URL = config.GetString("Cap_GetDisplayNames", string.Empty);
76 if (m_URL != string.Empty)
77 m_Enabled = true;
78 }
79
80 public void AddRegion(Scene s)
81 {
82 if (!m_Enabled)
83 return;
84
85 m_scene = s;
86 }
87
88 public void RemoveRegion(Scene s)
89 {
90 if (!m_Enabled)
91 return;
92
93 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
94 m_scene = null;
95 }
96
97 public void RegionLoaded(Scene s)
98 {
99 if (!m_Enabled)
100 return;
101
102 m_UserManager = m_scene.RequestModuleInterface<IUserManagement>();
103 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
104 }
105
106 public void PostInitialise()
107 {
108 }
109
110 public void Close() { }
111
112 public string Name { get { return "GetDisplayNamesModule"; } }
113
114 public Type ReplaceableInterface
115 {
116 get { return null; }
117 }
118
119 #endregion
120
121 public void RegisterCaps(UUID agentID, Caps caps)
122 {
123 UUID capID = UUID.Random();
124
125 if (m_URL == "localhost")
126 {
127 m_log.DebugFormat("[GET_DISPLAY_NAMES]: /CAPS/agents/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
128 caps.RegisterHandler(
129 "GetDisplayNames",
130 new GetDisplayNamesHandler("/CAPS/agents" + capID + "/", m_UserManager, "GetDisplayNames", agentID.ToString()));
131 }
132 else
133 {
134// m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
135 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>();
136 if (handler != null)
137 handler.RegisterExternalUserCapsHandler(agentID,caps,"GetDisplayNames", m_URL);
138 else
139 caps.RegisterHandler("GetDisplayNames", m_URL);
140 }
141 }
142
143 }
144}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index a381a1b..91efe8a 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -60,6 +60,11 @@ namespace OpenSim.Region.ClientStack.Linden
60 private IAssetService m_AssetService; 60 private IAssetService m_AssetService;
61 private bool m_Enabled = true; 61 private bool m_Enabled = true;
62 private string m_URL; 62 private string m_URL;
63<<<<<<< HEAD
64 private string m_URL2;
65 private string m_RedirectURL = null;
66 private string m_RedirectURL2 = null;
67=======
63 68
64 struct aPollRequest 69 struct aPollRequest
65 { 70 {
@@ -89,6 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden
89 new OpenMetaverse.BlockingQueue<aPollRequest>(); 94 new OpenMetaverse.BlockingQueue<aPollRequest>();
90 95
91 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>(); 96 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>();
97>>>>>>> avn/ubitvar
92 98
93 #region Region Module interfaceBase Members 99 #region Region Module interfaceBase Members
94 100
@@ -113,8 +119,22 @@ namespace OpenSim.Region.ClientStack.Linden
113 m_URL = config.GetString("Cap_GetMesh", string.Empty); 119 m_URL = config.GetString("Cap_GetMesh", string.Empty);
114 // Cap doesn't exist 120 // Cap doesn't exist
115 if (m_URL != string.Empty) 121 if (m_URL != string.Empty)
122 {
123 m_Enabled = true;
124 m_RedirectURL = config.GetString("GetMeshRedirectURL");
125 }
126
127 m_URL2 = config.GetString("Cap_GetMesh2", string.Empty);
128 // Cap doesn't exist
129 if (m_URL2 != string.Empty)
130 {
116 m_Enabled = true; 131 m_Enabled = true;
132<<<<<<< HEAD
133 m_RedirectURL2 = config.GetString("GetMesh2RedirectURL");
134 }
135=======
117 136
137>>>>>>> avn/ubitvar
118 } 138 }
119 139
120 public void AddRegion(Scene pScene) 140 public void AddRegion(Scene pScene)
@@ -316,6 +336,21 @@ namespace OpenSim.Region.ClientStack.Linden
316 336
317 public void RegisterCaps(UUID agentID, Caps caps) 337 public void RegisterCaps(UUID agentID, Caps caps)
318 { 338 {
339<<<<<<< HEAD
340 UUID capID = UUID.Random();
341 bool getMeshRegistered = false;
342
343 if (m_URL == string.Empty)
344 {
345
346 }
347 else if (m_URL == "localhost")
348 {
349 getMeshRegistered = true;
350 caps.RegisterHandler(
351 "GetMesh",
352 new GetMeshHandler("/CAPS/" + capID + "/", m_AssetService, "GetMesh", agentID.ToString(), m_RedirectURL));
353=======
319// UUID capID = UUID.Random(); 354// UUID capID = UUID.Random();
320 if (m_URL == "localhost") 355 if (m_URL == "localhost")
321 { 356 {
@@ -343,12 +378,30 @@ namespace OpenSim.Region.ClientStack.Linden
343 378
344 379
345 380
381>>>>>>> avn/ubitvar
346 } 382 }
347 else 383 else
348 { 384 {
349// m_log.DebugFormat("[GETMESH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
350 caps.RegisterHandler("GetMesh", m_URL); 385 caps.RegisterHandler("GetMesh", m_URL);
351 } 386 }
387
388 if(m_URL2 == string.Empty)
389 {
390
391 }
392 else if (m_URL2 == "localhost")
393 {
394 if (!getMeshRegistered)
395 {
396 caps.RegisterHandler(
397 "GetMesh2",
398 new GetMeshHandler("/CAPS/" + capID + "/", m_AssetService, "GetMesh2", agentID.ToString(), m_RedirectURL2));
399 }
400 }
401 else
402 {
403 caps.RegisterHandler("GetMesh2", m_URL2);
404 }
352 } 405 }
353 private void DeregisterCaps(UUID agentID, Caps caps) 406 private void DeregisterCaps(UUID agentID, Caps caps)
354 { 407 {
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index 99ccd4b..b9396b7 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -82,7 +82,12 @@ namespace OpenSim.Region.ClientStack.Linden
82 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = 82 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
83 new OpenMetaverse.BlockingQueue<aPollRequest>(); 83 new OpenMetaverse.BlockingQueue<aPollRequest>();
84 84
85<<<<<<< HEAD
86 // TODO: Change this to a config option
87 private string m_RedirectURL = null;
88=======
85 private Dictionary<UUID,PollServiceTextureEventArgs> m_pollservices = new Dictionary<UUID,PollServiceTextureEventArgs>(); 89 private Dictionary<UUID,PollServiceTextureEventArgs> m_pollservices = new Dictionary<UUID,PollServiceTextureEventArgs>();
90>>>>>>> avn/ubitvar
86 91
87 private string m_URL; 92 private string m_URL;
88 93
@@ -91,8 +96,21 @@ namespace OpenSim.Region.ClientStack.Linden
91 public void Initialise(IConfigSource source) 96 public void Initialise(IConfigSource source)
92 { 97 {
93 IConfig config = source.Configs["ClientStack.LindenCaps"]; 98 IConfig config = source.Configs["ClientStack.LindenCaps"];
99<<<<<<< HEAD
100 if (config == null)
101 return;
102
103 m_URL = config.GetString("Cap_GetTexture", string.Empty);
104 // Cap doesn't exist
105 if (m_URL != string.Empty)
106 {
107 m_Enabled = true;
108 m_RedirectURL = config.GetString("GetTextureRedirectURL");
109 }
110=======
94 if (config != null) 111 if (config != null)
95 m_Url = config.GetString("Cap_GetTexture", "localhost"); 112 m_Url = config.GetString("Cap_GetTexture", "localhost");
113>>>>>>> avn/ubitvar
96 } 114 }
97 115
98 public void AddRegion(Scene s) 116 public void AddRegion(Scene s)
@@ -219,6 +237,12 @@ namespace OpenSim.Region.ClientStack.Linden
219 public PollServiceTextureEventArgs(UUID pId, Scene scene) : 237 public PollServiceTextureEventArgs(UUID pId, Scene scene) :
220 base(null, "", null, null, null, pId, int.MaxValue) 238 base(null, "", null, null, null, pId, int.MaxValue)
221 { 239 {
240<<<<<<< HEAD
241// m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
242 caps.RegisterHandler(
243 "GetTexture",
244 new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString(), m_RedirectURL));
245=======
222 m_scene = scene; 246 m_scene = scene;
223 // x is request id, y is userid 247 // x is request id, y is userid
224 HasEvents = (x, y) => 248 HasEvents = (x, y) =>
@@ -288,6 +312,7 @@ namespace OpenSim.Region.ClientStack.Linden
288 312
289 return response; 313 return response;
290 }; 314 };
315>>>>>>> avn/ubitvar
291 } 316 }
292 317
293 public void Process(aPollRequest requestinfo) 318 public void Process(aPollRequest requestinfo)
@@ -377,7 +402,11 @@ namespace OpenSim.Region.ClientStack.Linden
377 } 402 }
378 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); 403 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>();
379 if (handler != null) 404 if (handler != null)
405<<<<<<< HEAD
406 handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture", m_URL);
407=======
380 handler.RegisterExternalUserCapsHandler(agentID, caps, "GetTexture", capUrl); 408 handler.RegisterExternalUserCapsHandler(agentID, caps, "GetTexture", capUrl);
409>>>>>>> avn/ubitvar
381 else 410 else
382 caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); 411 caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
383 m_pollservices[agentID] = args; 412 m_pollservices[agentID] = args;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs
index 112608b..264eaa3 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.0.*")] 32[assembly: AssemblyVersion("0.8.2.*")]
33 33
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
index bedec80..54542c9 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using log4net;
32using Nini.Config; 33using Nini.Config;
@@ -37,7 +38,7 @@ using OpenSim.Framework;
37using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 41// using OpenSim.Services.Interfaces;
41using Caps = OpenSim.Framework.Capabilities.Caps; 42using Caps = OpenSim.Framework.Capabilities.Caps;
42 43
43namespace OpenSim.Region.ClientStack.Linden 44namespace OpenSim.Region.ClientStack.Linden
@@ -56,8 +57,8 @@ namespace OpenSim.Region.ClientStack.Linden
56 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] 57 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")]
57 public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule 58 public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule
58 { 59 {
59// private static readonly ILog m_log = 60 private static readonly ILog m_log =
60// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 61 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 62
62 public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; 63 public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
63 64
@@ -69,18 +70,39 @@ namespace OpenSim.Region.ClientStack.Linden
69 private OSDMap m_features = new OSDMap(); 70 private OSDMap m_features = new OSDMap();
70 71
71 private string m_SearchURL = string.Empty; 72 private string m_SearchURL = string.Empty;
73 private string m_DestinationGuideURL = string.Empty;
72 private bool m_ExportSupported = false; 74 private bool m_ExportSupported = false;
75 private string m_GridName = string.Empty;
76 private string m_GridURL = string.Empty;
73 77
74 #region ISharedRegionModule Members 78 #region ISharedRegionModule Members
75 79
76 public void Initialise(IConfigSource source) 80 public void Initialise(IConfigSource source)
77 { 81 {
78 IConfig config = source.Configs["SimulatorFeatures"]; 82 IConfig config = source.Configs["SimulatorFeatures"];
83
79 if (config != null) 84 if (config != null)
80 { 85 {
81 m_SearchURL = config.GetString("SearchServerURI", string.Empty); 86 //
87 // All this is obsolete since getting these features from the grid service!!
88 // Will be removed after the next release
89 //
90 m_SearchURL = config.GetString("SearchServerURI", m_SearchURL);
91
92 m_DestinationGuideURL = config.GetString ("DestinationGuideURI", m_DestinationGuideURL);
93
94 if (m_DestinationGuideURL == string.Empty) // Make this consistent with the variable in the LoginService config
95 m_DestinationGuideURL = config.GetString("DestinationGuide", m_DestinationGuideURL);
82 96
83 m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported); 97 m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported);
98
99 m_GridURL = Util.GetConfigVarFromSections<string>(
100 source, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "SimulatorFeatures" }, String.Empty);
101
102 m_GridName = config.GetString("GridName", string.Empty);
103 if (m_GridName == string.Empty)
104 m_GridName = Util.GetConfigVarFromSections<string>(
105 source, "gridname", new string[] { "GridInfo", "SimulatorFeatures" }, String.Empty);
84 } 106 }
85 107
86 AddDefaultFeatures(); 108 AddDefaultFeatures();
@@ -101,6 +123,7 @@ namespace OpenSim.Region.ClientStack.Linden
101 123
102 public void RegionLoaded(Scene s) 124 public void RegionLoaded(Scene s)
103 { 125 {
126 GetGridExtraFeatures(s);
104 } 127 }
105 128
106 public void PostInitialise() 129 public void PostInitialise()
@@ -126,6 +149,7 @@ namespace OpenSim.Region.ClientStack.Linden
126 /// </remarks> 149 /// </remarks>
127 private void AddDefaultFeatures() 150 private void AddDefaultFeatures()
128 { 151 {
152
129 lock (m_features) 153 lock (m_features)
130 { 154 {
131 m_features["MeshRezEnabled"] = true; 155 m_features["MeshRezEnabled"] = true;
@@ -133,14 +157,29 @@ namespace OpenSim.Region.ClientStack.Linden
133 m_features["MeshXferEnabled"] = true; 157 m_features["MeshXferEnabled"] = true;
134 158
135 m_features["PhysicsMaterialsEnabled"] = true; 159 m_features["PhysicsMaterialsEnabled"] = true;
160<<<<<<< HEAD
161
162=======
136 163
164>>>>>>> avn/ubitvar
137 OSDMap typesMap = new OSDMap(); 165 OSDMap typesMap = new OSDMap();
138 typesMap["convex"] = true; 166 typesMap["convex"] = true;
139 typesMap["none"] = true; 167 typesMap["none"] = true;
140 typesMap["prim"] = true; 168 typesMap["prim"] = true;
141 m_features["PhysicsShapeTypes"] = typesMap; 169 m_features["PhysicsShapeTypes"] = typesMap;
142 170
143 // Extra information for viewers that want to use it 171 // Extra information for viewers that want to use it
172<<<<<<< HEAD
173 // TODO: Take these out of here into their respective modules, like map-server-url
174 OSDMap extrasMap;
175 if(m_features.ContainsKey("OpenSimExtras"))
176 {
177 extrasMap = (OSDMap)m_features["OpenSimExtras"];
178 }
179 else
180 extrasMap = new OSDMap();
181
182=======
144 183
145 OSDMap extrasMap = new OSDMap(); 184 OSDMap extrasMap = new OSDMap();
146 185
@@ -148,13 +187,25 @@ namespace OpenSim.Region.ClientStack.Linden
148 extrasMap["AnimationSet"] = true; 187 extrasMap["AnimationSet"] = true;
149 188
150 // TODO: Take these out of here into their respective modules, like map-server-url 189 // TODO: Take these out of here into their respective modules, like map-server-url
190>>>>>>> avn/ubitvar
151 if (m_SearchURL != string.Empty) 191 if (m_SearchURL != string.Empty)
152 extrasMap["search-server-url"] = m_SearchURL; 192 extrasMap["search-server-url"] = m_SearchURL;
193 if (!string.IsNullOrEmpty(m_DestinationGuideURL))
194 extrasMap["destination-guide-url"] = m_DestinationGuideURL;
153 if (m_ExportSupported) 195 if (m_ExportSupported)
154 extrasMap["ExportSupported"] = true; 196 extrasMap["ExportSupported"] = true;
155 197 if (m_GridURL != string.Empty)
198 extrasMap["GridURL"] = m_GridURL;
199 if (m_GridName != string.Empty)
200 extrasMap["GridName"] = m_GridName;
201
202<<<<<<< HEAD
203 if (extrasMap.Count > 0)
204 m_features["OpenSimExtras"] = extrasMap;
205=======
156 m_features["OpenSimExtras"] = extrasMap; 206 m_features["OpenSimExtras"] = extrasMap;
157 207
208>>>>>>> avn/ubitvar
158 } 209 }
159 } 210 }
160 211
@@ -208,7 +259,12 @@ namespace OpenSim.Region.ClientStack.Linden
208 259
209 OSDMap copy = DeepCopy(); 260 OSDMap copy = DeepCopy();
210 261
262 // Let's add the agentID to the destination guide, if it is expecting that.
263 if (copy.ContainsKey("OpenSimExtras") && ((OSDMap)(copy["OpenSimExtras"])).ContainsKey("destination-guide-url"))
264 ((OSDMap)copy["OpenSimExtras"])["destination-guide-url"] = Replace(((OSDMap)copy["OpenSimExtras"])["destination-guide-url"], "[USERID]", agentID.ToString());
265
211 SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; 266 SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest;
267
212 if (handlerOnSimulatorFeaturesRequest != null) 268 if (handlerOnSimulatorFeaturesRequest != null)
213 handlerOnSimulatorFeaturesRequest(agentID, ref copy); 269 handlerOnSimulatorFeaturesRequest(agentID, ref copy);
214 270
@@ -222,5 +278,46 @@ namespace OpenSim.Region.ClientStack.Linden
222 278
223 return responsedata; 279 return responsedata;
224 } 280 }
281
282 /// <summary>
283 /// Gets the grid extra features.
284 /// </summary>
285 /// <param name='featuresURI'>
286 /// The URI Robust uses to handle the get_extra_features request
287 /// </param>
288 private void GetGridExtraFeatures(Scene scene)
289 {
290 Dictionary<string, object> extraFeatures = scene.GridService.GetExtraFeatures();
291 if (extraFeatures.ContainsKey("Result") && extraFeatures["Result"] != null && extraFeatures["Result"].ToString() == "Failure")
292 {
293 m_log.WarnFormat("[SIMULATOR FEATURES MODULE]: Unable to retrieve grid-wide features");
294 return;
295 }
296
297 lock (m_features)
298 {
299 OSDMap extrasMap = new OSDMap();
300
301 foreach(string key in extraFeatures.Keys)
302 {
303 extrasMap[key] = (string)extraFeatures[key];
304
305 if (key == "ExportSupported")
306 {
307 bool.TryParse(extraFeatures[key].ToString(), out m_ExportSupported);
308 }
309 }
310 m_features["OpenSimExtras"] = extrasMap;
311
312 }
313 }
314
315 private string Replace(string url, string substring, string replacement)
316 {
317 if (!String.IsNullOrEmpty(url) && url.Contains(substring))
318 return url.Replace(substring, replacement);
319
320 return url;
321 }
225 } 322 }
226} 323}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
new file mode 100644
index 0000000..dd4a691
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
@@ -0,0 +1,159 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.IO;
32using System.Net;
33using System.Text;
34using HttpServer;
35using log4net.Config;
36using Nini.Config;
37using NUnit.Framework;
38using OpenMetaverse;
39using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData;
41using OpenSim.Framework;
42using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Servers;
44using OpenSim.Framework.Servers.HttpServer;
45using OpenSim.Region.ClientStack.Linden;
46using OpenSim.Region.CoreModules.Framework;
47using OpenSim.Region.Framework.Scenes;
48using OpenSim.Services.Interfaces;
49using OpenSim.Tests.Common;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52
53namespace OpenSim.Region.ClientStack.Linden.Caps.Tests
54{
55 [TestFixture]
56 public class WebFetchInvDescModuleTests : OpenSimTestCase
57 {
58 [TestFixtureSetUp]
59 public void TestFixtureSetUp()
60 {
61 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
62 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
63 }
64
65 [TestFixtureTearDown]
66 public void TestFixureTearDown()
67 {
68 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
69 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
70 // tests really shouldn't).
71 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
72 }
73
74 [SetUp]
75 public override void SetUp()
76 {
77 base.SetUp();
78
79 // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
80 // variables and the VM is not restarted between tests.
81 uint port = 9999;
82 MainServer.RemoveHttpServer(port);
83
84 BaseHttpServer server = new BaseHttpServer(port, false, 0, "");
85 MainServer.AddHttpServer(server);
86 MainServer.Instance = server;
87
88 server.Start(false);
89 }
90
91 [Test]
92 public void TestInventoryDescendentsFetch()
93 {
94 TestHelpers.InMethod();
95 TestHelpers.EnableLogging();
96
97 BaseHttpServer httpServer = MainServer.Instance;
98 Scene scene = new SceneHelpers().SetupScene();
99
100 CapabilitiesModule capsModule = new CapabilitiesModule();
101 WebFetchInvDescModule wfidModule = new WebFetchInvDescModule(false);
102
103 IConfigSource config = new IniConfigSource();
104 config.AddConfig("ClientStack.LindenCaps");
105 config.Configs["ClientStack.LindenCaps"].Set("Cap_FetchInventoryDescendents2", "localhost");
106
107 SceneHelpers.SetupSceneModules(scene, config, capsModule, wfidModule);
108
109 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
110
111 // We need a user present to have any capabilities set up
112 SceneHelpers.AddScenePresence(scene, ua.PrincipalID);
113
114 TestHttpRequest req = new TestHttpRequest();
115 OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID);
116 PollServiceEventArgs pseArgs;
117 userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs);
118 req.UriPath = pseArgs.Url;
119 req.Uri = new Uri("file://" + req.UriPath);
120
121 // Retrieve root folder details directly so that we can request
122 InventoryFolderBase folder = scene.InventoryService.GetRootFolder(ua.PrincipalID);
123
124 OSDMap osdFolder = new OSDMap();
125 osdFolder["folder_id"] = folder.ID;
126 osdFolder["owner_id"] = ua.PrincipalID;
127 osdFolder["fetch_folders"] = true;
128 osdFolder["fetch_items"] = true;
129 osdFolder["sort_order"] = 0;
130
131 OSDArray osdFoldersArray = new OSDArray();
132 osdFoldersArray.Add(osdFolder);
133
134 OSDMap osdReqMap = new OSDMap();
135 osdReqMap["folders"] = osdFoldersArray;
136
137 req.Body = new MemoryStream(OSDParser.SerializeLLSDXmlBytes(osdReqMap));
138
139 TestHttpClientContext context = new TestHttpClientContext(false);
140
141 // WARNING: This results in a caught exception, because queryString is null
142 MainServer.Instance.OnRequest(context, new RequestEventArgs(req));
143
144 // Drive processing of the queued inventory request synchronously.
145 wfidModule.WaitProcessQueuedInventoryRequest();
146 MainServer.Instance.PollServiceRequestManager.WaitPerformResponse();
147
148// System.Threading.Thread.Sleep(10000);
149
150 OSDMap responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody);
151 OSDArray foldersOsd = (OSDArray)responseOsd["folders"];
152 OSDMap folderOsd = (OSDMap)foldersOsd[0];
153
154 // A sanity check that the response has the expected number of descendents for a default inventory
155 // TODO: Need a more thorough check.
156 Assert.That((int)folderOsd["descendents"], Is.EqualTo(16));
157 }
158 }
159} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index 50e9275..c27d101 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -64,18 +64,13 @@ namespace OpenSim.Region.ClientStack.Linden
64 64
65 private Scene m_scene; 65 private Scene m_scene;
66 private bool m_persistBakedTextures; 66 private bool m_persistBakedTextures;
67 private string m_URL; 67
68 private IBakedTextureModule m_BakedTextureModule;
68 69
69 private IBakedTextureModule m_BakedTextureModule; 70 private IBakedTextureModule m_BakedTextureModule;
70 71
71 public void Initialise(IConfigSource source) 72 public void Initialise(IConfigSource source)
72 { 73 {
73 IConfig config = source.Configs["ClientStack.LindenCaps"];
74 if (config == null)
75 return;
76
77 m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty);
78
79 IConfig appearanceConfig = source.Configs["Appearance"]; 74 IConfig appearanceConfig = source.Configs["Appearance"];
80 if (appearanceConfig != null) 75 if (appearanceConfig != null)
81 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); 76 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
@@ -96,7 +91,13 @@ namespace OpenSim.Region.ClientStack.Linden
96 s.EventManager.OnRemovePresence -= DeRegisterPresence; 91 s.EventManager.OnRemovePresence -= DeRegisterPresence;
97 m_BakedTextureModule = null; 92 m_BakedTextureModule = null;
98 m_scene = null; 93 m_scene = null;
94<<<<<<< HEAD
95 }
96=======
99 } 97 }
98>>>>>>> avn/ubitvar
99
100
100 101
101 public void RegionLoaded(Scene s) 102 public void RegionLoaded(Scene s)
102 { 103 {
@@ -108,12 +109,173 @@ namespace OpenSim.Region.ClientStack.Linden
108 109
109 private void DeRegisterPresence(UUID agentId) 110 private void DeRegisterPresence(UUID agentId)
110 { 111 {
112<<<<<<< HEAD
113 ScenePresence presence = null;
114 if (m_scene.TryGetScenePresence(agentId, out presence))
115 {
116 presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
117 }
118
119 }
120
121 private void RegisterNewPresence(ScenePresence presence)
122 {
123 presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
124
125 }
126
127 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
128 {
129 int maxCacheitemsLoop = cacheItems.Length;
130 if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES)
131 {
132 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
133 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
134 }
135
136 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
137 if (cacheItems.Length > 0)
138 {
139// m_log.Debug("[Cacheitems]: " + cacheItems.Length);
140// for (int iter = 0; iter < maxCacheitemsLoop; iter++)
141// {
142// m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
143// cacheItems[iter].TextureID);
144// }
145
146 ScenePresence p = null;
147 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
148 {
149
150 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
151 if (existingitems == null)
152 {
153 if (m_BakedTextureModule != null)
154 {
155 WearableCacheItem[] savedcache = null;
156 try
157 {
158 if (p.Appearance.WearableCacheItemsDirty)
159 {
160 savedcache = m_BakedTextureModule.Get(p.UUID);
161 p.Appearance.WearableCacheItems = savedcache;
162 p.Appearance.WearableCacheItemsDirty = false;
163 }
164
165 }
166 /*
167 * The following Catch types DO NOT WORK with m_BakedTextureModule.Get
168 * it jumps to the General Packet Exception Handler if you don't catch Exception!
169 *
170 catch (System.Net.Sockets.SocketException)
171 {
172 cacheItems = null;
173 }
174 catch (WebException)
175 {
176 cacheItems = null;
177 }
178 catch (InvalidOperationException)
179 {
180 cacheItems = null;
181 } */
182 catch (Exception)
183 {
184 // The service logs a sufficient error message.
185 }
186
187
188 if (savedcache != null)
189 existingitems = savedcache;
190 }
191 }
192 // Existing items null means it's a fully new appearance
193 if (existingitems == null)
194 {
195
196 for (int i = 0; i < maxCacheitemsLoop; i++)
197 {
198 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
199 {
200 Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex];
201 if (face == null)
202 {
203 textureEntry.CreateFace(cacheItems[i].TextureIndex);
204 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID =
205 AppearanceManager.DEFAULT_AVATAR_TEXTURE;
206 continue;
207 }
208 cacheItems[i].TextureID =face.TextureID;
209 if (m_scene.AssetService != null)
210 cacheItems[i].TextureAsset =
211 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
212 }
213 else
214 {
215 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
216 }
217
218
219 }
220 }
221 else
222
223
224 {
225 // for each uploaded baked texture
226 for (int i = 0; i < maxCacheitemsLoop; i++)
227 {
228 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
229 {
230 Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex];
231 if (face == null)
232 {
233 textureEntry.CreateFace(cacheItems[i].TextureIndex);
234 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID =
235 AppearanceManager.DEFAULT_AVATAR_TEXTURE;
236 continue;
237 }
238 cacheItems[i].TextureID =
239 face.TextureID;
240 }
241 else
242 {
243 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
244 }
245 }
246
247 for (int i = 0; i < maxCacheitemsLoop; i++)
248 {
249 if (cacheItems[i].TextureAsset == null)
250 {
251 cacheItems[i].TextureAsset =
252 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
253 }
254 }
255 }
256
257
258
259 p.Appearance.WearableCacheItems = cacheItems;
260
261
262
263 if (m_BakedTextureModule != null)
264 {
265 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
266 p.Appearance.WearableCacheItemsDirty = true;
267
268 }
269 }
270 }
271=======
111// ScenePresence presence = null; 272// ScenePresence presence = null;
112// if (m_scene.TryGetScenePresence(agentId, out presence)) 273// if (m_scene.TryGetScenePresence(agentId, out presence))
113 { 274 {
114// presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; 275// presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
115 } 276 }
116 277
278>>>>>>> avn/ubitvar
117 } 279 }
118 280
119 private void RegisterNewPresence(ScenePresence presence) 281 private void RegisterNewPresence(ScenePresence presence)
@@ -279,8 +441,25 @@ namespace OpenSim.Region.ClientStack.Linden
279 441
280 public void RegisterCaps(UUID agentID, Caps caps) 442 public void RegisterCaps(UUID agentID, Caps caps)
281 { 443 {
282// UUID capID = UUID.Random(); 444 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
445 caps, m_scene.AssetService, m_persistBakedTextures);
446
447<<<<<<< HEAD
448
449
450 caps.RegisterHandler(
451 "UploadBakedTexture",
452 new RestStreamHandler(
453 "POST",
454 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
455 avatarhandler.UploadBakedTexture,
456 "UploadBakedTexture",
457 agentID.ToString()));
458
459
460
283 461
462=======
284 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); 463 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
285 if (m_URL == "localhost") 464 if (m_URL == "localhost")
286 { 465 {
@@ -301,6 +480,7 @@ namespace OpenSim.Region.ClientStack.Linden
301 { 480 {
302 caps.RegisterHandler("UploadBakedTexture", m_URL); 481 caps.RegisterHandler("UploadBakedTexture", m_URL);
303 } 482 }
483>>>>>>> avn/ubitvar
304 } 484 }
305 } 485 }
306} 486}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 6fc35cd..92f8c51 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -64,9 +64,32 @@ namespace OpenSim.Region.ClientStack.Linden
64 public List<UUID> folders; 64 public List<UUID> folders;
65 } 65 }
66 66
67<<<<<<< HEAD
68 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
69=======
67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
71>>>>>>> avn/ubitvar
68 72
69 private Scene m_scene; 73 /// <summary>
74 /// Control whether requests will be processed asynchronously.
75 /// </summary>
76 /// <remarks>
77 /// Defaults to true. Can currently not be changed once a region has been added to the module.
78 /// </remarks>
79 public bool ProcessQueuedRequestsAsync { get; private set; }
80
81 /// <summary>
82 /// Number of inventory requests processed by this module.
83 /// </summary>
84 /// <remarks>
85 /// It's the PollServiceRequestManager that actually sends completed requests back to the requester.
86 /// </remarks>
87 public static int ProcessedRequestsCount { get; set; }
88
89 private static Stat s_queuedRequestsStat;
90 private static Stat s_processedRequestsStat;
91
92 public Scene Scene { get; private set; }
70 93
71 private IInventoryService m_InventoryService; 94 private IInventoryService m_InventoryService;
72 private ILibraryService m_LibraryService; 95 private ILibraryService m_LibraryService;
@@ -76,7 +99,7 @@ namespace OpenSim.Region.ClientStack.Linden
76 private string m_fetchInventoryDescendents2Url; 99 private string m_fetchInventoryDescendents2Url;
77 private string m_webFetchInventoryDescendentsUrl; 100 private string m_webFetchInventoryDescendentsUrl;
78 101
79 private static WebFetchInvDescHandler m_webFetchHandler; 102 private static FetchInvDescHandler m_webFetchHandler;
80 103
81 private static Thread[] m_workerThreads = null; 104 private static Thread[] m_workerThreads = null;
82 105
@@ -85,6 +108,13 @@ namespace OpenSim.Region.ClientStack.Linden
85 108
86 #region ISharedRegionModule Members 109 #region ISharedRegionModule Members
87 110
111 public WebFetchInvDescModule() : this(true) {}
112
113 public WebFetchInvDescModule(bool processQueuedResultsAsync)
114 {
115 ProcessQueuedRequestsAsync = processQueuedResultsAsync;
116 }
117
88 public void Initialise(IConfigSource source) 118 public void Initialise(IConfigSource source)
89 { 119 {
90 IConfig config = source.Configs["ClientStack.LindenCaps"]; 120 IConfig config = source.Configs["ClientStack.LindenCaps"];
@@ -105,7 +135,7 @@ namespace OpenSim.Region.ClientStack.Linden
105 if (!m_Enabled) 135 if (!m_Enabled)
106 return; 136 return;
107 137
108 m_scene = s; 138 Scene = s;
109 } 139 }
110 140
111 public void RemoveRegion(Scene s) 141 public void RemoveRegion(Scene s)
@@ -113,12 +143,23 @@ namespace OpenSim.Region.ClientStack.Linden
113 if (!m_Enabled) 143 if (!m_Enabled)
114 return; 144 return;
115 145
116 m_scene.EventManager.OnRegisterCaps -= RegisterCaps; 146 Scene.EventManager.OnRegisterCaps -= RegisterCaps;
117 147
118 foreach (Thread t in m_workerThreads) 148 StatsManager.DeregisterStat(s_processedRequestsStat);
119 Watchdog.AbortThread(t.ManagedThreadId); 149 StatsManager.DeregisterStat(s_queuedRequestsStat);
120 150
121 m_scene = null; 151 if (ProcessQueuedRequestsAsync)
152 {
153 if (m_workerThreads != null)
154 {
155 foreach (Thread t in m_workerThreads)
156 Watchdog.AbortThread(t.ManagedThreadId);
157
158 m_workerThreads = null;
159 }
160 }
161
162 Scene = null;
122 } 163 }
123 164
124 public void RegionLoaded(Scene s) 165 public void RegionLoaded(Scene s)
@@ -126,21 +167,53 @@ namespace OpenSim.Region.ClientStack.Linden
126 if (!m_Enabled) 167 if (!m_Enabled)
127 return; 168 return;
128 169
129 m_InventoryService = m_scene.InventoryService; 170 if (s_processedRequestsStat == null)
130 m_LibraryService = m_scene.LibraryService; 171 s_processedRequestsStat =
172 new Stat(
173 "ProcessedFetchInventoryRequests",
174 "Number of processed fetch inventory requests",
175 "These have not necessarily yet been dispatched back to the requester.",
176 "",
177 "inventory",
178 "httpfetch",
179 StatType.Pull,
180 MeasuresOfInterest.AverageChangeOverTime,
181 stat => { stat.Value = ProcessedRequestsCount; },
182 StatVerbosity.Debug);
183
184 if (s_queuedRequestsStat == null)
185 s_queuedRequestsStat =
186 new Stat(
187 "QueuedFetchInventoryRequests",
188 "Number of fetch inventory requests queued for processing",
189 "",
190 "",
191 "inventory",
192 "httpfetch",
193 StatType.Pull,
194 MeasuresOfInterest.AverageChangeOverTime,
195 stat => { stat.Value = m_queue.Count; },
196 StatVerbosity.Debug);
197
198 StatsManager.RegisterStat(s_processedRequestsStat);
199 StatsManager.RegisterStat(s_queuedRequestsStat);
200
201 m_InventoryService = Scene.InventoryService;
202 m_LibraryService = Scene.LibraryService;
131 203
132 // We'll reuse the same handler for all requests. 204 // We'll reuse the same handler for all requests.
133 m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); 205 m_webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, Scene);
134 206
135 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 207 Scene.EventManager.OnRegisterCaps += RegisterCaps;
136 208
137 if (m_workerThreads == null) 209 int nworkers = 2; // was 2
210 if (ProcessQueuedRequestsAsync && m_workerThreads == null)
138 { 211 {
139 m_workerThreads = new Thread[2]; 212 m_workerThreads = new Thread[nworkers];
140 213
141 for (uint i = 0; i < 2; i++) 214 for (uint i = 0; i < nworkers; i++)
142 { 215 {
143 m_workerThreads[i] = Watchdog.StartThread(DoInventoryRequests, 216 m_workerThreads[i] = WorkManager.StartThread(DoInventoryRequests,
144 String.Format("InventoryWorkerThread{0}", i), 217 String.Format("InventoryWorkerThread{0}", i),
145 ThreadPriority.Normal, 218 ThreadPriority.Normal,
146 false, 219 false,
@@ -173,12 +246,12 @@ namespace OpenSim.Region.ClientStack.Linden
173 private Dictionary<UUID, Hashtable> responses = 246 private Dictionary<UUID, Hashtable> responses =
174 new Dictionary<UUID, Hashtable>(); 247 new Dictionary<UUID, Hashtable>();
175 248
176 private Scene m_scene; 249 private WebFetchInvDescModule m_module;
177 250
178 public PollServiceInventoryEventArgs(Scene scene, string url, UUID pId) : 251 public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) :
179 base(null, url, null, null, null, pId, int.MaxValue) 252 base(null, url, null, null, null, pId, int.MaxValue)
180 { 253 {
181 m_scene = scene; 254 m_module = module;
182 255
183 HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; 256 HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
184 GetEvents = (x, y) => 257 GetEvents = (x, y) =>
@@ -198,12 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden
198 271
199 Request = (x, y) => 272 Request = (x, y) =>
200 { 273 {
201 ScenePresence sp = m_scene.GetScenePresence(Id); 274 ScenePresence sp = m_module.Scene.GetScenePresence(Id);
202 if (sp == null)
203 {
204 m_log.ErrorFormat("[INVENTORY]: Unable to find ScenePresence for {0}", Id);
205 return;
206 }
207 275
208 aPollRequest reqinfo = new aPollRequest(); 276 aPollRequest reqinfo = new aPollRequest();
209 reqinfo.thepoll = this; 277 reqinfo.thepoll = this;
@@ -298,7 +366,13 @@ namespace OpenSim.Region.ClientStack.Linden
298 requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); 366 requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null);
299 367
300 lock (responses) 368 lock (responses)
369 {
370 if (responses.ContainsKey(requestID))
371 m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054");
301 responses[requestID] = response; 372 responses[requestID] = response;
373 }
374
375 WebFetchInvDescModule.ProcessedRequestsCount++;
302 } 376 }
303 } 377 }
304 378
@@ -322,7 +396,7 @@ namespace OpenSim.Region.ClientStack.Linden
322 capUrl = "/CAPS/" + UUID.Random() + "/"; 396 capUrl = "/CAPS/" + UUID.Random() + "/";
323 397
324 // Register this as a poll service 398 // Register this as a poll service
325 PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, capUrl, agentID); 399 PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(this, capUrl, agentID);
326 args.Type = PollServiceEventArgs.EventType.Inventory; 400 args.Type = PollServiceEventArgs.EventType.Inventory;
327 401
328 caps.RegisterPollHandler(capName, args); 402 caps.RegisterPollHandler(capName, args);
@@ -331,7 +405,7 @@ namespace OpenSim.Region.ClientStack.Linden
331 else 405 else
332 { 406 {
333 capUrl = url; 407 capUrl = url;
334 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); 408 IExternalCapsModule handler = Scene.RequestModuleInterface<IExternalCapsModule>();
335 if (handler != null) 409 if (handler != null)
336 handler.RegisterExternalUserCapsHandler(agentID,caps,capName,capUrl); 410 handler.RegisterExternalUserCapsHandler(agentID,caps,capName,capUrl);
337 else 411 else
@@ -360,10 +434,26 @@ namespace OpenSim.Region.ClientStack.Linden
360 { 434 {
361 Watchdog.UpdateThread(); 435 Watchdog.UpdateThread();
362 436
363 aPollRequest poolreq = m_queue.Dequeue(); 437 WaitProcessQueuedInventoryRequest();
438 }
439 }
440
441 public void WaitProcessQueuedInventoryRequest()
442 {
443 aPollRequest poolreq = m_queue.Dequeue();
364 444
365 if (poolreq != null && poolreq.thepoll != null) 445 if (poolreq != null && poolreq.thepoll != null)
446 {
447 try
448 {
366 poolreq.thepoll.Process(poolreq); 449 poolreq.thepoll.Process(poolreq);
450 }
451 catch (Exception e)
452 {
453 m_log.ErrorFormat(
454 "[INVENTORY]: Failed to process queued inventory request {0} for {1} in {2}. Exception {3}",
455 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", Scene.Name, e);
456 }
367 } 457 }
368 } 458 }
369 } 459 }