From ee4d4d784eb9b51b29fe4bda3fc9ec3594d24f5a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 21 Nov 2008 07:33:13 +0000 Subject: [PATCH] Fully implement object return from the parcel dialog --- .../Environment/Interfaces/ILandObject.cs | 2 +- .../World/Land/LandManagementModule.cs | 5 +- .../Modules/World/Land/LandObject.cs | 67 ++++++-- .../Region/Environment/Scenes/ReturnInfo.cs | 1 + .../Environment/Scenes/Scene.Inventory.cs | 144 +----------------- OpenSim/Region/Environment/Scenes/Scene.cs | 86 ++++++----- .../Environment/Scenes/SceneObjectGroup.cs | 2 +- 7 files changed, 114 insertions(+), 193 deletions(-) diff --git a/OpenSim/Region/Environment/Interfaces/ILandObject.cs b/OpenSim/Region/Environment/Interfaces/ILandObject.cs index 9d51109c0a..6fcf74b0db 100644 --- a/OpenSim/Region/Environment/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Environment/Interfaces/ILandObject.cs @@ -71,7 +71,7 @@ namespace OpenSim.Region.Environment.Interfaces void sendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client); void sendLandObjectOwners(IClientAPI remote_client); void returnObject(SceneObjectGroup obj); - void returnLandObjects(uint type, UUID[] owners, IClientAPI remote_client); + void returnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client); void resetLandPrimCounts(); void addPrimToCount(SceneObjectGroup obj); void removePrimFromCount(SceneObjectGroup obj); diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index f656fb6c0a..99128bc1af 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs @@ -1149,10 +1149,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land if (selectedParcel == null) return; - if (returnType == 16) // parcel return - { - selectedParcel.returnLandObjects(returnType, agentIDs, remoteClient); - } + selectedParcel.returnLandObjects(returnType, agentIDs, taskIDs, remoteClient); } public void NoLandDataFromStorage() diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index 208338fccf..1483118f44 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs @@ -776,28 +776,73 @@ namespace OpenSim.Region.Environment.Modules.World.Land m_scene.returnObjects(objs, obj.OwnerID); } - public void returnLandObjects(uint type, UUID[] owners, IClientAPI remote_client) + public void returnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) { - List objlist = new List(); - for (int i = 0; i < owners.Length; i++) + Dictionary> returns = + new Dictionary>(); + + lock (primsOverMe) { - lock (primsOverMe) + if (type == (uint)ObjectReturnType.Owner) { - try + foreach (SceneObjectGroup obj in primsOverMe) { - foreach (SceneObjectGroup obj in primsOverMe) + if (obj.OwnerID == m_landData.OwnerID) { - if (obj.OwnerID == owners[i]) - objlist.Add(obj); + if (!returns.ContainsKey(obj.OwnerID)) + returns[obj.OwnerID] = + new List(); + returns[obj.OwnerID].Add(obj); } } - catch (InvalidOperationException) + } + else if (type == (uint)ObjectReturnType.Group && m_landData.GroupID != UUID.Zero) + { + foreach (SceneObjectGroup obj in primsOverMe) { - m_log.Info("[PARCEL]: Unable to figure out all the objects owned by " + owners[i].ToString() + " arr."); + if (obj.GroupID == m_landData.GroupID) + { + if (!returns.ContainsKey(obj.OwnerID)) + returns[obj.OwnerID] = + new List(); + returns[obj.OwnerID].Add(obj); + } + } + } + else if (type == (uint)ObjectReturnType.Other) + { + foreach (SceneObjectGroup obj in primsOverMe) + { + if (obj.OwnerID != m_landData.OwnerID && + (obj.GroupID != m_landData.GroupID || + m_landData.GroupID == UUID.Zero)) + { + if (!returns.ContainsKey(obj.OwnerID)) + returns[obj.OwnerID] = + new List(); + returns[obj.OwnerID].Add(obj); + } + } + } + else if (type == (uint)ObjectReturnType.List) + { + List ownerlist = new List(owners); + + foreach (SceneObjectGroup obj in primsOverMe) + { + if (ownerlist.Contains(obj.OwnerID)) + { + if (!returns.ContainsKey(obj.OwnerID)) + returns[obj.OwnerID] = + new List(); + returns[obj.OwnerID].Add(obj); + } } } } - m_scene.returnObjects(objlist.ToArray(), remote_client.AgentId); + + foreach (List ol in returns.Values) + m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); } #endregion diff --git a/OpenSim/Region/Environment/Scenes/ReturnInfo.cs b/OpenSim/Region/Environment/Scenes/ReturnInfo.cs index 68c563d42c..898baab083 100644 --- a/OpenSim/Region/Environment/Scenes/ReturnInfo.cs +++ b/OpenSim/Region/Environment/Scenes/ReturnInfo.cs @@ -34,5 +34,6 @@ namespace OpenSim.Region.Environment.Scenes public int count; public Vector3 location; public string objectName; + public string reason; } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 79d79ef978..19b8e165c5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1610,6 +1610,10 @@ namespace OpenSim.Region.Environment.Scenes ExternalChecks.ExternalChecksCanDeleteObject( grp.UUID, remoteClient.AgentId); + if (permissionToDelete) + { + AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); + } } else // Auto return passes through here with null agent { @@ -2207,145 +2211,13 @@ namespace OpenSim.Region.Environment.Scenes public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) { - string message = ""; - 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"; - - bool permissionToDelete = false; - - for (int i = 0; i < returnobjects.Length; i++) + foreach (SceneObjectGroup grp in returnobjects) { - CachedUserInfo userInfo = - CommsManager.UserProfileCacheService.GetUserDetails(returnobjects[i].OwnerID); - if (userInfo == null) - { - CommsManager.UserProfileCacheService.AddNewUser(returnobjects[i].OwnerID); - - } - if (userInfo != null) - { - if (userInfo.HasReceivedInventory) - { - UUID folderID = UUID.Zero; - - List subrootfolders = userInfo.RootFolder.RequestListOfFolders(); - foreach (InventoryFolderBase flder in subrootfolders) - { - if (flder.Name == "Lost And Found") - { - folderID = flder.ID; - break; - } - } - - if (folderID == UUID.Zero) - { - folderID = userInfo.RootFolder.ID; - } - permissionToDelete = ExternalChecks.ExternalChecksCanReturnObject(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)AssetType.Object, - Utils.StringToBytes(sceneObjectXml)); - AssetCache.AddAsset(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Creator = returnobjects[i].RootPart.CreatorID; - item.Owner = returnobjects[i].OwnerID; - item.ID = UUID.Random(); - item.AssetID = asset.FullID; - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - item.InvType = (int)InventoryType.Object; - 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.GroupPermissions = returnobjects[i].RootPart.GroupMask & 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; - item.GroupPermissions = returnobjects[i].RootPart.GroupMask; - } - - // TODO: add the new fields (Flags, Sale info, etc) - - userInfo.AddItem(item); - - ScenePresence notifyUser = GetScenePresence(item.Owner); - if (notifyUser != null) - { - notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item); - } - - SceneObjectGroup ObjectDeleting = returnobjects[i]; - - returnobjects[i] = null; - - DeleteSceneObject(ObjectDeleting, false); - ObjectDeleting = null; - } - else - { - CommsManager.UserProfileCacheService.RequestInventoryForUser(returnobjects[i].OwnerID); - message = "Still waiting on the inventory service, some of the items won't be returned until the inventory services completes it's task. Try again shortly."; - } - } - else - { - message = "Still waiting on the inventory service, some of the items won't be returned until the inventory services completes it's task. Try again shortly."; - } - //return true; - } - - if (message.Length != 0) - { - ScenePresence returningavatar = GetScenePresence(AgentId); - if (returningavatar != null) - { - returningavatar.ControllingClient.SendAlertMessage(message); - } - return false; + AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); + DeRezObject(null, grp.RootPart.LocalId, + grp.RootPart.GroupID, 9, UUID.Zero); } return true; - } public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f37ba25d02..741c47e4da 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -966,54 +966,60 @@ namespace OpenSim.Region.Environment.Scenes /// public void Backup() { - m_returns.Clear(); - - EventManager.TriggerOnBackup(m_storageManager.DataStore); - m_backingup = false; - - foreach (KeyValuePair ret in m_returns) + lock(m_returns) { - UUID transaction = UUID.Random(); + EventManager.TriggerOnBackup(m_storageManager.DataStore); + m_backingup = false; - GridInstantMessage msg = new GridInstantMessage(); - msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server - msg.toAgentID = new Guid(ret.Key.ToString()); - msg.imSessionID = new Guid(transaction.ToString()); - msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); - msg.fromAgentName = "Server"; - msg.dialog = (byte)19; // Object msg - msg.fromGroup = false; - msg.offline = (byte)1; - msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; - msg.Position = Vector3.Zero; - msg.RegionID = RegionInfo.RegionID.Guid; - msg.binaryBucket = new byte[0]; - if (ret.Value.count > 1) - msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to parcel auto return", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName); - else - msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to parcel auto return", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName); + foreach (KeyValuePair ret in m_returns) + { + UUID transaction = UUID.Random(); - IMessageTransferModule tr = RequestModuleInterface(); - if (tr != null) - tr.SendInstantMessage(msg, delegate(bool success) {} ); + GridInstantMessage msg = new GridInstantMessage(); + msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server + msg.toAgentID = new Guid(ret.Key.ToString()); + msg.imSessionID = new Guid(transaction.ToString()); + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); + msg.fromAgentName = "Server"; + msg.dialog = (byte)19; // Object msg + msg.fromGroup = false; + msg.offline = (byte)1; + msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; + msg.Position = Vector3.Zero; + msg.RegionID = RegionInfo.RegionID.Guid; + msg.binaryBucket = new byte[0]; + if (ret.Value.count > 1) + msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); + else + msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); + + IMessageTransferModule tr = RequestModuleInterface(); + if (tr != null) + tr.SendInstantMessage(msg, delegate(bool success) {} ); + } + m_returns.Clear(); } } - public void AddReturn(UUID agentID, string objectName, Vector3 location) + public void AddReturn(UUID agentID, string objectName, Vector3 location, string reason) { - if (m_returns.ContainsKey(agentID)) + lock(m_returns) { - ReturnInfo info = m_returns[agentID]; - info.count++; - m_returns[agentID] = info; - } - else - { - ReturnInfo info = new ReturnInfo(); - info.count = 1; - info.objectName = objectName; - info.location = location; - m_returns[agentID] = info; + if (m_returns.ContainsKey(agentID)) + { + ReturnInfo info = m_returns[agentID]; + info.count++; + m_returns[agentID] = info; + } + else + { + ReturnInfo info = new ReturnInfo(); + info.count = 1; + info.objectName = objectName; + info.location = location; + info.reason = reason; + m_returns[agentID] = info; + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 82ab4ebdf2..e8eaef8474 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1224,7 +1224,7 @@ namespace OpenSim.Region.Environment.Scenes parcel.landData.OtherCleanTime) { m_log.InfoFormat("[SCENE] Returning object {0} due to parcel auto return", RootPart.UUID.ToString()); - m_scene.AddReturn(OwnerID, Name, AbsolutePosition); + m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return"); m_scene.DeRezObject(null, RootPart.LocalId, RootPart.GroupID, 9, UUID.Zero);