* Refactored Permissions into ScenePresence as requested by MW

* Un-hackerized generating the client_flags 
* Now handling the ObjectPermissions Update packet 
* Warning: Backup your prim before updating.  If you fail to do so and something goes wrong then, All Yr prim are belong to us!
afrisby
Teravus Ovares 2007-12-05 06:44:32 +00:00
parent a24b6fe924
commit bb824eadee
10 changed files with 321 additions and 132 deletions

View File

@ -331,6 +331,9 @@ namespace OpenSim.Framework
public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName);
public delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID);
public delegate void ObjectPermissions(IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID, List<ObjectPermissionsPacket.ObjectDataBlock> permChanges);
public interface IClientAPI
{
@ -387,6 +390,7 @@ namespace OpenSim.Framework
event StatusChange OnChildAgentStatus;
event GenericCall2 OnStopMovement;
event Action<LLUUID> OnRemoveAvatar;
event ObjectPermissions OnObjectPermissions;
event CreateNewInventoryItem OnCreateNewInventoryItem;
event CreateInventoryFolder OnCreateNewInventoryFolder;

View File

@ -564,6 +564,8 @@ namespace OpenSim.Region.ClientStack
// Previously ClientView.API partial class
public event Action<IClientAPI> OnLogout;
public event ObjectPermissions OnObjectPermissions;
public event Action<IClientAPI> OnConnectionClosed;
public event ViewerEffectEventHandler OnViewerEffect;
public event ImprovedInstantMessage OnInstantMessage;
@ -2919,7 +2921,35 @@ namespace OpenSim.Region.ClientStack
}
break;
case PacketType.ObjectPermissions:
// MainLog.Instance.Warn("CLIENT", "unhandled packet " + Pack.ToString());
MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString());
ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
List<ObjectPermissionsPacket.ObjectDataBlock> permChanges = new List<ObjectPermissionsPacket.ObjectDataBlock>();
for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
{
permChanges.Add(newobjPerms.ObjectData[i]);
}
// Here's our data,
// PermField contains the field the info goes into
// PermField determines which mask we're changing
//
// chmask is the mask of the change
// setTF is whether we're adding it or taking it away
//
// objLocalID is the localID of the object.
// Unfortunately, we have to pass the event the packet because objData is an array
// That means multiple object perms may be updated in a single packet.
LLUUID AgentID = newobjPerms.AgentData.AgentID;
LLUUID SessionID = newobjPerms.AgentData.SessionID;
if (OnObjectPermissions != null)
{
OnObjectPermissions(this, AgentID, SessionID, permChanges);
}
break;
case PacketType.RequestObjectPropertiesFamily:

View File

@ -164,7 +164,7 @@ namespace OpenSim.Region.Environment
if (user == objectOwner)
permission = true;
// If the 'anybody can move' flag is set then allow anyone to move it
// If the 'anybody can move' flag is set then allow anyone to copy it
if ((objectflags & (uint)LLObject.ObjectFlags.ObjectCopy ) != 0)
permission = true;
@ -212,7 +212,7 @@ namespace OpenSim.Region.Environment
// Added this because at this point in time it wouldn't be wise for
// the administrator object permissions to take effect.
LLUUID objectOwner = task.OwnerID;
uint objectflags = task.RootPart.ObjectFlags;
uint objectflags = task.RootPart.EveryoneMask;
// Object owners should be able to edit their own content
if (user == objectOwner)
@ -242,6 +242,54 @@ namespace OpenSim.Region.Environment
return permission;
}
public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID)
{
if (!m_scene.Entities.ContainsKey(objID))
{
return 0;
}
// If it's not an object, we cant edit it.
if (!(m_scene.Entities[objID] is SceneObjectGroup))
{
return 0;
}
SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID];
LLUUID taskOwner = null;
// Added this because at this point in time it wouldn't be wise for
// the administrator object permissions to take effect.
LLUUID objectOwner = task.OwnerID;
uint OwnerMask = task.RootPart.ObjectFlags | task.RootPart.OwnerMask;
uint GroupMask = task.RootPart.ObjectFlags | task.RootPart.GroupMask;
uint EveryoneMask = task.RootPart.ObjectFlags | task.RootPart.EveryoneMask;
if (m_bypassPermissions)
return OwnerMask;
// Object owners should be able to edit their own content
if (user == objectOwner)
return OwnerMask;
// Users should be able to edit what is over their land.
if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID ==
user)
return OwnerMask;
// Estate users should be able to edit anything in the sim
if (IsEstateManager(user))
return OwnerMask;
// Admin objects should not be editable by the above
if (IsAdministrator(taskOwner))
return EveryoneMask;
// Admin should be able to edit anything in the sim (including admin objects)
if (IsAdministrator(user))
return OwnerMask;
return 0;
}
protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId)
{

View File

@ -555,7 +555,7 @@ namespace OpenSim.Region.Environment.Scenes
public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
{
if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID))
if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID) || PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, objectID))
{
SceneObjectGroup group = GetGroupByPrim(objectID);
if (group != null)
@ -729,7 +729,7 @@ namespace OpenSim.Region.Environment.Scenes
if (originPrim != null)
{
if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID))
if (PermissionsMngr.CanCopyObject(AgentID, originPrim.UUID) || PermissionsMngr.AnyoneCanCopyPermission(AgentID, originPrim.UUID))
{
SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID);
copy.AbsolutePosition = copy.AbsolutePosition + offset;

