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.cs267
1 files changed, 160 insertions, 107 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3c47873..0b92818 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;
@@ -328,6 +310,7 @@ namespace OpenSim.Region.Framework.Scenes
328 { 310 {
329 if (UUID.Zero == transactionID) 311 if (UUID.Zero == transactionID)
330 { 312 {
313 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
331 item.Name = itemUpd.Name; 314 item.Name = itemUpd.Name;
332 item.Description = itemUpd.Description; 315 item.Description = itemUpd.Description;
333 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) 316 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
@@ -700,6 +683,8 @@ namespace OpenSim.Region.Framework.Scenes
700 return; 683 return;
701 } 684 }
702 685
686 if (newName == null) newName = item.Name;
687
703 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 688 AssetBase asset = AssetService.Get(item.AssetID.ToString());
704 689
705 if (asset != null) 690 if (asset != null)
@@ -753,6 +738,24 @@ namespace OpenSim.Region.Framework.Scenes
753 } 738 }
754 739
755 /// <summary> 740 /// <summary>
741 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
742 /// </summary>
743 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
744 {
745 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
746 foreach (InventoryItemBase b in items)
747 {
748 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
749 InventoryItemBase n = InventoryService.GetItem(b);
750 n.Folder = destfolder;
751 moveitems.Add(n);
752 remoteClient.SendInventoryItemCreateUpdate(n, 0);
753 }
754
755 MoveInventoryItem(remoteClient, moveitems);
756 }
757
758 /// <summary>
756 /// Move an item within the agent's inventory. 759 /// Move an item within the agent's inventory.
757 /// </summary> 760 /// </summary>
758 /// <param name="remoteClient"></param> 761 /// <param name="remoteClient"></param>
@@ -1025,8 +1028,12 @@ namespace OpenSim.Region.Framework.Scenes
1025 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 1028 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
1026 { 1029 {
1027 SceneObjectPart part = GetSceneObjectPart(localID); 1030 SceneObjectPart part = GetSceneObjectPart(localID);
1028 SceneObjectGroup group = part.ParentGroup; 1031 SceneObjectGroup group = null;
1029 if (group != null) 1032 if (part != null)
1033 {
1034 group = part.ParentGroup;
1035 }
1036 if (part != null && group != null)
1030 { 1037 {
1031 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 1038 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1032 return; 1039 return;
@@ -1262,6 +1269,10 @@ namespace OpenSim.Region.Framework.Scenes
1262 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1269 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1263 return; 1270 return;
1264 1271
1272 bool overrideNoMod = false;
1273 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1274 overrideNoMod = true;
1275
1265 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1276 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1266 { 1277 {
1267 // object cannot copy items to an object owned by a different owner 1278 // object cannot copy items to an object owned by a different owner
@@ -1271,7 +1282,7 @@ namespace OpenSim.Region.Framework.Scenes
1271 } 1282 }
1272 1283
1273 // must have both move and modify permission to put an item in an object 1284 // must have both move and modify permission to put an item in an object
1274 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1285 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1275 { 1286 {
1276 return; 1287 return;
1277 } 1288 }
@@ -1330,6 +1341,14 @@ namespace OpenSim.Region.Framework.Scenes
1330 1341
1331 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1342 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1332 { 1343 {
1344 SceneObjectPart destPart = GetSceneObjectPart(destID);
1345 if (destPart != null) // Move into a prim
1346 {
1347 foreach(UUID itemID in items)
1348 MoveTaskInventoryItem(destID, host, itemID);
1349 return destID; // Prim folder ID == prim ID
1350 }
1351
1333 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1352 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1334 1353
1335 UUID newFolderID = UUID.Random(); 1354 UUID newFolderID = UUID.Random();
@@ -1499,13 +1518,6 @@ namespace OpenSim.Region.Framework.Scenes
1499 { 1518 {
1500 agentTransactions.HandleTaskItemUpdateFromTransaction( 1519 agentTransactions.HandleTaskItemUpdateFromTransaction(
1501 remoteClient, part, transactionID, currentItem); 1520 remoteClient, part, transactionID, currentItem);
1502
1503 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1504 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1505 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1506 remoteClient.SendAgentAlertMessage("Script saved", false);
1507 else
1508 remoteClient.SendAgentAlertMessage("Item saved", false);
1509 } 1521 }
1510 1522
1511 // Base ALWAYS has move 1523 // Base ALWAYS has move
@@ -1646,7 +1658,7 @@ namespace OpenSim.Region.Framework.Scenes
1646 return; 1658 return;
1647 1659
1648 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1660 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1649 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1661 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1650 remoteClient.AgentId); 1662 remoteClient.AgentId);
1651 AssetService.Store(asset); 1663 AssetService.Store(asset);
1652 1664
@@ -1799,23 +1811,32 @@ namespace OpenSim.Region.Framework.Scenes
1799 // build a list of eligible objects 1811 // build a list of eligible objects
1800 List<uint> deleteIDs = new List<uint>(); 1812 List<uint> deleteIDs = new List<uint>();
1801 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1813 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1802 1814 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1803 // Start with true for both, then remove the flags if objects
1804 // that we can't derez are part of the selection
1805 bool permissionToTake = true;
1806 bool permissionToTakeCopy = true;
1807 bool permissionToDelete = true;
1808 1815
1809 foreach (uint localID in localIDs) 1816 foreach (uint localID in localIDs)
1810 { 1817 {
1818 // Start with true for both, then remove the flags if objects
1819 // that we can't derez are part of the selection
1820 bool permissionToTake = true;
1821 bool permissionToTakeCopy = true;
1822 bool permissionToDelete = true;
1823
1811 // Invalid id 1824 // Invalid id
1812 SceneObjectPart part = GetSceneObjectPart(localID); 1825 SceneObjectPart part = GetSceneObjectPart(localID);
1813 if (part == null) 1826 if (part == null)
1827 {
1828 //Client still thinks the object exists, kill it
1829 deleteIDs.Add(localID);
1814 continue; 1830 continue;
1831 }
1815 1832
1816 // Already deleted by someone else 1833 // Already deleted by someone else
1817 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1834 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1835 {
1836 //Client still thinks the object exists, kill it
1837 deleteIDs.Add(localID);
1818 continue; 1838 continue;
1839 }
1819 1840
1820 // Can't delete child prims 1841 // Can't delete child prims
1821 if (part != part.ParentGroup.RootPart) 1842 if (part != part.ParentGroup.RootPart)
@@ -1823,9 +1844,6 @@ namespace OpenSim.Region.Framework.Scenes
1823 1844
1824 SceneObjectGroup grp = part.ParentGroup; 1845 SceneObjectGroup grp = part.ParentGroup;
1825 1846
1826 deleteIDs.Add(localID);
1827 deleteGroups.Add(grp);
1828
1829 if (remoteClient == null) 1847 if (remoteClient == null)
1830 { 1848 {
1831 // Autoreturn has a null client. Nothing else does. So 1849 // Autoreturn has a null client. Nothing else does. So
@@ -1842,80 +1860,104 @@ namespace OpenSim.Region.Framework.Scenes
1842 } 1860 }
1843 else 1861 else
1844 { 1862 {
1845 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1863 if (action == DeRezAction.TakeCopy)
1864 {
1865 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1866 permissionToTakeCopy = false;
1867 }
1868 else
1869 {
1846 permissionToTakeCopy = false; 1870 permissionToTakeCopy = false;
1847 1871 }
1848 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1872 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1849 permissionToTake = false; 1873 permissionToTake = false;
1850 1874
1851 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1875 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1852 permissionToDelete = false; 1876 permissionToDelete = false;
1853 } 1877 }
1854 }
1855 1878
1856 // Handle god perms 1879 // Handle god perms
1857 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1880 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1858 { 1881 {
1859 permissionToTake = true; 1882 permissionToTake = true;
1860 permissionToTakeCopy = true; 1883 permissionToTakeCopy = true;
1861 permissionToDelete = true; 1884 permissionToDelete = true;
1862 } 1885 }
1863 1886
1864 // If we're re-saving, we don't even want to delete 1887 // If we're re-saving, we don't even want to delete
1865 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1888 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1866 permissionToDelete = false; 1889 permissionToDelete = false;
1867 1890
1868 // if we want to take a copy, we also don't want to delete 1891 // if we want to take a copy, we also don't want to delete
1869 // Note: after this point, the permissionToTakeCopy flag 1892 // Note: after this point, the permissionToTakeCopy flag
1870 // becomes irrelevant. It already includes the permissionToTake 1893 // becomes irrelevant. It already includes the permissionToTake
1871 // permission and after excluding no copy items here, we can 1894 // permission and after excluding no copy items here, we can
1872 // just use that. 1895 // just use that.
1873 if (action == DeRezAction.TakeCopy) 1896 if (action == DeRezAction.TakeCopy)
1874 { 1897 {
1875 // If we don't have permission, stop right here 1898 // If we don't have permission, stop right here
1876 if (!permissionToTakeCopy) 1899 if (!permissionToTakeCopy)
1877 return; 1900 return;
1878 1901
1879 permissionToTake = true; 1902 permissionToTake = true;
1880 // Don't delete 1903 // Don't delete
1881 permissionToDelete = false; 1904 permissionToDelete = false;
1882 } 1905 }
1883 1906
1884 if (action == DeRezAction.Return) 1907 if (action == DeRezAction.Return)
1885 {
1886 if (remoteClient != null)
1887 { 1908 {
1888 if (Permissions.CanReturnObjects( 1909 if (remoteClient != null)
1889 null,
1890 remoteClient.AgentId,
1891 deleteGroups))
1892 { 1910 {
1893 permissionToTake = true; 1911 if (Permissions.CanReturnObjects(
1894 permissionToDelete = true; 1912 null,
1895 1913 remoteClient.AgentId,
1896 foreach (SceneObjectGroup g in deleteGroups) 1914 deleteGroups))
1897 { 1915 {
1898 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1916 permissionToTake = true;
1917 permissionToDelete = true;
1918
1919 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1899 } 1920 }
1900 } 1921 }
1922 else // Auto return passes through here with null agent
1923 {
1924 permissionToTake = true;
1925 permissionToDelete = true;
1926 }
1901 } 1927 }
1902 else // Auto return passes through here with null agent 1928
1929 if (permissionToTake && (!permissionToDelete))
1930 takeGroups.Add(grp);
1931
1932 if (permissionToDelete)
1903 { 1933 {
1904 permissionToTake = true; 1934 if (permissionToTake)
1905 permissionToDelete = true; 1935 deleteGroups.Add(grp);
1936 deleteIDs.Add(grp.LocalId);
1906 } 1937 }
1907 } 1938 }
1908 1939
1909 if (permissionToTake) 1940 SendKillObject(deleteIDs);
1941
1942 if (deleteGroups.Count > 0)
1910 { 1943 {
1944 foreach (SceneObjectGroup g in deleteGroups)
1945 deleteIDs.Remove(g.LocalId);
1946
1911 m_asyncSceneObjectDeleter.DeleteToInventory( 1947 m_asyncSceneObjectDeleter.DeleteToInventory(
1912 action, destinationID, deleteGroups, remoteClient, 1948 action, destinationID, deleteGroups, remoteClient,
1913 permissionToDelete); 1949 true);
1950 }
1951 if (takeGroups.Count > 0)
1952 {
1953 m_asyncSceneObjectDeleter.DeleteToInventory(
1954 action, destinationID, takeGroups, remoteClient,
1955 false);
1914 } 1956 }
1915 else if (permissionToDelete) 1957 if (deleteIDs.Count > 0)
1916 { 1958 {
1917 foreach (SceneObjectGroup g in deleteGroups) 1959 foreach (SceneObjectGroup g in deleteGroups)
1918 DeleteSceneObject(g, false); 1960 DeleteSceneObject(g, true);
1919 } 1961 }
1920 } 1962 }
1921 1963
@@ -1967,21 +2009,29 @@ namespace OpenSim.Region.Framework.Scenes
1967 else // oopsies 2009 else // oopsies
1968 item.Folder = UUID.Zero; 2010 item.Folder = UUID.Zero;
1969 2011
2012 // Set up base perms properly
2013 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2014 permsBase &= grp.RootPart.BaseMask;
2015 permsBase |= (uint)PermissionMask.Move;
2016
2017 // Make sure we don't lock it
2018 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2019
1970 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 2020 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1971 { 2021 {
1972 item.BasePermissions = grp.RootPart.NextOwnerMask; 2022 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1973 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 2023 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1974 item.NextPermissions = grp.RootPart.NextOwnerMask; 2024 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1975 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 2025 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1976 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 2026 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1977 } 2027 }
1978 else 2028 else
1979 { 2029 {
1980 item.BasePermissions = grp.RootPart.BaseMask; 2030 item.BasePermissions = permsBase;
1981 item.CurrentPermissions = grp.RootPart.OwnerMask; 2031 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1982 item.NextPermissions = grp.RootPart.NextOwnerMask; 2032 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1983 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 2033 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1984 item.GroupPermissions = grp.RootPart.GroupMask; 2034 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1985 } 2035 }
1986 item.CreationDate = Util.UnixTimeSinceEpoch(); 2036 item.CreationDate = Util.UnixTimeSinceEpoch();
1987 2037
@@ -2125,6 +2175,9 @@ namespace OpenSim.Region.Framework.Scenes
2125 2175
2126 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2176 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2127 { 2177 {
2178 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2179 return;
2180
2128 SceneObjectPart part = GetSceneObjectPart(objectID); 2181 SceneObjectPart part = GetSceneObjectPart(objectID);
2129 if (part == null) 2182 if (part == null)
2130 return; 2183 return;