diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 152 |
1 files changed, 149 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index d2fe388..a71584a 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | 31 | ||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Client; | ||
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Connectors.Hypergrid; | 36 | using OpenSim.Services.Connectors.Hypergrid; |
@@ -57,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
57 | private string m_HomeURI; | 58 | private string m_HomeURI; |
58 | private bool m_OutboundPermission; | 59 | private bool m_OutboundPermission; |
59 | private string m_ThisGatekeeper; | 60 | private string m_ThisGatekeeper; |
61 | private bool m_RestrictInventoryAccessAbroad; | ||
60 | 62 | ||
61 | // private bool m_Initialized = false; | 63 | // private bool m_Initialized = false; |
62 | 64 | ||
@@ -90,6 +92,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
90 | m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); | 92 | m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); |
91 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | 93 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); |
92 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); | 94 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); |
95 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", false); | ||
93 | } | 96 | } |
94 | else | 97 | else |
95 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 98 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
@@ -105,13 +108,79 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
105 | base.AddRegion(scene); | 108 | base.AddRegion(scene); |
106 | m_assMapper = new HGAssetMapper(scene, m_HomeURI); | 109 | m_assMapper = new HGAssetMapper(scene, m_HomeURI); |
107 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | 110 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; |
108 | 111 | scene.EventManager.OnTeleportStart += TeleportStart; | |
112 | scene.EventManager.OnTeleportFail += TeleportFail; | ||
109 | } | 113 | } |
110 | 114 | ||
111 | #endregion | 115 | #endregion |
112 | 116 | ||
113 | #region Event handlers | 117 | #region Event handlers |
114 | 118 | ||
119 | protected override void OnNewClient(IClientAPI client) | ||
120 | { | ||
121 | base.OnNewClient(client); | ||
122 | client.OnCompleteMovementToRegion += new Action<IClientAPI, bool>(OnCompleteMovementToRegion); | ||
123 | } | ||
124 | |||
125 | protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2) | ||
126 | { | ||
127 | //m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: OnCompleteMovementToRegion of user {0}", client.Name); | ||
128 | object sp = null; | ||
129 | if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) | ||
130 | { | ||
131 | if (sp is ScenePresence) | ||
132 | { | ||
133 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); | ||
134 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) | ||
135 | { | ||
136 | if (m_RestrictInventoryAccessAbroad) | ||
137 | { | ||
138 | IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>(); | ||
139 | if (uMan.IsLocalGridUser(client.AgentId)) | ||
140 | ProcessInventoryForComingHome(client); | ||
141 | else | ||
142 | ProcessInventoryForArriving(client); | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | |||
149 | protected void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout) | ||
150 | { | ||
151 | if (gridLogout && m_RestrictInventoryAccessAbroad) | ||
152 | { | ||
153 | IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>(); | ||
154 | if (uMan != null && uMan.IsLocalGridUser(client.AgentId)) | ||
155 | { | ||
156 | // local grid user | ||
157 | ProcessInventoryForHypergriding(client); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | // Foreigner | ||
162 | ProcessInventoryForLeaving(client); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | } | ||
167 | |||
168 | protected void TeleportFail(IClientAPI client, bool gridLogout) | ||
169 | { | ||
170 | if (gridLogout && m_RestrictInventoryAccessAbroad) | ||
171 | { | ||
172 | IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>(); | ||
173 | if (uMan.IsLocalGridUser(client.AgentId)) | ||
174 | { | ||
175 | ProcessInventoryForComingHome(client); | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | ProcessInventoryForArriving(client); | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | |||
115 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | 184 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) |
116 | { | 185 | { |
117 | string userAssetServer = string.Empty; | 186 | string userAssetServer = string.Empty; |
@@ -236,8 +305,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
236 | return false; | 305 | return false; |
237 | } | 306 | } |
238 | 307 | ||
239 | #endregion | ||
240 | |||
241 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) | 308 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) |
242 | { | 309 | { |
243 | InventoryItemBase item = base.GetItem(agentID, itemID); | 310 | InventoryItemBase item = base.GetItem(agentID, itemID); |
@@ -248,5 +315,84 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
248 | 315 | ||
249 | return item; | 316 | return item; |
250 | } | 317 | } |
318 | |||
319 | #endregion | ||
320 | |||
321 | #region Inventory manipulation upon arriving/leaving | ||
322 | |||
323 | // | ||
324 | // These 2 are for local and foreign users coming back, respectively | ||
325 | // | ||
326 | |||
327 | private void ProcessInventoryForComingHome(IClientAPI client) | ||
328 | { | ||
329 | m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: Restoring root folder for local user {0}", client.Name); | ||
330 | if (client is IClientCore) | ||
331 | { | ||
332 | IClientCore core = (IClientCore)client; | ||
333 | IClientInventory inv; | ||
334 | |||
335 | if (core.TryGet<IClientInventory>(out inv)) | ||
336 | { | ||
337 | InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); | ||
338 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
339 | |||
340 | inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); | ||
341 | } | ||
342 | } | ||
343 | } | ||
344 | |||
345 | private void ProcessInventoryForArriving(IClientAPI client) | ||
346 | { | ||
347 | } | ||
348 | |||
349 | // | ||
350 | // These 2 are for local and foreign users going away respectively | ||
351 | // | ||
352 | |||
353 | private void ProcessInventoryForHypergriding(IClientAPI client) | ||
354 | { | ||
355 | if (client is IClientCore) | ||
356 | { | ||
357 | IClientCore core = (IClientCore)client; | ||
358 | IClientInventory inv; | ||
359 | |||
360 | if (core.TryGet<IClientInventory>(out inv)) | ||
361 | { | ||
362 | InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); | ||
363 | if (root != null) | ||
364 | { | ||
365 | m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: Changing root inventory for user {0}", client.Name); | ||
366 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
367 | List<UUID> fids = new List<UUID>(); | ||
368 | List<UUID> iids = new List<UUID>(); | ||
369 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); | ||
370 | |||
371 | foreach (InventoryFolderBase f in content.Folders) | ||
372 | { | ||
373 | if (f.Name != "My Suitcase") | ||
374 | { | ||
375 | f.Name = f.Name + " (Unavailable)"; | ||
376 | keep.Add(f); | ||
377 | } | ||
378 | } | ||
379 | |||
380 | // items directly under the root folder | ||
381 | foreach (InventoryItemBase it in content.Items) | ||
382 | it.Name = it.Name + " (Unavailable)"; ; | ||
383 | |||
384 | // Send the new names | ||
385 | inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); | ||
386 | |||
387 | } | ||
388 | } | ||
389 | } | ||
390 | } | ||
391 | |||
392 | private void ProcessInventoryForLeaving(IClientAPI client) | ||
393 | { | ||
394 | } | ||
395 | |||
396 | #endregion | ||
251 | } | 397 | } |
252 | } | 398 | } |