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 0f85925..f41c6b9 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>
@@ -985,8 +988,12 @@ namespace OpenSim.Region.Framework.Scenes
985 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 988 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
986 { 989 {
987 SceneObjectPart part = GetSceneObjectPart(localID); 990 SceneObjectPart part = GetSceneObjectPart(localID);
988 SceneObjectGroup group = part.ParentGroup; 991 SceneObjectGroup group = null;
989 if (group != null) 992 if (part != null)
993 {
994 group = part.ParentGroup;
995 }
996 if (part != null && group != null)
990 { 997 {
991 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 998 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
992 return; 999 return;
@@ -1222,6 +1229,10 @@ namespace OpenSim.Region.Framework.Scenes
1222 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1229 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1223 return; 1230 return;
1224 1231
1232 bool overrideNoMod = false;
1233 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1234 overrideNoMod = true;
1235
1225 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1236 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1226 { 1237 {
1227 // object cannot copy items to an object owned by a different owner 1238 // object cannot copy items to an object owned by a different owner
@@ -1231,7 +1242,7 @@ namespace OpenSim.Region.Framework.Scenes
1231 } 1242 }
1232 1243
1233 // must have both move and modify permission to put an item in an object 1244 // must have both move and modify permission to put an item in an object
1234 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1245 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1235 { 1246 {
1236 return; 1247 return;
1237 } 1248 }
@@ -1290,6 +1301,14 @@ namespace OpenSim.Region.Framework.Scenes
1290 1301
1291 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1302 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1292 { 1303 {
1304 SceneObjectPart destPart = GetSceneObjectPart(destID);
1305 if (destPart != null) // Move into a prim
1306 {
1307 foreach(UUID itemID in items)
1308 MoveTaskInventoryItem(destID, host, itemID);
1309 return destID; // Prim folder ID == prim ID
1310 }
1311
1293 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1312 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1294 1313
1295 UUID newFolderID = UUID.Random(); 1314 UUID newFolderID = UUID.Random();
@@ -1435,13 +1454,6 @@ namespace OpenSim.Region.Framework.Scenes
1435 { 1454 {
1436 agentTransactions.HandleTaskItemUpdateFromTransaction( 1455 agentTransactions.HandleTaskItemUpdateFromTransaction(
1437 remoteClient, part, transactionID, currentItem); 1456 remoteClient, part, transactionID, currentItem);
1438
1439 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1440 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1441 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1442 remoteClient.SendAgentAlertMessage("Script saved", false);
1443 else
1444 remoteClient.SendAgentAlertMessage("Item saved", false);
1445 } 1457 }
1446 1458
1447 // Base ALWAYS has move 1459 // Base ALWAYS has move
@@ -1582,7 +1594,7 @@ namespace OpenSim.Region.Framework.Scenes
1582 return; 1594 return;
1583 1595
1584 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1596 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1585 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1597 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1586 remoteClient.AgentId); 1598 remoteClient.AgentId);
1587 AssetService.Store(asset); 1599 AssetService.Store(asset);
1588 1600
@@ -1735,23 +1747,32 @@ namespace OpenSim.Region.Framework.Scenes
1735 // build a list of eligible objects 1747 // build a list of eligible objects
1736 List<uint> deleteIDs = new List<uint>(); 1748 List<uint> deleteIDs = new List<uint>();
1737 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1749 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1738 1750 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1739 // Start with true for both, then remove the flags if objects
1740 // that we can't derez are part of the selection
1741 bool permissionToTake = true;
1742 bool permissionToTakeCopy = true;
1743 bool permissionToDelete = true;
1744 1751
1745 foreach (uint localID in localIDs) 1752 foreach (uint localID in localIDs)
1746 { 1753 {
1754 // Start with true for both, then remove the flags if objects
1755 // that we can't derez are part of the selection
1756 bool permissionToTake = true;
1757 bool permissionToTakeCopy = true;
1758 bool permissionToDelete = true;
1759
1747 // Invalid id 1760 // Invalid id
1748 SceneObjectPart part = GetSceneObjectPart(localID); 1761 SceneObjectPart part = GetSceneObjectPart(localID);
1749 if (part == null) 1762 if (part == null)
1763 {
1764 //Client still thinks the object exists, kill it
1765 deleteIDs.Add(localID);
1750 continue; 1766 continue;
1767 }
1751 1768
1752 // Already deleted by someone else 1769 // Already deleted by someone else
1753 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1770 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1771 {
1772 //Client still thinks the object exists, kill it
1773 deleteIDs.Add(localID);
1754 continue; 1774 continue;
1775 }
1755 1776
1756 // Can't delete child prims 1777 // Can't delete child prims
1757 if (part != part.ParentGroup.RootPart) 1778 if (part != part.ParentGroup.RootPart)
@@ -1759,9 +1780,6 @@ namespace OpenSim.Region.Framework.Scenes
1759 1780
1760 SceneObjectGroup grp = part.ParentGroup; 1781 SceneObjectGroup grp = part.ParentGroup;
1761 1782
1762 deleteIDs.Add(localID);
1763 deleteGroups.Add(grp);
1764
1765 if (remoteClient == null) 1783 if (remoteClient == null)
1766 { 1784 {
1767 // Autoreturn has a null client. Nothing else does. So 1785 // Autoreturn has a null client. Nothing else does. So
@@ -1778,80 +1796,104 @@ namespace OpenSim.Region.Framework.Scenes
1778 } 1796 }
1779 else 1797 else
1780 { 1798 {
1781 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1799 if (action == DeRezAction.TakeCopy)
1800 {
1801 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1802 permissionToTakeCopy = false;
1803 }
1804 else
1805 {
1782 permissionToTakeCopy = false; 1806 permissionToTakeCopy = false;
1783 1807 }
1784 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1808 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1785 permissionToTake = false; 1809 permissionToTake = false;
1786 1810
1787 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1811 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1788 permissionToDelete = false; 1812 permissionToDelete = false;
1789 } 1813 }
1790 }
1791 1814
1792 // Handle god perms 1815 // Handle god perms
1793 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1816 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1794 { 1817 {
1795 permissionToTake = true; 1818 permissionToTake = true;
1796 permissionToTakeCopy = true; 1819 permissionToTakeCopy = true;
1797 permissionToDelete = true; 1820 permissionToDelete = true;
1798 } 1821 }
1799 1822
1800 // If we're re-saving, we don't even want to delete 1823 // If we're re-saving, we don't even want to delete
1801 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1824 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1802 permissionToDelete = false; 1825 permissionToDelete = false;
1803 1826
1804 // if we want to take a copy, we also don't want to delete 1827 // if we want to take a copy, we also don't want to delete
1805 // Note: after this point, the permissionToTakeCopy flag 1828 // Note: after this point, the permissionToTakeCopy flag
1806 // becomes irrelevant. It already includes the permissionToTake 1829 // becomes irrelevant. It already includes the permissionToTake
1807 // permission and after excluding no copy items here, we can 1830 // permission and after excluding no copy items here, we can
1808 // just use that. 1831 // just use that.
1809 if (action == DeRezAction.TakeCopy) 1832 if (action == DeRezAction.TakeCopy)
1810 { 1833 {
1811 // If we don't have permission, stop right here 1834 // If we don't have permission, stop right here
1812 if (!permissionToTakeCopy) 1835 if (!permissionToTakeCopy)
1813 return; 1836 return;
1814 1837
1815 permissionToTake = true; 1838 permissionToTake = true;
1816 // Don't delete 1839 // Don't delete
1817 permissionToDelete = false; 1840 permissionToDelete = false;
1818 } 1841 }
1819 1842
1820 if (action == DeRezAction.Return) 1843 if (action == DeRezAction.Return)
1821 {
1822 if (remoteClient != null)
1823 { 1844 {
1824 if (Permissions.CanReturnObjects( 1845 if (remoteClient != null)
1825 null,
1826 remoteClient.AgentId,
1827 deleteGroups))
1828 { 1846 {
1829 permissionToTake = true; 1847 if (Permissions.CanReturnObjects(
1830 permissionToDelete = true; 1848 null,
1831 1849 remoteClient.AgentId,
1832 foreach (SceneObjectGroup g in deleteGroups) 1850 deleteGroups))
1833 { 1851 {
1834 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1852 permissionToTake = true;
1853 permissionToDelete = true;
1854
1855 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1835 } 1856 }
1836 } 1857 }
1858 else // Auto return passes through here with null agent
1859 {
1860 permissionToTake = true;
1861 permissionToDelete = true;
1862 }
1837 } 1863 }
1838 else // Auto return passes through here with null agent 1864
1865 if (permissionToTake && (!permissionToDelete))
1866 takeGroups.Add(grp);
1867
1868 if (permissionToDelete)
1839 { 1869 {
1840 permissionToTake = true; 1870 if (permissionToTake)
1841 permissionToDelete = true; 1871 deleteGroups.Add(grp);
1872 deleteIDs.Add(grp.LocalId);
1842 } 1873 }
1843 } 1874 }
1844 1875
1845 if (permissionToTake) 1876 SendKillObject(deleteIDs);
1877
1878 if (deleteGroups.Count > 0)
1846 { 1879 {
1880 foreach (SceneObjectGroup g in deleteGroups)
1881 deleteIDs.Remove(g.LocalId);
1882
1847 m_asyncSceneObjectDeleter.DeleteToInventory( 1883 m_asyncSceneObjectDeleter.DeleteToInventory(
1848 action, destinationID, deleteGroups, remoteClient, 1884 action, destinationID, deleteGroups, remoteClient,
1849 permissionToDelete); 1885 true);
1886 }
1887 if (takeGroups.Count > 0)
1888 {
1889 m_asyncSceneObjectDeleter.DeleteToInventory(
1890 action, destinationID, takeGroups, remoteClient,
1891 false);
1850 } 1892 }
1851 else if (permissionToDelete) 1893 if (deleteIDs.Count > 0)
1852 { 1894 {
1853 foreach (SceneObjectGroup g in deleteGroups) 1895 foreach (SceneObjectGroup g in deleteGroups)
1854 DeleteSceneObject(g, false); 1896 DeleteSceneObject(g, true);
1855 } 1897 }
1856 } 1898 }
1857 1899
@@ -1903,21 +1945,29 @@ namespace OpenSim.Region.Framework.Scenes
1903 else // oopsies 1945 else // oopsies
1904 item.Folder = UUID.Zero; 1946 item.Folder = UUID.Zero;
1905 1947
1948 // Set up base perms properly
1949 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
1950 permsBase &= grp.RootPart.BaseMask;
1951 permsBase |= (uint)PermissionMask.Move;
1952
1953 // Make sure we don't lock it
1954 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
1955
1906 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1956 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1907 { 1957 {
1908 item.BasePermissions = grp.RootPart.NextOwnerMask; 1958 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1909 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 1959 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1910 item.NextPermissions = grp.RootPart.NextOwnerMask; 1960 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1911 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 1961 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1912 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 1962 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1913 } 1963 }
1914 else 1964 else
1915 { 1965 {
1916 item.BasePermissions = grp.RootPart.BaseMask; 1966 item.BasePermissions = permsBase;
1917 item.CurrentPermissions = grp.RootPart.OwnerMask; 1967 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1918 item.NextPermissions = grp.RootPart.NextOwnerMask; 1968 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1919 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 1969 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1920 item.GroupPermissions = grp.RootPart.GroupMask; 1970 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1921 } 1971 }
1922 item.CreationDate = Util.UnixTimeSinceEpoch(); 1972 item.CreationDate = Util.UnixTimeSinceEpoch();
1923 1973
@@ -2067,6 +2117,9 @@ namespace OpenSim.Region.Framework.Scenes
2067 2117
2068 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2118 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2069 { 2119 {
2120 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2121 return;
2122
2070 SceneObjectPart part = GetSceneObjectPart(objectID); 2123 SceneObjectPart part = GetSceneObjectPart(objectID);
2071 if (part == null) 2124 if (part == null)
2072 return; 2125 return;