diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 343b5a66db..44d32958c5 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -564,7 +564,7 @@ namespace OpenSim.Framework public delegate void RequestAsset(IClientAPI remoteClient, RequestAssetArgs transferRequest); - public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID); + public delegate void RezScript(IClientAPI remoteClient, InventoryItemBase item, LLUUID transactionID, uint localID); public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index d6329ceecf..4d27a0c403 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -5007,10 +5007,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP RezScriptPacket rezScriptx = (RezScriptPacket)Pack; handlerRezScript = OnRezScript; + InventoryItemBase item=new InventoryItemBase(); + item.ID=rezScriptx.InventoryBlock.ItemID; + item.Folder=rezScriptx.InventoryBlock.FolderID; + item.Creator=rezScriptx.InventoryBlock.CreatorID; + item.Owner=rezScriptx.InventoryBlock.OwnerID; + item.BasePermissions=rezScriptx.InventoryBlock.BaseMask; + item.CurrentPermissions=rezScriptx.InventoryBlock.OwnerMask; + item.EveryOnePermissions=rezScriptx.InventoryBlock.EveryoneMask; + item.NextPermissions=rezScriptx.InventoryBlock.NextOwnerMask; + item.GroupOwned=rezScriptx.InventoryBlock.GroupOwned; + item.GroupID=rezScriptx.InventoryBlock.GroupID; + item.AssetType=rezScriptx.InventoryBlock.Type; + item.InvType=rezScriptx.InventoryBlock.InvType; + item.Flags=rezScriptx.InventoryBlock.Flags; + item.SaleType=rezScriptx.InventoryBlock.SaleType; + item.SalePrice=rezScriptx.InventoryBlock.SalePrice; + item.Name=Util.FieldToString(rezScriptx.InventoryBlock.Name); + item.Description=Util.FieldToString(rezScriptx.InventoryBlock.Description); + item.CreationDate=(int)rezScriptx.InventoryBlock.CreationDate; if (handlerRezScript != null) { - handlerRezScript(this, rezScriptx.InventoryBlock.ItemID, rezScriptx.UpdateBlock.ObjectLocalID); + handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID); } break; diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 5e2ccec99f..04476319fe 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -221,7 +221,7 @@ namespace OpenSim.Region.Environment.Scenes // Update item with new asset item.AssetID = asset.FullID; group.UpdateInventoryItem(item); - group.GetProperties(remoteClient); + part.GetProperties(remoteClient); // Trigger rerunning of script (use TriggerRezScript event, see RezScript) if (isScriptRunning) @@ -572,7 +572,7 @@ namespace OpenSim.Region.Environment.Scenes private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, AssetBase asset, uint nextOwnerMask) { - CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask, nextOwnerMask, 0, nextOwnerMask); + CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask); } /// @@ -789,11 +789,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) { - SceneObjectGroup group = GetGroupByPrim(localID); + SceneObjectPart part = GetSceneObjectPart(localID); + SceneObjectGroup group = part.ParentGroup; if (group != null) { int type = group.RemoveInventoryItem(localID, itemID); - group.GetProperties(remoteClient); + part.GetProperties(remoteClient); if (type == 10) { EventManager.TriggerRemoveScript(localID, itemID); @@ -917,7 +918,7 @@ namespace OpenSim.Region.Environment.Scenes m_log.InfoFormat( "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", item.Name, primLocalID, remoteClient.Name); - part.ParentGroup.GetProperties(remoteClient); + part.GetProperties(remoteClient); if (!ExternalChecks.ExternalChecksBypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) @@ -948,8 +949,9 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) + public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, LLUUID transactionID, uint localID) { + LLUUID itemID=itemBase.ID; LLUUID copyID = LLUUID.Random(); if (itemID != LLUUID.Zero) @@ -974,7 +976,7 @@ namespace OpenSim.Region.Environment.Scenes { part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); part.ParentGroup.StartScript(localID, copyID); - part.ParentGroup.GetProperties(remoteClient); + part.GetProperties(remoteClient); // m_log.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", @@ -999,11 +1001,38 @@ namespace OpenSim.Region.Environment.Scenes } else // If the itemID is zero then the script has been rezzed directly in an object's inventory { - // not yet implemented - // TODO Need to get more details from original RezScript packet - // XXX jc tmp -// AssetBase asset = CreateAsset("chimney sweep", "sailor.lsl", 10, 10, null); -// AssetCache.AddAsset(asset); + SceneObjectPart part=GetSceneObjectPart(itemBase.Folder); + if(part == null) + return; + + AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.InvType, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); + AssetCache.AddAsset(asset); + + TaskInventoryItem taskItem=new TaskInventoryItem(); + + taskItem.ResetIDs(itemBase.Folder); + taskItem.ParentID = itemBase.Folder; + taskItem.CreationDate = (uint)itemBase.CreationDate; + taskItem.Name = itemBase.Name; + taskItem.Description = itemBase.Description; + taskItem.Type = itemBase.AssetType; + taskItem.InvType = itemBase.InvType; + taskItem.OwnerID = itemBase.Owner; + taskItem.CreatorID = itemBase.Creator; + taskItem.BaseMask = itemBase.BasePermissions; + taskItem.OwnerMask = itemBase.CurrentPermissions; + taskItem.EveryoneMask = itemBase.EveryOnePermissions; + taskItem.NextOwnerMask = itemBase.NextPermissions; + taskItem.GroupID = itemBase.GroupID; + taskItem.GroupMask = 0; + taskItem.Flags = itemBase.Flags; + taskItem.PermsGranter = LLUUID.Zero; + taskItem.PermsMask = 0; + taskItem.AssetID = asset.ID; + + part.AddInventoryItem(taskItem); + part.GetProperties(remoteClient); + part.StartScript(taskItem); } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 332d160414..7f26f35299 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1927,13 +1927,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void GetProperties(IClientAPI client) { - - client.SendObjectPropertiesReply(LLUUID.Zero, (ulong)m_rootPart.CreationDate, m_rootPart.CreatorID, LLUUID.Zero, LLUUID.Zero, - LLUUID.Zero, (short)m_rootPart.InventorySerial, m_rootPart.LastOwnerID, UUID, m_rootPart.OwnerID, - m_rootPart.TouchName, new byte[0], m_rootPart.SitName, m_rootPart.Name, m_rootPart.Description, - m_rootPart.OwnerMask, m_rootPart.NextOwnerMask, m_rootPart.GroupMask, m_rootPart.EveryoneMask, - m_rootPart.BaseMask); - + m_rootPart.GetProperties(client); } /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index b151d75d4b..0444685265 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs @@ -42,6 +42,7 @@ namespace OpenSim.Region.Environment.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_inventoryFileName = String.Empty; + private int m_inventoryFileNameSerial = 0; /// /// Exposing this is not particularly good, but it's one of the least evils at the moment to see @@ -444,6 +445,17 @@ namespace OpenSim.Region.Environment.Scenes return -1; } + public string GetInventoryFileName() + { + if(m_inventoryFileName == String.Empty) + m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp"; + if(m_inventoryFileNameSerial < m_inventorySerial) + { + m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp"; + } + return m_inventoryFileName; + } + /// /// Return the name with which a client can request a xfer of this prim's inventory metadata /// @@ -458,7 +470,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_inventorySerial > 0) { client.SendTaskInventory(m_uuid, (short)m_inventorySerial, - Helpers.StringToField(m_inventoryFileName)); + Helpers.StringToField(GetInventoryFileName())); return true; } else diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 80b93b1153..a7b76923a7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -759,7 +759,6 @@ namespace OpenSim.Region.Environment.Scenes public SceneObjectPart() { // It's not necessary to persist this - m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp"; m_TextureAnimation = new byte[0]; } @@ -808,7 +807,6 @@ namespace OpenSim.Region.Environment.Scenes AngularVelocity = new LLVector3(0, 0, 0); Acceleration = new LLVector3(0, 0, 0); m_TextureAnimation = new byte[0]; - m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp"; // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from @@ -2530,7 +2528,7 @@ namespace OpenSim.Region.Environment.Scenes throw new ArgumentNullException("info"); } - info.AddValue("m_inventoryFileName", m_inventoryFileName); + info.AddValue("m_inventoryFileName", GetInventoryFileName()); info.AddValue("m_folderID", UUID); info.AddValue("PhysActor", PhysActor); @@ -2758,5 +2756,17 @@ namespace OpenSim.Region.Environment.Scenes return m_parentGroup.RootPart.DIE_AT_EDGE; } + + public void GetProperties(IClientAPI client) + { + + client.SendObjectPropertiesReply(LLUUID.Zero, (ulong)CreationDate, CreatorID, LLUUID.Zero, LLUUID.Zero, + LLUUID.Zero, (short)InventorySerial, LastOwnerID, UUID, OwnerID, + ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, + ParentGroup.RootPart.OwnerMask, ParentGroup.RootPart.NextOwnerMask, ParentGroup.RootPart.GroupMask, ParentGroup.RootPart.EveryoneMask, + ParentGroup.RootPart.BaseMask); + + } + } }