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.cs249
1 files changed, 143 insertions, 106 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 2cf0ced..a1f1ea5 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;
@@ -688,6 +670,8 @@ namespace OpenSim.Region.Framework.Scenes
688 return; 670 return;
689 } 671 }
690 672
673 if (newName == null) newName = item.Name;
674
691 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 675 AssetBase asset = AssetService.Get(item.AssetID.ToString());
692 676
693 if (asset != null) 677 if (asset != null)
@@ -735,6 +719,24 @@ namespace OpenSim.Region.Framework.Scenes
735 } 719 }
736 720
737 /// <summary> 721 /// <summary>
722 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
723 /// </summary>
724 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
725 {
726 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
727 foreach (InventoryItemBase b in items)
728 {
729 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
730 InventoryItemBase n = InventoryService.GetItem(b);
731 n.Folder = destfolder;
732 moveitems.Add(n);
733 remoteClient.SendInventoryItemCreateUpdate(n, 0);
734 }
735
736 MoveInventoryItem(remoteClient, moveitems);
737 }
738
739 /// <summary>
738 /// Move an item within the agent's inventory. 740 /// Move an item within the agent's inventory.
739 /// </summary> 741 /// </summary>
740 /// <param name="remoteClient"></param> 742 /// <param name="remoteClient"></param>
@@ -978,8 +980,12 @@ namespace OpenSim.Region.Framework.Scenes
978 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) 980 public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
979 { 981 {
980 SceneObjectPart part = GetSceneObjectPart(localID); 982 SceneObjectPart part = GetSceneObjectPart(localID);
981 SceneObjectGroup group = part.ParentGroup; 983 SceneObjectGroup group = null;
982 if (group != null) 984 if (part != null)
985 {
986 group = part.ParentGroup;
987 }
988 if (part != null && group != null)
983 { 989 {
984 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 990 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
985 return; 991 return;
@@ -1428,13 +1434,6 @@ namespace OpenSim.Region.Framework.Scenes
1428 { 1434 {
1429 agentTransactions.HandleTaskItemUpdateFromTransaction( 1435 agentTransactions.HandleTaskItemUpdateFromTransaction(
1430 remoteClient, part, transactionID, currentItem); 1436 remoteClient, part, transactionID, currentItem);
1431
1432 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1433 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1434 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1435 remoteClient.SendAgentAlertMessage("Script saved", false);
1436 else
1437 remoteClient.SendAgentAlertMessage("Item saved", false);
1438 } 1437 }
1439 1438
1440 // Base ALWAYS has move 1439 // Base ALWAYS has move
@@ -1552,7 +1551,7 @@ namespace OpenSim.Region.Framework.Scenes
1552 return; 1551 return;
1553 1552
1554 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1553 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1555 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1554 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1556 remoteClient.AgentId); 1555 remoteClient.AgentId);
1557 AssetService.Store(asset); 1556 AssetService.Store(asset);
1558 1557
@@ -1705,23 +1704,32 @@ namespace OpenSim.Region.Framework.Scenes
1705 // build a list of eligible objects 1704 // build a list of eligible objects
1706 List<uint> deleteIDs = new List<uint>(); 1705 List<uint> deleteIDs = new List<uint>();
1707 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1706 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1708 1707 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1709 // Start with true for both, then remove the flags if objects
1710 // that we can't derez are part of the selection
1711 bool permissionToTake = true;
1712 bool permissionToTakeCopy = true;
1713 bool permissionToDelete = true;
1714 1708
1715 foreach (uint localID in localIDs) 1709 foreach (uint localID in localIDs)
1716 { 1710 {
1711 // Start with true for both, then remove the flags if objects
1712 // that we can't derez are part of the selection
1713 bool permissionToTake = true;
1714 bool permissionToTakeCopy = true;
1715 bool permissionToDelete = true;
1716
1717 // Invalid id 1717 // Invalid id
1718 SceneObjectPart part = GetSceneObjectPart(localID); 1718 SceneObjectPart part = GetSceneObjectPart(localID);
1719 if (part == null) 1719 if (part == null)
1720 {
1721 //Client still thinks the object exists, kill it
1722 deleteIDs.Add(localID);
1720 continue; 1723 continue;
1724 }
1721 1725
1722 // Already deleted by someone else 1726 // Already deleted by someone else
1723 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1727 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1728 {
1729 //Client still thinks the object exists, kill it
1730 deleteIDs.Add(localID);
1724 continue; 1731 continue;
1732 }
1725 1733
1726 // Can't delete child prims 1734 // Can't delete child prims
1727 if (part != part.ParentGroup.RootPart) 1735 if (part != part.ParentGroup.RootPart)
@@ -1729,9 +1737,6 @@ namespace OpenSim.Region.Framework.Scenes
1729 1737
1730 SceneObjectGroup grp = part.ParentGroup; 1738 SceneObjectGroup grp = part.ParentGroup;
1731 1739
1732 deleteIDs.Add(localID);
1733 deleteGroups.Add(grp);
1734
1735 if (remoteClient == null) 1740 if (remoteClient == null)
1736 { 1741 {
1737 // Autoreturn has a null client. Nothing else does. So 1742 // Autoreturn has a null client. Nothing else does. So
@@ -1748,80 +1753,104 @@ namespace OpenSim.Region.Framework.Scenes
1748 } 1753 }
1749 else 1754 else
1750 { 1755 {
1751 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1756 if (action == DeRezAction.TakeCopy)
1757 {
1758 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1759 permissionToTakeCopy = false;
1760 }
1761 else
1762 {
1752 permissionToTakeCopy = false; 1763 permissionToTakeCopy = false;
1753 1764 }
1754 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1765 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1755 permissionToTake = false; 1766 permissionToTake = false;
1756 1767
1757 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1768 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1758 permissionToDelete = false; 1769 permissionToDelete = false;
1759 } 1770 }
1760 }
1761 1771
1762 // Handle god perms 1772 // Handle god perms
1763 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1773 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1764 { 1774 {
1765 permissionToTake = true; 1775 permissionToTake = true;
1766 permissionToTakeCopy = true; 1776 permissionToTakeCopy = true;
1767 permissionToDelete = true; 1777 permissionToDelete = true;
1768 } 1778 }
1769 1779
1770 // If we're re-saving, we don't even want to delete 1780 // If we're re-saving, we don't even want to delete
1771 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1781 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1772 permissionToDelete = false; 1782 permissionToDelete = false;
1773 1783
1774 // if we want to take a copy, we also don't want to delete 1784 // if we want to take a copy, we also don't want to delete
1775 // Note: after this point, the permissionToTakeCopy flag 1785 // Note: after this point, the permissionToTakeCopy flag
1776 // becomes irrelevant. It already includes the permissionToTake 1786 // becomes irrelevant. It already includes the permissionToTake
1777 // permission and after excluding no copy items here, we can 1787 // permission and after excluding no copy items here, we can
1778 // just use that. 1788 // just use that.
1779 if (action == DeRezAction.TakeCopy) 1789 if (action == DeRezAction.TakeCopy)
1780 { 1790 {
1781 // If we don't have permission, stop right here 1791 // If we don't have permission, stop right here
1782 if (!permissionToTakeCopy) 1792 if (!permissionToTakeCopy)
1783 return; 1793 return;
1784 1794
1785 permissionToTake = true; 1795 permissionToTake = true;
1786 // Don't delete 1796 // Don't delete
1787 permissionToDelete = false; 1797 permissionToDelete = false;
1788 } 1798 }
1789 1799
1790 if (action == DeRezAction.Return) 1800 if (action == DeRezAction.Return)
1791 {
1792 if (remoteClient != null)
1793 { 1801 {
1794 if (Permissions.CanReturnObjects( 1802 if (remoteClient != null)
1795 null,
1796 remoteClient.AgentId,
1797 deleteGroups))
1798 { 1803 {
1799 permissionToTake = true; 1804 if (Permissions.CanReturnObjects(
1800 permissionToDelete = true; 1805 null,
1801 1806 remoteClient.AgentId,
1802 foreach (SceneObjectGroup g in deleteGroups) 1807 deleteGroups))
1803 { 1808 {
1804 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1809 permissionToTake = true;
1810 permissionToDelete = true;
1811
1812 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1805 } 1813 }
1806 } 1814 }
1815 else // Auto return passes through here with null agent
1816 {
1817 permissionToTake = true;
1818 permissionToDelete = true;
1819 }
1807 } 1820 }
1808 else // Auto return passes through here with null agent 1821
1822 if (permissionToTake && (!permissionToDelete))
1823 takeGroups.Add(grp);
1824
1825 if (permissionToDelete)
1809 { 1826 {
1810 permissionToTake = true; 1827 if (permissionToTake)
1811 permissionToDelete = true; 1828 deleteGroups.Add(grp);
1829 deleteIDs.Add(grp.LocalId);
1812 } 1830 }
1813 } 1831 }
1814 1832
1815 if (permissionToTake) 1833 SendKillObject(deleteIDs);
1834
1835 if (deleteGroups.Count > 0)
1816 { 1836 {
1837 foreach (SceneObjectGroup g in deleteGroups)
1838 deleteIDs.Remove(g.LocalId);
1839
1817 m_asyncSceneObjectDeleter.DeleteToInventory( 1840 m_asyncSceneObjectDeleter.DeleteToInventory(
1818 action, destinationID, deleteGroups, remoteClient, 1841 action, destinationID, deleteGroups, remoteClient,
1819 permissionToDelete); 1842 true);
1820 } 1843 }
1821 else if (permissionToDelete) 1844 if (takeGroups.Count > 0)
1845 {
1846 m_asyncSceneObjectDeleter.DeleteToInventory(
1847 action, destinationID, takeGroups, remoteClient,
1848 false);
1849 }
1850 if (deleteIDs.Count > 0)
1822 { 1851 {
1823 foreach (SceneObjectGroup g in deleteGroups) 1852 foreach (SceneObjectGroup g in deleteGroups)
1824 DeleteSceneObject(g, false); 1853 DeleteSceneObject(g, true);
1825 } 1854 }
1826 } 1855 }
1827 1856
@@ -1873,21 +1902,29 @@ namespace OpenSim.Region.Framework.Scenes
1873 else // oopsies 1902 else // oopsies
1874 item.Folder = UUID.Zero; 1903 item.Folder = UUID.Zero;
1875 1904
1905 // Set up base perms properly
1906 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
1907 permsBase &= grp.RootPart.BaseMask;
1908 permsBase |= (uint)PermissionMask.Move;
1909
1910 // Make sure we don't lock it
1911 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
1912
1876 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1913 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1877 { 1914 {
1878 item.BasePermissions = grp.RootPart.NextOwnerMask; 1915 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
1879 item.CurrentPermissions = grp.RootPart.NextOwnerMask; 1916 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
1880 item.NextPermissions = grp.RootPart.NextOwnerMask; 1917 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1881 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; 1918 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1882 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; 1919 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1883 } 1920 }
1884 else 1921 else
1885 { 1922 {
1886 item.BasePermissions = grp.RootPart.BaseMask; 1923 item.BasePermissions = permsBase;
1887 item.CurrentPermissions = grp.RootPart.OwnerMask; 1924 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
1888 item.NextPermissions = grp.RootPart.NextOwnerMask; 1925 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
1889 item.EveryOnePermissions = grp.RootPart.EveryoneMask; 1926 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
1890 item.GroupPermissions = grp.RootPart.GroupMask; 1927 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
1891 } 1928 }
1892 item.CreationDate = Util.UnixTimeSinceEpoch(); 1929 item.CreationDate = Util.UnixTimeSinceEpoch();
1893 1930