diff options
author | Justin Clarke Casey | 2008-11-25 15:19:00 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-25 15:19:00 +0000 |
commit | e187972377c19bdd85093677c4c54034e4f9196e (patch) | |
tree | cc1bb5f003628b018b823eafc9ee0a67f98df31c /OpenSim/Region/Environment/Modules | |
parent | * Adding some virtual hooks and making some privaets protected for great just... (diff) | |
download | opensim-SC_OLD-e187972377c19bdd85093677c4c54034e4f9196e.zip opensim-SC_OLD-e187972377c19bdd85093677c4c54034e4f9196e.tar.gz opensim-SC_OLD-e187972377c19bdd85093677c4c54034e4f9196e.tar.bz2 opensim-SC_OLD-e187972377c19bdd85093677c4c54034e4f9196e.tar.xz |
* Apply http://opensimulator.org/mantis/view.php?id=2640
* This is Diva's hypergrid patch, as perviously discussed on the opensim-dev mailing list
* Applied some minor prebuild.xml jiggling to resolve a dependency issue
* Thanks Diva!
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
3 files changed, 692 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs new file mode 100644 index 0000000..cfcda42 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs | |||
@@ -0,0 +1,199 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | |||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Framework.Communications.Cache; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Region.Environment.Interfaces; | ||
44 | using OpenSim.Region.Environment.Scenes; | ||
45 | using OpenSim.Grid.AssetServer; | ||
46 | |||
47 | namespace OpenSim.Region.Environment.Modules.Hypergrid | ||
48 | { | ||
49 | public class HGStandaloneAssetService : IRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | private static bool initialized = false; | ||
53 | private static bool enabled = false; | ||
54 | |||
55 | Scene m_scene; | ||
56 | AssetService m_assetService; | ||
57 | |||
58 | #region IRegionModule interface | ||
59 | |||
60 | public void Initialise(Scene scene, IConfigSource config) | ||
61 | { | ||
62 | if (!initialized) | ||
63 | { | ||
64 | initialized = true; | ||
65 | m_scene = scene; | ||
66 | |||
67 | // This module is only on for standalones in hypergrid mode | ||
68 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | if (enabled) | ||
75 | { | ||
76 | m_log.Info("[HGStandaloneAssetService]: Starting..."); | ||
77 | |||
78 | m_assetService = new AssetService(m_scene); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void Close() | ||
83 | { | ||
84 | } | ||
85 | |||
86 | public string Name | ||
87 | { | ||
88 | get { return "HGStandaloneAssetService"; } | ||
89 | } | ||
90 | |||
91 | public bool IsSharedModule | ||
92 | { | ||
93 | get { return true; } | ||
94 | } | ||
95 | |||
96 | #endregion | ||
97 | |||
98 | } | ||
99 | |||
100 | public class AssetService | ||
101 | { | ||
102 | private IUserService m_userService; | ||
103 | private bool m_doLookup = false; | ||
104 | |||
105 | public bool DoLookup | ||
106 | { | ||
107 | get { return m_doLookup; } | ||
108 | set { m_doLookup = value; } | ||
109 | } | ||
110 | private static readonly ILog m_log | ||
111 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
112 | |||
113 | public AssetService(Scene m_scene) | ||
114 | { | ||
115 | AddHttpHandlers(m_scene); | ||
116 | m_userService = m_scene.CommsManager.UserService; | ||
117 | } | ||
118 | |||
119 | protected void AddHttpHandlers(Scene m_scene) | ||
120 | { | ||
121 | IAssetProviderPlugin m_assetProvider = ((AssetServerBase)m_scene.AssetCache.AssetServer).AssetProviderPlugin; | ||
122 | |||
123 | m_scene.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); | ||
124 | m_scene.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); | ||
125 | |||
126 | } | ||
127 | |||
128 | |||
129 | ///// <summary> | ||
130 | ///// Check that the source of an inventory request is one that we trust. | ||
131 | ///// </summary> | ||
132 | ///// <param name="peer"></param> | ||
133 | ///// <returns></returns> | ||
134 | //public bool CheckTrustSource(IPEndPoint peer) | ||
135 | //{ | ||
136 | // if (m_doLookup) | ||
137 | // { | ||
138 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | ||
139 | // UriBuilder ub = new UriBuilder(m_userserver_url); | ||
140 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | ||
141 | // foreach (IPAddress uaddr in uaddrs) | ||
142 | // { | ||
143 | // if (uaddr.Equals(peer.Address)) | ||
144 | // { | ||
145 | // return true; | ||
146 | // } | ||
147 | // } | ||
148 | |||
149 | // m_log.WarnFormat( | ||
150 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | ||
151 | // peer); | ||
152 | |||
153 | // return false; | ||
154 | // } | ||
155 | // else | ||
156 | // { | ||
157 | // return true; | ||
158 | // } | ||
159 | //} | ||
160 | |||
161 | /// <summary> | ||
162 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
163 | /// that agent. | ||
164 | /// </summary> | ||
165 | /// <param name="session_id"></param> | ||
166 | /// <param name="avatar_id"></param> | ||
167 | /// <returns></returns> | ||
168 | public bool CheckAuthSession(string session_id, string avatar_id) | ||
169 | { | ||
170 | if (m_doLookup) | ||
171 | { | ||
172 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); | ||
173 | UUID userID = UUID.Zero; | ||
174 | UUID sessionID = UUID.Zero; | ||
175 | UUID.TryParse(avatar_id, out userID); | ||
176 | UUID.TryParse(session_id, out sessionID); | ||
177 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) | ||
178 | { | ||
179 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); | ||
180 | return false; | ||
181 | } | ||
182 | UserProfileData userProfile = m_userService.GetUserProfile(userID); | ||
183 | if (userProfile != null && userProfile.CurrentAgent != null && | ||
184 | userProfile.CurrentAgent.SessionID == sessionID) | ||
185 | { | ||
186 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); | ||
187 | return true; | ||
188 | } | ||
189 | |||
190 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); | ||
191 | return false; | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | return true; | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs new file mode 100644 index 0000000..7203b88 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs | |||
@@ -0,0 +1,315 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | |||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Framework.Communications.Cache; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Region.Environment.Interfaces; | ||
44 | using OpenSim.Region.Environment.Scenes; | ||
45 | |||
46 | namespace OpenSim.Region.Environment.Modules.Hypergrid | ||
47 | { | ||
48 | public class HGStandaloneInventoryService : IRegionModule | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | private static bool initialized = false; | ||
52 | private static bool enabled = false; | ||
53 | |||
54 | Scene m_scene; | ||
55 | InventoryService m_inventoryService; | ||
56 | |||
57 | #region IRegionModule interface | ||
58 | |||
59 | public void Initialise(Scene scene, IConfigSource config) | ||
60 | { | ||
61 | if (!initialized) | ||
62 | { | ||
63 | initialized = true; | ||
64 | m_scene = scene; | ||
65 | |||
66 | // This module is only on for standalones | ||
67 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | public void PostInitialise() | ||
72 | { | ||
73 | if (enabled) | ||
74 | { | ||
75 | m_log.Info("[HGStandaloneInvService]: Starting..."); | ||
76 | m_inventoryService = new InventoryService(m_scene); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | public void Close() | ||
81 | { | ||
82 | } | ||
83 | |||
84 | public string Name | ||
85 | { | ||
86 | get { return "HGStandaloneInventoryService"; } | ||
87 | } | ||
88 | |||
89 | public bool IsSharedModule | ||
90 | { | ||
91 | get { return true; } | ||
92 | } | ||
93 | |||
94 | #endregion | ||
95 | |||
96 | } | ||
97 | |||
98 | public class InventoryService | ||
99 | { | ||
100 | private InventoryServiceBase m_inventoryService; | ||
101 | private IUserService m_userService; | ||
102 | private bool m_doLookup = false; | ||
103 | |||
104 | public bool DoLookup | ||
105 | { | ||
106 | get { return m_doLookup; } | ||
107 | set { m_doLookup = value; } | ||
108 | } | ||
109 | private static readonly ILog m_log | ||
110 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
111 | |||
112 | public InventoryService(Scene m_scene) | ||
113 | { | ||
114 | m_inventoryService = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; | ||
115 | m_userService = m_scene.CommsManager.UserService; | ||
116 | AddHttpHandlers(m_scene); | ||
117 | |||
118 | } | ||
119 | |||
120 | protected void AddHttpHandlers(Scene m_scene) | ||
121 | { | ||
122 | m_scene.AddStreamHandler( | ||
123 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
124 | "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); | ||
125 | |||
126 | m_scene.AddStreamHandler( | ||
127 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
128 | "POST", "/NewFolder/", m_inventoryService.AddFolder, CheckAuthSession)); | ||
129 | |||
130 | m_scene.AddStreamHandler( | ||
131 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
132 | "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, CheckAuthSession)); | ||
133 | |||
134 | m_scene.AddStreamHandler( | ||
135 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
136 | "POST", "/MoveFolder/", m_inventoryService.MoveFolder, CheckAuthSession)); | ||
137 | |||
138 | m_scene.AddStreamHandler( | ||
139 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
140 | "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, CheckAuthSession)); | ||
141 | |||
142 | m_scene.AddStreamHandler( | ||
143 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
144 | "POST", "/NewItem/", m_inventoryService.AddItem, CheckAuthSession)); | ||
145 | |||
146 | m_scene.AddStreamHandler( | ||
147 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
148 | "POST", "/DeleteItem/", m_inventoryService.DeleteItem, CheckAuthSession)); | ||
149 | |||
150 | //// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g | ||
151 | //// system folders such as Objects, Textures), but it now returns the entire inventory skeleton. | ||
152 | //// It would have been better to rename this request, but complexities in the BaseHttpServer | ||
153 | //// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier | ||
154 | //// to do this for now. | ||
155 | //m_scene.AddStreamHandler( | ||
156 | // new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> | ||
157 | // ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); | ||
158 | |||
159 | //// for persistent active gestures | ||
160 | //m_scene.AddStreamHandler( | ||
161 | // new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> | ||
162 | // ("POST", "/ActiveGestures/", GetActiveGestures, CheckTrustSource)); | ||
163 | } | ||
164 | |||
165 | |||
166 | ///// <summary> | ||
167 | ///// Check that the source of an inventory request is one that we trust. | ||
168 | ///// </summary> | ||
169 | ///// <param name="peer"></param> | ||
170 | ///// <returns></returns> | ||
171 | //public bool CheckTrustSource(IPEndPoint peer) | ||
172 | //{ | ||
173 | // if (m_doLookup) | ||
174 | // { | ||
175 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | ||
176 | // UriBuilder ub = new UriBuilder(m_userserver_url); | ||
177 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | ||
178 | // foreach (IPAddress uaddr in uaddrs) | ||
179 | // { | ||
180 | // if (uaddr.Equals(peer.Address)) | ||
181 | // { | ||
182 | // return true; | ||
183 | // } | ||
184 | // } | ||
185 | |||
186 | // m_log.WarnFormat( | ||
187 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | ||
188 | // peer); | ||
189 | |||
190 | // return false; | ||
191 | // } | ||
192 | // else | ||
193 | // { | ||
194 | // return true; | ||
195 | // } | ||
196 | //} | ||
197 | |||
198 | /// <summary> | ||
199 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
200 | /// that agent. | ||
201 | /// </summary> | ||
202 | /// <param name="session_id"></param> | ||
203 | /// <param name="avatar_id"></param> | ||
204 | /// <returns></returns> | ||
205 | public bool CheckAuthSession(string session_id, string avatar_id) | ||
206 | { | ||
207 | if (m_doLookup) | ||
208 | { | ||
209 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); | ||
210 | UUID userID = UUID.Zero; | ||
211 | UUID sessionID = UUID.Zero; | ||
212 | UUID.TryParse(avatar_id, out userID); | ||
213 | UUID.TryParse(session_id, out sessionID); | ||
214 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) | ||
215 | { | ||
216 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); | ||
217 | return false; | ||
218 | } | ||
219 | UserProfileData userProfile = m_userService.GetUserProfile(userID); | ||
220 | if (userProfile != null && userProfile.CurrentAgent != null && | ||
221 | userProfile.CurrentAgent.SessionID == sessionID) | ||
222 | { | ||
223 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); | ||
224 | return true; | ||
225 | } | ||
226 | |||
227 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); | ||
228 | return false; | ||
229 | } | ||
230 | else | ||
231 | { | ||
232 | return true; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | |||
237 | /// <summary> | ||
238 | /// Return a user's entire inventory | ||
239 | /// </summary> | ||
240 | /// <param name="rawUserID"></param> | ||
241 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> | ||
242 | public InventoryCollection GetUserInventory(Guid rawUserID) | ||
243 | { | ||
244 | UUID userID = new UUID(rawUserID); | ||
245 | |||
246 | m_log.Info("[HGStandaloneInvService]: Processing request for inventory of " + userID); | ||
247 | |||
248 | // Uncomment me to simulate a slow responding inventory server | ||
249 | //Thread.Sleep(16000); | ||
250 | |||
251 | InventoryCollection invCollection = new InventoryCollection(); | ||
252 | |||
253 | List<InventoryFolderBase> allFolders = ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); | ||
254 | |||
255 | if (null == allFolders) | ||
256 | { | ||
257 | m_log.WarnFormat("[HGStandaloneInvService]: No inventory found for user {0}", rawUserID); | ||
258 | |||
259 | return invCollection; | ||
260 | } | ||
261 | |||
262 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
263 | |||
264 | foreach (InventoryFolderBase folder in allFolders) | ||
265 | { | ||
266 | List<InventoryItemBase> items = ((InventoryServiceBase)m_inventoryService).RequestFolderItems(folder.ID); | ||
267 | |||
268 | if (items != null) | ||
269 | { | ||
270 | allItems.InsertRange(0, items); | ||
271 | } | ||
272 | } | ||
273 | |||
274 | invCollection.UserID = userID; | ||
275 | invCollection.Folders = allFolders; | ||
276 | invCollection.Items = allItems; | ||
277 | |||
278 | // foreach (InventoryFolderBase folder in invCollection.Folders) | ||
279 | // { | ||
280 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | ||
281 | // } | ||
282 | // | ||
283 | // foreach (InventoryItemBase item in invCollection.Items) | ||
284 | // { | ||
285 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | ||
286 | // } | ||
287 | |||
288 | m_log.InfoFormat( | ||
289 | "[HGStandaloneInvService]: Sending back inventory response to user {0} containing {1} folders and {2} items", | ||
290 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | ||
291 | |||
292 | return invCollection; | ||
293 | } | ||
294 | |||
295 | /// <summary> | ||
296 | /// Guid to UUID wrapper for same name IInventoryServices method | ||
297 | /// </summary> | ||
298 | /// <param name="rawUserID"></param> | ||
299 | /// <returns></returns> | ||
300 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | ||
301 | { | ||
302 | UUID userID = new UUID(rawUserID); | ||
303 | return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); | ||
304 | } | ||
305 | |||
306 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) | ||
307 | { | ||
308 | UUID userID = new UUID(rawUserID); | ||
309 | |||
310 | m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); | ||
311 | |||
312 | return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); | ||
313 | } | ||
314 | } | ||
315 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs new file mode 100644 index 0000000..7f8f285 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs | |||
@@ -0,0 +1,178 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | |||
30 | using System; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Drawing; | ||
34 | using System.Drawing.Imaging; | ||
35 | using System.IO; | ||
36 | using System.Net; | ||
37 | using System.Reflection; | ||
38 | using System.Threading; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.Imaging; | ||
41 | using OpenMetaverse.StructuredData; | ||
42 | using log4net; | ||
43 | using Nini.Config; | ||
44 | using Nwc.XmlRpc; | ||
45 | |||
46 | using OpenSim.Framework; | ||
47 | using OpenSim.Framework.Communications.Cache; | ||
48 | using OpenSim.Framework.Communications.Capabilities; | ||
49 | using OpenSim.Framework.Servers; | ||
50 | using OpenSim.Region.Environment.Interfaces; | ||
51 | using OpenSim.Region.Environment.Modules.World.WorldMap; | ||
52 | using OpenSim.Region.Environment.Scenes; | ||
53 | using OpenSim.Region.Environment.Types; | ||
54 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | ||
55 | |||
56 | using OSD = OpenMetaverse.StructuredData.OSD; | ||
57 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
58 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
59 | |||
60 | namespace OpenSim.Region.Environment.Modules.Hypergrid | ||
61 | { | ||
62 | public class HGWorldMapModule : WorldMapModule, IRegionModule | ||
63 | { | ||
64 | private static readonly ILog m_log = | ||
65 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
66 | |||
67 | #region IRegionModule Members | ||
68 | |||
69 | public override void Initialise(Scene scene, IConfigSource config) | ||
70 | { | ||
71 | IConfig startupConfig = config.Configs["Startup"]; | ||
72 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") | ||
73 | m_Enabled = true; | ||
74 | |||
75 | if (!m_Enabled) | ||
76 | return; | ||
77 | m_log.Info("[HGMap] Initializing..."); | ||
78 | m_scene = scene; | ||
79 | } | ||
80 | |||
81 | |||
82 | public override string Name | ||
83 | { | ||
84 | get { return "HGWorldMap"; } | ||
85 | } | ||
86 | |||
87 | |||
88 | #endregion | ||
89 | |||
90 | /// <summary> | ||
91 | /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates | ||
92 | /// </summary> | ||
93 | /// <param name="minX"></param> | ||
94 | /// <param name="minY"></param> | ||
95 | /// <param name="maxX"></param> | ||
96 | /// <param name="maxY"></param> | ||
97 | public override void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | ||
98 | { | ||
99 | // | ||
100 | // WARNING!!! COPY & PASTE FROM SUPERCLASS | ||
101 | // The only difference is at the very end | ||
102 | // | ||
103 | |||
104 | m_log.Info("[HGMap]: Request map blocks " + minX + "-" + maxX + " " + minY + "-" + maxY); | ||
105 | |||
106 | //m_scene.ForEachScenePresence(delegate (ScenePresence sp) { | ||
107 | // if (!sp.IsChildAgent && sp.UUID == remoteClient.AgentId) | ||
108 | // { | ||
109 | // Console.WriteLine("XXX Root agent"); | ||
110 | // DoRequestMapBlocks(remoteClient, minX, minY, maxX, maxY, flag); | ||
111 | // } | ||
112 | //}; | ||
113 | |||
114 | List<MapBlockData> mapBlocks; | ||
115 | if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible | ||
116 | { | ||
117 | List<MapBlockData> response = new List<MapBlockData>(); | ||
118 | |||
119 | // this should return one mapblock at most. But make sure: Look whether the one we requested is in there | ||
120 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | ||
121 | if (mapBlocks != null) | ||
122 | { | ||
123 | foreach (MapBlockData block in mapBlocks) | ||
124 | { | ||
125 | if (block.X == minX && block.Y == minY) | ||
126 | { | ||
127 | // found it => add it to response | ||
128 | response.Add(block); | ||
129 | break; | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | response = mapBlocks; | ||
134 | if (response.Count == 0) | ||
135 | { | ||
136 | // response still empty => couldn't find the map-tile the user clicked on => tell the client | ||
137 | MapBlockData block = new MapBlockData(); | ||
138 | block.X = (ushort)minX; | ||
139 | block.Y = (ushort)minY; | ||
140 | block.Access = 254; // == not there | ||
141 | response.Add(block); | ||
142 | } | ||
143 | remoteClient.SendMapBlock(response, 0); | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | // normal mapblock request. Use the provided values | ||
148 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); | ||
149 | |||
150 | // Different from super | ||
151 | FillInMap(mapBlocks, minX, minY, maxX, maxY); | ||
152 | // | ||
153 | |||
154 | remoteClient.SendMapBlock(mapBlocks, flag); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | |||
159 | private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY) | ||
160 | { | ||
161 | for (int x = minX; x <= maxX; x++) | ||
162 | for (int y = minY; y <= maxY; y++) | ||
163 | { | ||
164 | MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); | ||
165 | if (mblock == null) | ||
166 | { | ||
167 | mblock = new MapBlockData(); | ||
168 | mblock.X = (ushort)x; | ||
169 | mblock.Y = (ushort)y; | ||
170 | mblock.Name = ""; | ||
171 | mblock.Access = 254; // not here??? | ||
172 | mblock.MapImageId = UUID.Zero; | ||
173 | mapBlocks.Add(mblock); | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | } | ||