aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs249
1 files changed, 143 insertions, 106 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 321d0aa..47c574a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -99,34 +99,22 @@ namespace OpenSim.Region.Framework.Scenes
99 /// <param name="item"></param> 99 /// <param name="item"></param>
100 public bool AddInventoryItem(InventoryItemBase item) 100 public bool AddInventoryItem(InventoryItemBase item)
101 { 101 {
102 if (UUID.Zero == item.Folder) 102 InventoryFolderBase folder;
103
104 if (item.Folder == UUID.Zero)
103 { 105 {
104 InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); 106 folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType);
105 if (f != null) 107 if (folder == null)
106 {
107// m_log.DebugFormat(
108// "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}",
109// f.Name, (AssetType)f.Type, item.Name);
110
111 item.Folder = f.ID;
112 }
113 else
114 { 108 {
115 f = InventoryService.GetRootFolder(item.Owner); 109 folder = InventoryService.GetRootFolder(item.Owner);
116 if (f != null) 110
117 { 111 if (folder == null)
118 item.Folder = f.ID;
119 }
120 else
121 {
122 m_log.WarnFormat(
123 "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified",
124 item.Owner, item.Name);
125 return false; 112 return false;
126 }
127 } 113 }
114
115 item.Folder = folder.ID;
128 } 116 }
129 117
130 if (InventoryService.AddItem(item)) 118 if (InventoryService.AddItem(item))
131 { 119 {
132 int userlevel = 0; 120 int userlevel = 0;
@@ -252,8 +240,7 @@ namespace OpenSim.Region.Framework.Scenes
252 240
253 // Update item with new asset 241 // Update item with new asset
254 item.AssetID = asset.FullID; 242 item.AssetID = asset.FullID;
255 if (group.UpdateInventoryItem(item)) 243 group.UpdateInventoryItem(item);
256 remoteClient.SendAgentAlertMessage("Script saved", false);
257 244
258 part.GetProperties(remoteClient); 245 part.GetProperties(remoteClient);
259 246
@@ -264,12 +251,7 @@ namespace OpenSim.Region.Framework.Scenes
264 { 251 {
265 // Needs to determine which engine was running it and use that 252 // Needs to determine which engine was running it and use that
266 // 253 //
267 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 254 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
268 errors = part.Inventory.GetScriptErrors(item.ItemID);
269 }
270 else
271 {
272 remoteClient.SendAgentAlertMessage("Script saved", false);
273 } 255 }
274 part.ParentGroup.ResumeScripts(); 256 part.ParentGroup.ResumeScripts();
275 return errors; 257 return errors;
@@ -688,6 +670,8 @@ namespace OpenSim.Region.Framework.Scenes
688 return; 670 return;
689 } 671 }
690 672
673 if (newName == null) newName = item.Name;
674
691 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 675 AssetBase asset = AssetService.Get(item.AssetID.ToString());
692 676
693 if (asset != null) 677 if (asset != null)
@@ -735,6 +719,24 @@ namespace OpenSim.Region.Framework.Scenes
735 } 719 }
736 720
737 /// <summary> 721 /// <summary>
722 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
723 /// </summary>
724 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
725 {
726 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
727 foreach (InventoryItemBase b in items)
728 {
729 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
730 InventoryItemBase n = InventoryService.GetItem(b);
731 n.Folder = destfolder;
732 moveitems.Add(n);
733 remoteClient.SendInventoryItemCreateUpdate(n, 0);
734 }
735
736 MoveInventoryItem(remoteClient, moveitems);
737 }
738
739 /// <summary>
738 /// Move an item within the agent's inventory. 740 /// Move an item within the agent's inventory.
739 /// </summary> 741 /// </summary>
740 /// <param name="remoteClient"></param> 742 /// <param name="remoteClient"></param>
@@ -967,8 +969,12 @@ namespace OpenSim.Region.Framework.Scenes
967 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 969 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
968 { 970 {
969 SceneObjectPart part = GetSceneObjectPart(localID); 971 SceneObjectPart part = GetSceneObjectPart(localID);
970 SceneObjectGroup group = part.ParentGroup; 972 SceneObjectGroup group = null;
971 if (group != null) 973 if (part != null)
974 {
975 group = part.ParentGroup;
976 }
977 if (part != null && group != null)
972 { 978 {
973 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 979 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
974 return; 980 return;
@@ -1417,13 +1423,6 @@ namespace OpenSim.Region.Framework.Scenes
1417 { 1423 {
1418 agentTransactions.HandleTaskItemUpdateFromTransaction( 1424 agentTransactions.HandleTaskItemUpdateFromTransaction(
1419 remoteClient, part, transactionID, currentItem); 1425 remoteClient, part, transactionID, currentItem);
1420
1421 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1422 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1423 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1424 remoteClient.SendAgentAlertMessage("Script saved", false);
1425 else
1426 remoteClient.SendAgentAlertMessage("Item saved", false);
1427 } 1426 }
1428 1427
1429 // Base ALWAYS has move 1428 // Base ALWAYS has move
@@ -1541,7 +1540,7 @@ namespace OpenSim.Region.Framework.Scenes
1541 return; 1540 return;
1542 1541
1543 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1542 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1544 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1543 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1545 remoteClient.AgentId); 1544 remoteClient.AgentId);
1546 AssetService.Store(asset); 1545 AssetService.Store(asset);
1547 1546
@@ -1694,23 +1693,32 @@ namespace OpenSim.Region.Framework.Scenes
1694 // build a list of eligible objects 1693 // build a list of eligible objects
1695 List<uint> deleteIDs = new List<uint>(); 1694 List<uint> deleteIDs = new List<uint>();
1696 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1695 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1697 1696 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1698 // Start with true for both, then remove the flags if objects
1699 // that we can't derez are part of the selection
1700 bool permissionToTake = true;
1701 bool permissionToTakeCopy = true;
1702 bool permissionToDelete = true;
1703 1697
1704 foreach (uint localID in localIDs) 1698 foreach (uint localID in localIDs)
1705 { 1699 {
1700 // Start with true for both, then remove the flags if objects
1701 // that we can't derez are part of the selection
1702 bool permissionToTake = true;
1703 bool permissionToTakeCopy = true;
1704 bool permissionToDelete = true;
1705
1706 // Invalid id 1706 // Invalid id
1707 SceneObjectPart part = GetSceneObjectPart(localID); 1707 SceneObjectPart part = GetSceneObjectPart(localID);
1708 if (part == null) 1708 if (part == null)
1709 {
1710 //Client still thinks the object exists, kill it
1711 deleteIDs.Add(localID);
1709 continue; 1712 continue;
1713 }
1710 1714
1711 // Already deleted by someone else 1715 // Already deleted by someone else
1712 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1716 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1717 {
1718 //Client still thinks the object exists, kill it
1719 deleteIDs.Add(localID);
1713 continue; 1720 continue;
1721 }
1714 1722
1715 // Can't delete child prims 1723 // Can't delete child prims
1716 if (part != part.ParentGroup.RootPart) 1724 if (part != part.ParentGroup.RootPart)
@@ -1718,9 +1726,6 @@ namespace OpenSim.Region.Framework.Scenes
1718 1726
1719 SceneObjectGroup grp = part.ParentGroup; 1727 SceneObjectGroup grp = part.ParentGroup;
1720 1728
1721 deleteIDs.Add(localID);
1722 deleteGroups.Add(grp);
1723
1724 if (remoteClient == null) 1729 if (remoteClient == null)
1725 { 1730 {
1726 // Autoreturn has a null client. Nothing else does. So 1731 // Autoreturn has a null client. Nothing else does. So
@@ -1737,80 +1742,104 @@ namespace OpenSim.Region.Framework.Scenes
1737 } 1742 }
1738 else 1743 else
1739 { 1744 {
1740 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1745 if (action == DeRezAction.TakeCopy)
1746 {
1747 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1748 permissionToTakeCopy = false;
1749 }
1750 else
1751 {
1741 permissionToTakeCopy = false; 1752 permissionToTakeCopy = false;
1742 1753 }
1743 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1754 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1744 permissionToTake = false; 1755 permissionToTake = false;
1745 1756
1746 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1757 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1747 permissionToDelete = false; 1758 permissionToDelete = false;
1748 } 1759 }
1749 }
1750 1760
1751 // Handle god perms 1761 // Handle god perms
1752 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1762 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1753 { 1763 {
1754 permissionToTake = true; 1764 permissionToTake = true;
1755 permissionToTakeCopy = true; 1765 permissionToTakeCopy = true;
1756 permissionToDelete = true; 1766 permissionToDelete = true;
1757 } 1767 }
1758 1768
1759 // If we're re-saving, we don't even want to delete 1769 // If we're re-saving, we don't even want to delete
1760 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1770 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1761 permissionToDelete = false; 1771 permissionToDelete = false;
1762 1772
1763 // if we want to take a copy, we also don't want to delete 1773 // if we want to take a copy, we also don't want to delete
1764 // Note: after this point, the permissionToTakeCopy flag 1774 // Note: after this point, the permissionToTakeCopy flag
1765 // becomes irrelevant. It already includes the permissionToTake 1775 // becomes irrelevant. It already includes the permissionToTake
1766 // permission and after excluding no copy items here, we can 1776 // permission and after excluding no copy items here, we can
1767 // just use that. 1777 // just use that.
1768 if (action == DeRezAction.TakeCopy) 1778 if (action == DeRezAction.TakeCopy)
1769 { 1779 {
1770 // If we don't have permission, stop right here 1780 // If we don't have permission, stop right here
1771 if (!permissionToTakeCopy) 1781 if (!permissionToTakeCopy)
1772 return; 1782 return;
1773 1783
1774 permissionToTake = true; 1784 permissionToTake = true;
1775 // Don't delete 1785 // Don't delete
1776 permissionToDelete = false; 1786 permissionToDelete = false;
1777 } 1787 }
1778 1788
1779 if (action == DeRezAction.Return) 1789 if (action == DeRezAction.Return)
1780 {
1781 if (remoteClient != null)
1782 { 1790 {
1783 if (Permissions.CanReturnObjects( 1791 if (remoteClient != null)
1784 null,
1785 remoteClient.AgentId,
1786 deleteGroups))
1787 { 1792 {
1788 permissionToTake = true; 1793 if (Permissions.CanReturnObjects(
1789 permissionToDelete = true; 1794 null,
1790 1795 remoteClient.AgentId,
1791 foreach (SceneObjectGroup g in deleteGroups) 1796 deleteGroups))
1792 { 1797 {
1793 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1798 permissionToTake = true;
1799 permissionToDelete = true;
1800
1801 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1794 } 1802 }
1795 } 1803 }
1804 else // Auto return passes through here with null agent
1805 {
1806 permissionToTake = true;
1807 permissionToDelete = true;
1808 }
1796 } 1809 }
1797 else // Auto return passes through here with null agent 1810
1811 if (permissionToTake && (!permissionToDelete))
1812 takeGroups.Add(grp);
1813
1814 if (permissionToDelete)
1798 { 1815 {
1799 permissionToTake = true; 1816 if (permissionToTake)
1800 permissionToDelete = true; 1817 deleteGroups.Add(grp);
1818 deleteIDs.Add(grp.LocalId);
1801 } 1819 }
1802 } 1820 }
1803 1821
1804 if (permissionToTake) 1822 SendKillObject(deleteIDs);
1823
1824 if (deleteGroups.Count > 0)
1805 { 1825 {
1826 foreach (SceneObjectGroup g in deleteGroups)
1827 deleteIDs.Remove(g.LocalId);
1828
1806 m_asyncSceneObjectDeleter.DeleteToInventory( 1829 m_asyncSceneObjectDeleter.DeleteToInventory(
1807 action, destinationID, deleteGroups, remoteClient, 1830 action, destinationID, deleteGroups, remoteClient,
1808 permissionToDelete); 1831 true);
1809 } 1832 }
1810 else if (permissionToDelete) 1833 if (takeGroups.Count > 0)
1834 {
1835 m_asyncSceneObjectDeleter.DeleteToInventory(
1836 action, destinationID, takeGroups, remoteClient,
1837 false);
1838 }
1839 if (deleteIDs.Count > 0)
1811 { 1840 {
1812 foreach (SceneObjectGroup g in deleteGroups) 1841 foreach (SceneObjectGroup g in deleteGroups)
1813 DeleteSceneObject(g, false); 1842 DeleteSceneObject(g, true);
1814 } 1843 }
1815 } 1844 }
1816 1845
@@ -1862,21 +1891,29 @@ namespace OpenSim.Region.Framework.Scenes
1862 else // oopsies 1891 else // oopsies
1863 item.Folder = UUID.Zero; 1892 item.Folder = UUID.Zero;
1864 1893
1894 // Set up base perms properly
1895 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
1896 permsBase &= grp.RootPart.BaseMask;
1897 permsBase |= (uint)PermissionMask.Move;
1898
1899 // Make sure we don't lock it
1900 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
1901
1865 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1902 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1866 { 1903 {
1867 item.BasePermissions = grp.RootPart.NextOwnerMask; 1904 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1868 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 1905 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1869 item.NextPermissions = grp.RootPart.NextOwnerMask; 1906 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1870 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 1907 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1871 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 1908 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1872 } 1909 }
1873 else 1910 else
1874 { 1911 {
1875 item.BasePermissions = grp.RootPart.BaseMask; 1912 item.BasePermissions = permsBase;
1876 item.CurrentPermissions = grp.RootPart.OwnerMask; 1913 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1877 item.NextPermissions = grp.RootPart.NextOwnerMask; 1914 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1878 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 1915 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1879 item.GroupPermissions = grp.RootPart.GroupMask; 1916 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1880 } 1917 }
1881 item.CreationDate = Util.UnixTimeSinceEpoch(); 1918 item.CreationDate = Util.UnixTimeSinceEpoch();
1882 1919