diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps')
21 files changed, 1738 insertions, 248 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.IO; | ||
32 | using log4net; | ||
33 | using Mono.Addins; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
44 | using OpenSim.Capabilities.Handlers; | ||
45 | |||
46 | namespace 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/AvatarPickerSearchModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/AvatarPickerSearchModule.cs new file mode 100644 index 0000000..bbadc55 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/AvatarPickerSearchModule.cs | |||
@@ -0,0 +1,136 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Drawing; | ||
32 | using System.Drawing.Imaging; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Web; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using Mono.Addins; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using OpenSim.Region.Framework.Interfaces; | ||
45 | using OpenSim.Region.Framework.Scenes; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
48 | using OpenSim.Capabilities.Handlers; | ||
49 | |||
50 | namespace OpenSim.Region.ClientStack.Linden | ||
51 | { | ||
52 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AvatarPickerSearchModule")] | ||
53 | public class AvatarPickerSearchModule : INonSharedRegionModule | ||
54 | { | ||
55 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | |||
57 | private Scene m_scene; | ||
58 | private IPeople m_People; | ||
59 | private bool m_Enabled = false; | ||
60 | |||
61 | private string m_URL; | ||
62 | |||
63 | #region ISharedRegionModule Members | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
68 | if (config == null) | ||
69 | return; | ||
70 | |||
71 | m_URL = config.GetString("Cap_AvatarPickerSearch", string.Empty); | ||
72 | // Cap doesn't exist | ||
73 | if (m_URL != string.Empty) | ||
74 | m_Enabled = true; | ||
75 | } | ||
76 | |||
77 | public void AddRegion(Scene s) | ||
78 | { | ||
79 | if (!m_Enabled) | ||
80 | return; | ||
81 | |||
82 | m_scene = s; | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene s) | ||
86 | { | ||
87 | if (!m_Enabled) | ||
88 | return; | ||
89 | |||
90 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
91 | m_scene = null; | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene s) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | m_People = m_scene.RequestModuleInterface<IPeople>(); | ||
100 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
101 | } | ||
102 | |||
103 | public void PostInitialise() | ||
104 | { | ||
105 | } | ||
106 | |||
107 | public void Close() { } | ||
108 | |||
109 | public string Name { get { return "AvatarPickerSearchModule"; } } | ||
110 | |||
111 | public Type ReplaceableInterface | ||
112 | { | ||
113 | get { return null; } | ||
114 | } | ||
115 | |||
116 | #endregion | ||
117 | |||
118 | public void RegisterCaps(UUID agentID, Caps caps) | ||
119 | { | ||
120 | UUID capID = UUID.Random(); | ||
121 | |||
122 | if (m_URL == "localhost") | ||
123 | { | ||
124 | // m_log.DebugFormat("[AVATAR PICKER SEARCH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
125 | caps.RegisterHandler( | ||
126 | "AvatarPickerSearch", | ||
127 | new AvatarPickerSearchHandler("/CAPS/" + capID + "/", m_People, "AvatarPickerSearch", "Search for avatars by name")); | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | // m_log.DebugFormat("[AVATAR PICKER SEARCH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | ||
132 | caps.RegisterHandler("AvatarPickerSearch", m_URL); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 568e216..774202e 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -44,11 +44,13 @@ using OpenSim.Region.Framework.Scenes; | |||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | 44 | using OpenSim.Region.Framework.Scenes.Serialization; |
45 | using OpenSim.Framework.Servers; | 45 | using OpenSim.Framework.Servers; |
46 | using OpenSim.Framework.Servers.HttpServer; | 46 | using OpenSim.Framework.Servers.HttpServer; |
47 | using OpenSim.Framework.Client; | ||
47 | using OpenSim.Services.Interfaces; | 48 | using OpenSim.Services.Interfaces; |
48 | 49 | ||
49 | using Caps = OpenSim.Framework.Capabilities.Caps; | 50 | using Caps = OpenSim.Framework.Capabilities.Caps; |
50 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | 51 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 52 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
53 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
52 | 54 | ||
53 | namespace OpenSim.Region.ClientStack.Linden | 55 | namespace OpenSim.Region.ClientStack.Linden |
54 | { | 56 | { |
@@ -96,6 +98,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
96 | // private static readonly string m_fetchInventoryPath = "0006/"; | 98 | // private static readonly string m_fetchInventoryPath = "0006/"; |
97 | private static readonly string m_copyFromNotecardPath = "0007/"; | 99 | private static readonly string m_copyFromNotecardPath = "0007/"; |
98 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. | 100 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. |
101 | private static readonly string m_getObjectPhysicsDataPath = "0101/"; | ||
102 | /* 0102 - 0103 RESERVED */ | ||
99 | private static readonly string m_UpdateAgentInformationPath = "0500/"; | 103 | private static readonly string m_UpdateAgentInformationPath = "0500/"; |
100 | 104 | ||
101 | // These are callbacks which will be setup by the scene so that we can update scene data when we | 105 | // These are callbacks which will be setup by the scene so that we can update scene data when we |
@@ -204,7 +208,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
204 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); | 208 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); |
205 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); | 209 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); |
206 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); | 210 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); |
207 | IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler("POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation); | 211 | |
212 | IRequestHandler getObjectPhysicsDataHandler | ||
213 | = new RestStreamHandler( | ||
214 | "POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData, "GetObjectPhysicsData", null); | ||
215 | m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); | ||
216 | |||
217 | IRequestHandler UpdateAgentInformationHandler | ||
218 | = new RestStreamHandler( | ||
219 | "POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation, "UpdateAgentInformation", null); | ||
208 | m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler); | 220 | m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler); |
209 | 221 | ||
210 | m_HostCapsObj.RegisterHandler( | 222 | m_HostCapsObj.RegisterHandler( |
@@ -256,8 +268,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
256 | public string SeedCapRequest(string request, string path, string param, | 268 | public string SeedCapRequest(string request, string path, string param, |
257 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 269 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
258 | { | 270 | { |
259 | m_log.DebugFormat( | 271 | // m_log.DebugFormat( |
260 | "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID); | 272 | // "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID); |
261 | 273 | ||
262 | if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) | 274 | if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) |
263 | { | 275 | { |
@@ -268,13 +280,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
268 | return string.Empty; | 280 | return string.Empty; |
269 | } | 281 | } |
270 | 282 | ||
271 | Hashtable caps = m_HostCapsObj.CapsHandlers.GetCapsDetails(true); | 283 | OSDArray capsRequested = (OSDArray)OSDParser.DeserializeLLSDXml(request); |
284 | List<string> validCaps = new List<string>(); | ||
272 | 285 | ||
273 | // Add the external too | 286 | foreach (OSD c in capsRequested) |
274 | foreach (KeyValuePair<string, string> kvp in m_HostCapsObj.ExternalCapsHandlers) | 287 | validCaps.Add(c.AsString()); |
275 | caps[kvp.Key] = kvp.Value; | ||
276 | 288 | ||
277 | string result = LLSDHelpers.SerialiseLLSDReply(caps); | 289 | string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps)); |
278 | 290 | ||
279 | //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); | 291 | //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); |
280 | 292 | ||
@@ -487,24 +499,28 @@ namespace OpenSim.Region.ClientStack.Linden | |||
487 | 499 | ||
488 | if (inventoryType == "sound") | 500 | if (inventoryType == "sound") |
489 | { | 501 | { |
490 | inType = 1; | 502 | inType = (sbyte)InventoryType.Sound; |
491 | assType = 1; | 503 | assType = (sbyte)AssetType.Sound; |
504 | } | ||
505 | else if (inventoryType == "snapshot") | ||
506 | { | ||
507 | inType = (sbyte)InventoryType.Snapshot; | ||
492 | } | 508 | } |
493 | else if (inventoryType == "animation") | 509 | else if (inventoryType == "animation") |
494 | { | 510 | { |
495 | inType = 19; | 511 | inType = (sbyte)InventoryType.Animation; |
496 | assType = 20; | 512 | assType = (sbyte)AssetType.Animation; |
497 | } | 513 | } |
498 | else if (inventoryType == "wearable") | 514 | else if (inventoryType == "wearable") |
499 | { | 515 | { |
500 | inType = 18; | 516 | inType = (sbyte)InventoryType.Wearable; |
501 | switch (assetType) | 517 | switch (assetType) |
502 | { | 518 | { |
503 | case "bodypart": | 519 | case "bodypart": |
504 | assType = 13; | 520 | assType = (sbyte)AssetType.Bodypart; |
505 | break; | 521 | break; |
506 | case "clothing": | 522 | case "clothing": |
507 | assType = 5; | 523 | assType = (sbyte)AssetType.Clothing; |
508 | break; | 524 | break; |
509 | } | 525 | } |
510 | } | 526 | } |
@@ -521,6 +537,41 @@ namespace OpenSim.Region.ClientStack.Linden | |||
521 | OSDArray texture_list = (OSDArray)request["texture_list"]; | 537 | OSDArray texture_list = (OSDArray)request["texture_list"]; |
522 | SceneObjectGroup grp = null; | 538 | SceneObjectGroup grp = null; |
523 | 539 | ||
540 | InventoryFolderBase textureUploadFolder = null; | ||
541 | |||
542 | List<InventoryFolderBase> foldersToUpdate = new List<InventoryFolderBase>(); | ||
543 | List<InventoryItemBase> itemsToUpdate = new List<InventoryItemBase>(); | ||
544 | IClientInventory clientInv = null; | ||
545 | |||
546 | if (texture_list.Count > 0) | ||
547 | { | ||
548 | ScenePresence avatar = null; | ||
549 | m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); | ||
550 | |||
551 | if (avatar != null) | ||
552 | { | ||
553 | IClientCore core = (IClientCore)avatar.ControllingClient; | ||
554 | |||
555 | if (core.TryGet<IClientInventory>(out clientInv)) | ||
556 | { | ||
557 | var systemTextureFolder = m_Scene.InventoryService.GetFolderForType(m_HostCapsObj.AgentID, FolderType.Texture); | ||
558 | textureUploadFolder = new InventoryFolderBase(UUID.Random(), assetName, m_HostCapsObj.AgentID, (short)FolderType.None, systemTextureFolder.ID, 1); | ||
559 | if (m_Scene.InventoryService.AddFolder(textureUploadFolder)) | ||
560 | { | ||
561 | foldersToUpdate.Add(textureUploadFolder); | ||
562 | |||
563 | m_log.DebugFormat( | ||
564 | "[BUNCH OF CAPS]: Created new folder '{0}' ({1}) for textures uploaded with mesh object {2}", | ||
565 | textureUploadFolder.Name, textureUploadFolder.ID, assetName); | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | textureUploadFolder = null; | ||
570 | } | ||
571 | } | ||
572 | } | ||
573 | } | ||
574 | |||
524 | List<UUID> textures = new List<UUID>(); | 575 | List<UUID> textures = new List<UUID>(); |
525 | for (int i = 0; i < texture_list.Count; i++) | 576 | for (int i = 0; i < texture_list.Count; i++) |
526 | { | 577 | { |
@@ -528,6 +579,38 @@ namespace OpenSim.Region.ClientStack.Linden | |||
528 | textureAsset.Data = texture_list[i].AsBinary(); | 579 | textureAsset.Data = texture_list[i].AsBinary(); |
529 | m_assetService.Store(textureAsset); | 580 | m_assetService.Store(textureAsset); |
530 | textures.Add(textureAsset.FullID); | 581 | textures.Add(textureAsset.FullID); |
582 | |||
583 | if (textureUploadFolder != null) | ||
584 | { | ||
585 | InventoryItemBase textureItem = new InventoryItemBase(); | ||
586 | textureItem.Owner = m_HostCapsObj.AgentID; | ||
587 | textureItem.CreatorId = m_HostCapsObj.AgentID.ToString(); | ||
588 | textureItem.CreatorData = String.Empty; | ||
589 | textureItem.ID = UUID.Random(); | ||
590 | textureItem.AssetID = textureAsset.FullID; | ||
591 | textureItem.Description = assetDescription; | ||
592 | textureItem.Name = assetName + " - Texture " + (i + 1).ToString(); | ||
593 | textureItem.AssetType = (int)AssetType.Texture; | ||
594 | textureItem.InvType = (int)InventoryType.Texture; | ||
595 | textureItem.Folder = textureUploadFolder.ID; | ||
596 | textureItem.CurrentPermissions | ||
597 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export); | ||
598 | textureItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; | ||
599 | textureItem.EveryOnePermissions = 0; | ||
600 | textureItem.NextPermissions = (uint)PermissionMask.All; | ||
601 | textureItem.CreationDate = Util.UnixTimeSinceEpoch(); | ||
602 | m_Scene.InventoryService.AddItem(textureItem); | ||
603 | itemsToUpdate.Add(textureItem); | ||
604 | |||
605 | m_log.DebugFormat( | ||
606 | "[BUNCH OF CAPS]: Created new inventory item '{0}' ({1}) for texture uploaded with mesh object {2}", | ||
607 | textureItem.Name, textureItem.ID, assetName); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | if (clientInv != null && (foldersToUpdate.Count > 0 || itemsToUpdate.Count > 0)) | ||
612 | { | ||
613 | clientInv.SendBulkUpdateInventory(foldersToUpdate.ToArray(), itemsToUpdate.ToArray()); | ||
531 | } | 614 | } |
532 | 615 | ||
533 | for (int i = 0; i < mesh_list.Count; i++) | 616 | for (int i = 0; i < mesh_list.Count; i++) |
@@ -701,9 +784,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
701 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | 784 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current |
702 | // (owner) permissions. This becomes a problem if next permissions are changed. | 785 | // (owner) permissions. This becomes a problem if next permissions are changed. |
703 | item.CurrentPermissions | 786 | item.CurrentPermissions |
704 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | 787 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export); |
705 | 788 | ||
706 | item.BasePermissions = (uint)PermissionMask.All; | 789 | item.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; |
707 | item.EveryOnePermissions = 0; | 790 | item.EveryOnePermissions = 0; |
708 | item.NextPermissions = (uint)PermissionMask.All; | 791 | item.NextPermissions = (uint)PermissionMask.All; |
709 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 792 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
@@ -850,18 +933,26 @@ namespace OpenSim.Region.ClientStack.Linden | |||
850 | item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); | 933 | item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); |
851 | if (item != null) | 934 | if (item != null) |
852 | { | 935 | { |
853 | copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); | 936 | string message; |
854 | if (copyItem != null && client != null) | 937 | copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message); |
938 | if (client != null) | ||
855 | { | 939 | { |
856 | m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); | 940 | if (copyItem != null) |
857 | client.SendBulkUpdateInventory(copyItem); | 941 | { |
942 | m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); | ||
943 | client.SendBulkUpdateInventory(copyItem); | ||
944 | } | ||
945 | else | ||
946 | { | ||
947 | client.SendAgentAlertMessage(message, false); | ||
948 | } | ||
858 | } | 949 | } |
859 | } | 950 | } |
860 | else | 951 | else |
861 | { | 952 | { |
862 | m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); | 953 | m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); |
863 | if (client != null) | 954 | if (client != null) |
864 | client.SendAlertMessage("Failed to retrieve item"); | 955 | client.SendAgentAlertMessage("Failed to retrieve item", false); |
865 | } | 956 | } |
866 | } | 957 | } |
867 | catch (Exception e) | 958 | catch (Exception e) |
@@ -873,17 +964,49 @@ namespace OpenSim.Region.ClientStack.Linden | |||
873 | return LLSDHelpers.SerialiseLLSDReply(response); | 964 | return LLSDHelpers.SerialiseLLSDReply(response); |
874 | } | 965 | } |
875 | 966 | ||
876 | public string UpdateAgentInformation(string request, string path, | 967 | public string GetObjectPhysicsData(string request, string path, |
877 | string param, IOSHttpRequest httpRequest, | 968 | string param, IOSHttpRequest httpRequest, |
878 | IOSHttpResponse httpResponse) | 969 | IOSHttpResponse httpResponse) |
879 | { | 970 | { |
880 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 971 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
881 | OSDMap resp = new OSDMap(); | 972 | OSDMap resp = new OSDMap(); |
973 | OSDArray object_ids = (OSDArray)req["object_ids"]; | ||
882 | 974 | ||
883 | OSDMap accessPrefs = new OSDMap(); | 975 | for (int i = 0 ; i < object_ids.Count ; i++) |
884 | accessPrefs["max"] = "A"; | 976 | { |
977 | UUID uuid = object_ids[i].AsUUID(); | ||
978 | |||
979 | SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); | ||
980 | if (obj != null) | ||
981 | { | ||
982 | OSDMap object_data = new OSDMap(); | ||
885 | 983 | ||
886 | resp["access_prefs"] = accessPrefs; | 984 | object_data["PhysicsShapeType"] = obj.PhysicsShapeType; |
985 | object_data["Density"] = obj.Density; | ||
986 | object_data["Friction"] = obj.Friction; | ||
987 | object_data["Restitution"] = obj.Restitution; | ||
988 | object_data["GravityMultiplier"] = obj.GravityModifier; | ||
989 | |||
990 | resp[uuid.ToString()] = object_data; | ||
991 | } | ||
992 | } | ||
993 | |||
994 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
995 | return response; | ||
996 | } | ||
997 | |||
998 | public string UpdateAgentInformation(string request, string path, | ||
999 | string param, IOSHttpRequest httpRequest, | ||
1000 | IOSHttpResponse httpResponse) | ||
1001 | { | ||
1002 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
1003 | OSDMap accessPrefs = (OSDMap)req["access_prefs"]; | ||
1004 | string desiredMaturity = accessPrefs["max"]; | ||
1005 | |||
1006 | OSDMap resp = new OSDMap(); | ||
1007 | OSDMap respAccessPrefs = new OSDMap(); | ||
1008 | respAccessPrefs["max"] = desiredMaturity; // echoing the maturity back means success | ||
1009 | resp["access_prefs"] = respAccessPrefs; | ||
887 | 1010 | ||
888 | string response = OSDParser.SerializeLLSDXmlString(resp); | 1011 | string response = OSDParser.SerializeLLSDXmlString(resp); |
889 | return response; | 1012 | 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; | |||
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | 41 | using 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)] |
45 | namespace OpenSim.Region.ClientStack.Linden | 45 | namespace 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 4d2c0f2..9b9f6a7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -59,12 +59,20 @@ namespace OpenSim.Region.ClientStack.Linden | |||
59 | public class EventQueueGetModule : IEventQueue, INonSharedRegionModule | 59 | public class EventQueueGetModule : IEventQueue, INonSharedRegionModule |
60 | { | 60 | { |
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
62 | private static string LogHeader = "[EVENT QUEUE GET MODULE]"; | ||
62 | 63 | ||
63 | /// <value> | 64 | /// <value> |
64 | /// Debug level. | 65 | /// Debug level. |
65 | /// </value> | 66 | /// </value> |
66 | public int DebugLevel { get; set; } | 67 | public int DebugLevel { get; set; } |
67 | 68 | ||
69 | // Viewer post requests timeout in 60 secs | ||
70 | // https://bitbucket.org/lindenlab/viewer-release/src/421c20423df93d650cc305dc115922bb30040999/indra/llmessage/llhttpclient.cpp?at=default#cl-44 | ||
71 | // | ||
72 | private const int VIEWER_TIMEOUT = 60 * 1000; | ||
73 | // Just to be safe, we work on a 10 sec shorter cycle | ||
74 | private const int SERVER_EQ_TIME_NO_EVENTS = VIEWER_TIMEOUT - (10 * 1000); | ||
75 | |||
68 | protected Scene m_scene; | 76 | protected Scene m_scene; |
69 | 77 | ||
70 | private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); | 78 | private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); |
@@ -84,7 +92,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
84 | scene.RegisterModuleInterface<IEventQueue>(this); | 92 | scene.RegisterModuleInterface<IEventQueue>(this); |
85 | 93 | ||
86 | scene.EventManager.OnClientClosed += ClientClosed; | 94 | scene.EventManager.OnClientClosed += ClientClosed; |
87 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
88 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | 95 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; |
89 | 96 | ||
90 | MainConsole.Instance.Commands.AddCommand( | 97 | MainConsole.Instance.Commands.AddCommand( |
@@ -94,9 +101,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
94 | "debug eq [0|1|2]", | 101 | "debug eq [0|1|2]", |
95 | "Turn on event queue debugging\n" | 102 | "Turn on event queue debugging\n" |
96 | + " <= 0 - turns off all event queue logging\n" | 103 | + " <= 0 - turns off all event queue logging\n" |
97 | + " >= 1 - turns on outgoing event logging\n" | 104 | + " >= 1 - turns on event queue setup and outgoing event logging\n" |
98 | + " >= 2 - turns on poll notification", | 105 | + " >= 2 - turns on poll notification", |
99 | HandleDebugEq); | 106 | HandleDebugEq); |
107 | |||
108 | MainConsole.Instance.Commands.AddCommand( | ||
109 | "Debug", | ||
110 | false, | ||
111 | "show eq", | ||
112 | "show eq", | ||
113 | "Show contents of event queues for logged in avatars. Used for debugging.", | ||
114 | HandleShowEq); | ||
100 | } | 115 | } |
101 | 116 | ||
102 | public void RemoveRegion(Scene scene) | 117 | public void RemoveRegion(Scene scene) |
@@ -105,7 +120,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
105 | return; | 120 | return; |
106 | 121 | ||
107 | scene.EventManager.OnClientClosed -= ClientClosed; | 122 | scene.EventManager.OnClientClosed -= ClientClosed; |
108 | scene.EventManager.OnMakeChildAgent -= MakeChildAgent; | ||
109 | scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | 123 | scene.EventManager.OnRegisterCaps -= OnRegisterCaps; |
110 | 124 | ||
111 | scene.UnregisterModuleInterface<IEventQueue>(this); | 125 | scene.UnregisterModuleInterface<IEventQueue>(this); |
@@ -138,7 +152,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
138 | 152 | ||
139 | if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel))) | 153 | if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel))) |
140 | { | 154 | { |
141 | MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]"); | 155 | MainConsole.Instance.OutputFormat("Usage: debug eq [0|1|2]"); |
142 | } | 156 | } |
143 | else | 157 | else |
144 | { | 158 | { |
@@ -148,6 +162,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
148 | } | 162 | } |
149 | } | 163 | } |
150 | 164 | ||
165 | protected void HandleShowEq(string module, string[] args) | ||
166 | { | ||
167 | MainConsole.Instance.OutputFormat("For scene {0}", m_scene.Name); | ||
168 | |||
169 | lock (queues) | ||
170 | { | ||
171 | foreach (KeyValuePair<UUID, Queue<OSD>> kvp in queues) | ||
172 | { | ||
173 | MainConsole.Instance.OutputFormat( | ||
174 | "For agent {0} there are {1} messages queued for send.", | ||
175 | kvp.Key, kvp.Value.Count); | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | |||
151 | /// <summary> | 180 | /// <summary> |
152 | /// Always returns a valid queue | 181 | /// Always returns a valid queue |
153 | /// </summary> | 182 | /// </summary> |
@@ -159,14 +188,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
159 | { | 188 | { |
160 | if (!queues.ContainsKey(agentId)) | 189 | if (!queues.ContainsKey(agentId)) |
161 | { | 190 | { |
162 | /* | 191 | if (DebugLevel > 0) |
163 | m_log.DebugFormat( | 192 | m_log.DebugFormat( |
164 | "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", | 193 | "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", |
165 | agentId, m_scene.RegionInfo.RegionName); | 194 | agentId, m_scene.RegionInfo.RegionName); |
166 | */ | 195 | |
167 | queues[agentId] = new Queue<OSD>(); | 196 | queues[agentId] = new Queue<OSD>(); |
168 | } | 197 | } |
169 | 198 | ||
170 | return queues[agentId]; | 199 | return queues[agentId]; |
171 | } | 200 | } |
172 | } | 201 | } |
@@ -198,8 +227,23 @@ namespace OpenSim.Region.ClientStack.Linden | |||
198 | { | 227 | { |
199 | Queue<OSD> queue = GetQueue(avatarID); | 228 | Queue<OSD> queue = GetQueue(avatarID); |
200 | if (queue != null) | 229 | if (queue != null) |
230 | { | ||
201 | lock (queue) | 231 | lock (queue) |
202 | queue.Enqueue(ev); | 232 | queue.Enqueue(ev); |
233 | } | ||
234 | else if (DebugLevel > 0) | ||
235 | { | ||
236 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | ||
237 | |||
238 | // This assumes that an NPC should never have a queue. | ||
239 | if (sp != null && sp.PresenceType != PresenceType.Npc) | ||
240 | { | ||
241 | OSDMap evMap = (OSDMap)ev; | ||
242 | m_log.WarnFormat( | ||
243 | "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}", | ||
244 | sp.Name, sp.UUID, evMap["message"], m_scene.Name); | ||
245 | } | ||
246 | } | ||
203 | } | 247 | } |
204 | catch (NullReferenceException e) | 248 | catch (NullReferenceException e) |
205 | { | 249 | { |
@@ -214,44 +258,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
214 | 258 | ||
215 | private void ClientClosed(UUID agentID, Scene scene) | 259 | private void ClientClosed(UUID agentID, Scene scene) |
216 | { | 260 | { |
217 | // m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); | 261 | //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); |
218 | |||
219 | int count = 0; | ||
220 | while (queues.ContainsKey(agentID) && queues[agentID].Count > 0 && count++ < 5) | ||
221 | { | ||
222 | Thread.Sleep(1000); | ||
223 | } | ||
224 | 262 | ||
225 | lock (queues) | 263 | lock (queues) |
226 | { | ||
227 | queues.Remove(agentID); | 264 | queues.Remove(agentID); |
228 | } | ||
229 | 265 | ||
230 | List<UUID> removeitems = new List<UUID>(); | 266 | List<UUID> removeitems = new List<UUID>(); |
231 | lock (m_AvatarQueueUUIDMapping) | 267 | lock (m_AvatarQueueUUIDMapping) |
232 | { | 268 | m_AvatarQueueUUIDMapping.Remove(agentID); |
233 | foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) | ||
234 | { | ||
235 | // m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); | ||
236 | if (ky == agentID) | ||
237 | { | ||
238 | removeitems.Add(ky); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | foreach (UUID ky in removeitems) | ||
243 | { | ||
244 | UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; | ||
245 | m_AvatarQueueUUIDMapping.Remove(ky); | ||
246 | |||
247 | string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); | ||
248 | MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); | ||
249 | |||
250 | // m_log.DebugFormat( | ||
251 | // "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", | ||
252 | // eqgPath, agentID, m_scene.RegionInfo.RegionName); | ||
253 | } | ||
254 | } | ||
255 | 269 | ||
256 | UUID searchval = UUID.Zero; | 270 | UUID searchval = UUID.Zero; |
257 | 271 | ||
@@ -272,19 +286,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
272 | foreach (UUID ky in removeitems) | 286 | foreach (UUID ky in removeitems) |
273 | m_QueueUUIDAvatarMapping.Remove(ky); | 287 | m_QueueUUIDAvatarMapping.Remove(ky); |
274 | } | 288 | } |
275 | } | ||
276 | 289 | ||
277 | private void MakeChildAgent(ScenePresence avatar) | 290 | // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); |
278 | { | 291 | |
279 | //m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName); | ||
280 | //lock (m_ids) | ||
281 | // { | ||
282 | //if (m_ids.ContainsKey(avatar.UUID)) | ||
283 | //{ | ||
284 | // close the event queue. | ||
285 | //m_ids[avatar.UUID] = -1; | ||
286 | //} | ||
287 | //} | ||
288 | } | 292 | } |
289 | 293 | ||
290 | /// <summary> | 294 | /// <summary> |
@@ -300,9 +304,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
300 | { | 304 | { |
301 | // Register an event queue for the client | 305 | // Register an event queue for the client |
302 | 306 | ||
303 | //m_log.DebugFormat( | 307 | if (DebugLevel > 0) |
304 | // "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", | 308 | m_log.DebugFormat( |
305 | // agentID, caps, m_scene.RegionInfo.RegionName); | 309 | "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", |
310 | agentID, caps, m_scene.RegionInfo.RegionName); | ||
306 | 311 | ||
307 | // Let's instantiate a Queue for this agent right now | 312 | // Let's instantiate a Queue for this agent right now |
308 | TryGetQueue(agentID); | 313 | TryGetQueue(agentID); |
@@ -336,28 +341,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
336 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); | 341 | m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); |
337 | } | 342 | } |
338 | 343 | ||
339 | string eventQueueGetPath = GenerateEqgCapPath(eventQueueGetUUID); | 344 | caps.RegisterPollHandler( |
340 | 345 | "EventQueueGet", | |
341 | // Register this as a caps handler | 346 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); |
342 | // FIXME: Confusingly, we need to register separate as a capability so that the client is told about | ||
343 | // EventQueueGet when it receive capability information, but then we replace the rest handler immediately | ||
344 | // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but | ||
345 | // really it should be possible to directly register the poll handler as a capability. | ||
346 | caps.RegisterHandler("EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null)); | ||
347 | // delegate(Hashtable m_dhttpMethod) | ||
348 | // { | ||
349 | // return ProcessQueue(m_dhttpMethod, agentID, caps); | ||
350 | // })); | ||
351 | |||
352 | // This will persist this beyond the expiry of the caps handlers | ||
353 | // TODO: Add EventQueueGet name/description for diagnostics | ||
354 | MainServer.Instance.AddPollServiceHTTPHandler( | ||
355 | eventQueueGetPath, | ||
356 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); | ||
357 | |||
358 | // m_log.DebugFormat( | ||
359 | // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", | ||
360 | // eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); | ||
361 | 347 | ||
362 | Random rnd = new Random(Environment.TickCount); | 348 | Random rnd = new Random(Environment.TickCount); |
363 | lock (m_ids) | 349 | lock (m_ids) |
@@ -375,7 +361,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
375 | Queue<OSD> queue = GetQueue(agentID); | 361 | Queue<OSD> queue = GetQueue(agentID); |
376 | if (queue != null) | 362 | if (queue != null) |
377 | lock (queue) | 363 | lock (queue) |
364 | { | ||
365 | //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count); | ||
378 | return queue.Count > 0; | 366 | return queue.Count > 0; |
367 | } | ||
379 | 368 | ||
380 | return false; | 369 | return false; |
381 | } | 370 | } |
@@ -391,16 +380,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
391 | OSDMap ev = (OSDMap)element; | 380 | OSDMap ev = (OSDMap)element; |
392 | m_log.DebugFormat( | 381 | m_log.DebugFormat( |
393 | "Eq OUT {0,-30} to {1,-20} {2,-20}", | 382 | "Eq OUT {0,-30} to {1,-20} {2,-20}", |
394 | ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.RegionInfo.RegionName); | 383 | ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.Name); |
395 | } | 384 | } |
396 | } | 385 | } |
397 | 386 | ||
398 | public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) | 387 | public Hashtable GetEvents(UUID requestID, UUID pAgentId) |
399 | { | 388 | { |
400 | if (DebugLevel >= 2) | 389 | if (DebugLevel >= 2) |
401 | m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); | 390 | m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.Name); |
391 | |||
392 | Queue<OSD> queue = GetQueue(pAgentId); | ||
393 | if (queue == null) | ||
394 | { | ||
395 | return NoEvents(requestID, pAgentId); | ||
396 | } | ||
402 | 397 | ||
403 | Queue<OSD> queue = TryGetQueue(pAgentId); | ||
404 | OSD element; | 398 | OSD element; |
405 | lock (queue) | 399 | lock (queue) |
406 | { | 400 | { |
@@ -727,34 +721,51 @@ namespace OpenSim.Region.ClientStack.Linden | |||
727 | Enqueue(item, avatarID); | 721 | Enqueue(item, avatarID); |
728 | } | 722 | } |
729 | 723 | ||
730 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID) | 724 | public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) |
731 | { | 725 | { |
732 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint); | 726 | if (DebugLevel > 0) |
727 | m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", | ||
728 | LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); | ||
729 | |||
730 | OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); | ||
733 | Enqueue(item, avatarID); | 731 | Enqueue(item, avatarID); |
734 | } | 732 | } |
735 | 733 | ||
736 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath) | 734 | public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, |
735 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
737 | { | 736 | { |
738 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath); | 737 | if (DebugLevel > 0) |
738 | m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", | ||
739 | LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); | ||
740 | |||
741 | OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); | ||
739 | Enqueue(item, avatarID); | 742 | Enqueue(item, avatarID); |
740 | } | 743 | } |
741 | 744 | ||
742 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, | 745 | public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, |
743 | IPEndPoint regionExternalEndPoint, | 746 | IPEndPoint regionExternalEndPoint, |
744 | uint locationID, uint flags, string capsURL, | 747 | uint locationID, uint flags, string capsURL, |
745 | UUID avatarID) | 748 | UUID avatarID, int regionSizeX, int regionSizeY) |
746 | { | 749 | { |
750 | if (DebugLevel > 0) | ||
751 | m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", | ||
752 | LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); | ||
753 | |||
747 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, | 754 | OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, |
748 | locationID, flags, capsURL, avatarID); | 755 | locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); |
749 | Enqueue(item, avatarID); | 756 | Enqueue(item, avatarID); |
750 | } | 757 | } |
751 | 758 | ||
752 | public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 759 | public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
753 | IPEndPoint newRegionExternalEndPoint, | 760 | IPEndPoint newRegionExternalEndPoint, |
754 | string capsURL, UUID avatarID, UUID sessionID) | 761 | string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) |
755 | { | 762 | { |
763 | if (DebugLevel > 0) | ||
764 | m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", | ||
765 | LogHeader, handle, avatarID, regionSizeX, regionSizeY); | ||
766 | |||
756 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, | 767 | OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, |
757 | capsURL, avatarID, sessionID); | 768 | capsURL, avatarID, sessionID, regionSizeX, regionSizeY); |
758 | Enqueue(item, avatarID); | 769 | Enqueue(item, avatarID); |
759 | } | 770 | } |
760 | 771 | ||
@@ -771,12 +782,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
771 | 782 | ||
772 | } | 783 | } |
773 | 784 | ||
774 | public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, | 785 | public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID anotherAgent, bool canVoiceChat, |
775 | bool isModerator, bool textMute) | 786 | bool isModerator, bool textMute) |
776 | { | 787 | { |
777 | OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat, | 788 | OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat, |
778 | isModerator, textMute); | 789 | isModerator, textMute); |
779 | Enqueue(item, toAgent); | 790 | Enqueue(item, fromAgent); |
780 | //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item); | 791 | //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item); |
781 | } | 792 | } |
782 | 793 | ||
@@ -807,5 +818,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
807 | { | 818 | { |
808 | return EventQueueHelper.BuildEvent(eventName, eventBody); | 819 | return EventQueueHelper.BuildEvent(eventName, eventBody); |
809 | } | 820 | } |
821 | |||
822 | public void partPhysicsProperties(uint localID, byte physhapetype, | ||
823 | float density, float friction, float bounce, float gravmod,UUID avatarID) | ||
824 | { | ||
825 | OSD item = EventQueueHelper.partPhysicsProperties(localID, physhapetype, | ||
826 | density, friction, bounce, gravmod); | ||
827 | Enqueue(item, avatarID); | ||
828 | } | ||
810 | } | 829 | } |
811 | } | 830 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 3f49aba..384af74 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | |||
@@ -70,13 +70,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
70 | return llsdEvent; | 70 | return llsdEvent; |
71 | } | 71 | } |
72 | 72 | ||
73 | public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint) | 73 | public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint, int regionSizeX, int regionSizeY) |
74 | { | 74 | { |
75 | OSDMap llsdSimInfo = new OSDMap(3); | 75 | OSDMap llsdSimInfo = new OSDMap(5); |
76 | 76 | ||
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 | llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint) regionSizeX)); | ||
81 | llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint) regionSizeY)); | ||
80 | 82 | ||
81 | OSDArray arr = new OSDArray(1); | 83 | OSDArray arr = new OSDArray(1); |
82 | arr.Add(llsdSimInfo); | 84 | arr.Add(llsdSimInfo); |
@@ -104,7 +106,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
104 | 106 | ||
105 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, | 107 | public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, |
106 | IPEndPoint newRegionExternalEndPoint, | 108 | IPEndPoint newRegionExternalEndPoint, |
107 | string capsURL, UUID agentID, UUID sessionID) | 109 | string capsURL, UUID agentID, UUID sessionID, |
110 | int regionSizeX, int regionSizeY) | ||
108 | { | 111 | { |
109 | OSDArray lookAtArr = new OSDArray(3); | 112 | OSDArray lookAtArr = new OSDArray(3); |
110 | lookAtArr.Add(OSD.FromReal(lookAt.X)); | 113 | lookAtArr.Add(OSD.FromReal(lookAt.X)); |
@@ -130,11 +133,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
130 | OSDArray agentDataArr = new OSDArray(1); | 133 | OSDArray agentDataArr = new OSDArray(1); |
131 | agentDataArr.Add(agentDataMap); | 134 | agentDataArr.Add(agentDataMap); |
132 | 135 | ||
133 | OSDMap regionDataMap = new OSDMap(4); | 136 | OSDMap regionDataMap = new OSDMap(6); |
134 | regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); | 137 | regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); |
135 | regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); | 138 | regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); |
136 | regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); | 139 | regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); |
137 | regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); | 140 | regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); |
141 | regionDataMap.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); | ||
142 | regionDataMap.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); | ||
138 | 143 | ||
139 | OSDArray regionDataArr = new OSDArray(1); | 144 | OSDArray regionDataArr = new OSDArray(1); |
140 | regionDataArr.Add(regionDataMap); | 145 | regionDataArr.Add(regionDataMap); |
@@ -148,8 +153,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
148 | } | 153 | } |
149 | 154 | ||
150 | public static OSD TeleportFinishEvent( | 155 | public static OSD TeleportFinishEvent( |
151 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, | 156 | ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, |
152 | uint locationID, uint flags, string capsURL, UUID agentID) | 157 | uint locationID, uint flags, string capsURL, UUID agentID, |
158 | int regionSizeX, int regionSizeY) | ||
153 | { | 159 | { |
154 | OSDMap info = new OSDMap(); | 160 | OSDMap info = new OSDMap(); |
155 | info.Add("AgentID", OSD.FromUUID(agentID)); | 161 | info.Add("AgentID", OSD.FromUUID(agentID)); |
@@ -160,6 +166,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
160 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); | 166 | info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); |
161 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); | 167 | info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); |
162 | info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation | 168 | info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation |
169 | info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); | ||
170 | info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); | ||
163 | 171 | ||
164 | OSDArray infoArr = new OSDArray(); | 172 | OSDArray infoArr = new OSDArray(); |
165 | infoArr.Add(info); | 173 | infoArr.Add(info); |
@@ -187,12 +195,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
187 | return BuildEvent("ScriptRunningReply", body); | 195 | return BuildEvent("ScriptRunningReply", body); |
188 | } | 196 | } |
189 | 197 | ||
190 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap) | 198 | public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap, |
199 | ulong regionHandle, int regionSizeX, int regionSizeY) | ||
191 | { | 200 | { |
192 | OSDMap body = new OSDMap(3); | 201 | OSDMap body = new OSDMap(6) |
193 | body.Add("agent-id", new OSDUUID(agentID)); | 202 | { |
194 | body.Add("sim-ip-and-port", new OSDString(simIpAndPort)); | 203 | {"agent-id", new OSDUUID(agentID)}, |
195 | body.Add("seed-capability", new OSDString(seedcap)); | 204 | {"sim-ip-and-port", new OSDString(simIpAndPort)}, |
205 | {"seed-capability", new OSDString(seedcap)}, | ||
206 | {"region-handle", OSD.FromULong(regionHandle)}, | ||
207 | {"region-size-x", OSD.FromInteger(regionSizeX)}, | ||
208 | {"region-size-y", OSD.FromInteger(regionSizeY)} | ||
209 | }; | ||
196 | 210 | ||
197 | return BuildEvent("EstablishAgentCommunication", body); | 211 | return BuildEvent("EstablishAgentCommunication", body); |
198 | } | 212 | } |
@@ -395,5 +409,25 @@ namespace OpenSim.Region.ClientStack.Linden | |||
395 | return message; | 409 | return message; |
396 | } | 410 | } |
397 | 411 | ||
412 | public static OSD partPhysicsProperties(uint localID, byte physhapetype, | ||
413 | float density, float friction, float bounce, float gravmod) | ||
414 | { | ||
415 | |||
416 | OSDMap physinfo = new OSDMap(6); | ||
417 | physinfo["LocalID"] = localID; | ||
418 | physinfo["Density"] = density; | ||
419 | physinfo["Friction"] = friction; | ||
420 | physinfo["GravityMultiplier"] = gravmod; | ||
421 | physinfo["Restitution"] = bounce; | ||
422 | physinfo["PhysicsShapeType"] = (int)physhapetype; | ||
423 | |||
424 | OSDArray array = new OSDArray(1); | ||
425 | array.Add(physinfo); | ||
426 | |||
427 | OSDMap llsdBody = new OSDMap(1); | ||
428 | llsdBody.Add("ObjectData", array); | ||
429 | |||
430 | return BuildEvent("ObjectPhysicsProperties", llsdBody); | ||
431 | } | ||
398 | } | 432 | } |
399 | } | 433 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index ed8ec16..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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Net; | 31 | using System.Net; |
31 | using log4net.Config; | 32 | using log4net.Config; |
@@ -33,13 +34,15 @@ using Nini.Config; | |||
33 | using NUnit.Framework; | 34 | using NUnit.Framework; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenMetaverse.Packets; | 36 | using OpenMetaverse.Packets; |
37 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Servers; | 39 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Region.ClientStack.Linden; | 41 | using OpenSim.Region.ClientStack.Linden; |
40 | using OpenSim.Region.CoreModules.Framework; | 42 | using OpenSim.Region.CoreModules.Framework; |
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
42 | using OpenSim.Tests.Common.Mock; | ||
43 | 46 | ||
44 | namespace OpenSim.Region.ClientStack.Linden.Tests | 47 | namespace OpenSim.Region.ClientStack.Linden.Tests |
45 | { | 48 | { |
@@ -47,10 +50,14 @@ 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 void SetUp() | 57 | public override void SetUp() |
53 | { | 58 | { |
59 | base.SetUp(); | ||
60 | |||
54 | uint port = 9999; | 61 | uint port = 9999; |
55 | uint sslPort = 9998; | 62 | uint sslPort = 9998; |
56 | 63 | ||
@@ -67,14 +74,19 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
67 | config.Configs["Startup"].Set("EventQueue", "true"); | 74 | config.Configs["Startup"].Set("EventQueue", "true"); |
68 | 75 | ||
69 | CapabilitiesModule capsModule = new CapabilitiesModule(); | 76 | CapabilitiesModule capsModule = new CapabilitiesModule(); |
70 | 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(); | ||
71 | 83 | ||
72 | m_scene = new SceneHelpers().SetupScene(); | 84 | m_scene = new SceneHelpers().SetupScene(); |
73 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); | 85 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod); |
74 | } | 86 | } |
75 | 87 | ||
76 | [Test] | 88 | [Test] |
77 | public void AddForClient() | 89 | public void TestAddForClient() |
78 | { | 90 | { |
79 | TestHelpers.InMethod(); | 91 | TestHelpers.InMethod(); |
80 | // log4net.Config.XmlConfigurator.Configure(); | 92 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -86,18 +98,93 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
86 | } | 98 | } |
87 | 99 | ||
88 | [Test] | 100 | [Test] |
89 | public void RemoveForClient() | 101 | public void TestRemoveForClient() |
90 | { | 102 | { |
91 | TestHelpers.InMethod(); | 103 | TestHelpers.InMethod(); |
92 | // log4net.Config.XmlConfigurator.Configure(); | 104 | // TestHelpers.EnableLogging(); |
93 | 105 | ||
94 | UUID spId = TestHelpers.ParseTail(0x1); | 106 | UUID spId = TestHelpers.ParseTail(0x1); |
95 | 107 | ||
96 | SceneHelpers.AddScenePresence(m_scene, spId); | 108 | SceneHelpers.AddScenePresence(m_scene, spId); |
97 | m_scene.IncomingCloseAgent(spId, false); | 109 | m_scene.CloseAgent(spId, false); |
98 | 110 | ||
99 | // TODO: Add more assertions for the other aspects of event queues | 111 | // TODO: Add more assertions for the other aspects of event queues |
100 | Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); | 112 | Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); |
101 | } | 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 | } | ||
102 | } | 189 | } |
103 | } \ 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 | ||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using Mono.Addins; | 28 | using Mono.Addins; |
29 | using Nini.Config; | ||
34 | using OpenMetaverse; | 30 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 31 | using OpenSim.Capabilities.Handlers; |
36 | using OpenSim.Framework.Servers.HttpServer; | 32 | using OpenSim.Framework.Servers.HttpServer; |
37 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
36 | using System; | ||
40 | using Caps = OpenSim.Framework.Capabilities.Caps; | 37 | using Caps = OpenSim.Framework.Capabilities.Caps; |
41 | using OpenSim.Capabilities.Handlers; | ||
42 | 38 | ||
43 | namespace OpenSim.Region.ClientStack.Linden | 39 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Drawing; | ||
32 | using System.Drawing.Imaging; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Web; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using Mono.Addins; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenMetaverse.Imaging; | ||
42 | using OpenSim.Framework; | ||
43 | using OpenSim.Framework.Servers; | ||
44 | using OpenSim.Framework.Servers.HttpServer; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Region.Framework.Scenes; | ||
47 | using OpenSim.Services.Interfaces; | ||
48 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
49 | using OpenSim.Capabilities.Handlers; | ||
50 | |||
51 | namespace 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 8e1f63a..f57d857 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -57,6 +57,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
57 | private IAssetService m_AssetService; | 57 | private IAssetService m_AssetService; |
58 | private bool m_Enabled = true; | 58 | private bool m_Enabled = true; |
59 | private string m_URL; | 59 | private string m_URL; |
60 | private string m_URL2; | ||
61 | private string m_RedirectURL = null; | ||
62 | private string m_RedirectURL2 = null; | ||
60 | 63 | ||
61 | #region Region Module interfaceBase Members | 64 | #region Region Module interfaceBase Members |
62 | 65 | ||
@@ -74,7 +77,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
74 | m_URL = config.GetString("Cap_GetMesh", string.Empty); | 77 | m_URL = config.GetString("Cap_GetMesh", string.Empty); |
75 | // Cap doesn't exist | 78 | // Cap doesn't exist |
76 | if (m_URL != string.Empty) | 79 | if (m_URL != string.Empty) |
80 | { | ||
81 | m_Enabled = true; | ||
82 | m_RedirectURL = config.GetString("GetMeshRedirectURL"); | ||
83 | } | ||
84 | |||
85 | m_URL2 = config.GetString("Cap_GetMesh2", string.Empty); | ||
86 | // Cap doesn't exist | ||
87 | if (m_URL2 != string.Empty) | ||
88 | { | ||
77 | m_Enabled = true; | 89 | m_Enabled = true; |
90 | m_RedirectURL2 = config.GetString("GetMesh2RedirectURL"); | ||
91 | } | ||
78 | } | 92 | } |
79 | 93 | ||
80 | public void AddRegion(Scene pScene) | 94 | public void AddRegion(Scene pScene) |
@@ -113,28 +127,42 @@ namespace OpenSim.Region.ClientStack.Linden | |||
113 | 127 | ||
114 | public void RegisterCaps(UUID agentID, Caps caps) | 128 | public void RegisterCaps(UUID agentID, Caps caps) |
115 | { | 129 | { |
116 | // UUID capID = UUID.Random(); | 130 | UUID capID = UUID.Random(); |
131 | bool getMeshRegistered = false; | ||
117 | 132 | ||
118 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | 133 | if (m_URL == string.Empty) |
119 | if (m_URL == "localhost") | 134 | { |
135 | |||
136 | } | ||
137 | else if (m_URL == "localhost") | ||
120 | { | 138 | { |
121 | // m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | 139 | getMeshRegistered = true; |
122 | GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); | 140 | caps.RegisterHandler( |
123 | IRequestHandler reqHandler | 141 | "GetMesh", |
124 | = new RestHTTPHandler( | 142 | new GetMeshHandler("/CAPS/" + capID + "/", m_AssetService, "GetMesh", agentID.ToString(), m_RedirectURL)); |
125 | "GET", | ||
126 | "/CAPS/" + UUID.Random(), | ||
127 | httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null), | ||
128 | "GetMesh", | ||
129 | agentID.ToString()); | ||
130 | |||
131 | caps.RegisterHandler("GetMesh", reqHandler); | ||
132 | } | 143 | } |
133 | else | 144 | else |
134 | { | 145 | { |
135 | // m_log.DebugFormat("[GETMESH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | ||
136 | caps.RegisterHandler("GetMesh", m_URL); | 146 | caps.RegisterHandler("GetMesh", m_URL); |
137 | } | 147 | } |
148 | |||
149 | if(m_URL2 == string.Empty) | ||
150 | { | ||
151 | |||
152 | } | ||
153 | else if (m_URL2 == "localhost") | ||
154 | { | ||
155 | if (!getMeshRegistered) | ||
156 | { | ||
157 | caps.RegisterHandler( | ||
158 | "GetMesh2", | ||
159 | new GetMeshHandler("/CAPS/" + capID + "/", m_AssetService, "GetMesh2", agentID.ToString(), m_RedirectURL2)); | ||
160 | } | ||
161 | } | ||
162 | else | ||
163 | { | ||
164 | caps.RegisterHandler("GetMesh2", m_URL2); | ||
165 | } | ||
138 | } | 166 | } |
139 | 167 | ||
140 | } | 168 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 13415f8..bb932f2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
63 | private bool m_Enabled = false; | 63 | private bool m_Enabled = false; |
64 | 64 | ||
65 | // TODO: Change this to a config option | 65 | // TODO: Change this to a config option |
66 | const string REDIRECT_URL = null; | 66 | private string m_RedirectURL = null; |
67 | 67 | ||
68 | private string m_URL; | 68 | private string m_URL; |
69 | 69 | ||
@@ -78,7 +78,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
78 | m_URL = config.GetString("Cap_GetTexture", string.Empty); | 78 | m_URL = config.GetString("Cap_GetTexture", string.Empty); |
79 | // Cap doesn't exist | 79 | // Cap doesn't exist |
80 | if (m_URL != string.Empty) | 80 | if (m_URL != string.Empty) |
81 | { | ||
81 | m_Enabled = true; | 82 | m_Enabled = true; |
83 | m_RedirectURL = config.GetString("GetTextureRedirectURL"); | ||
84 | } | ||
82 | } | 85 | } |
83 | 86 | ||
84 | public void AddRegion(Scene s) | 87 | public void AddRegion(Scene s) |
@@ -132,12 +135,16 @@ namespace OpenSim.Region.ClientStack.Linden | |||
132 | // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | 135 | // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); |
133 | caps.RegisterHandler( | 136 | caps.RegisterHandler( |
134 | "GetTexture", | 137 | "GetTexture", |
135 | new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString())); | 138 | new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString(), m_RedirectURL)); |
136 | } | 139 | } |
137 | else | 140 | else |
138 | { | 141 | { |
139 | // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | 142 | // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); |
140 | caps.RegisterHandler("GetTexture", m_URL); | 143 | IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); |
144 | if (handler != null) | ||
145 | handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture", m_URL); | ||
146 | else | ||
147 | caps.RegisterHandler("GetTexture", m_URL); | ||
141 | } | 148 | } |
142 | } | 149 | } |
143 | 150 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs index 33b1f77..45d33cd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs | |||
@@ -57,7 +57,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
57 | public bool Enabled { get; private set; } | 57 | public bool Enabled { get; private set; } |
58 | 58 | ||
59 | private Scene m_scene; | 59 | private Scene m_scene; |
60 | private UUID m_agentID; | ||
61 | 60 | ||
62 | #region ISharedRegionModule Members | 61 | #region ISharedRegionModule Members |
63 | 62 | ||
@@ -118,25 +117,26 @@ namespace OpenSim.Region.ClientStack.Linden | |||
118 | public void RegisterCaps(UUID agentID, Caps caps) | 117 | public void RegisterCaps(UUID agentID, Caps caps) |
119 | { | 118 | { |
120 | IRequestHandler reqHandler | 119 | IRequestHandler reqHandler |
121 | = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), MeshUploadFlag, "MeshUploadFlag", agentID.ToString()); | 120 | = new RestHTTPHandler( |
121 | "GET", "/CAPS/" + UUID.Random(), ht => MeshUploadFlag(ht, agentID), "MeshUploadFlag", agentID.ToString()); | ||
122 | 122 | ||
123 | caps.RegisterHandler("MeshUploadFlag", reqHandler); | 123 | caps.RegisterHandler("MeshUploadFlag", reqHandler); |
124 | m_agentID = agentID; | 124 | |
125 | } | 125 | } |
126 | 126 | ||
127 | private Hashtable MeshUploadFlag(Hashtable mDhttpMethod) | 127 | private Hashtable MeshUploadFlag(Hashtable mDhttpMethod, UUID agentID) |
128 | { | 128 | { |
129 | // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); | 129 | // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); |
130 | 130 | ||
131 | OSDMap data = new OSDMap(); | 131 | OSDMap data = new OSDMap(); |
132 | ScenePresence sp = m_scene.GetScenePresence(m_agentID); | 132 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
133 | data["username"] = sp.Firstname + "." + sp.Lastname; | 133 | data["username"] = sp.Firstname + "." + sp.Lastname; |
134 | data["display_name_next_update"] = new OSDDate(DateTime.Now); | 134 | data["display_name_next_update"] = new OSDDate(DateTime.Now); |
135 | data["legacy_first_name"] = sp.Firstname; | 135 | data["legacy_first_name"] = sp.Firstname; |
136 | data["mesh_upload_status"] = "valid"; | 136 | data["mesh_upload_status"] = "valid"; |
137 | data["display_name"] = sp.Firstname + " " + sp.Lastname; | 137 | data["display_name"] = sp.Firstname + " " + sp.Lastname; |
138 | data["legacy_last_name"] = sp.Lastname; | 138 | data["legacy_last_name"] = sp.Lastname; |
139 | data["id"] = m_agentID; | 139 | data["id"] = agentID; |
140 | data["is_display_name_default"] = true; | 140 | data["is_display_name_default"] = true; |
141 | 141 | ||
142 | //Send back data | 142 | //Send back data |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index 5529550..f69a0bb 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs | |||
@@ -44,6 +44,7 @@ using OpenSim.Region.Framework.Scenes; | |||
44 | using OpenSim.Services.Interfaces; | 44 | using OpenSim.Services.Interfaces; |
45 | using Caps = OpenSim.Framework.Capabilities.Caps; | 45 | using Caps = OpenSim.Framework.Capabilities.Caps; |
46 | using OpenSim.Framework.Capabilities; | 46 | using OpenSim.Framework.Capabilities; |
47 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
47 | 48 | ||
48 | namespace OpenSim.Region.ClientStack.Linden | 49 | namespace OpenSim.Region.ClientStack.Linden |
49 | { | 50 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs index 92805e2..94f8bc1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs | |||
@@ -155,6 +155,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
155 | Quaternion rotation = Quaternion.Identity; | 155 | Quaternion rotation = Quaternion.Identity; |
156 | Vector3 scale = Vector3.Zero; | 156 | Vector3 scale = Vector3.Zero; |
157 | int state = 0; | 157 | int state = 0; |
158 | int lastattach = 0; | ||
158 | 159 | ||
159 | if (r.Type != OSDType.Map) // not a proper req | 160 | if (r.Type != OSDType.Map) // not a proper req |
160 | return responsedata; | 161 | return responsedata; |
@@ -224,6 +225,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
224 | 225 | ||
225 | ray_target_id = ObjMap["RayTargetId"].AsUUID(); | 226 | ray_target_id = ObjMap["RayTargetId"].AsUUID(); |
226 | state = ObjMap["State"].AsInteger(); | 227 | state = ObjMap["State"].AsInteger(); |
228 | lastattach = ObjMap["LastAttachPoint"].AsInteger(); | ||
227 | try | 229 | try |
228 | { | 230 | { |
229 | ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3(); | 231 | ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3(); |
@@ -290,6 +292,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
290 | 292 | ||
291 | //session_id = rm["session_id"].AsUUID(); | 293 | //session_id = rm["session_id"].AsUUID(); |
292 | state = rm["state"].AsInteger(); | 294 | state = rm["state"].AsInteger(); |
295 | lastattach = rm["last_attach_point"].AsInteger(); | ||
293 | try | 296 | try |
294 | { | 297 | { |
295 | ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); | 298 | ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); |
@@ -331,6 +334,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
331 | pbs.ProfileEnd = (ushort)profile_end; | 334 | pbs.ProfileEnd = (ushort)profile_end; |
332 | pbs.Scale = scale; | 335 | pbs.Scale = scale; |
333 | pbs.State = (byte)state; | 336 | pbs.State = (byte)state; |
337 | pbs.LastAttachPoint = (byte)lastattach; | ||
334 | 338 | ||
335 | SceneObjectGroup obj = null; ; | 339 | SceneObjectGroup obj = null; ; |
336 | 340 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index 55a503e..769fe28 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs | |||
@@ -277,6 +277,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
277 | pbs.ProfileEnd = (ushort) obj.ProfileEnd; | 277 | pbs.ProfileEnd = (ushort) obj.ProfileEnd; |
278 | pbs.Scale = obj.Scale; | 278 | pbs.Scale = obj.Scale; |
279 | pbs.State = (byte) 0; | 279 | pbs.State = (byte) 0; |
280 | pbs.LastAttachPoint = (byte) 0; | ||
280 | SceneObjectPart prim = new SceneObjectPart(); | 281 | SceneObjectPart prim = new SceneObjectPart(); |
281 | prim.UUID = UUID.Random(); | 282 | prim.UUID = UUID.Random(); |
282 | prim.CreatorID = AgentId; | 283 | prim.CreatorID = AgentId; |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs index 060a61c..0adfa1a 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.7.5.*")] | 32 | [assembly: AssemblyVersion("0.8.3.*")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs index 17c7270..a133a69 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs | |||
@@ -56,8 +56,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionConsoleModule")] | 56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionConsoleModule")] |
57 | public class RegionConsoleModule : INonSharedRegionModule, IRegionConsole | 57 | public class RegionConsoleModule : INonSharedRegionModule, IRegionConsole |
58 | { | 58 | { |
59 | private static readonly ILog m_log = | 59 | // private static readonly ILog m_log = |
60 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
61 | 61 | ||
62 | private Scene m_scene; | 62 | private Scene m_scene; |
63 | private IEventQueue m_eventQueue; | 63 | private IEventQueue m_eventQueue; |
@@ -157,8 +157,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
157 | 157 | ||
158 | public class ConsoleHandler : BaseStreamHandler | 158 | public class ConsoleHandler : BaseStreamHandler |
159 | { | 159 | { |
160 | private static readonly ILog m_log = | 160 | // private static readonly ILog m_log = |
161 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 161 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
162 | 162 | ||
163 | private RegionConsoleModule m_consoleModule; | 163 | private RegionConsoleModule m_consoleModule; |
164 | private UUID m_agentID; | 164 | private UUID m_agentID; |
@@ -176,7 +176,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
176 | m_isGod = m_scene.Permissions.IsGod(agentID); | 176 | m_isGod = m_scene.Permissions.IsGod(agentID); |
177 | } | 177 | } |
178 | 178 | ||
179 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 179 | protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
180 | { | 180 | { |
181 | StreamReader reader = new StreamReader(request); | 181 | StreamReader reader = new StreamReader(request); |
182 | string message = reader.ReadToEnd(); | 182 | string message = reader.ReadToEnd(); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 191bccf..e258bcb 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using log4net; | 32 | using log4net; |
32 | using Nini.Config; | 33 | using Nini.Config; |
@@ -37,7 +38,7 @@ using OpenSim.Framework; | |||
37 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Services.Interfaces; | 41 | // using OpenSim.Services.Interfaces; |
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | 42 | using Caps = OpenSim.Framework.Capabilities.Caps; |
42 | 43 | ||
43 | namespace OpenSim.Region.ClientStack.Linden | 44 | namespace OpenSim.Region.ClientStack.Linden |
@@ -56,8 +57,10 @@ 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); |
62 | |||
63 | public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; | ||
61 | 64 | ||
62 | private Scene m_scene; | 65 | private Scene m_scene; |
63 | 66 | ||
@@ -66,25 +69,40 @@ namespace OpenSim.Region.ClientStack.Linden | |||
66 | /// </summary> | 69 | /// </summary> |
67 | private OSDMap m_features = new OSDMap(); | 70 | private OSDMap m_features = new OSDMap(); |
68 | 71 | ||
69 | private string m_MapImageServerURL = string.Empty; | ||
70 | private string m_SearchURL = string.Empty; | 72 | private string m_SearchURL = string.Empty; |
73 | private string m_DestinationGuideURL = string.Empty; | ||
74 | private bool m_ExportSupported = false; | ||
75 | private string m_GridName = string.Empty; | ||
76 | private string m_GridURL = string.Empty; | ||
71 | 77 | ||
72 | #region ISharedRegionModule Members | 78 | #region ISharedRegionModule Members |
73 | 79 | ||
74 | public void Initialise(IConfigSource source) | 80 | public void Initialise(IConfigSource source) |
75 | { | 81 | { |
76 | IConfig config = source.Configs["SimulatorFeatures"]; | 82 | IConfig config = source.Configs["SimulatorFeatures"]; |
83 | |||
77 | if (config != null) | 84 | if (config != null) |
78 | { | 85 | { |
79 | m_MapImageServerURL = config.GetString("MapImageServerURI", string.Empty); | 86 | // |
80 | if (m_MapImageServerURL != string.Empty) | 87 | // All this is obsolete since getting these features from the grid service!! |
81 | { | 88 | // Will be removed after the next release |
82 | m_MapImageServerURL = m_MapImageServerURL.Trim(); | 89 | // |
83 | if (!m_MapImageServerURL.EndsWith("/")) | 90 | m_SearchURL = config.GetString("SearchServerURI", m_SearchURL); |
84 | m_MapImageServerURL = m_MapImageServerURL + "/"; | 91 | |
85 | } | 92 | m_DestinationGuideURL = config.GetString ("DestinationGuideURI", m_DestinationGuideURL); |
86 | 93 | ||
87 | m_SearchURL = config.GetString("SearchServerURI", string.Empty); | 94 | if (m_DestinationGuideURL == string.Empty) // Make this consistent with the variable in the LoginService config |
95 | m_DestinationGuideURL = config.GetString("DestinationGuide", m_DestinationGuideURL); | ||
96 | |||
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); | ||
88 | } | 106 | } |
89 | 107 | ||
90 | AddDefaultFeatures(); | 108 | AddDefaultFeatures(); |
@@ -94,6 +112,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
94 | { | 112 | { |
95 | m_scene = s; | 113 | m_scene = s; |
96 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 114 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
115 | |||
116 | m_scene.RegisterModuleInterface<ISimulatorFeaturesModule>(this); | ||
97 | } | 117 | } |
98 | 118 | ||
99 | public void RemoveRegion(Scene s) | 119 | public void RemoveRegion(Scene s) |
@@ -103,6 +123,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
103 | 123 | ||
104 | public void RegionLoaded(Scene s) | 124 | public void RegionLoaded(Scene s) |
105 | { | 125 | { |
126 | GetGridExtraFeatures(s); | ||
106 | } | 127 | } |
107 | 128 | ||
108 | public void PostInitialise() | 129 | public void PostInitialise() |
@@ -128,26 +149,43 @@ namespace OpenSim.Region.ClientStack.Linden | |||
128 | /// </remarks> | 149 | /// </remarks> |
129 | private void AddDefaultFeatures() | 150 | private void AddDefaultFeatures() |
130 | { | 151 | { |
152 | |||
131 | lock (m_features) | 153 | lock (m_features) |
132 | { | 154 | { |
133 | m_features["MeshRezEnabled"] = true; | 155 | m_features["MeshRezEnabled"] = true; |
134 | m_features["MeshUploadEnabled"] = true; | 156 | m_features["MeshUploadEnabled"] = true; |
135 | m_features["MeshXferEnabled"] = true; | 157 | m_features["MeshXferEnabled"] = true; |
136 | m_features["PhysicsMaterialsEnabled"] = true; | 158 | m_features["PhysicsMaterialsEnabled"] = true; |
137 | 159 | ||
138 | OSDMap typesMap = new OSDMap(); | 160 | OSDMap typesMap = new OSDMap(); |
139 | typesMap["convex"] = true; | 161 | typesMap["convex"] = true; |
140 | typesMap["none"] = true; | 162 | typesMap["none"] = true; |
141 | typesMap["prim"] = true; | 163 | typesMap["prim"] = true; |
142 | m_features["PhysicsShapeTypes"] = typesMap; | 164 | m_features["PhysicsShapeTypes"] = typesMap; |
143 | 165 | ||
144 | // Extra information for viewers that want to use it | 166 | // Extra information for viewers that want to use it |
145 | OSDMap gridServicesMap = new OSDMap(); | 167 | // TODO: Take these out of here into their respective modules, like map-server-url |
146 | if (m_MapImageServerURL != string.Empty) | 168 | OSDMap extrasMap; |
147 | gridServicesMap["map-server-url"] = m_MapImageServerURL; | 169 | if(m_features.ContainsKey("OpenSimExtras")) |
170 | { | ||
171 | extrasMap = (OSDMap)m_features["OpenSimExtras"]; | ||
172 | } | ||
173 | else | ||
174 | extrasMap = new OSDMap(); | ||
175 | |||
148 | if (m_SearchURL != string.Empty) | 176 | if (m_SearchURL != string.Empty) |
149 | gridServicesMap["search"] = m_SearchURL; | 177 | extrasMap["search-server-url"] = m_SearchURL; |
150 | m_features["GridServices"] = gridServicesMap; | 178 | if (!string.IsNullOrEmpty(m_DestinationGuideURL)) |
179 | extrasMap["destination-guide-url"] = m_DestinationGuideURL; | ||
180 | if (m_ExportSupported) | ||
181 | extrasMap["ExportSupported"] = true; | ||
182 | if (m_GridURL != string.Empty) | ||
183 | extrasMap["GridURL"] = m_GridURL; | ||
184 | if (m_GridName != string.Empty) | ||
185 | extrasMap["GridName"] = m_GridName; | ||
186 | |||
187 | if (extrasMap.Count > 0) | ||
188 | m_features["OpenSimExtras"] = extrasMap; | ||
151 | } | 189 | } |
152 | } | 190 | } |
153 | 191 | ||
@@ -156,7 +194,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
156 | IRequestHandler reqHandler | 194 | IRequestHandler reqHandler |
157 | = new RestHTTPHandler( | 195 | = new RestHTTPHandler( |
158 | "GET", "/CAPS/" + UUID.Random(), | 196 | "GET", "/CAPS/" + UUID.Random(), |
159 | HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString()); | 197 | x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString()); |
160 | 198 | ||
161 | caps.RegisterHandler("SimulatorFeatures", reqHandler); | 199 | caps.RegisterHandler("SimulatorFeatures", reqHandler); |
162 | } | 200 | } |
@@ -185,20 +223,81 @@ namespace OpenSim.Region.ClientStack.Linden | |||
185 | return new OSDMap(m_features); | 223 | return new OSDMap(m_features); |
186 | } | 224 | } |
187 | 225 | ||
188 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) | 226 | private OSDMap DeepCopy() |
227 | { | ||
228 | // This isn't the cheapest way of doing this but the rate | ||
229 | // of occurrence is low (on sim entry only) and it's a sure | ||
230 | // way to get a true deep copy. | ||
231 | OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features)); | ||
232 | |||
233 | return (OSDMap)copy; | ||
234 | } | ||
235 | |||
236 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID) | ||
189 | { | 237 | { |
190 | // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); | 238 | // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); |
191 | 239 | ||
240 | OSDMap copy = DeepCopy(); | ||
241 | |||
242 | // Let's add the agentID to the destination guide, if it is expecting that. | ||
243 | if (copy.ContainsKey("OpenSimExtras") && ((OSDMap)(copy["OpenSimExtras"])).ContainsKey("destination-guide-url")) | ||
244 | ((OSDMap)copy["OpenSimExtras"])["destination-guide-url"] = Replace(((OSDMap)copy["OpenSimExtras"])["destination-guide-url"], "[USERID]", agentID.ToString()); | ||
245 | |||
246 | SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; | ||
247 | |||
248 | if (handlerOnSimulatorFeaturesRequest != null) | ||
249 | handlerOnSimulatorFeaturesRequest(agentID, ref copy); | ||
250 | |||
192 | //Send back data | 251 | //Send back data |
193 | Hashtable responsedata = new Hashtable(); | 252 | Hashtable responsedata = new Hashtable(); |
194 | responsedata["int_response_code"] = 200; | 253 | responsedata["int_response_code"] = 200; |
195 | responsedata["content_type"] = "text/plain"; | 254 | responsedata["content_type"] = "text/plain"; |
196 | responsedata["keepalive"] = false; | 255 | responsedata["keepalive"] = false; |
197 | 256 | ||
198 | lock (m_features) | 257 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy); |
199 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); | ||
200 | 258 | ||
201 | return responsedata; | 259 | return responsedata; |
202 | } | 260 | } |
261 | |||
262 | /// <summary> | ||
263 | /// Gets the grid extra features. | ||
264 | /// </summary> | ||
265 | /// <param name='featuresURI'> | ||
266 | /// The URI Robust uses to handle the get_extra_features request | ||
267 | /// </param> | ||
268 | private void GetGridExtraFeatures(Scene scene) | ||
269 | { | ||
270 | Dictionary<string, object> extraFeatures = scene.GridService.GetExtraFeatures(); | ||
271 | if (extraFeatures.ContainsKey("Result") && extraFeatures["Result"] != null && extraFeatures["Result"].ToString() == "Failure") | ||
272 | { | ||
273 | m_log.WarnFormat("[SIMULATOR FEATURES MODULE]: Unable to retrieve grid-wide features"); | ||
274 | return; | ||
275 | } | ||
276 | |||
277 | lock (m_features) | ||
278 | { | ||
279 | OSDMap extrasMap = new OSDMap(); | ||
280 | |||
281 | foreach(string key in extraFeatures.Keys) | ||
282 | { | ||
283 | extrasMap[key] = (string)extraFeatures[key]; | ||
284 | |||
285 | if (key == "ExportSupported") | ||
286 | { | ||
287 | bool.TryParse(extraFeatures[key].ToString(), out m_ExportSupported); | ||
288 | } | ||
289 | } | ||
290 | m_features["OpenSimExtras"] = extrasMap; | ||
291 | |||
292 | } | ||
293 | } | ||
294 | |||
295 | private string Replace(string url, string substring, string replacement) | ||
296 | { | ||
297 | if (!String.IsNullOrEmpty(url) && url.Contains(substring)) | ||
298 | return url.Replace(substring, replacement); | ||
299 | |||
300 | return url; | ||
301 | } | ||
203 | } | 302 | } |
204 | } | 303 | } |
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Net; | ||
33 | using System.Text; | ||
34 | using HttpServer; | ||
35 | using log4net.Config; | ||
36 | using Nini.Config; | ||
37 | using NUnit.Framework; | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.Packets; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Capabilities; | ||
43 | using OpenSim.Framework.Servers; | ||
44 | using OpenSim.Framework.Servers.HttpServer; | ||
45 | using OpenSim.Region.ClientStack.Linden; | ||
46 | using OpenSim.Region.CoreModules.Framework; | ||
47 | using OpenSim.Region.Framework.Scenes; | ||
48 | using OpenSim.Services.Interfaces; | ||
49 | using OpenSim.Tests.Common; | ||
50 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
52 | |||
53 | namespace 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 3b0ccd7..8cdebcd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | 31 | using System.Collections.Specialized; |
31 | using System.Drawing; | 32 | using System.Drawing; |
32 | using System.Drawing.Imaging; | 33 | using System.Drawing.Imaging; |
@@ -53,8 +54,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] | 54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] |
54 | public class UploadBakedTextureModule : INonSharedRegionModule | 55 | public class UploadBakedTextureModule : INonSharedRegionModule |
55 | { | 56 | { |
56 | // private static readonly ILog m_log = | 57 | private static readonly ILog m_log = |
57 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
58 | 59 | ||
59 | /// <summary> | 60 | /// <summary> |
60 | /// For historical reasons this is fixed, but there | 61 | /// For historical reasons this is fixed, but there |
@@ -64,31 +65,210 @@ namespace OpenSim.Region.ClientStack.Linden | |||
64 | private Scene m_scene; | 65 | private Scene m_scene; |
65 | private bool m_persistBakedTextures; | 66 | private bool m_persistBakedTextures; |
66 | 67 | ||
68 | private IBakedTextureModule m_BakedTextureModule; | ||
69 | |||
67 | public void Initialise(IConfigSource source) | 70 | public void Initialise(IConfigSource source) |
68 | { | 71 | { |
69 | IConfig appearanceConfig = source.Configs["Appearance"]; | 72 | IConfig appearanceConfig = source.Configs["Appearance"]; |
70 | if (appearanceConfig != null) | 73 | if (appearanceConfig != null) |
71 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); | 74 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); |
75 | |||
76 | |||
72 | } | 77 | } |
73 | 78 | ||
74 | public void AddRegion(Scene s) | 79 | public void AddRegion(Scene s) |
75 | { | 80 | { |
76 | m_scene = s; | 81 | m_scene = s; |
82 | |||
77 | } | 83 | } |
78 | 84 | ||
79 | public void RemoveRegion(Scene s) | 85 | public void RemoveRegion(Scene s) |
80 | { | 86 | { |
87 | s.EventManager.OnRegisterCaps -= RegisterCaps; | ||
88 | s.EventManager.OnNewPresence -= RegisterNewPresence; | ||
89 | s.EventManager.OnRemovePresence -= DeRegisterPresence; | ||
90 | m_BakedTextureModule = null; | ||
91 | m_scene = null; | ||
81 | } | 92 | } |
82 | 93 | ||
94 | |||
95 | |||
83 | public void RegionLoaded(Scene s) | 96 | public void RegionLoaded(Scene s) |
84 | { | 97 | { |
85 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 98 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
99 | m_scene.EventManager.OnNewPresence += RegisterNewPresence; | ||
100 | m_scene.EventManager.OnRemovePresence += DeRegisterPresence; | ||
101 | |||
102 | } | ||
103 | |||
104 | private void DeRegisterPresence(UUID agentId) | ||
105 | { | ||
106 | ScenePresence presence = null; | ||
107 | if (m_scene.TryGetScenePresence(agentId, out presence)) | ||
108 | { | ||
109 | presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; | ||
110 | } | ||
111 | |||
112 | } | ||
113 | |||
114 | private void RegisterNewPresence(ScenePresence presence) | ||
115 | { | ||
116 | presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; | ||
117 | |||
118 | } | ||
119 | |||
120 | private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) | ||
121 | { | ||
122 | int maxCacheitemsLoop = cacheItems.Length; | ||
123 | if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) | ||
124 | { | ||
125 | maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; | ||
126 | m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); | ||
127 | } | ||
128 | |||
129 | m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
130 | if (cacheItems.Length > 0) | ||
131 | { | ||
132 | // m_log.Debug("[Cacheitems]: " + cacheItems.Length); | ||
133 | // for (int iter = 0; iter < maxCacheitemsLoop; iter++) | ||
134 | // { | ||
135 | // m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + | ||
136 | // cacheItems[iter].TextureID); | ||
137 | // } | ||
138 | |||
139 | ScenePresence p = null; | ||
140 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) | ||
141 | { | ||
142 | |||
143 | WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; | ||
144 | if (existingitems == null) | ||
145 | { | ||
146 | if (m_BakedTextureModule != null) | ||
147 | { | ||
148 | WearableCacheItem[] savedcache = null; | ||
149 | try | ||
150 | { | ||
151 | if (p.Appearance.WearableCacheItemsDirty) | ||
152 | { | ||
153 | savedcache = m_BakedTextureModule.Get(p.UUID); | ||
154 | p.Appearance.WearableCacheItems = savedcache; | ||
155 | p.Appearance.WearableCacheItemsDirty = false; | ||
156 | } | ||
157 | |||
158 | } | ||
159 | /* | ||
160 | * The following Catch types DO NOT WORK with m_BakedTextureModule.Get | ||
161 | * it jumps to the General Packet Exception Handler if you don't catch Exception! | ||
162 | * | ||
163 | catch (System.Net.Sockets.SocketException) | ||
164 | { | ||
165 | cacheItems = null; | ||
166 | } | ||
167 | catch (WebException) | ||
168 | { | ||
169 | cacheItems = null; | ||
170 | } | ||
171 | catch (InvalidOperationException) | ||
172 | { | ||
173 | cacheItems = null; | ||
174 | } */ | ||
175 | catch (Exception) | ||
176 | { | ||
177 | // The service logs a sufficient error message. | ||
178 | } | ||
179 | |||
180 | |||
181 | if (savedcache != null) | ||
182 | existingitems = savedcache; | ||
183 | } | ||
184 | } | ||
185 | // Existing items null means it's a fully new appearance | ||
186 | if (existingitems == null) | ||
187 | { | ||
188 | |||
189 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
190 | { | ||
191 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
192 | { | ||
193 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex]; | ||
194 | if (face == null) | ||
195 | { | ||
196 | textureEntry.CreateFace(cacheItems[i].TextureIndex); | ||
197 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID = | ||
198 | AppearanceManager.DEFAULT_AVATAR_TEXTURE; | ||
199 | continue; | ||
200 | } | ||
201 | cacheItems[i].TextureID =face.TextureID; | ||
202 | if (m_scene.AssetService != null) | ||
203 | cacheItems[i].TextureAsset = | ||
204 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | 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); | ||
209 | } | ||
210 | |||
211 | |||
212 | } | ||
213 | } | ||
214 | else | ||
215 | |||
216 | |||
217 | { | ||
218 | // for each uploaded baked texture | ||
219 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
220 | { | ||
221 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
222 | { | ||
223 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex]; | ||
224 | if (face == null) | ||
225 | { | ||
226 | textureEntry.CreateFace(cacheItems[i].TextureIndex); | ||
227 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID = | ||
228 | AppearanceManager.DEFAULT_AVATAR_TEXTURE; | ||
229 | continue; | ||
230 | } | ||
231 | cacheItems[i].TextureID = | ||
232 | face.TextureID; | ||
233 | } | ||
234 | else | ||
235 | { | ||
236 | 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); | ||
237 | } | ||
238 | } | ||
239 | |||
240 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
241 | { | ||
242 | if (cacheItems[i].TextureAsset == null) | ||
243 | { | ||
244 | cacheItems[i].TextureAsset = | ||
245 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | |||
250 | |||
251 | |||
252 | p.Appearance.WearableCacheItems = cacheItems; | ||
253 | |||
254 | |||
255 | |||
256 | if (m_BakedTextureModule != null) | ||
257 | { | ||
258 | m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); | ||
259 | p.Appearance.WearableCacheItemsDirty = true; | ||
260 | |||
261 | } | ||
262 | } | ||
263 | } | ||
86 | } | 264 | } |
87 | 265 | ||
88 | public void PostInitialise() | 266 | public void PostInitialise() |
89 | { | 267 | { |
90 | } | 268 | } |
91 | 269 | ||
270 | |||
271 | |||
92 | public void Close() { } | 272 | public void Close() { } |
93 | 273 | ||
94 | public string Name { get { return "UploadBakedTextureModule"; } } | 274 | public string Name { get { return "UploadBakedTextureModule"; } } |
@@ -100,15 +280,23 @@ namespace OpenSim.Region.ClientStack.Linden | |||
100 | 280 | ||
101 | public void RegisterCaps(UUID agentID, Caps caps) | 281 | public void RegisterCaps(UUID agentID, Caps caps) |
102 | { | 282 | { |
283 | UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler( | ||
284 | caps, m_scene.AssetService, m_persistBakedTextures); | ||
285 | |||
286 | |||
287 | |||
103 | caps.RegisterHandler( | 288 | caps.RegisterHandler( |
104 | "UploadBakedTexture", | 289 | "UploadBakedTexture", |
105 | new RestStreamHandler( | 290 | new RestStreamHandler( |
106 | "POST", | 291 | "POST", |
107 | "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, | 292 | "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, |
108 | new UploadBakedTextureHandler( | 293 | avatarhandler.UploadBakedTexture, |
109 | caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture, | ||
110 | "UploadBakedTexture", | 294 | "UploadBakedTexture", |
111 | agentID.ToString())); | 295 | agentID.ToString())); |
296 | |||
297 | |||
298 | |||
299 | |||
112 | } | 300 | } |
113 | } | 301 | } |
114 | } \ No newline at end of file | 302 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 6890f4a..025ffea 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -27,15 +27,21 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | ||
31 | using log4net; | 33 | using log4net; |
32 | using Nini.Config; | 34 | using Nini.Config; |
33 | using Mono.Addins; | 35 | using Mono.Addins; |
34 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | ||
35 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Monitoring; | ||
40 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | 41 | using OpenSim.Framework.Servers.HttpServer; |
37 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Framework.Capabilities; | ||
39 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
40 | using Caps = OpenSim.Framework.Capabilities.Caps; | 46 | using Caps = OpenSim.Framework.Capabilities.Caps; |
41 | using OpenSim.Capabilities.Handlers; | 47 | using OpenSim.Capabilities.Handlers; |
@@ -48,9 +54,37 @@ namespace OpenSim.Region.ClientStack.Linden | |||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] | 54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] |
49 | public class WebFetchInvDescModule : INonSharedRegionModule | 55 | public class WebFetchInvDescModule : INonSharedRegionModule |
50 | { | 56 | { |
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | class aPollRequest |
58 | { | ||
59 | public PollServiceInventoryEventArgs thepoll; | ||
60 | public UUID reqID; | ||
61 | public Hashtable request; | ||
62 | public ScenePresence presence; | ||
63 | public List<UUID> folders; | ||
64 | } | ||
65 | |||
66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
67 | |||
68 | /// <summary> | ||
69 | /// Control whether requests will be processed asynchronously. | ||
70 | /// </summary> | ||
71 | /// <remarks> | ||
72 | /// Defaults to true. Can currently not be changed once a region has been added to the module. | ||
73 | /// </remarks> | ||
74 | public bool ProcessQueuedRequestsAsync { get; private set; } | ||
52 | 75 | ||
53 | private Scene m_scene; | 76 | /// <summary> |
77 | /// Number of inventory requests processed by this module. | ||
78 | /// </summary> | ||
79 | /// <remarks> | ||
80 | /// It's the PollServiceRequestManager that actually sends completed requests back to the requester. | ||
81 | /// </remarks> | ||
82 | public static int ProcessedRequestsCount { get; set; } | ||
83 | |||
84 | private static Stat s_queuedRequestsStat; | ||
85 | private static Stat s_processedRequestsStat; | ||
86 | |||
87 | public Scene Scene { get; private set; } | ||
54 | 88 | ||
55 | private IInventoryService m_InventoryService; | 89 | private IInventoryService m_InventoryService; |
56 | private ILibraryService m_LibraryService; | 90 | private ILibraryService m_LibraryService; |
@@ -60,10 +94,22 @@ namespace OpenSim.Region.ClientStack.Linden | |||
60 | private string m_fetchInventoryDescendents2Url; | 94 | private string m_fetchInventoryDescendents2Url; |
61 | private string m_webFetchInventoryDescendentsUrl; | 95 | private string m_webFetchInventoryDescendentsUrl; |
62 | 96 | ||
63 | private WebFetchInvDescHandler m_webFetchHandler; | 97 | private static FetchInvDescHandler m_webFetchHandler; |
98 | |||
99 | private static Thread[] m_workerThreads = null; | ||
100 | |||
101 | private static DoubleQueue<aPollRequest> m_queue = | ||
102 | new DoubleQueue<aPollRequest>(); | ||
64 | 103 | ||
65 | #region ISharedRegionModule Members | 104 | #region ISharedRegionModule Members |
66 | 105 | ||
106 | public WebFetchInvDescModule() : this(true) {} | ||
107 | |||
108 | public WebFetchInvDescModule(bool processQueuedResultsAsync) | ||
109 | { | ||
110 | ProcessQueuedRequestsAsync = processQueuedResultsAsync; | ||
111 | } | ||
112 | |||
67 | public void Initialise(IConfigSource source) | 113 | public void Initialise(IConfigSource source) |
68 | { | 114 | { |
69 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | 115 | IConfig config = source.Configs["ClientStack.LindenCaps"]; |
@@ -84,7 +130,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
84 | if (!m_Enabled) | 130 | if (!m_Enabled) |
85 | return; | 131 | return; |
86 | 132 | ||
87 | m_scene = s; | 133 | Scene = s; |
88 | } | 134 | } |
89 | 135 | ||
90 | public void RemoveRegion(Scene s) | 136 | public void RemoveRegion(Scene s) |
@@ -92,8 +138,23 @@ namespace OpenSim.Region.ClientStack.Linden | |||
92 | if (!m_Enabled) | 138 | if (!m_Enabled) |
93 | return; | 139 | return; |
94 | 140 | ||
95 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | 141 | Scene.EventManager.OnRegisterCaps -= RegisterCaps; |
96 | m_scene = null; | 142 | |
143 | StatsManager.DeregisterStat(s_processedRequestsStat); | ||
144 | StatsManager.DeregisterStat(s_queuedRequestsStat); | ||
145 | |||
146 | if (ProcessQueuedRequestsAsync) | ||
147 | { | ||
148 | if (m_workerThreads != null) | ||
149 | { | ||
150 | foreach (Thread t in m_workerThreads) | ||
151 | Watchdog.AbortThread(t.ManagedThreadId); | ||
152 | |||
153 | m_workerThreads = null; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | Scene = null; | ||
97 | } | 158 | } |
98 | 159 | ||
99 | public void RegionLoaded(Scene s) | 160 | public void RegionLoaded(Scene s) |
@@ -101,14 +162,61 @@ namespace OpenSim.Region.ClientStack.Linden | |||
101 | if (!m_Enabled) | 162 | if (!m_Enabled) |
102 | return; | 163 | return; |
103 | 164 | ||
104 | m_InventoryService = m_scene.InventoryService; | 165 | if (s_processedRequestsStat == null) |
105 | m_LibraryService = m_scene.LibraryService; | 166 | s_processedRequestsStat = |
167 | new Stat( | ||
168 | "ProcessedFetchInventoryRequests", | ||
169 | "Number of processed fetch inventory requests", | ||
170 | "These have not necessarily yet been dispatched back to the requester.", | ||
171 | "", | ||
172 | "inventory", | ||
173 | "httpfetch", | ||
174 | StatType.Pull, | ||
175 | MeasuresOfInterest.AverageChangeOverTime, | ||
176 | stat => { stat.Value = ProcessedRequestsCount; }, | ||
177 | StatVerbosity.Debug); | ||
178 | |||
179 | if (s_queuedRequestsStat == null) | ||
180 | s_queuedRequestsStat = | ||
181 | new Stat( | ||
182 | "QueuedFetchInventoryRequests", | ||
183 | "Number of fetch inventory requests queued for processing", | ||
184 | "", | ||
185 | "", | ||
186 | "inventory", | ||
187 | "httpfetch", | ||
188 | StatType.Pull, | ||
189 | MeasuresOfInterest.AverageChangeOverTime, | ||
190 | stat => { stat.Value = m_queue.Count; }, | ||
191 | StatVerbosity.Debug); | ||
192 | |||
193 | StatsManager.RegisterStat(s_processedRequestsStat); | ||
194 | StatsManager.RegisterStat(s_queuedRequestsStat); | ||
195 | |||
196 | m_InventoryService = Scene.InventoryService; | ||
197 | m_LibraryService = Scene.LibraryService; | ||
106 | 198 | ||
107 | // We'll reuse the same handler for all requests. | 199 | // We'll reuse the same handler for all requests. |
108 | if (m_fetchInventoryDescendents2Url == "localhost" || m_webFetchInventoryDescendentsUrl == "localhost") | 200 | m_webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, Scene); |
109 | m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); | ||
110 | 201 | ||
111 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 202 | Scene.EventManager.OnRegisterCaps += RegisterCaps; |
203 | |||
204 | int nworkers = 2; // was 2 | ||
205 | if (ProcessQueuedRequestsAsync && m_workerThreads == null) | ||
206 | { | ||
207 | m_workerThreads = new Thread[nworkers]; | ||
208 | |||
209 | for (uint i = 0; i < nworkers; i++) | ||
210 | { | ||
211 | m_workerThreads[i] = WorkManager.StartThread(DoInventoryRequests, | ||
212 | String.Format("InventoryWorkerThread{0}", i), | ||
213 | ThreadPriority.Normal, | ||
214 | false, | ||
215 | true, | ||
216 | null, | ||
217 | int.MaxValue); | ||
218 | } | ||
219 | } | ||
112 | } | 220 | } |
113 | 221 | ||
114 | public void PostInitialise() | 222 | public void PostInitialise() |
@@ -126,43 +234,221 @@ namespace OpenSim.Region.ClientStack.Linden | |||
126 | 234 | ||
127 | #endregion | 235 | #endregion |
128 | 236 | ||
129 | private void RegisterCaps(UUID agentID, Caps caps) | 237 | private class PollServiceInventoryEventArgs : PollServiceEventArgs |
130 | { | 238 | { |
131 | if (m_webFetchInventoryDescendentsUrl != "") | 239 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
132 | RegisterFetchCap(agentID, caps, "WebFetchInventoryDescendents", m_webFetchInventoryDescendentsUrl); | 240 | |
241 | private Dictionary<UUID, Hashtable> responses = | ||
242 | new Dictionary<UUID, Hashtable>(); | ||
243 | |||
244 | private WebFetchInvDescModule m_module; | ||
133 | 245 | ||
134 | if (m_fetchInventoryDescendents2Url != "") | 246 | public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : |
135 | RegisterFetchCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url); | 247 | base(null, url, null, null, null, pId, int.MaxValue) |
248 | { | ||
249 | m_module = module; | ||
250 | |||
251 | HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; | ||
252 | GetEvents = (x, y) => | ||
253 | { | ||
254 | lock (responses) | ||
255 | { | ||
256 | try | ||
257 | { | ||
258 | return responses[x]; | ||
259 | } | ||
260 | finally | ||
261 | { | ||
262 | responses.Remove(x); | ||
263 | } | ||
264 | } | ||
265 | }; | ||
266 | |||
267 | Request = (x, y) => | ||
268 | { | ||
269 | ScenePresence sp = m_module.Scene.GetScenePresence(Id); | ||
270 | |||
271 | aPollRequest reqinfo = new aPollRequest(); | ||
272 | reqinfo.thepoll = this; | ||
273 | reqinfo.reqID = x; | ||
274 | reqinfo.request = y; | ||
275 | reqinfo.presence = sp; | ||
276 | reqinfo.folders = new List<UUID>(); | ||
277 | |||
278 | // Decode the request here | ||
279 | string request = y["body"].ToString(); | ||
280 | |||
281 | request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); | ||
282 | |||
283 | request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); | ||
284 | request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); | ||
285 | |||
286 | Hashtable hash = new Hashtable(); | ||
287 | try | ||
288 | { | ||
289 | hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); | ||
290 | } | ||
291 | catch (LLSD.LLSDParseException e) | ||
292 | { | ||
293 | m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace); | ||
294 | m_log.Error("Request: " + request); | ||
295 | return; | ||
296 | } | ||
297 | catch (System.Xml.XmlException) | ||
298 | { | ||
299 | m_log.ErrorFormat("[INVENTORY]: XML Format error"); | ||
300 | } | ||
301 | |||
302 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | ||
303 | |||
304 | bool highPriority = false; | ||
305 | |||
306 | for (int i = 0; i < foldersrequested.Count; i++) | ||
307 | { | ||
308 | Hashtable inventoryhash = (Hashtable)foldersrequested[i]; | ||
309 | string folder = inventoryhash["folder_id"].ToString(); | ||
310 | UUID folderID; | ||
311 | if (UUID.TryParse(folder, out folderID)) | ||
312 | { | ||
313 | if (!reqinfo.folders.Contains(folderID)) | ||
314 | { | ||
315 | //TODO: Port COF handling from Avination | ||
316 | reqinfo.folders.Add(folderID); | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | |||
321 | if (highPriority) | ||
322 | m_queue.EnqueueHigh(reqinfo); | ||
323 | else | ||
324 | m_queue.EnqueueLow(reqinfo); | ||
325 | }; | ||
326 | |||
327 | NoEvents = (x, y) => | ||
328 | { | ||
329 | /* | ||
330 | lock (requests) | ||
331 | { | ||
332 | Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); | ||
333 | requests.Remove(request); | ||
334 | } | ||
335 | */ | ||
336 | Hashtable response = new Hashtable(); | ||
337 | |||
338 | response["int_response_code"] = 500; | ||
339 | response["str_response_string"] = "Script timeout"; | ||
340 | response["content_type"] = "text/plain"; | ||
341 | response["keepalive"] = false; | ||
342 | response["reusecontext"] = false; | ||
343 | |||
344 | return response; | ||
345 | }; | ||
346 | } | ||
347 | |||
348 | public void Process(aPollRequest requestinfo) | ||
349 | { | ||
350 | UUID requestID = requestinfo.reqID; | ||
351 | |||
352 | Hashtable response = new Hashtable(); | ||
353 | |||
354 | response["int_response_code"] = 200; | ||
355 | response["content_type"] = "text/plain"; | ||
356 | response["keepalive"] = false; | ||
357 | response["reusecontext"] = false; | ||
358 | |||
359 | response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( | ||
360 | requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); | ||
361 | |||
362 | lock (responses) | ||
363 | { | ||
364 | if (responses.ContainsKey(requestID)) | ||
365 | m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); | ||
366 | responses[requestID] = response; | ||
367 | } | ||
368 | |||
369 | WebFetchInvDescModule.ProcessedRequestsCount++; | ||
370 | } | ||
371 | } | ||
372 | |||
373 | private void RegisterCaps(UUID agentID, Caps caps) | ||
374 | { | ||
375 | RegisterFetchDescendentsCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url); | ||
136 | } | 376 | } |
137 | 377 | ||
138 | private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) | 378 | private void RegisterFetchDescendentsCap(UUID agentID, Caps caps, string capName, string url) |
139 | { | 379 | { |
140 | string capUrl; | 380 | string capUrl; |
141 | 381 | ||
142 | if (url == "localhost") | 382 | // disable the cap clause |
383 | if (url == "") | ||
384 | { | ||
385 | return; | ||
386 | } | ||
387 | // handled by the simulator | ||
388 | else if (url == "localhost") | ||
143 | { | 389 | { |
144 | capUrl = "/CAPS/" + UUID.Random(); | 390 | capUrl = "/CAPS/" + UUID.Random() + "/"; |
145 | 391 | ||
146 | IRequestHandler reqHandler | 392 | // Register this as a poll service |
147 | = new RestStreamHandler( | 393 | PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(this, capUrl, agentID); |
148 | "POST", | 394 | args.Type = PollServiceEventArgs.EventType.Inventory; |
149 | capUrl, | ||
150 | m_webFetchHandler.FetchInventoryDescendentsRequest, | ||
151 | "FetchInventoryDescendents2", | ||
152 | agentID.ToString()); | ||
153 | 395 | ||
154 | caps.RegisterHandler(capName, reqHandler); | 396 | caps.RegisterPollHandler(capName, args); |
155 | } | 397 | } |
398 | // external handler | ||
156 | else | 399 | else |
157 | { | 400 | { |
158 | capUrl = url; | 401 | capUrl = url; |
402 | IExternalCapsModule handler = Scene.RequestModuleInterface<IExternalCapsModule>(); | ||
403 | if (handler != null) | ||
404 | handler.RegisterExternalUserCapsHandler(agentID,caps,capName,capUrl); | ||
405 | else | ||
406 | caps.RegisterHandler(capName, capUrl); | ||
407 | } | ||
159 | 408 | ||
160 | caps.RegisterHandler(capName, capUrl); | 409 | // m_log.DebugFormat( |
410 | // "[FETCH INVENTORY DESCENDENTS2 MODULE]: Registered capability {0} at {1} in region {2} for {3}", | ||
411 | // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); | ||
412 | } | ||
413 | |||
414 | // private void DeregisterCaps(UUID agentID, Caps caps) | ||
415 | // { | ||
416 | // string capUrl; | ||
417 | // | ||
418 | // if (m_capsDict.TryGetValue(agentID, out capUrl)) | ||
419 | // { | ||
420 | // MainServer.Instance.RemoveHTTPHandler("", capUrl); | ||
421 | // m_capsDict.Remove(agentID); | ||
422 | // } | ||
423 | // } | ||
424 | |||
425 | private void DoInventoryRequests() | ||
426 | { | ||
427 | while (true) | ||
428 | { | ||
429 | Watchdog.UpdateThread(); | ||
430 | |||
431 | WaitProcessQueuedInventoryRequest(); | ||
161 | } | 432 | } |
433 | } | ||
434 | |||
435 | public void WaitProcessQueuedInventoryRequest() | ||
436 | { | ||
437 | aPollRequest poolreq = m_queue.Dequeue(); | ||
162 | 438 | ||
163 | // m_log.DebugFormat( | 439 | if (poolreq != null && poolreq.thepoll != null) |
164 | // "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}", | 440 | { |
165 | // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); | 441 | try |
442 | { | ||
443 | poolreq.thepoll.Process(poolreq); | ||
444 | } | ||
445 | catch (Exception e) | ||
446 | { | ||
447 | m_log.ErrorFormat( | ||
448 | "[INVENTORY]: Failed to process queued inventory request {0} for {1} in {2}. Exception {3}", | ||
449 | poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", Scene.Name, e); | ||
450 | } | ||
451 | } | ||
166 | } | 452 | } |
167 | } | 453 | } |
168 | } \ No newline at end of file | 454 | } |