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 13085e3..28c0276 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))
@@ -706,6 +689,8 @@ namespace OpenSim.Region.Framework.Scenes
706 return; 689 return;
707 } 690 }
708 691
692 if (newName == null) newName = item.Name;
693
709 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 694 AssetBase asset = AssetService.Get(item.AssetID.ToString());
710 695
711 if (asset != null) 696 if (asset != null)
@@ -759,6 +744,24 @@ namespace OpenSim.Region.Framework.Scenes
759 } 744 }
760 745
761 /// <summary> 746 /// <summary>
747 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
748 /// </summary>
749 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
750 {
751 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
752 foreach (InventoryItemBase b in items)
753 {
754 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
755 InventoryItemBase n = InventoryService.GetItem(b);
756 n.Folder = destfolder;
757 moveitems.Add(n);
758 remoteClient.SendInventoryItemCreateUpdate(n, 0);
759 }
760
761 MoveInventoryItem(remoteClient, moveitems);
762 }
763
764 /// <summary>
762 /// Move an item within the agent's inventory. 765 /// Move an item within the agent's inventory.
763 /// </summary> 766 /// </summary>
764 /// <param name="remoteClient"></param> 767 /// <param name="remoteClient"></param>
@@ -959,8 +962,12 @@ namespace OpenSim.Region.Framework.Scenes
959 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 962 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
960 { 963 {
961 SceneObjectPart part = GetSceneObjectPart(localID); 964 SceneObjectPart part = GetSceneObjectPart(localID);
962 SceneObjectGroup group = part.ParentGroup; 965 SceneObjectGroup group = null;
963 if (group != null) 966 if (part != null)
967 {
968 group = part.ParentGroup;
969 }
970 if (part != null && group != null)
964 { 971 {
965 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 972 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
966 return; 973 return;
@@ -1196,6 +1203,10 @@ namespace OpenSim.Region.Framework.Scenes
1196 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1203 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1197 return; 1204 return;
1198 1205
1206 bool overrideNoMod = false;
1207 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1208 overrideNoMod = true;
1209
1199 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1210 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1200 { 1211 {
1201 // object cannot copy items to an object owned by a different owner 1212 // object cannot copy items to an object owned by a different owner
@@ -1205,7 +1216,7 @@ namespace OpenSim.Region.Framework.Scenes
1205 } 1216 }
1206 1217
1207 // must have both move and modify permission to put an item in an object 1218 // must have both move and modify permission to put an item in an object
1208 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1219 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1209 { 1220 {
1210 return; 1221 return;
1211 } 1222 }
@@ -1264,6 +1275,14 @@ namespace OpenSim.Region.Framework.Scenes
1264 1275
1265 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1276 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1266 { 1277 {
1278 SceneObjectPart destPart = GetSceneObjectPart(destID);
1279 if (destPart != null) // Move into a prim
1280 {
1281 foreach(UUID itemID in items)
1282 MoveTaskInventoryItem(destID, host, itemID);
1283 return destID; // Prim folder ID == prim ID
1284 }
1285
1267 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1286 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1268 1287
1269 UUID newFolderID = UUID.Random(); 1288 UUID newFolderID = UUID.Random();
@@ -1443,13 +1462,6 @@ namespace OpenSim.Region.Framework.Scenes
1443 { 1462 {
1444 agentTransactions.HandleTaskItemUpdateFromTransaction( 1463 agentTransactions.HandleTaskItemUpdateFromTransaction(
1445 remoteClient, part, transactionID, currentItem); 1464 remoteClient, part, transactionID, currentItem);
1446
1447 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1448 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1449 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1450 remoteClient.SendAgentAlertMessage("Script saved", false);
1451 else
1452 remoteClient.SendAgentAlertMessage("Item saved", false);
1453 } 1465 }
1454 1466
1455 // Base ALWAYS has move 1467 // Base ALWAYS has move
@@ -1590,7 +1602,7 @@ namespace OpenSim.Region.Framework.Scenes
1590 return; 1602 return;
1591 1603
1592 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1604 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1593 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1605 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1594 remoteClient.AgentId); 1606 remoteClient.AgentId);
1595 AssetService.Store(asset); 1607 AssetService.Store(asset);
1596 1608
@@ -1743,23 +1755,32 @@ namespace OpenSim.Region.Framework.Scenes
1743 // build a list of eligible objects 1755 // build a list of eligible objects
1744 List<uint> deleteIDs = new List<uint>(); 1756 List<uint> deleteIDs = new List<uint>();
1745 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1757 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1746 1758 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1747 // Start with true for both, then remove the flags if objects
1748 // that we can't derez are part of the selection
1749 bool permissionToTake = true;
1750 bool permissionToTakeCopy = true;
1751 bool permissionToDelete = true;
1752 1759
1753 foreach (uint localID in localIDs) 1760 foreach (uint localID in localIDs)
1754 { 1761 {
1762 // Start with true for both, then remove the flags if objects
1763 // that we can't derez are part of the selection
1764 bool permissionToTake = true;
1765 bool permissionToTakeCopy = true;
1766 bool permissionToDelete = true;
1767
1755 // Invalid id 1768 // Invalid id
1756 SceneObjectPart part = GetSceneObjectPart(localID); 1769 SceneObjectPart part = GetSceneObjectPart(localID);
1757 if (part == null) 1770 if (part == null)
1771 {
1772 //Client still thinks the object exists, kill it
1773 deleteIDs.Add(localID);
1758 continue; 1774 continue;
1775 }
1759 1776
1760 // Already deleted by someone else 1777 // Already deleted by someone else
1761 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1778 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1779 {
1780 //Client still thinks the object exists, kill it
1781 deleteIDs.Add(localID);
1762 continue; 1782 continue;
1783 }
1763 1784
1764 // Can't delete child prims 1785 // Can't delete child prims
1765 if (part != part.ParentGroup.RootPart) 1786 if (part != part.ParentGroup.RootPart)
@@ -1767,9 +1788,6 @@ namespace OpenSim.Region.Framework.Scenes
1767 1788
1768 SceneObjectGroup grp = part.ParentGroup; 1789 SceneObjectGroup grp = part.ParentGroup;
1769 1790
1770 deleteIDs.Add(localID);
1771 deleteGroups.Add(grp);
1772
1773 if (remoteClient == null) 1791 if (remoteClient == null)
1774 { 1792 {
1775 // Autoreturn has a null client. Nothing else does. So 1793 // Autoreturn has a null client. Nothing else does. So
@@ -1786,80 +1804,104 @@ namespace OpenSim.Region.Framework.Scenes
1786 } 1804 }
1787 else 1805 else
1788 { 1806 {
1789 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1807 if (action == DeRezAction.TakeCopy)
1808 {
1809 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1810 permissionToTakeCopy = false;
1811 }
1812 else
1813 {
1790 permissionToTakeCopy = false; 1814 permissionToTakeCopy = false;
1791 1815 }
1792 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1816 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1793 permissionToTake = false; 1817 permissionToTake = false;
1794 1818
1795 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1819 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1796 permissionToDelete = false; 1820 permissionToDelete = false;
1797 } 1821 }
1798 }
1799 1822
1800 // Handle god perms 1823 // Handle god perms
1801 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1824 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1802 { 1825 {
1803 permissionToTake = true; 1826 permissionToTake = true;
1804 permissionToTakeCopy = true; 1827 permissionToTakeCopy = true;
1805 permissionToDelete = true; 1828 permissionToDelete = true;
1806 } 1829 }
1807 1830
1808 // If we're re-saving, we don't even want to delete 1831 // If we're re-saving, we don't even want to delete
1809 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1832 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1810 permissionToDelete = false; 1833 permissionToDelete = false;
1811 1834
1812 // if we want to take a copy, we also don't want to delete 1835 // if we want to take a copy, we also don't want to delete
1813 // Note: after this point, the permissionToTakeCopy flag 1836 // Note: after this point, the permissionToTakeCopy flag
1814 // becomes irrelevant. It already includes the permissionToTake 1837 // becomes irrelevant. It already includes the permissionToTake
1815 // permission and after excluding no copy items here, we can 1838 // permission and after excluding no copy items here, we can
1816 // just use that. 1839 // just use that.
1817 if (action == DeRezAction.TakeCopy) 1840 if (action == DeRezAction.TakeCopy)
1818 { 1841 {
1819 // If we don't have permission, stop right here 1842 // If we don't have permission, stop right here
1820 if (!permissionToTakeCopy) 1843 if (!permissionToTakeCopy)
1821 return; 1844 return;
1822 1845
1823 permissionToTake = true; 1846 permissionToTake = true;
1824 // Don't delete 1847 // Don't delete
1825 permissionToDelete = false; 1848 permissionToDelete = false;
1826 } 1849 }
1827 1850
1828 if (action == DeRezAction.Return) 1851 if (action == DeRezAction.Return)
1829 {
1830 if (remoteClient != null)
1831 { 1852 {
1832 if (Permissions.CanReturnObjects( 1853 if (remoteClient != null)
1833 null,
1834 remoteClient.AgentId,
1835 deleteGroups))
1836 { 1854 {
1837 permissionToTake = true; 1855 if (Permissions.CanReturnObjects(
1838 permissionToDelete = true; 1856 null,
1839 1857 remoteClient.AgentId,
1840 foreach (SceneObjectGroup g in deleteGroups) 1858 deleteGroups))
1841 { 1859 {
1842 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1860 permissionToTake = true;
1861 permissionToDelete = true;
1862
1863 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1843 } 1864 }
1844 } 1865 }
1866 else // Auto return passes through here with null agent
1867 {
1868 permissionToTake = true;
1869 permissionToDelete = true;
1870 }
1845 } 1871 }
1846 else // Auto return passes through here with null agent 1872
1873 if (permissionToTake && (!permissionToDelete))
1874 takeGroups.Add(grp);
1875
1876 if (permissionToDelete)
1847 { 1877 {
1848 permissionToTake = true; 1878 if (permissionToTake)
1849 permissionToDelete = true; 1879 deleteGroups.Add(grp);
1880 deleteIDs.Add(grp.LocalId);
1850 } 1881 }
1851 } 1882 }
1852 1883
1853 if (permissionToTake) 1884 SendKillObject(deleteIDs);
1885
1886 if (deleteGroups.Count > 0)
1854 { 1887 {
1888 foreach (SceneObjectGroup g in deleteGroups)
1889 deleteIDs.Remove(g.LocalId);
1890
1855 m_asyncSceneObjectDeleter.DeleteToInventory( 1891 m_asyncSceneObjectDeleter.DeleteToInventory(
1856 action, destinationID, deleteGroups, remoteClient, 1892 action, destinationID, deleteGroups, remoteClient,
1857 permissionToDelete); 1893 true);
1894 }
1895 if (takeGroups.Count > 0)
1896 {
1897 m_asyncSceneObjectDeleter.DeleteToInventory(
1898 action, destinationID, takeGroups, remoteClient,
1899 false);
1858 } 1900 }
1859 else if (permissionToDelete) 1901 if (deleteIDs.Count > 0)
1860 { 1902 {
1861 foreach (SceneObjectGroup g in deleteGroups) 1903 foreach (SceneObjectGroup g in deleteGroups)
1862 DeleteSceneObject(g, false); 1904 DeleteSceneObject(g, true);
1863 } 1905 }
1864 } 1906 }
1865 1907
@@ -1911,21 +1953,29 @@ namespace OpenSim.Region.Framework.Scenes
1911 else // oopsies 1953 else // oopsies
1912 item.Folder = UUID.Zero; 1954 item.Folder = UUID.Zero;
1913 1955
1956 // Set up base perms properly
1957 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
1958 permsBase &= grp.RootPart.BaseMask;
1959 permsBase |= (uint)PermissionMask.Move;
1960
1961 // Make sure we don't lock it
1962 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
1963
1914 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1964 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1915 { 1965 {
1916 item.BasePermissions = grp.RootPart.NextOwnerMask; 1966 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1917 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 1967 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1918 item.NextPermissions = grp.RootPart.NextOwnerMask; 1968 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1919 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 1969 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1920 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 1970 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1921 } 1971 }
1922 else 1972 else
1923 { 1973 {
1924 item.BasePermissions = grp.RootPart.BaseMask; 1974 item.BasePermissions = permsBase;
1925 item.CurrentPermissions = grp.RootPart.OwnerMask; 1975 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1926 item.NextPermissions = grp.RootPart.NextOwnerMask; 1976 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1927 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 1977 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1928 item.GroupPermissions = grp.RootPart.GroupMask; 1978 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1929 } 1979 }
1930 item.CreationDate = Util.UnixTimeSinceEpoch(); 1980 item.CreationDate = Util.UnixTimeSinceEpoch();
1931 1981
@@ -2069,6 +2119,9 @@ namespace OpenSim.Region.Framework.Scenes
2069 2119
2070 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2120 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2071 { 2121 {
2122 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2123 return;
2124
2072 SceneObjectPart part = GetSceneObjectPart(objectID); 2125 SceneObjectPart part = GetSceneObjectPart(objectID);
2073 if (part == null) 2126 if (part == null)
2074 return; 2127 return;