From d42de53ddaeae154f17bbc240bdfdf6a349ea860 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 29 Apr 2016 21:23:32 +0200 Subject: [PATCH] Allow default permissions from the viewer to be applied to uploaded objects. Make inventory items reflect coorect permissions immediately unstead of after relog --- .../Capabilities/LLSDAssetUploadComplete.cs | 4 ++ .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 47 +++++++++++++++---- .../AssetTransaction/AssetXferUploader.cs | 2 +- .../HGInventoryAccessModule.cs | 34 ++++++++++---- .../Region/Framework/Scenes/EventManager.cs | 6 +-- .../Framework/Scenes/Scene.Inventory.cs | 4 +- 6 files changed, 74 insertions(+), 23 deletions(-) diff --git a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs index ae8eb09345..476cf6e7fe 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs @@ -40,6 +40,10 @@ namespace OpenSim.Framework.Capabilities public string state = String.Empty; public LLSDAssetUploadError error = null; //public bool success = false; + public int new_next_owner_mask = 0; + public int new_group_mask = 0; + public int new_everyone_mask = 0; + public int inventory_item_flags = 0; public LLSDAssetUploadComplete() { diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 66b9f06fc4..39ba708a8a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload, ref string error); + bool IsAtestUpload, ref string error, ref int nextOwnerMask, ref int groupMask, ref int everyoneMask); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -666,7 +666,8 @@ namespace OpenSim.Region.ClientStack.Linden AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, - texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload); + texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload, + llsdRequest.next_owner_mask, llsdRequest.group_mask, llsdRequest.everyone_mask); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -713,9 +714,9 @@ namespace OpenSim.Region.ClientStack.Linden UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload, ref string error) + bool IsAtestUpload, ref string error, + ref int nextOwnerMask, ref int groupMask, ref int everyoneMask) { - lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.processUpload; @@ -1081,7 +1082,13 @@ namespace OpenSim.Region.ClientStack.Linden { prim.BaseMask = (uint)PermissionMask.All | (uint)PermissionMask.Export; prim.OwnerMask = (uint)PermissionMask.All | (uint)PermissionMask.Export; - prim.NextOwnerMask = (uint)PermissionMask.Transfer; + prim.GroupMask = prim.BaseMask & (uint)groupMask; + prim.EveryoneMask = prim.BaseMask & (uint)everyoneMask; + prim.NextOwnerMask = prim.BaseMask & (uint)nextOwnerMask; + // If the viewer gives us bogus permissions, revert to the SL + // default of transfer only. + if ((prim.NextOwnerMask & (uint)PermissionMask.All) == 0) + prim.NextOwnerMask = (uint)PermissionMask.Transfer; } if(istest) @@ -1191,6 +1198,7 @@ namespace OpenSim.Region.ClientStack.Linden { item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); + item.GroupPermissions = 0; item.EveryOnePermissions = 0; item.NextPermissions = 0; } @@ -1198,12 +1206,19 @@ namespace OpenSim.Region.ClientStack.Linden { item.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; item.CurrentPermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; - item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.Transfer; + item.GroupPermissions = item.BasePermissions & (uint)groupMask; + item.EveryOnePermissions = item.BasePermissions & (uint)everyoneMask; + item.NextPermissions = item.BasePermissions & (uint)nextOwnerMask; + if ((item.NextPermissions & (uint)PermissionMask.All) == 0) + item.NextPermissions = (uint)PermissionMask.Transfer; } item.CreationDate = Util.UnixTimeSinceEpoch(); + everyoneMask = (int)item.EveryOnePermissions; + groupMask = (int)item.GroupPermissions; + nextOwnerMask = (int)item.NextPermissions; + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); if (AddNewInventoryItem != null) @@ -1592,12 +1607,17 @@ namespace OpenSim.Region.ClientStack.Linden private int m_nreqmeshs; private int m_nreqinstances; private bool m_IsAtestUpload; + + private int m_nextOwnerMask; + private int m_groupMask; + private int m_everyoneMask; + public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, IHttpServer httpServer, bool dumpAssetsToFile, int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload) + bool IsAtestUpload, int nextOwnerMask, int groupMask, int everyoneMask) { m_assetName = assetName; m_assetDes = description; @@ -1621,6 +1641,10 @@ namespace OpenSim.Region.ClientStack.Linden m_timeoutTimer.Interval = 120000; m_timeoutTimer.AutoReset = false; m_timeoutTimer.Start(); + + m_nextOwnerMask = nextOwnerMask; + m_groupMask = groupMask; + m_everyoneMask = everyoneMask; } /// @@ -1661,8 +1685,13 @@ namespace OpenSim.Region.ClientStack.Linden { handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, - ref m_error); + ref m_error, ref m_nextOwnerMask, ref m_groupMask, ref m_everyoneMask); } + + uploadComplete.new_next_owner_mask = m_nextOwnerMask; + uploadComplete.new_group_mask = m_groupMask; + uploadComplete.new_everyone_mask = m_everyoneMask; + if (m_IsAtestUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 64bcfa2cf9..60a254e59e 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -429,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction m_transactions.RemoveXferUploader(m_transactionID); - m_Scene.EventManager.TriggerOnNewInventoryItemUploadComplete(ourClient.AgentId, (AssetType)type, m_asset.FullID, m_asset.Name, 0); + m_Scene.EventManager.TriggerOnNewInventoryItemUploadComplete(item, 0); } /// diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 582b267ca4..6b78fe8c18 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -209,15 +209,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } - public void PostInventoryAsset(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel) + public void PostInventoryAsset(InventoryItemBase item, int userlevel) { - if (type == AssetType.Link) + if (item.AssetType == (int)AssetType.Link) return; string userAssetServer = string.Empty; - if (IsForeignUser(avatarID, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) + if (IsForeignUser(item.Owner, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) { - m_assMapper.Post(assetID, avatarID, userAssetServer); + m_assMapper.Post(item.AssetID, item.Owner, userAssetServer); } } @@ -248,7 +248,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); - PostInventoryAsset(remoteClient.AgentId, AssetType.Unknown, newAssetID, "", 0); + // We need to construct this here to satisfy the calling convention. + // Better this in two places than five formal params in all others. + InventoryItemBase item = new InventoryItemBase(); + item.Owner = remoteClient.AgentId; + item.AssetType = (int)AssetType.Unknown; + item.AssetID = newAssetID; + item.Name = String.Empty; + + PostInventoryAsset(item, 0); return newAssetID; } @@ -260,7 +268,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { if (base.UpdateInventoryItemAsset(ownerID, item, asset)) { - PostInventoryAsset(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0); + PostInventoryAsset(item, 0); return true; } @@ -273,9 +281,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess protected override void ExportAsset(UUID agentID, UUID assetID) { if (!assetID.Equals(UUID.Zero)) - PostInventoryAsset(agentID, AssetType.Unknown, assetID, "", 0); + { + InventoryItemBase item = new InventoryItemBase(); + item.Owner = agentID; + item.AssetType = (int)AssetType.Unknown; + item.AssetID = assetID; + item.Name = String.Empty; + + PostInventoryAsset(item, 0); + } else + { m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); + } } /// @@ -535,4 +553,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 0a6bca4c4e..868359921d 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -748,7 +748,7 @@ namespace OpenSim.Region.Framework.Scenes public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); - public delegate void NewInventoryItemUploadComplete(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel); + public delegate void NewInventoryItemUploadComplete(InventoryItemBase item, int userlevel); public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; @@ -2262,7 +2262,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, AssetType type, UUID AssetID, String AssetName, int userlevel) + public void TriggerOnNewInventoryItemUploadComplete(InventoryItemBase item, int userlevel) { NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = OnNewInventoryItemUploadComplete; if (handlerNewInventoryItemUpdateComplete != null) @@ -2271,7 +2271,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - d(agentID, type, AssetID, AssetName, userlevel); + d(item, userlevel); } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1910a78ae3..a28737e24e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -149,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes userlevel = 1; } if (trigger) - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); + EventManager.TriggerOnNewInventoryItemUploadComplete(item, userlevel); return true; } @@ -191,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes userlevel = 1; } if (trigger) - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); + EventManager.TriggerOnNewInventoryItemUploadComplete(item, userlevel); if (originalFolder != UUID.Zero) {