Unify a previous refactor of object return with the older solution. We

really don't need two methods doing the same thing, but differently.
slimupdates
Melanie 2010-03-18 18:57:29 +00:00
parent 73e9b0be72
commit 734b0416de
6 changed files with 21 additions and 102 deletions

View File

@ -892,7 +892,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);
}
}

View File

@ -217,7 +217,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
@ -247,7 +247,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>",
@ -1275,12 +1274,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)
@ -1747,67 +1749,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) {

View File

@ -1518,9 +1518,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)

View File

@ -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;
}
}
}

View File

@ -1004,7 +1004,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
@ -1030,7 +1030,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

View File

@ -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
}
}