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.cs323
1 files changed, 228 insertions, 95 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9293aeb..31d9ce59 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -117,34 +117,22 @@ namespace OpenSim.Region.Framework.Scenes
117 /// <param name="item"></param> 117 /// <param name="item"></param>
118 public bool AddInventoryItem(InventoryItemBase item) 118 public bool AddInventoryItem(InventoryItemBase item)
119 { 119 {
120 if (UUID.Zero == item.Folder) 120 InventoryFolderBase folder;
121
122 if (item.Folder == UUID.Zero)
121 { 123 {
122 InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); 124 folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType);
123 if (f != null) 125 if (folder == null)
124 { 126 {
125// m_log.DebugFormat( 127 folder = InventoryService.GetRootFolder(item.Owner);
126// "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", 128
127// f.Name, (AssetType)f.Type, item.Name); 129 if (folder == null)
128
129 item.Folder = f.ID;
130 }
131 else
132 {
133 f = InventoryService.GetRootFolder(item.Owner);
134 if (f != null)
135 {
136 item.Folder = f.ID;
137 }
138 else
139 {
140 m_log.WarnFormat(
141 "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified",
142 item.Owner, item.Name);
143 return false; 130 return false;
144 }
145 } 131 }
132
133 item.Folder = folder.ID;
146 } 134 }
147 135
148 if (InventoryService.AddItem(item)) 136 if (InventoryService.AddItem(item))
149 { 137 {
150 int userlevel = 0; 138 int userlevel = 0;
@@ -264,8 +252,7 @@ namespace OpenSim.Region.Framework.Scenes
264 252
265 // Update item with new asset 253 // Update item with new asset
266 item.AssetID = asset.FullID; 254 item.AssetID = asset.FullID;
267 if (group.UpdateInventoryItem(item)) 255 group.UpdateInventoryItem(item);
268 remoteClient.SendAgentAlertMessage("Script saved", false);
269 256
270 part.SendPropertiesToClient(remoteClient); 257 part.SendPropertiesToClient(remoteClient);
271 258
@@ -276,12 +263,7 @@ namespace OpenSim.Region.Framework.Scenes
276 { 263 {
277 // Needs to determine which engine was running it and use that 264 // Needs to determine which engine was running it and use that
278 // 265 //
279 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 266 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
280 errors = part.Inventory.GetScriptErrors(item.ItemID);
281 }
282 else
283 {
284 remoteClient.SendAgentAlertMessage("Script saved", false);
285 } 267 }
286 part.ParentGroup.ResumeScripts(); 268 part.ParentGroup.ResumeScripts();
287 return errors; 269 return errors;
@@ -345,6 +327,7 @@ namespace OpenSim.Region.Framework.Scenes
345 327
346 if (UUID.Zero == transactionID) 328 if (UUID.Zero == transactionID)
347 { 329 {
330 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
348 item.Name = itemUpd.Name; 331 item.Name = itemUpd.Name;
349 item.Description = itemUpd.Description; 332 item.Description = itemUpd.Description;
350 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) 333 if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
@@ -723,6 +706,8 @@ namespace OpenSim.Region.Framework.Scenes
723 return; 706 return;
724 } 707 }
725 708
709 if (newName == null) newName = item.Name;
710
726 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 711 AssetBase asset = AssetService.Get(item.AssetID.ToString());
727 712
728 if (asset != null) 713 if (asset != null)
@@ -779,6 +764,24 @@ namespace OpenSim.Region.Framework.Scenes
779 } 764 }
780 765
781 /// <summary> 766 /// <summary>
767 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
768 /// </summary>
769 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
770 {
771 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
772 foreach (InventoryItemBase b in items)
773 {
774 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
775 InventoryItemBase n = InventoryService.GetItem(b);
776 n.Folder = destfolder;
777 moveitems.Add(n);
778 remoteClient.SendInventoryItemCreateUpdate(n, 0);
779 }
780
781 MoveInventoryItem(remoteClient, moveitems);
782 }
783
784 /// <summary>
782 /// Move an item within the agent's inventory. 785 /// Move an item within the agent's inventory.
783 /// </summary> 786 /// </summary>
784 /// <param name="remoteClient"></param> 787 /// <param name="remoteClient"></param>
@@ -1121,6 +1124,10 @@ namespace OpenSim.Region.Framework.Scenes
1121 { 1124 {
1122 SceneObjectPart part = GetSceneObjectPart(primLocalId); 1125 SceneObjectPart part = GetSceneObjectPart(primLocalId);
1123 1126
1127 // Can't move a null item
1128 if (itemId == UUID.Zero)
1129 return;
1130
1124 if (null == part) 1131 if (null == part)
1125 { 1132 {
1126 m_log.WarnFormat( 1133 m_log.WarnFormat(
@@ -1231,6 +1238,10 @@ namespace OpenSim.Region.Framework.Scenes
1231 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1238 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1232 return; 1239 return;
1233 1240
1241 bool overrideNoMod = false;
1242 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1243 overrideNoMod = true;
1244
1234 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1245 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1235 { 1246 {
1236 // object cannot copy items to an object owned by a different owner 1247 // object cannot copy items to an object owned by a different owner
@@ -1240,7 +1251,7 @@ namespace OpenSim.Region.Framework.Scenes
1240 } 1251 }
1241 1252
1242 // must have both move and modify permission to put an item in an object 1253 // must have both move and modify permission to put an item in an object
1243 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1254 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1244 { 1255 {
1245 return; 1256 return;
1246 } 1257 }
@@ -1299,6 +1310,14 @@ namespace OpenSim.Region.Framework.Scenes
1299 1310
1300 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1311 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1301 { 1312 {
1313 SceneObjectPart destPart = GetSceneObjectPart(destID);
1314 if (destPart != null) // Move into a prim
1315 {
1316 foreach(UUID itemID in items)
1317 MoveTaskInventoryItem(destID, host, itemID);
1318 return destID; // Prim folder ID == prim ID
1319 }
1320
1302 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1321 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1303 1322
1304 UUID newFolderID = UUID.Random(); 1323 UUID newFolderID = UUID.Random();
@@ -1478,13 +1497,6 @@ namespace OpenSim.Region.Framework.Scenes
1478 { 1497 {
1479 agentTransactions.HandleTaskItemUpdateFromTransaction( 1498 agentTransactions.HandleTaskItemUpdateFromTransaction(
1480 remoteClient, part, transactionID, currentItem); 1499 remoteClient, part, transactionID, currentItem);
1481
1482 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1483 remoteClient.SendAgentAlertMessage("Notecard saved", false);
1484 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1485 remoteClient.SendAgentAlertMessage("Script saved", false);
1486 else
1487 remoteClient.SendAgentAlertMessage("Item saved", false);
1488 } 1500 }
1489 1501
1490 // Base ALWAYS has move 1502 // Base ALWAYS has move
@@ -1652,7 +1664,7 @@ namespace OpenSim.Region.Framework.Scenes
1652 return null; 1664 return null;
1653 1665
1654 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1666 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1655 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1667 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1656 agentID); 1668 agentID);
1657 AssetService.Store(asset); 1669 AssetService.Store(asset);
1658 1670
@@ -1804,23 +1816,32 @@ namespace OpenSim.Region.Framework.Scenes
1804 // build a list of eligible objects 1816 // build a list of eligible objects
1805 List<uint> deleteIDs = new List<uint>(); 1817 List<uint> deleteIDs = new List<uint>();
1806 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1818 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1807 1819 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1808 // Start with true for both, then remove the flags if objects
1809 // that we can't derez are part of the selection
1810 bool permissionToTake = true;
1811 bool permissionToTakeCopy = true;
1812 bool permissionToDelete = true;
1813 1820
1814 foreach (uint localID in localIDs) 1821 foreach (uint localID in localIDs)
1815 { 1822 {
1823 // Start with true for both, then remove the flags if objects
1824 // that we can't derez are part of the selection
1825 bool permissionToTake = true;
1826 bool permissionToTakeCopy = true;
1827 bool permissionToDelete = true;
1828
1816 // Invalid id 1829 // Invalid id
1817 SceneObjectPart part = GetSceneObjectPart(localID); 1830 SceneObjectPart part = GetSceneObjectPart(localID);
1818 if (part == null) 1831 if (part == null)
1832 {
1833 //Client still thinks the object exists, kill it
1834 deleteIDs.Add(localID);
1819 continue; 1835 continue;
1836 }
1820 1837
1821 // Already deleted by someone else 1838 // Already deleted by someone else
1822 if (part.ParentGroup.IsDeleted) 1839 if (part.ParentGroup.IsDeleted)
1840 {
1841 //Client still thinks the object exists, kill it
1842 deleteIDs.Add(localID);
1823 continue; 1843 continue;
1844 }
1824 1845
1825 // Can't delete child prims 1846 // Can't delete child prims
1826 if (part != part.ParentGroup.RootPart) 1847 if (part != part.ParentGroup.RootPart)
@@ -1828,9 +1849,6 @@ namespace OpenSim.Region.Framework.Scenes
1828 1849
1829 SceneObjectGroup grp = part.ParentGroup; 1850 SceneObjectGroup grp = part.ParentGroup;
1830 1851
1831 deleteIDs.Add(localID);
1832 deleteGroups.Add(grp);
1833
1834 if (remoteClient == null) 1852 if (remoteClient == null)
1835 { 1853 {
1836 // Autoreturn has a null client. Nothing else does. So 1854 // Autoreturn has a null client. Nothing else does. So
@@ -1847,83 +1865,195 @@ namespace OpenSim.Region.Framework.Scenes
1847 } 1865 }
1848 else 1866 else
1849 { 1867 {
1850 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1868 if (action == DeRezAction.TakeCopy)
1869 {
1870 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1871 permissionToTakeCopy = false;
1872 }
1873 else
1874 {
1851 permissionToTakeCopy = false; 1875 permissionToTakeCopy = false;
1852 1876 }
1853 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1877 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1854 permissionToTake = false; 1878 permissionToTake = false;
1855 1879
1856 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1880 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1857 permissionToDelete = false; 1881 permissionToDelete = false;
1858 } 1882 }
1859 }
1860 1883
1861 // Handle god perms 1884 // Handle god perms
1862 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1885 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1863 { 1886 {
1864 permissionToTake = true; 1887 permissionToTake = true;
1865 permissionToTakeCopy = true; 1888 permissionToTakeCopy = true;
1866 permissionToDelete = true; 1889 permissionToDelete = true;
1867 } 1890 }
1868 1891
1869 // If we're re-saving, we don't even want to delete 1892 // If we're re-saving, we don't even want to delete
1870 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1893 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1871 permissionToDelete = false; 1894 permissionToDelete = false;
1872 1895
1873 // if we want to take a copy, we also don't want to delete 1896 // if we want to take a copy, we also don't want to delete
1874 // Note: after this point, the permissionToTakeCopy flag 1897 // Note: after this point, the permissionToTakeCopy flag
1875 // becomes irrelevant. It already includes the permissionToTake 1898 // becomes irrelevant. It already includes the permissionToTake
1876 // permission and after excluding no copy items here, we can 1899 // permission and after excluding no copy items here, we can
1877 // just use that. 1900 // just use that.
1878 if (action == DeRezAction.TakeCopy) 1901 if (action == DeRezAction.TakeCopy)
1879 { 1902 {
1880 // If we don't have permission, stop right here 1903 // If we don't have permission, stop right here
1881 if (!permissionToTakeCopy) 1904 if (!permissionToTakeCopy)
1882 return; 1905 return;
1883 1906
1884 permissionToTake = true; 1907 permissionToTake = true;
1885 // Don't delete 1908 // Don't delete
1886 permissionToDelete = false; 1909 permissionToDelete = false;
1887 } 1910 }
1888 1911
1889 if (action == DeRezAction.Return) 1912 if (action == DeRezAction.Return)
1890 {
1891 if (remoteClient != null)
1892 { 1913 {
1893 if (Permissions.CanReturnObjects( 1914 if (remoteClient != null)
1894 null,
1895 remoteClient.AgentId,
1896 deleteGroups))
1897 { 1915 {
1898 permissionToTake = true; 1916 if (Permissions.CanReturnObjects(
1899 permissionToDelete = true; 1917 null,
1900 1918 remoteClient.AgentId,
1901 foreach (SceneObjectGroup g in deleteGroups) 1919 deleteGroups))
1902 { 1920 {
1903 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1921 permissionToTake = true;
1922 permissionToDelete = true;
1923
1924 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1904 } 1925 }
1905 } 1926 }
1927 else // Auto return passes through here with null agent
1928 {
1929 permissionToTake = true;
1930 permissionToDelete = true;
1931 }
1906 } 1932 }
1907 else // Auto return passes through here with null agent 1933
1934 if (permissionToTake && (!permissionToDelete))
1935 takeGroups.Add(grp);
1936
1937 if (permissionToDelete)
1908 { 1938 {
1909 permissionToTake = true; 1939 if (permissionToTake)
1910 permissionToDelete = true; 1940 deleteGroups.Add(grp);
1941 deleteIDs.Add(grp.LocalId);
1911 } 1942 }
1912 } 1943 }
1913 1944
1914 if (permissionToTake) 1945 SendKillObject(deleteIDs);
1946
1947 if (deleteGroups.Count > 0)
1915 { 1948 {
1949 foreach (SceneObjectGroup g in deleteGroups)
1950 deleteIDs.Remove(g.LocalId);
1951
1916 m_asyncSceneObjectDeleter.DeleteToInventory( 1952 m_asyncSceneObjectDeleter.DeleteToInventory(
1917 action, destinationID, deleteGroups, remoteClient, 1953 action, destinationID, deleteGroups, remoteClient,
1918 permissionToDelete); 1954 true);
1955 }
1956 if (takeGroups.Count > 0)
1957 {
1958 m_asyncSceneObjectDeleter.DeleteToInventory(
1959 action, destinationID, takeGroups, remoteClient,
1960 false);
1919 } 1961 }
1920 else if (permissionToDelete) 1962 if (deleteIDs.Count > 0)
1921 { 1963 {
1922 foreach (SceneObjectGroup g in deleteGroups) 1964 foreach (SceneObjectGroup g in deleteGroups)
1923 DeleteSceneObject(g, false); 1965 DeleteSceneObject(g, true);
1924 } 1966 }
1925 } 1967 }
1926 1968
1969 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
1970 {
1971 itemID = UUID.Zero;
1972 if (grp != null)
1973 {
1974 Vector3 inventoryStoredPosition = new Vector3
1975 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
1976 ? 250
1977 : grp.AbsolutePosition.X)
1978 ,
1979 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
1980 ? 250
1981 : grp.AbsolutePosition.X,
1982 grp.AbsolutePosition.Z);
1983
1984 Vector3 originalPosition = grp.AbsolutePosition;
1985
1986 grp.AbsolutePosition = inventoryStoredPosition;
1987
1988 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
1989
1990 grp.AbsolutePosition = originalPosition;
1991
1992 AssetBase asset = CreateAsset(
1993 grp.GetPartName(grp.LocalId),
1994 grp.GetPartDescription(grp.LocalId),
1995 (sbyte)AssetType.Object,
1996 Utils.StringToBytes(sceneObjectXml),
1997 remoteClient.AgentId);
1998 AssetService.Store(asset);
1999
2000 InventoryItemBase item = new InventoryItemBase();
2001 item.CreatorId = grp.RootPart.CreatorID.ToString();
2002 item.CreatorData = grp.RootPart.CreatorData;
2003 item.Owner = remoteClient.AgentId;
2004 item.ID = UUID.Random();
2005 item.AssetID = asset.FullID;
2006 item.Description = asset.Description;
2007 item.Name = asset.Name;
2008 item.AssetType = asset.Type;
2009 item.InvType = (int)InventoryType.Object;
2010
2011 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
2012 if (folder != null)
2013 item.Folder = folder.ID;
2014 else // oopsies
2015 item.Folder = UUID.Zero;
2016
2017 // Set up base perms properly
2018 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2019 permsBase &= grp.RootPart.BaseMask;
2020 permsBase |= (uint)PermissionMask.Move;
2021
2022 // Make sure we don't lock it
2023 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2024
2025 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
2026 {
2027 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
2028 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
2029 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2030 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
2031 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
2032 }
2033 else
2034 {
2035 item.BasePermissions = permsBase;
2036 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
2037 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2038 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
2039 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
2040 }
2041 item.CreationDate = Util.UnixTimeSinceEpoch();
2042
2043 // sets itemID so client can show item as 'attached' in inventory
2044 grp.SetFromItemID(item.ID);
2045
2046 if (AddInventoryItem(item))
2047 remoteClient.SendInventoryItemCreateUpdate(item, 0);
2048 else
2049 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
2050
2051 itemID = item.ID;
2052 return item.AssetID;
2053 }
2054 return UUID.Zero;
2055 }
2056
1927 /// <summary> 2057 /// <summary>
1928 /// Event Handler Rez an object into a scene 2058 /// Event Handler Rez an object into a scene
1929 /// Calls the non-void event handler 2059 /// Calls the non-void event handler
@@ -2050,6 +2180,9 @@ namespace OpenSim.Region.Framework.Scenes
2050 2180
2051 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2181 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2052 { 2182 {
2183 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2184 return;
2185
2053 SceneObjectPart part = GetSceneObjectPart(objectID); 2186 SceneObjectPart part = GetSceneObjectPart(objectID);
2054 if (part == null) 2187 if (part == null)
2055 return; 2188 return;