diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 117 |
1 files changed, 96 insertions, 21 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index ce7ed26..5e831cc 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!"); |
@@ -240,6 +253,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
240 | return newAssetID; | 253 | return newAssetID; |
241 | } | 254 | } |
242 | 255 | ||
256 | /// | ||
257 | /// UpdateInventoryItemAsset | ||
258 | /// | ||
259 | public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) | ||
260 | { | ||
261 | if (base.UpdateInventoryItemAsset(ownerID, item, asset)) | ||
262 | { | ||
263 | UploadInventoryItem(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0); | ||
264 | return true; | ||
265 | } | ||
266 | |||
267 | return false; | ||
268 | } | ||
269 | |||
243 | /// | 270 | /// |
244 | /// Used in DeleteToInventory | 271 | /// Used in DeleteToInventory |
245 | /// | 272 | /// |
@@ -284,50 +311,98 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
284 | SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 311 | SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
285 | RezSelected, RemoveItem, fromTaskID, attachment); | 312 | RezSelected, RemoveItem, fromTaskID, attachment); |
286 | 313 | ||
287 | if (sog == null) | ||
288 | remoteClient.SendAgentAlertMessage("Unable to rez: problem accessing inventory or locating assets", false); | ||
289 | |||
290 | return sog; | 314 | return sog; |
291 | 315 | ||
292 | } | 316 | } |
293 | 317 | ||
294 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | 318 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) |
295 | { | 319 | { |
296 | string userAssetServer = string.Empty; | 320 | string senderAssetServer = string.Empty; |
297 | if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) | 321 | string receiverAssetServer = string.Empty; |
298 | m_assMapper.Get(item.AssetID, sender, userAssetServer); | 322 | bool isForeignSender, isForeignReceiver; |
323 | isForeignSender = IsForeignUser(sender, out senderAssetServer); | ||
324 | isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer); | ||
325 | |||
326 | // They're both local. Nothing to do. | ||
327 | if (!isForeignSender && !isForeignReceiver) | ||
328 | return; | ||
299 | 329 | ||
300 | if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) | 330 | // At least one of them is foreign. |
301 | m_assMapper.Post(item.AssetID, receiver, userAssetServer); | 331 | // If both users have the same asset server, no need to transfer the asset |
332 | if (senderAssetServer.Equals(receiverAssetServer)) | ||
333 | { | ||
334 | m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer."); | ||
335 | return; | ||
336 | } | ||
337 | |||
338 | if (isForeignSender && senderAssetServer != string.Empty) | ||
339 | m_assMapper.Get(item.AssetID, sender, senderAssetServer); | ||
340 | |||
341 | if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission) | ||
342 | m_assMapper.Post(item.AssetID, receiver, receiverAssetServer); | ||
302 | } | 343 | } |
303 | 344 | ||
304 | public override bool IsForeignUser(UUID userID, out string assetServerURL) | 345 | public override bool IsForeignUser(UUID userID, out string assetServerURL) |
305 | { | 346 | { |
306 | assetServerURL = string.Empty; | 347 | assetServerURL = string.Empty; |
307 | 348 | ||
308 | if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) | 349 | if (UserManagementModule != null) |
309 | { // foreign | 350 | { |
310 | ScenePresence sp = null; | 351 | if (!m_CheckSeparateAssets) |
311 | if (m_Scene.TryGetScenePresence(userID, out sp)) | ||
312 | { | 352 | { |
313 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 353 | if (!UserManagementModule.IsLocalGridUser(userID)) |
314 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | 354 | { // foreign |
315 | { | 355 | ScenePresence sp = null; |
316 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 356 | if (m_Scene.TryGetScenePresence(userID, out sp)) |
317 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 357 | { |
358 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
359 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | ||
360 | { | ||
361 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | ||
362 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
363 | } | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | ||
368 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
369 | } | ||
370 | return true; | ||
318 | } | 371 | } |
319 | } | 372 | } |
320 | else | 373 | else |
321 | { | 374 | { |
322 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | 375 | if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) |
323 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 376 | { |
377 | m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); | ||
378 | return false; | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); | ||
383 | return true; | ||
384 | } | ||
324 | } | 385 | } |
325 | return true; | ||
326 | } | 386 | } |
327 | |||
328 | return false; | 387 | return false; |
329 | } | 388 | } |
330 | 389 | ||
390 | private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL) | ||
391 | { | ||
392 | assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI"); | ||
393 | if (assetsURL == string.Empty) | ||
394 | { | ||
395 | AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid); | ||
396 | if (agent != null) | ||
397 | { | ||
398 | assetsURL = agent.ServiceURLs["AssetServerURI"].ToString(); | ||
399 | assetsURL = assetsURL.Trim(new char[] { '/' }); | ||
400 | } | ||
401 | } | ||
402 | return m_LocalAssetsURL.Equals(assetsURL); | ||
403 | } | ||
404 | |||
405 | |||
331 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) | 406 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) |
332 | { | 407 | { |
333 | InventoryItemBase item = base.GetItem(agentID, itemID); | 408 | InventoryItemBase item = base.GetItem(agentID, itemID); |