View File

@ -543,6 +543,7 @@ namespace OpenSim.Region.Environment.Scenes
AddEntity(group);
group.AbsolutePosition = pos;
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.ApplySanePermissions();
bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim);
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
{

View File

@ -733,20 +733,8 @@ namespace OpenSim.Region.Environment.Scenes
{
AddEntityFromStorage(prim);
SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
if (m_permissions)
{
rootPart.EveryoneMask = rootPart.ObjectFlags;
rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
rootPart.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
}
else
{
rootPart.EveryoneMask = rootPart.ObjectFlags;
}
rootPart.ApplySanePermissions();
bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
rootPart.PhysActor = PhysicsScene.AddPrimShape(
@ -839,6 +827,7 @@ namespace OpenSim.Region.Environment.Scenes
AddEntity(sceneOb);
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
// if grass or tree, make phantom
//rootPart.ApplySanePermissions();
if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255))
{
rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
@ -983,6 +972,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
client.OnRequestGodlikePowers += handleRequestGodlikePowers;
client.OnGodKickUser += handleGodlikeKickUser;
client.OnObjectPermissions += HandleObjectPermissionsUpdate;
client.OnCreateNewInventoryItem += CreateNewInventoryItem;
client.OnCreateNewInventoryFolder += CommsManager.UserProfileCacheService.HandleCreateInventoryFolder;
@ -1404,16 +1394,16 @@ namespace OpenSim.Region.Environment.Scenes
{
if (godid == RegionInfo.MasterAvatarAssignedUUID)
{
if (agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb"))
if (agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb"))
{
ClientManager.ForEachClient(delegate (IClientAPI controller)
ClientManager.ForEachClient(delegate(IClientAPI controller)
{
ScenePresence p = GetScenePresence(controller.AgentId);
bool childagent = false;
if (!p.Equals(null))
if (p.IsChildAgent)
childagent=true;
childagent = true;
if (controller.AgentId != godid && !childagent) // Do we really want to kick the initiator of this madness?
{
controller.Kick(Helpers.FieldToUTF8String(reason));
@ -1424,7 +1414,7 @@ namespace OpenSim.Region.Environment.Scenes
// This is a bit crude. It seems the client will be null before it actually stops the thread
// The thread will kill itself eventually :/
// Is there another way to make sure *all* clients get this 'inter region' message?
ClientManager.ForEachClient(delegate (IClientAPI controller)
ClientManager.ForEachClient(delegate(IClientAPI controller)
{
ScenePresence p = GetScenePresence(controller.AgentId);
bool childagent = false;
@ -1439,7 +1429,7 @@ namespace OpenSim.Region.Environment.Scenes
}
);
}
else
else
{
m_scenePresences[agentid].ControllingClient.Kick(Helpers.FieldToUTF8String(reason));
m_scenePresences[agentid].ControllingClient.Close();
@ -1452,7 +1442,26 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
public void HandleObjectPermissionsUpdate (IClientAPI controller, LLUUID AgentID, LLUUID SessionID, List<libsecondlife.Packets.ObjectPermissionsPacket.ObjectDataBlock> permChanges)
{
// Check for spoofing.. since this is permissions we're talking about here!
if ((controller.SessionId == SessionID) && (controller.AgentId == AgentID))
{
for (int i = 0; i < permChanges.Count; i++)
{
// Tell the object to do permission update
byte field = permChanges[i].Field;
uint localID = permChanges[i].ObjectLocalID;
uint mask = permChanges[i].Mask;
byte addRemTF = permChanges[i].Set;
SceneObjectGroup chObjectGroup = GetGroupByPrim(localID);
chObjectGroup.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
}
}
}
public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
{
foreach (ScenePresence presence in m_scenePresences.Values)

View File

@ -283,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes
AddPart(part);
part.RegionHandle = m_regionHandle;
part.ApplyPermissions();
part.ApplySanePermissions();
}
break;
case XmlNodeType.EndElement:
@ -530,7 +530,7 @@ namespace OpenSim.Region.Environment.Scenes
dupe.m_regionHandle = m_regionHandle;
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID);
dupe.m_rootPart.ApplySanePermissions();
/// may need to create a new Physics actor.
if (dupe.RootPart.PhysActor != null)
@ -555,6 +555,8 @@ namespace OpenSim.Region.Environment.Scenes
// So, we have to make a copy of this one, set it in it's place then set the owner on this one
SetRootPartOwner(m_rootPart, cAgentID, cGroupID);
m_rootPart.ScheduleFullUpdate();
List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values);
@ -592,6 +594,15 @@ namespace OpenSim.Region.Environment.Scenes
part.LastOwnerID = part.OwnerID;
part.OwnerID = cAgentID;
part.GroupID = cGroupID;
if (part.OwnerID != cAgentID)
{
// Apply Next Owner Permissions if we're not bypassing permissions
if (!m_scene.PermissionsMngr.BypassPermissions)
m_rootPart.ApplyNextOwnerPermissions();
}
part.ScheduleFullUpdate();
}
@ -1224,6 +1235,14 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
{
SceneObjectPart updatePart = GetChildPart(localID);
updatePart.UpdatePermissions(AgentID,field,localID,mask,addRemTF);
}
#endregion
#region Shape
@ -1514,13 +1533,13 @@ namespace OpenSim.Region.Environment.Scenes
#region Client Updating
public void SendFullUpdateToClient(IClientAPI remoteClient)
public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientFlags)
{
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
SendPartFullUpdate(remoteClient, part);
SendPartFullUpdate(remoteClient, part, clientFlags);
}
}
}
@ -1530,15 +1549,15 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="part"></param>
internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part)
internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
{
if (m_rootPart.UUID == part.UUID)
{
part.SendFullUpdateToClient(remoteClient, AbsolutePosition);
part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
}
else
{
part.SendFullUpdateToClient(remoteClient);
part.SendFullUpdateToClient(remoteClient, clientFlags);
}
}

View File

@ -44,8 +44,12 @@ namespace OpenSim.Region.Environment.Scenes
{
public class SceneObjectPart : IScriptHost
{
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer;
private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner;
private const uint OBJNEXT_OWNER = 2147483647;
private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
private string m_inventoryFileName = "";
private LLUUID m_folderID = LLUUID.Zero;
@ -64,11 +68,13 @@ namespace OpenSim.Region.Environment.Scenes
public Int32 CreationDate;
public uint ParentID = 0;
public uint OwnerMask = FULL_MASK_PERMISSIONS;
public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
public uint GroupMask = FULL_MASK_PERMISSIONS;
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS;
// Main grid has default permissions as follows
//
public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
public uint NextOwnerMask = OBJNEXT_OWNER;
public uint GroupMask = (uint) LLObject.ObjectFlags.None;
public uint EveryoneMask = (uint) LLObject.ObjectFlags.None;
public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER;
protected byte[] m_particleSystem = new byte[0];
@ -463,17 +469,11 @@ namespace OpenSim.Region.Environment.Scenes
m_folderID = LLUUID.Random();
m_flags = 0;
m_flags |= LLObject.ObjectFlags.ObjectModify |
LLObject.ObjectFlags.ObjectCopy |
LLObject.ObjectFlags.ObjectYouOwner |
LLObject.ObjectFlags.Touch |
LLObject.ObjectFlags.ObjectMove |
LLObject.ObjectFlags.AllowInventoryDrop |
LLObject.ObjectFlags.ObjectTransfer |
LLObject.ObjectFlags.CreateSelected |
LLObject.ObjectFlags.ObjectOwnerModify;
m_flags |= LLObject.ObjectFlags.Touch |
LLObject.ObjectFlags.AllowInventoryDrop |
LLObject.ObjectFlags.CreateSelected;
ApplyPermissions();
ApplySanePermissions();
ScheduleFullUpdate();
}
@ -511,7 +511,7 @@ namespace OpenSim.Region.Environment.Scenes
RotationOffset = rotation;
ObjectFlags = flags;
ApplyPermissions();
ApplySanePermissions();
// ApplyPhysics();
ScheduleFullUpdate();
@ -552,24 +552,99 @@ namespace OpenSim.Region.Environment.Scenes
DoPhysicsPropertyUpdate(usePhysics, true);
}
public void ApplyPermissions()
public void ApplyNextOwnerPermissions()
{
if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
{
EveryoneMask = ObjectFlags;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
}
else
{
EveryoneMask = ObjectFlags;
}
BaseMask = NextOwnerMask;
OwnerMask = NextOwnerMask;
}
public void ApplySanePermissions()
{
// These are some flags that The OwnerMask should never have
OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics;
OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom;
OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted;
OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch;
OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary;
OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
OwnerMask &= ~(uint)LLObject.ObjectFlags.Money;
OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
// These are some flags that the next owner mask should never have
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
// These are some flags that the GroupMask should never have
GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
GroupMask &= ~(uint)LLObject.ObjectFlags.Physics;
GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom;
GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted;
GroupMask &= ~(uint)LLObject.ObjectFlags.Touch;
GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary;
GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
GroupMask &= ~(uint)LLObject.ObjectFlags.Money;
GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
// These are some flags that EveryoneMask should never have
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty;
EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected;
// These are some flags that ObjectFlags (m_flags) should never have
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
}
/// <summary>
@ -774,9 +849,7 @@ namespace OpenSim.Region.Environment.Scenes
{
//Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString());
m_flags |= flag;
BaseMask |= (uint)flag;
GroupMask |= (uint)flag;
EveryoneMask |= (uint)flag;
}
uint currflag = (uint)m_flags;
//System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
@ -790,9 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
{
//Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString());
m_flags &= ~flag;
BaseMask &= ~(uint)flag;
GroupMask &= ~(uint)flag;
EveryoneMask &= ~(uint)flag;
}
//System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
//ScheduleFullUpdate();
@ -1198,6 +1269,51 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
{
// Are we the owner?
if (AgentID == OwnerID)
{
MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString());
//Field 8 = EveryoneMask
if (field == (byte)8)
{
MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask));
if (addRemTF == (byte)0)
{
//EveryoneMask = (uint)0;
EveryoneMask &= ~mask;
//EveryoneMask &= ~(uint)57344;
}
else
{
//EveryoneMask = (uint)0;
EveryoneMask |= mask;
//EveryoneMask |= (uint)57344;
}
ScheduleFullUpdate();
}
//Field 16 = NextownerMask
if (field == (byte)16)
{
if (addRemTF == (byte)0)
{
NextOwnerMask &= ~mask;
}
else
{
NextOwnerMask |= mask;
}
ScheduleFullUpdate();
}
}
}
#region Client Update Methods
public void AddFullUpdateToAllAvatars()
@ -1222,7 +1338,8 @@ namespace OpenSim.Region.Environment.Scenes
List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
for (int i = 0; i < avatars.Count; i++)
{
m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this);
// Ugly reference :(
m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID));
}
}
@ -1230,20 +1347,20 @@ namespace OpenSim.Region.Environment.Scenes
///
/// </summary>
/// <param name="remoteClient"></param>
public void SendFullUpdate(IClientAPI remoteClient)
public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
{
m_parentGroup.SendPartFullUpdate(remoteClient, this);
m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
public void SendFullUpdateToClient(IClientAPI remoteClient)
public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientflags)
{
LLVector3 lPos;
lPos = OffsetPosition;
SendFullUpdateToClient(remoteClient, lPos);
SendFullUpdateToClient(remoteClient, lPos, clientflags);
}
/// <summary>
@ -1251,56 +1368,13 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="lPos"></param>
public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos)
public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos, uint clientFlags)
{
LLQuaternion lRot;
lRot = RotationOffset;
uint clientFlags = ObjectFlags & ~(uint)LLObject.ObjectFlags.CreateSelected;
List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
foreach (ScenePresence s in avatars)
if (remoteClient.AgentId == OwnerID)
{
if (s.m_uuid == OwnerID)
{
if (s.ControllingClient == remoteClient)
{
clientFlags = ObjectFlags;
m_flags &= ~LLObject.ObjectFlags.CreateSelected;
}
break;
}
}
// If you can't edit it, send the base permissions minus the flag to edit
// We're going to be moving this into ScenePresence and the PermissionsManager itself.
if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
{
if (ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID))
{
// we should be merging the objectflags with the ownermask here.
// TODO: Future refactoring here.
clientFlags = ObjectFlags;
}
else
{
//clientFlags = ObjectFlags;
clientFlags = EveryoneMask;
if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanCopyPermission(remoteClient.AgentId, this.ParentGroup.UUID))
{
clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
}
if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, this.ParentGroup.UUID))
{
clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
}
clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
}
clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected;
}
@ -1479,11 +1553,11 @@ namespace OpenSim.Region.Environment.Scenes
public LLUUID item_id = LLUUID.Zero;
public LLUUID parent_id = LLUUID.Zero; //parent folder id
public uint base_mask = FULL_MASK_PERMISSIONS;
public uint owner_mask = FULL_MASK_PERMISSIONS;
public uint group_mask = FULL_MASK_PERMISSIONS;
public uint everyone_mask = FULL_MASK_PERMISSIONS;
public uint next_owner_mask = FULL_MASK_PERMISSIONS;
public uint base_mask = FULL_MASK_PERMISSIONS_GENERAL;
public uint owner_mask = FULL_MASK_PERMISSIONS_GENERAL;
public uint group_mask = FULL_MASK_PERMISSIONS_GENERAL;
public uint everyone_mask = FULL_MASK_PERMISSIONS_GENERAL;
public uint next_owner_mask = FULL_MASK_PERMISSIONS_GENERAL;
public LLUUID creator_id = LLUUID.Zero;
public LLUUID owner_id = LLUUID.Zero;
public LLUUID last_owner_id = LLUUID.Zero;

View File

@ -343,7 +343,10 @@ namespace OpenSim.Region.Environment.Scenes
}
// }
}
public uint GenerateClientFlags(LLUUID ObjectID)
{
return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID);
}
public void SendPrimUpdates()
{
// if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode)
@ -380,7 +383,7 @@ namespace OpenSim.Region.Environment.Scenes
if (update.LastFullUpdateTime < part.TimeStampFull)
{
//need to do a full update
part.SendFullUpdate(ControllingClient);
part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
// We'll update to the part's timestamp rather than the current to
// avoid the race condition whereby the next tick occurs while we are
@ -403,7 +406,7 @@ namespace OpenSim.Region.Environment.Scenes
else
{
//never been sent to client before so do full update
part.SendFullUpdate(ControllingClient);
part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
ScenePartUpdate update = new ScenePartUpdate();
update.FullID = part.UUID;
update.LastFullUpdateTime = part.TimeStampFull;

View File

@ -47,6 +47,7 @@ namespace SimpleApp
#pragma warning disable 67
public event Action<IClientAPI> OnLogout;
public event ObjectPermissions OnObjectPermissions;
public event Action<IClientAPI> OnConnectionClosed;
public event ImprovedInstantMessage OnInstantMessage;