From 3965fa2ff3fd59dd5bb049b1321468380cf2af2d Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 24 May 2008 09:40:14 +0000 Subject: * Implements selected object return. * If user is in the same sim with you, they'll get an inventory update, if not.... oh well, they'll have to clear their cache potentially before they'll see it. --- .../Environment/Modules/World/Land/LandObject.cs | 70 ++-- .../Region/Environment/Scenes/Scene.Inventory.cs | 352 ++++++++++++++++----- 2 files changed, 312 insertions(+), 110 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index 54870d8..98f3a3a 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs @@ -596,23 +596,32 @@ namespace OpenSim.Region.Environment.Modules.World.Land if (m_scene.ExternalChecks.ExternalChecksCanEditParcel(remote_client.AgentId, this)) { List resultLocalIDs = new List(); - foreach (SceneObjectGroup obj in primsOverMe) + try { - if (obj.LocalId > 0) + lock (primsOverMe) { - if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID) - { - resultLocalIDs.Add(obj.LocalId); - } - // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support - // { - // } - else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && - obj.OwnerID != remote_client.AgentId) + foreach (SceneObjectGroup obj in primsOverMe) { - resultLocalIDs.Add(obj.LocalId); + if (obj.LocalId > 0) + { + if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID) + { + resultLocalIDs.Add(obj.LocalId); + } + // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support + // { + // } + else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && + obj.OwnerID != remote_client.AgentId) + { + resultLocalIDs.Add(obj.LocalId); + } + } } } + } catch (InvalidOperationException) + { + m_log.Error("[LAND]: Unable to force select the parcel objects. Arr."); } remote_client.sendForceClientSelectObjects(resultLocalIDs); @@ -633,26 +642,37 @@ namespace OpenSim.Region.Environment.Modules.World.Land { Dictionary primCount = new Dictionary(); - foreach (SceneObjectGroup obj in primsOverMe) + lock (primsOverMe) { try { - if (!primCount.ContainsKey(obj.OwnerID)) + + foreach (SceneObjectGroup obj in primsOverMe) { - primCount.Add(obj.OwnerID, 0); + try + { + if (!primCount.ContainsKey(obj.OwnerID)) + { + primCount.Add(obj.OwnerID, 0); + } + } + catch (NullReferenceException) + { + m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); + } + try + { + primCount[obj.OwnerID] += obj.PrimCount; + } + catch (KeyNotFoundException) + { + m_log.Error("[LAND]: Unable to match a prim with it's owner."); + } } } - catch (NullReferenceException) - { - m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); - } - try - { - primCount[obj.OwnerID] += obj.PrimCount; - } - catch (KeyNotFoundException) + catch (InvalidOperationException) { - m_log.Error("[LAND]: Unable to match a prim with it's owner."); + m_log.Error("[LAND]: Unable to Enumerate Land object arr."); } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index e92178c..a284ba5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -70,6 +70,24 @@ namespace OpenSim.Region.Environment.Scenes AddInventoryItem(agentID, item); } + public bool AddInventoryItemReturned(LLUUID AgentId, InventoryItemBase item) + { + CachedUserInfo userInfo + = CommsManager.UserProfileCacheService.GetUserDetails(AgentId); + if (userInfo != null) + { + userInfo.AddItem(item); + return true; + } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Agent was not found for add of item {1} {2}", item.Name, item.ID); + + return false; + } + } + /// /// Add an inventory item to an avatar's inventory. /// @@ -1060,6 +1078,7 @@ namespace OpenSim.Region.Environment.Scenes } } + /// /// Called when an object is removed from the environment into inventory. /// @@ -1068,123 +1087,178 @@ namespace OpenSim.Region.Environment.Scenes public virtual void DeRezObject(Packet packet, IClientAPI remoteClient) { DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; + + LLUUID folderID = LLUUID.Zero; - if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) - { - //currently following code not used (or don't know of any case of destination being zero - } - else + + + + + foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) { - foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) - { // m_log.DebugFormat( // "[AGENT INVENTORY]: Received request to derez {0} into folder {1}", // Data.ObjectLocalID, DeRezPacket.AgentBlock.DestinationID); - EntityBase selectedEnt = null; - //m_log.Info("[CLIENT]: LocalID:" + Data.ObjectLocalID.ToString()); + EntityBase selectedEnt = null; + //m_log.Info("[CLIENT]: LocalID:" + Data.ObjectLocalID.ToString()); - List EntityList = GetEntities(); + List EntityList = GetEntities(); - foreach (EntityBase ent in EntityList) + foreach (EntityBase ent in EntityList) + { + if (ent.LocalId == Data.ObjectLocalID) { - if (ent.LocalId == Data.ObjectLocalID) - { - selectedEnt = ent; - break; - } + selectedEnt = ent; + break; } - if (selectedEnt != null) + } + if (selectedEnt != null) + { + bool permissionToTake = false; + bool permissionToDelete = false; + if (DeRezPacket.AgentBlock.Destination == 1)// Take Copy { - bool permissionToTake = false; - bool permissionToDelete = false; - if (DeRezPacket.AgentBlock.Destination == 1)// Take Copy - { - permissionToTake = ExternalChecks.ExternalChecksCanTakeCopyObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); - permissionToDelete = false; //Just taking copy! + permissionToTake = ExternalChecks.ExternalChecksCanTakeCopyObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); + permissionToDelete = false; //Just taking copy! - } - else if (DeRezPacket.AgentBlock.Destination == 4) //Take - { - // Take - permissionToTake = ExternalChecks.ExternalChecksCanTakeObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); - permissionToDelete = permissionToTake; //If they can take, they can delete! - } + } + else if (DeRezPacket.AgentBlock.Destination == 4) //Take + { + // Take + permissionToTake = ExternalChecks.ExternalChecksCanTakeObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); + permissionToDelete = permissionToTake; //If they can take, they can delete! + } - else if (DeRezPacket.AgentBlock.Destination == 6) //Delete - { - permissionToTake = false; - permissionToDelete = ExternalChecks.ExternalChecksCanDeleteObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); - } + else if (DeRezPacket.AgentBlock.Destination == 6) //Delete + { + permissionToTake = ExternalChecks.ExternalChecksCanDeleteObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); + permissionToDelete = ExternalChecks.ExternalChecksCanDeleteObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); + } + else if (DeRezPacket.AgentBlock.Destination == 9) //Return + { + permissionToTake = ExternalChecks.ExternalChecksCanDeleteObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); + permissionToDelete = ExternalChecks.ExternalChecksCanDeleteObject(((SceneObjectGroup)selectedEnt).UUID, remoteClient.AgentId); + } - SceneObjectGroup objectGroup = (SceneObjectGroup)selectedEnt; + SceneObjectGroup objectGroup = (SceneObjectGroup)selectedEnt; + + if (permissionToTake) + { - if (permissionToTake) + string sceneObjectXml = objectGroup.ToXmlString(); + + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) { - string sceneObjectXml = objectGroup.ToXmlString(); + string searchFolder = ""; + + if (DeRezPacket.AgentBlock.Destination == 6) + searchFolder = "Trash"; + else if (DeRezPacket.AgentBlock.Destination == 9) + searchFolder = "Lost And Found"; + + // If we're deleting someone else's item, it goes back to their deleted items folder + // If we're returning someone's item, it goes back to the owner's Lost And Found folder. - CachedUserInfo userInfo = - CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) + if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero || (DeRezPacket.AgentBlock.Destination == 6 && objectGroup.OwnerID != remoteClient.AgentId)) { - AssetBase asset = CreateAsset( - ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId), - ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId), - (sbyte) InventoryType.Object, - (sbyte) AssetType.Object, - Helpers.StringToField(sceneObjectXml)); - AssetCache.AddAsset(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Creator = objectGroup.RootPart.CreatorID; - item.Owner = remoteClient.AgentId; - item.ID = LLUUID.Random(); - item.AssetID = asset.FullID; - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - item.InvType = asset.InvType; - item.Folder = DeRezPacket.AgentBlock.DestinationID; - if ((remoteClient.AgentId != objectGroup.RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions()) + List subrootfolders = userInfo.RootFolder.RequestListOfFolders(); + foreach (InventoryFolderBase flder in subrootfolders) { - uint perms=objectGroup.GetEffectivePermissions(); - uint nextPerms=(perms & 7) << 13; - if ((nextPerms & (uint)PermissionMask.Copy) == 0) - perms &= ~(uint)PermissionMask.Copy; - if ((nextPerms & (uint)PermissionMask.Transfer) == 0) - perms &= ~(uint)PermissionMask.Transfer; - if ((nextPerms & (uint)PermissionMask.Modify) == 0) - perms &= ~(uint)PermissionMask.Modify; - - item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; - item.CurrentPermissions = item.BasePermissions; - item.NextPermissions = objectGroup.RootPart.NextOwnerMask; - item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; - item.CurrentPermissions |= 8; // Slam! + if (flder.Name == "Lost And Found") + { + folderID = flder.ID; + break; + } } - else + + if (folderID == LLUUID.Zero) { - item.BasePermissions = objectGroup.GetEffectivePermissions(); - item.CurrentPermissions = objectGroup.GetEffectivePermissions(); - item.NextPermissions = objectGroup.RootPart.NextOwnerMask; - item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + folderID = userInfo.RootFolder.ID; } + //currently following code not used (or don't know of any case of destination being zero + } + else + { + folderID = DeRezPacket.AgentBlock.DestinationID; + } + + AssetBase asset = CreateAsset( + ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId), + ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId), + (sbyte) InventoryType.Object, + (sbyte) AssetType.Object, + Helpers.StringToField(sceneObjectXml)); + AssetCache.AddAsset(asset); - // TODO: add the new fields (Flags, Sale info, etc) + InventoryItemBase item = new InventoryItemBase(); + item.Creator = objectGroup.RootPart.CreatorID; - userInfo.AddItem(item); + if (DeRezPacket.AgentBlock.Destination == 1 || DeRezPacket.AgentBlock.Destination == 4)// Take / Copy + item.Owner = remoteClient.AgentId; + else // Delete / Return + item.Owner = objectGroup.OwnerID; + + item.ID = LLUUID.Random(); + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = asset.InvType; + item.Folder = folderID; + if ((remoteClient.AgentId != objectGroup.RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions()) + { + uint perms=objectGroup.GetEffectivePermissions(); + uint nextPerms=(perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; + + item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions = item.BasePermissions; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions |= 8; // Slam! + } + else + { + item.BasePermissions = objectGroup.GetEffectivePermissions(); + item.CurrentPermissions = objectGroup.GetEffectivePermissions(); + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + } + + // TODO: add the new fields (Flags, Sale info, etc) + + userInfo.AddItem(item); + if (item.Owner == remoteClient.AgentId) + { remoteClient.SendInventoryItemCreateUpdate(item); } + else + { + ScenePresence notifyUser = GetScenePresence(item.Owner); + if (notifyUser != null) + { + notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item); + } + } } + } - if (permissionToDelete) - { - DeleteSceneObjectGroup(objectGroup); - } + if (permissionToDelete) + { + DeleteSceneObjectGroup(objectGroup); } } } + } public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID) @@ -1599,6 +1673,114 @@ namespace OpenSim.Region.Environment.Scenes } return null; } + public virtual bool returnObjects(SceneObjectGroup[] returnobjects, LLUUID AgentId) + { + if (returnobjects.Length <= 0) + return false; + + // for the moment we're going to store them individually.. however, in the future, the rezObject + // will be able to have more items. + + //string returnstring = ""; + //returnstring += "\n"; + //for (int i = 0; i < returnobjects.Length; i++) + //{ + // returnstring += grp.ToXmlString2(); + //} + //returnstring += "\n"; + + + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(AgentId); + if (userInfo != null) + { + LLUUID folderID = LLUUID.Zero; + + List subrootfolders = userInfo.RootFolder.RequestListOfFolders(); + foreach (InventoryFolderBase flder in subrootfolders) + { + if (flder.Name == "Lost And Found") + { + folderID = flder.ID; + break; + } + } + + if (folderID == LLUUID.Zero) + { + folderID = userInfo.RootFolder.ID; + } + + bool permissionToDelete = false; + + for (int i = 0; i < returnobjects.Length; i++) + { + permissionToDelete = ExternalChecks.ExternalChecksCanDeleteObject(returnobjects[i].UUID, AgentId); + + // If the user doesn't have permission, go on to the next one. + if (!permissionToDelete) + continue; + + string sceneObjectXml = returnobjects[i].ToXmlString2(); + AssetBase asset = CreateAsset( + returnobjects[i].GetPartName(returnobjects[i].LocalId), + returnobjects[i].GetPartDescription(returnobjects[i].LocalId), + (sbyte)InventoryType.Object, + (sbyte)AssetType.Object, + Helpers.StringToField(sceneObjectXml)); + AssetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Creator = returnobjects[i].RootPart.CreatorID; + item.Owner = AgentId; + item.ID = LLUUID.Random(); + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = asset.InvType; + item.Folder = folderID; + if ((AgentId != returnobjects[i].RootPart.OwnerID) && ExternalChecks.ExternalChecksPropagatePermissions()) + { + uint perms = returnobjects[i].GetEffectivePermissions(); + uint nextPerms = (perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; + + item.BasePermissions = perms & returnobjects[i].RootPart.NextOwnerMask; + item.CurrentPermissions = item.BasePermissions; + item.NextPermissions = returnobjects[i].RootPart.NextOwnerMask; + item.EveryOnePermissions = returnobjects[i].RootPart.EveryoneMask & returnobjects[i].RootPart.NextOwnerMask; + item.CurrentPermissions |= 8; // Slam! + } + else + { + item.BasePermissions = returnobjects[i].GetEffectivePermissions(); + item.CurrentPermissions = returnobjects[i].GetEffectivePermissions(); + item.NextPermissions = returnobjects[i].RootPart.NextOwnerMask; + item.EveryOnePermissions = returnobjects[i].RootPart.EveryoneMask; + } + + // TODO: add the new fields (Flags, Sale info, etc) + + userInfo.AddItem(item); + + SceneObjectGroup ObjectDeleting = returnobjects[i]; + + returnobjects[i] = null; + + DeleteSceneObjectGroup(ObjectDeleting); + ObjectDeleting = null; + } + return true; + } + return false; + + } } } -- cgit v1.1