diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 100 |
1 files changed, 82 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index ce7ed26..283a0cf 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -64,6 +64,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
64 | 64 | ||
65 | private bool m_bypassPermissions = true; | 65 | private bool m_bypassPermissions = true; |
66 | 66 | ||
67 | // This simple check makes it possible to support grids in which all the simulators | ||
68 | // share all central services of the Robust server EXCEPT assets. In other words, | ||
69 | // grids where the simulators' assets are kept in one DB and the users' inventory assets | ||
70 | // are kept on another. When users rez items from inventory or take objects from world, | ||
71 | // an HG-like asset copy takes place between the 2 servers, the world asset server and | ||
72 | // the user's asset server. | ||
73 | private bool m_CheckSeparateAssets = false; | ||
74 | private string m_LocalAssetsURL = string.Empty; | ||
75 | |||
67 | // private bool m_Initialized = false; | 76 | // private bool m_Initialized = false; |
68 | 77 | ||
69 | #region INonSharedRegionModule | 78 | #region INonSharedRegionModule |
@@ -99,6 +108,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
99 | 108 | ||
100 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | 109 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); |
101 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); | 110 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); |
111 | m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false); | ||
112 | m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty); | ||
113 | m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' }); | ||
114 | |||
102 | } | 115 | } |
103 | else | 116 | else |
104 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 117 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
@@ -293,41 +306,92 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
293 | 306 | ||
294 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | 307 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) |
295 | { | 308 | { |
296 | string userAssetServer = string.Empty; | 309 | string senderAssetServer = string.Empty; |
297 | if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) | 310 | string receiverAssetServer = string.Empty; |
298 | m_assMapper.Get(item.AssetID, sender, userAssetServer); | 311 | bool isForeignSender, isForeignReceiver; |
312 | isForeignSender = IsForeignUser(sender, out senderAssetServer); | ||
313 | isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer); | ||
314 | |||
315 | // They're both local. Nothing to do. | ||
316 | if (!isForeignSender && !isForeignReceiver) | ||
317 | return; | ||
318 | |||
319 | // At least one of them is foreign. | ||
320 | // If both users have the same asset server, no need to transfer the asset | ||
321 | if (senderAssetServer.Equals(receiverAssetServer)) | ||
322 | { | ||
323 | m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer."); | ||
324 | return; | ||
325 | } | ||
299 | 326 | ||
300 | if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) | 327 | if (isForeignSender && senderAssetServer != string.Empty) |
301 | m_assMapper.Post(item.AssetID, receiver, userAssetServer); | 328 | m_assMapper.Get(item.AssetID, sender, senderAssetServer); |
329 | |||
330 | if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission) | ||
331 | m_assMapper.Post(item.AssetID, receiver, receiverAssetServer); | ||
302 | } | 332 | } |
303 | 333 | ||
304 | public override bool IsForeignUser(UUID userID, out string assetServerURL) | 334 | public override bool IsForeignUser(UUID userID, out string assetServerURL) |
305 | { | 335 | { |
306 | assetServerURL = string.Empty; | 336 | assetServerURL = string.Empty; |
307 | 337 | ||
308 | if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) | 338 | if (UserManagementModule != null) |
309 | { // foreign | 339 | { |
310 | ScenePresence sp = null; | 340 | if (!m_CheckSeparateAssets) |
311 | if (m_Scene.TryGetScenePresence(userID, out sp)) | ||
312 | { | 341 | { |
313 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 342 | if (!UserManagementModule.IsLocalGridUser(userID)) |
314 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | 343 | { // foreign |
315 | { | 344 | ScenePresence sp = null; |
316 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 345 | if (m_Scene.TryGetScenePresence(userID, out sp)) |
317 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 346 | { |
347 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
348 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | ||
349 | { | ||
350 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | ||
351 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
352 | } | ||
353 | } | ||
354 | else | ||
355 | { | ||
356 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | ||
357 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
358 | } | ||
359 | return true; | ||
318 | } | 360 | } |
319 | } | 361 | } |
320 | else | 362 | else |
321 | { | 363 | { |
322 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | 364 | if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) |
323 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 365 | { |
366 | m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); | ||
367 | return false; | ||
368 | } | ||
369 | else | ||
370 | { | ||
371 | m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); | ||
372 | return true; | ||
373 | } | ||
324 | } | 374 | } |
325 | return true; | ||
326 | } | 375 | } |
327 | |||
328 | return false; | 376 | return false; |
329 | } | 377 | } |
330 | 378 | ||
379 | private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL) | ||
380 | { | ||
381 | assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI"); | ||
382 | if (assetsURL == string.Empty) | ||
383 | { | ||
384 | AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid); | ||
385 | if (agent != null) | ||
386 | { | ||
387 | assetsURL = agent.ServiceURLs["AssetServerURI"].ToString(); | ||
388 | assetsURL = assetsURL.Trim(new char[] { '/' }); | ||
389 | } | ||
390 | } | ||
391 | return m_LocalAssetsURL.Equals(assetsURL); | ||
392 | } | ||
393 | |||
394 | |||
331 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) | 395 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) |
332 | { | 396 | { |
333 | InventoryItemBase item = base.GetItem(agentID, itemID); | 397 | InventoryItemBase item = base.GetItem(agentID, itemID); |