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.cs253
1 files changed, 147 insertions, 106 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index e2d96d9..9a93a26 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;
@@ -326,6 +308,7 @@ namespace OpenSim.Region.Framework.Scenes
326 { 308 {
327 if (UUID.Zero == transactionID) 309 if (UUID.Zero == transactionID)
328 { 310 {
311 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
329 item.Name = itemUpd.Name; 312 item.Name = itemUpd.Name;
330 item.Description = itemUpd.Description; 313 item.Description = itemUpd.Description;
331 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) 314 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
@@ -698,6 +681,8 @@ namespace OpenSim.Region.Framework.Scenes
698 return; 681 return;
699 } 682 }
700 683
684 if (newName == null) newName = item.Name;
685
701 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 686 AssetBase asset = AssetService.Get(item.AssetID.ToString());
702 687
703 if (asset != null) 688 if (asset != null)
@@ -751,6 +736,24 @@ namespace OpenSim.Region.Framework.Scenes
751 } 736 }
752 737
753 /// <summary> 738 /// <summary>
739 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
740 /// </summary>
741 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
742 {
743 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
744 foreach (InventoryItemBase b in items)
745 {
746 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
747 InventoryItemBase n = InventoryService.GetItem(b);
748 n.Folder = destfolder;
749 moveitems.Add(n);
750 remoteClient.SendInventoryItemCreateUpdate(n, 0);
751 }
752
753 MoveInventoryItem(remoteClient, moveitems);
754 }
755
756 /// <summary>
754 /// Move an item within the agent's inventory. 757 /// Move an item within the agent's inventory.
755 /// </summary> 758 /// </summary>
756 /// <param name="remoteClient"></param> 759 /// <param name="remoteClient"></param>
@@ -983,8 +986,12 @@ namespace OpenSim.Region.Framework.Scenes
983 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 986 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
984 { 987 {
985 SceneObjectPart part = GetSceneObjectPart(localID); 988 SceneObjectPart part = GetSceneObjectPart(localID);
986 SceneObjectGroup group = part.ParentGroup; 989 SceneObjectGroup group = null;
987 if (group != null) 990 if (part != null)
991 {
992 group = part.ParentGroup;
993 }
994 if (part != null && group != null)
988 { 995 {
989 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 996 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
990 return; 997 return;
@@ -1433,13 +1440,6 @@ namespace OpenSim.Region.Framework.Scenes
1433 { 1440 {
1434 agentTransactions.HandleTaskItemUpdateFromTransaction( 1441 agentTransactions.HandleTaskItemUpdateFromTransaction(
1435 remoteClient, part, transactionID, currentItem); 1442 remoteClient, part, transactionID, currentItem);
1436
1437 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1438 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1439 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1440 remoteClient.SendAgentAlertMessage("Script saved", false);
1441 else
1442 remoteClient.SendAgentAlertMessage("Item saved", false);
1443 } 1443 }
1444 1444
1445 // Base ALWAYS has move 1445 // Base ALWAYS has move
@@ -1580,7 +1580,7 @@ namespace OpenSim.Region.Framework.Scenes
1580 return; 1580 return;
1581 1581
1582 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1582 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1583 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1583 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1584 remoteClient.AgentId); 1584 remoteClient.AgentId);
1585 AssetService.Store(asset); 1585 AssetService.Store(asset);
1586 1586
@@ -1733,23 +1733,32 @@ namespace OpenSim.Region.Framework.Scenes
1733 // build a list of eligible objects 1733 // build a list of eligible objects
1734 List<uint> deleteIDs = new List<uint>(); 1734 List<uint> deleteIDs = new List<uint>();
1735 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1735 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1736 1736 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1737 // Start with true for both, then remove the flags if objects
1738 // that we can't derez are part of the selection
1739 bool permissionToTake = true;
1740 bool permissionToTakeCopy = true;
1741 bool permissionToDelete = true;
1742 1737
1743 foreach (uint localID in localIDs) 1738 foreach (uint localID in localIDs)
1744 { 1739 {
1740 // Start with true for both, then remove the flags if objects
1741 // that we can't derez are part of the selection
1742 bool permissionToTake = true;
1743 bool permissionToTakeCopy = true;
1744 bool permissionToDelete = true;
1745
1745 // Invalid id 1746 // Invalid id
1746 SceneObjectPart part = GetSceneObjectPart(localID); 1747 SceneObjectPart part = GetSceneObjectPart(localID);
1747 if (part == null) 1748 if (part == null)
1749 {
1750 //Client still thinks the object exists, kill it
1751 deleteIDs.Add(localID);
1748 continue; 1752 continue;
1753 }
1749 1754
1750 // Already deleted by someone else 1755 // Already deleted by someone else
1751 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1756 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1757 {
1758 //Client still thinks the object exists, kill it
1759 deleteIDs.Add(localID);
1752 continue; 1760 continue;
1761 }
1753 1762
1754 // Can't delete child prims 1763 // Can't delete child prims
1755 if (part != part.ParentGroup.RootPart) 1764 if (part != part.ParentGroup.RootPart)
@@ -1757,9 +1766,6 @@ namespace OpenSim.Region.Framework.Scenes
1757 1766
1758 SceneObjectGroup grp = part.ParentGroup; 1767 SceneObjectGroup grp = part.ParentGroup;
1759 1768
1760 deleteIDs.Add(localID);
1761 deleteGroups.Add(grp);
1762
1763 if (remoteClient == null) 1769 if (remoteClient == null)
1764 { 1770 {
1765 // Autoreturn has a null client. Nothing else does. So 1771 // Autoreturn has a null client. Nothing else does. So
@@ -1776,80 +1782,104 @@ namespace OpenSim.Region.Framework.Scenes
1776 } 1782 }
1777 else 1783 else
1778 { 1784 {
1779 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1785 if (action == DeRezAction.TakeCopy)
1786 {
1787 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1788 permissionToTakeCopy = false;
1789 }
1790 else
1791 {
1780 permissionToTakeCopy = false; 1792 permissionToTakeCopy = false;
1781 1793 }
1782 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1794 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1783 permissionToTake = false; 1795 permissionToTake = false;
1784 1796
1785 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1797 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1786 permissionToDelete = false; 1798 permissionToDelete = false;
1787 } 1799 }
1788 }
1789 1800
1790 // Handle god perms 1801 // Handle god perms
1791 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1802 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1792 { 1803 {
1793 permissionToTake = true; 1804 permissionToTake = true;
1794 permissionToTakeCopy = true; 1805 permissionToTakeCopy = true;
1795 permissionToDelete = true; 1806 permissionToDelete = true;
1796 } 1807 }
1797 1808
1798 // If we're re-saving, we don't even want to delete 1809 // If we're re-saving, we don't even want to delete
1799 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1810 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1800 permissionToDelete = false; 1811 permissionToDelete = false;
1801 1812
1802 // if we want to take a copy, we also don't want to delete 1813 // if we want to take a copy, we also don't want to delete
1803 // Note: after this point, the permissionToTakeCopy flag 1814 // Note: after this point, the permissionToTakeCopy flag
1804 // becomes irrelevant. It already includes the permissionToTake 1815 // becomes irrelevant. It already includes the permissionToTake
1805 // permission and after excluding no copy items here, we can 1816 // permission and after excluding no copy items here, we can
1806 // just use that. 1817 // just use that.
1807 if (action == DeRezAction.TakeCopy) 1818 if (action == DeRezAction.TakeCopy)
1808 { 1819 {
1809 // If we don't have permission, stop right here 1820 // If we don't have permission, stop right here
1810 if (!permissionToTakeCopy) 1821 if (!permissionToTakeCopy)
1811 return; 1822 return;
1812 1823
1813 permissionToTake = true; 1824 permissionToTake = true;
1814 // Don't delete 1825 // Don't delete
1815 permissionToDelete = false; 1826 permissionToDelete = false;
1816 } 1827 }
1817 1828
1818 if (action == DeRezAction.Return) 1829 if (action == DeRezAction.Return)
1819 {
1820 if (remoteClient != null)
1821 { 1830 {
1822 if (Permissions.CanReturnObjects( 1831 if (remoteClient != null)
1823 null,
1824 remoteClient.AgentId,
1825 deleteGroups))
1826 { 1832 {
1827 permissionToTake = true; 1833 if (Permissions.CanReturnObjects(
1828 permissionToDelete = true; 1834 null,
1829 1835 remoteClient.AgentId,
1830 foreach (SceneObjectGroup g in deleteGroups) 1836 deleteGroups))
1831 { 1837 {
1832 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1838 permissionToTake = true;
1839 permissionToDelete = true;
1840
1841 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1833 } 1842 }
1834 } 1843 }
1844 else // Auto return passes through here with null agent
1845 {
1846 permissionToTake = true;
1847 permissionToDelete = true;
1848 }
1835 } 1849 }
1836 else // Auto return passes through here with null agent 1850
1851 if (permissionToTake && (!permissionToDelete))
1852 takeGroups.Add(grp);
1853
1854 if (permissionToDelete)
1837 { 1855 {
1838 permissionToTake = true; 1856 if (permissionToTake)
1839 permissionToDelete = true; 1857 deleteGroups.Add(grp);
1858 deleteIDs.Add(grp.LocalId);
1840 } 1859 }
1841 } 1860 }
1842 1861
1843 if (permissionToTake) 1862 SendKillObject(deleteIDs);
1863
1864 if (deleteGroups.Count > 0)
1844 { 1865 {
1866 foreach (SceneObjectGroup g in deleteGroups)
1867 deleteIDs.Remove(g.LocalId);
1868
1845 m_asyncSceneObjectDeleter.DeleteToInventory( 1869 m_asyncSceneObjectDeleter.DeleteToInventory(
1846 action, destinationID, deleteGroups, remoteClient, 1870 action, destinationID, deleteGroups, remoteClient,
1847 permissionToDelete); 1871 true);
1872 }
1873 if (takeGroups.Count > 0)
1874 {
1875 m_asyncSceneObjectDeleter.DeleteToInventory(
1876 action, destinationID, takeGroups, remoteClient,
1877 false);
1848 } 1878 }
1849 else if (permissionToDelete) 1879 if (deleteIDs.Count > 0)
1850 { 1880 {
1851 foreach (SceneObjectGroup g in deleteGroups) 1881 foreach (SceneObjectGroup g in deleteGroups)
1852 DeleteSceneObject(g, false); 1882 DeleteSceneObject(g, true);
1853 } 1883 }
1854 } 1884 }
1855 1885
@@ -1901,21 +1931,29 @@ namespace OpenSim.Region.Framework.Scenes
1901 else // oopsies 1931 else // oopsies
1902 item.Folder = UUID.Zero; 1932 item.Folder = UUID.Zero;
1903 1933
1934 // Set up base perms properly
1935 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
1936 permsBase &= grp.RootPart.BaseMask;
1937 permsBase |= (uint)PermissionMask.Move;
1938
1939 // Make sure we don't lock it
1940 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
1941
1904 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1942 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1905 { 1943 {
1906 item.BasePermissions = grp.RootPart.NextOwnerMask; 1944 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1907 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 1945 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1908 item.NextPermissions = grp.RootPart.NextOwnerMask; 1946 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1909 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 1947 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1910 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 1948 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1911 } 1949 }
1912 else 1950 else
1913 { 1951 {
1914 item.BasePermissions = grp.RootPart.BaseMask; 1952 item.BasePermissions = permsBase;
1915 item.CurrentPermissions = grp.RootPart.OwnerMask; 1953 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1916 item.NextPermissions = grp.RootPart.NextOwnerMask; 1954 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1917 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 1955 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1918 item.GroupPermissions = grp.RootPart.GroupMask; 1956 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1919 } 1957 }
1920 item.CreationDate = Util.UnixTimeSinceEpoch(); 1958 item.CreationDate = Util.UnixTimeSinceEpoch();
1921 1959
@@ -2021,6 +2059,9 @@ namespace OpenSim.Region.Framework.Scenes
2021 2059
2022 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2060 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2023 { 2061 {
2062 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2063 return;
2064
2024 SceneObjectPart part = GetSceneObjectPart(objectID); 2065 SceneObjectPart part = GetSceneObjectPart(objectID);
2025 if (part == null) 2066 if (part == null)
2026 return; 2067 return;