From f35eb8819c6a872e7c4727940ffc560f7d5d68bd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Mar 2010 18:57:29 +0000 Subject: Unify a previous refactor of object return with the older solution. We really don't need two methods doing the same thing, but differently. --- .../Region/CoreModules/World/Land/LandObject.cs | 2 +- .../World/Permissions/PermissionsModule.cs | 71 ++-------------------- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 ++- .../Region/Framework/Scenes/Scene.Permissions.cs | 29 ++------- .../RegionCombinerModule/RegionCombinerModule.cs | 3 +- .../RegionCombinerPermissionModule.cs | 11 +--- 6 files changed, 21 insertions(+), 102 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 1c65965..b8c35f7 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -915,7 +915,7 @@ namespace OpenSim.Region.CoreModules.World.Land foreach (List<SceneObjectGroup> ol in returns.Values) { - if (m_scene.Permissions.CanUseObjectReturn(this, type, remote_client, ol)) + if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); } } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 1533462..7159dc6 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnObjectEntry += CanObjectEntry; - m_scene.Permissions.OnReturnObject += CanReturnObject; //NOT YET IMPLEMENTED + m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED @@ -230,7 +230,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED - m_scene.Permissions.OnUseObjectReturn += CanUseObjectReturn; //NOT YET IMPLEMENTED m_scene.AddCommand(this, "bypass permissions", "bypass permissions <true / false>", @@ -1258,12 +1257,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } - private bool CanReturnObject(UUID objectID, UUID returnerID, Scene scene) + private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) { + if (objects.Count == 0) + return false; + DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - return GenericObjectPermission(returnerID, objectID, false); + return GenericObjectPermission(user, objects[0].UUID, false); } private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) @@ -1730,67 +1732,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions return GenericObjectPermission(agentID, prim, false); } - private bool CanUseObjectReturn(ILandObject parcel, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene) - { - DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); - if (m_bypassPermissions) return m_bypassPermissionsValue; - - long powers = 0; - if (parcel.LandData.GroupID != UUID.Zero) - client.GetGroupPowers(parcel.LandData.GroupID); - - switch (type) - { - case (uint)ObjectReturnType.Owner: - // Don't let group members return owner's objects, ever - // - if (parcel.LandData.IsGroupOwned) - { - if ((powers & (long)GroupPowers.ReturnGroupOwned) != 0) - return true; - } - else - { - if (parcel.LandData.OwnerID != client.AgentId) - return false; - } - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupOwned); - case (uint)ObjectReturnType.Group: - if (parcel.LandData.OwnerID != client.AgentId) - { - // If permissionis granted through a group... - // - if ((powers & (long)GroupPowers.ReturnGroupSet) != 0) - { - foreach (SceneObjectGroup g in new List<SceneObjectGroup>(retlist)) - { - // check for and remove group owned objects unless - // the user also has permissions to return those - // - if (g.OwnerID == g.GroupID && - ((powers & (long)GroupPowers.ReturnGroupOwned) == 0)) - { - retlist.Remove(g); - } - } - // And allow the operation - // - return true; - } - } - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupSet); - case (uint)ObjectReturnType.Other: - if ((powers & (long)GroupPowers.ReturnNonGroup) != 0) - return true; - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnNonGroup); - case (uint)ObjectReturnType.List: - break; - } - - return GenericParcelOwnerPermission(client.AgentId, parcel, 0); - // Is it correct to be less restrictive for lists of objects to be returned? - } - private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); switch (scriptType) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b2b061e..ffbf745 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1581,9 +1581,10 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient != null) { permissionToTake = - Permissions.CanReturnObject( - grp.UUID, - remoteClient.AgentId); + Permissions.CanReturnObjects( + null, + remoteClient.AgentId, + new List<SceneObjectGroup>() {grp}); permissionToDelete = permissionToTake; if (permissionToDelete) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d1d6b6a..7dab04f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); - public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene); + public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool TeleportHandler(UUID userID, Scene scene); - public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene); #endregion public class ScenePermissions @@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes public event EditObjectInventoryHandler OnEditObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; - public event ReturnObjectHandler OnReturnObject; + public event ReturnObjectsHandler OnReturnObjects; public event InstantMessageHandler OnInstantMessage; public event InventoryTransferHandler OnInventoryTransfer; public event ViewScriptHandler OnViewScript; @@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes public event CopyUserInventoryHandler OnCopyUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory; public event TeleportHandler OnTeleport; - public event UseObjectReturnHandler OnUseObjectReturn; #endregion #region Object Permission Checks @@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region RETURN OBJECT - public bool CanReturnObject(UUID objectID, UUID returnerID) + public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects) { - ReturnObjectHandler handler = OnReturnObject; + ReturnObjectsHandler handler = OnReturnObjects; if (handler != null) { Delegate[] list = handler.GetInvocationList(); - foreach (ReturnObjectHandler h in list) + foreach (ReturnObjectsHandler h in list) { - if (h(objectID, returnerID, m_scene) == false) + if (h(land, user, objects, m_scene) == false) return false; } } @@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes } return true; } - - public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List<SceneObjectGroup> retlist) - { - UseObjectReturnHandler handler = OnUseObjectReturn; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (UseObjectReturnHandler h in list) - { - if (h(landData, type, client, retlist, m_scene) == false) - return false; - } - } - return true; - } } } diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 92f060b..0b8771c 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -922,7 +922,7 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; - VirtualRegion.Permissions.OnReturnObject += BigRegion.PermissionModule.CanReturnObject; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnReturnObjects += BigRegion.PermissionModule.CanReturnObjects; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED @@ -948,7 +948,6 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED } #region console commands diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs index 4d1af57..393322d 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs @@ -135,9 +135,9 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint); } - public bool CanReturnObject(UUID objectid, UUID returnerid, Scene scene) + public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) { - return m_rootScene.Permissions.CanReturnObject(objectid, returnerid); + return m_rootScene.Permissions.CanReturnObjects(land, user, objects); } public bool CanRezObject(int objectcount, UUID owner, Vector3 objectposition, Scene scene) @@ -265,11 +265,6 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanTeleport(userid); } - public bool CanUseObjectReturn(ILandObject landdata, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene) - { - return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); - } - #endregion } -} \ No newline at end of file +} -- cgit v1.1