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.cs261
1 files changed, 154 insertions, 107 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index e2d96d9..bc892e0 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;
@@ -321,11 +303,14 @@ namespace OpenSim.Region.Framework.Scenes
321 // Passing something to another avatar or a an object will already 303 // Passing something to another avatar or a an object will already
322 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 304 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
323 item = InventoryService.GetItem(item); 305 item = InventoryService.GetItem(item);
306 if (item.Owner != remoteClient.AgentId)
307 return;
324 308
325 if (item != null) 309 if (item != null)
326 { 310 {
327 if (UUID.Zero == transactionID) 311 if (UUID.Zero == transactionID)
328 { 312 {
313 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
329 item.Name = itemUpd.Name; 314 item.Name = itemUpd.Name;
330 item.Description = itemUpd.Description; 315 item.Description = itemUpd.Description;
331 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) 316 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
@@ -698,6 +683,8 @@ namespace OpenSim.Region.Framework.Scenes
698 return; 683 return;
699 } 684 }
700 685
686 if (newName == null) newName = item.Name;
687
701 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 688 AssetBase asset = AssetService.Get(item.AssetID.ToString());
702 689
703 if (asset != null) 690 if (asset != null)
@@ -751,6 +738,24 @@ namespace OpenSim.Region.Framework.Scenes
751 } 738 }
752 739
753 /// <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>
754 /// Move an item within the agent's inventory. 759 /// Move an item within the agent's inventory.
755 /// </summary> 760 /// </summary>
756 /// <param name="remoteClient"></param> 761 /// <param name="remoteClient"></param>
@@ -983,8 +988,12 @@ namespace OpenSim.Region.Framework.Scenes
983 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 988 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
984 { 989 {
985 SceneObjectPart part = GetSceneObjectPart(localID); 990 SceneObjectPart part = GetSceneObjectPart(localID);
986 SceneObjectGroup group = part.ParentGroup; 991 SceneObjectGroup group = null;
987 if (group != null) 992 if (part != null)
993 {
994 group = part.ParentGroup;
995 }
996 if (part != null && group != null)
988 { 997 {
989 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 998 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
990 return; 999 return;
@@ -1220,6 +1229,10 @@ namespace OpenSim.Region.Framework.Scenes
1220 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1229 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1221 return; 1230 return;
1222 1231
1232 bool overrideNoMod = false;
1233 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1234 overrideNoMod = true;
1235
1223 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1236 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1224 { 1237 {
1225 // 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
@@ -1229,7 +1242,7 @@ namespace OpenSim.Region.Framework.Scenes
1229 } 1242 }
1230 1243
1231 // 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
1232 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1245 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1233 { 1246 {
1234 return; 1247 return;
1235 } 1248 }
@@ -1433,13 +1446,6 @@ namespace OpenSim.Region.Framework.Scenes
1433 { 1446 {
1434 agentTransactions.HandleTaskItemUpdateFromTransaction( 1447 agentTransactions.HandleTaskItemUpdateFromTransaction(
1435 remoteClient, part, transactionID, currentItem); 1448 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 } 1449 }
1444 1450
1445 // Base ALWAYS has move 1451 // Base ALWAYS has move
@@ -1580,7 +1586,7 @@ namespace OpenSim.Region.Framework.Scenes
1580 return; 1586 return;
1581 1587
1582 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1588 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}"), 1589 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); 1590 remoteClient.AgentId);
1585 AssetService.Store(asset); 1591 AssetService.Store(asset);
1586 1592
@@ -1733,23 +1739,32 @@ namespace OpenSim.Region.Framework.Scenes
1733 // build a list of eligible objects 1739 // build a list of eligible objects
1734 List<uint> deleteIDs = new List<uint>(); 1740 List<uint> deleteIDs = new List<uint>();
1735 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1741 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1736 1742 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 1743
1743 foreach (uint localID in localIDs) 1744 foreach (uint localID in localIDs)
1744 { 1745 {
1746 // Start with true for both, then remove the flags if objects
1747 // that we can't derez are part of the selection
1748 bool permissionToTake = true;
1749 bool permissionToTakeCopy = true;
1750 bool permissionToDelete = true;
1751
1745 // Invalid id 1752 // Invalid id
1746 SceneObjectPart part = GetSceneObjectPart(localID); 1753 SceneObjectPart part = GetSceneObjectPart(localID);
1747 if (part == null) 1754 if (part == null)
1755 {
1756 //Client still thinks the object exists, kill it
1757 deleteIDs.Add(localID);
1748 continue; 1758 continue;
1759 }
1749 1760
1750 // Already deleted by someone else 1761 // Already deleted by someone else
1751 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1762 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1763 {
1764 //Client still thinks the object exists, kill it
1765 deleteIDs.Add(localID);
1752 continue; 1766 continue;
1767 }
1753 1768
1754 // Can't delete child prims 1769 // Can't delete child prims
1755 if (part != part.ParentGroup.RootPart) 1770 if (part != part.ParentGroup.RootPart)
@@ -1757,9 +1772,6 @@ namespace OpenSim.Region.Framework.Scenes
1757 1772
1758 SceneObjectGroup grp = part.ParentGroup; 1773 SceneObjectGroup grp = part.ParentGroup;
1759 1774
1760 deleteIDs.Add(localID);
1761 deleteGroups.Add(grp);
1762
1763 if (remoteClient == null) 1775 if (remoteClient == null)
1764 { 1776 {
1765 // Autoreturn has a null client. Nothing else does. So 1777 // Autoreturn has a null client. Nothing else does. So
@@ -1776,80 +1788,104 @@ namespace OpenSim.Region.Framework.Scenes
1776 } 1788 }
1777 else 1789 else
1778 { 1790 {
1779 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1791 if (action == DeRezAction.TakeCopy)
1792 {
1793 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1794 permissionToTakeCopy = false;
1795 }
1796 else
1797 {
1780 permissionToTakeCopy = false; 1798 permissionToTakeCopy = false;
1781 1799 }
1782 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1800 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1783 permissionToTake = false; 1801 permissionToTake = false;
1784 1802
1785 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1803 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1786 permissionToDelete = false; 1804 permissionToDelete = false;
1787 } 1805 }
1788 }
1789 1806
1790 // Handle god perms 1807 // Handle god perms
1791 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1808 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1792 { 1809 {
1793 permissionToTake = true; 1810 permissionToTake = true;
1794 permissionToTakeCopy = true; 1811 permissionToTakeCopy = true;
1795 permissionToDelete = true; 1812 permissionToDelete = true;
1796 } 1813 }
1797 1814
1798 // If we're re-saving, we don't even want to delete 1815 // If we're re-saving, we don't even want to delete
1799 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1816 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1800 permissionToDelete = false; 1817 permissionToDelete = false;
1801 1818
1802 // if we want to take a copy, we also don't want to delete 1819 // if we want to take a copy, we also don't want to delete
1803 // Note: after this point, the permissionToTakeCopy flag 1820 // Note: after this point, the permissionToTakeCopy flag
1804 // becomes irrelevant. It already includes the permissionToTake 1821 // becomes irrelevant. It already includes the permissionToTake
1805 // permission and after excluding no copy items here, we can 1822 // permission and after excluding no copy items here, we can
1806 // just use that. 1823 // just use that.
1807 if (action == DeRezAction.TakeCopy) 1824 if (action == DeRezAction.TakeCopy)
1808 { 1825 {
1809 // If we don't have permission, stop right here 1826 // If we don't have permission, stop right here
1810 if (!permissionToTakeCopy) 1827 if (!permissionToTakeCopy)
1811 return; 1828 return;
1812 1829
1813 permissionToTake = true; 1830 permissionToTake = true;
1814 // Don't delete 1831 // Don't delete
1815 permissionToDelete = false; 1832 permissionToDelete = false;
1816 } 1833 }
1817 1834
1818 if (action == DeRezAction.Return) 1835 if (action == DeRezAction.Return)
1819 {
1820 if (remoteClient != null)
1821 { 1836 {
1822 if (Permissions.CanReturnObjects( 1837 if (remoteClient != null)
1823 null,
1824 remoteClient.AgentId,
1825 deleteGroups))
1826 { 1838 {
1827 permissionToTake = true; 1839 if (Permissions.CanReturnObjects(
1828 permissionToDelete = true; 1840 null,
1829 1841 remoteClient.AgentId,
1830 foreach (SceneObjectGroup g in deleteGroups) 1842 deleteGroups))
1831 { 1843 {
1832 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1844 permissionToTake = true;
1845 permissionToDelete = true;
1846
1847 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1833 } 1848 }
1834 } 1849 }
1850 else // Auto return passes through here with null agent
1851 {
1852 permissionToTake = true;
1853 permissionToDelete = true;
1854 }
1835 } 1855 }
1836 else // Auto return passes through here with null agent 1856
1857 if (permissionToTake && (!permissionToDelete))
1858 takeGroups.Add(grp);
1859
1860 if (permissionToDelete)
1837 { 1861 {
1838 permissionToTake = true; 1862 if (permissionToTake)
1839 permissionToDelete = true; 1863 deleteGroups.Add(grp);
1864 deleteIDs.Add(grp.LocalId);
1840 } 1865 }
1841 } 1866 }
1842 1867
1843 if (permissionToTake) 1868 SendKillObject(deleteIDs);
1869
1870 if (deleteGroups.Count > 0)
1844 { 1871 {
1872 foreach (SceneObjectGroup g in deleteGroups)
1873 deleteIDs.Remove(g.LocalId);
1874
1845 m_asyncSceneObjectDeleter.DeleteToInventory( 1875 m_asyncSceneObjectDeleter.DeleteToInventory(
1846 action, destinationID, deleteGroups, remoteClient, 1876 action, destinationID, deleteGroups, remoteClient,
1847 permissionToDelete); 1877 true);
1878 }
1879 if (takeGroups.Count > 0)
1880 {
1881 m_asyncSceneObjectDeleter.DeleteToInventory(
1882 action, destinationID, takeGroups, remoteClient,
1883 false);
1848 } 1884 }
1849 else if (permissionToDelete) 1885 if (deleteIDs.Count > 0)
1850 { 1886 {
1851 foreach (SceneObjectGroup g in deleteGroups) 1887 foreach (SceneObjectGroup g in deleteGroups)
1852 DeleteSceneObject(g, false); 1888 DeleteSceneObject(g, true);
1853 } 1889 }
1854 } 1890 }
1855 1891
@@ -1901,21 +1937,29 @@ namespace OpenSim.Region.Framework.Scenes
1901 else // oopsies 1937 else // oopsies
1902 item.Folder = UUID.Zero; 1938 item.Folder = UUID.Zero;
1903 1939
1940 // Set up base perms properly
1941 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
1942 permsBase &= grp.RootPart.BaseMask;
1943 permsBase |= (uint)PermissionMask.Move;
1944
1945 // Make sure we don't lock it
1946 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
1947
1904 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1948 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1905 { 1949 {
1906 item.BasePermissions = grp.RootPart.NextOwnerMask; 1950 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1907 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 1951 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1908 item.NextPermissions = grp.RootPart.NextOwnerMask; 1952 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1909 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 1953 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1910 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 1954 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1911 } 1955 }
1912 else 1956 else
1913 { 1957 {
1914 item.BasePermissions = grp.RootPart.BaseMask; 1958 item.BasePermissions = permsBase;
1915 item.CurrentPermissions = grp.RootPart.OwnerMask; 1959 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1916 item.NextPermissions = grp.RootPart.NextOwnerMask; 1960 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1917 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 1961 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1918 item.GroupPermissions = grp.RootPart.GroupMask; 1962 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1919 } 1963 }
1920 item.CreationDate = Util.UnixTimeSinceEpoch(); 1964 item.CreationDate = Util.UnixTimeSinceEpoch();
1921 1965
@@ -2021,6 +2065,9 @@ namespace OpenSim.Region.Framework.Scenes
2021 2065
2022 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2066 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2023 { 2067 {
2068 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2069 return;
2070
2024 SceneObjectPart part = GetSceneObjectPart(objectID); 2071 SceneObjectPart part = GetSceneObjectPart(objectID);
2025 if (part == null) 2072 if (part == null)
2026 return; 2073 return;