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 f344dcc..764bd2f 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
@@ -1663,7 +1675,7 @@ namespace OpenSim.Region.Framework.Scenes
1663 } 1675 }
1664 1676
1665 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1677 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1666 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1678 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1667 agentID); 1679 agentID);
1668 AssetService.Store(asset); 1680 AssetService.Store(asset);
1669 1681
@@ -1815,23 +1827,32 @@ namespace OpenSim.Region.Framework.Scenes
1815 // build a list of eligible objects 1827 // build a list of eligible objects
1816 List<uint> deleteIDs = new List<uint>(); 1828 List<uint> deleteIDs = new List<uint>();
1817 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1829 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1818 1830 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1819 // Start with true for both, then remove the flags if objects
1820 // that we can't derez are part of the selection
1821 bool permissionToTake = true;
1822 bool permissionToTakeCopy = true;
1823 bool permissionToDelete = true;
1824 1831
1825 foreach (uint localID in localIDs) 1832 foreach (uint localID in localIDs)
1826 { 1833 {
1834 // Start with true for both, then remove the flags if objects
1835 // that we can't derez are part of the selection
1836 bool permissionToTake = true;
1837 bool permissionToTakeCopy = true;
1838 bool permissionToDelete = true;
1839
1827 // Invalid id 1840 // Invalid id
1828 SceneObjectPart part = GetSceneObjectPart(localID); 1841 SceneObjectPart part = GetSceneObjectPart(localID);
1829 if (part == null) 1842 if (part == null)
1843 {
1844 //Client still thinks the object exists, kill it
1845 deleteIDs.Add(localID);
1830 continue; 1846 continue;
1847 }
1831 1848
1832 // Already deleted by someone else 1849 // Already deleted by someone else
1833 if (part.ParentGroup.IsDeleted) 1850 if (part.ParentGroup.IsDeleted)
1851 {
1852 //Client still thinks the object exists, kill it
1853 deleteIDs.Add(localID);
1834 continue; 1854 continue;
1855 }
1835 1856
1836 // Can't delete child prims 1857 // Can't delete child prims
1837 if (part != part.ParentGroup.RootPart) 1858 if (part != part.ParentGroup.RootPart)
@@ -1839,9 +1860,6 @@ namespace OpenSim.Region.Framework.Scenes
1839 1860
1840 SceneObjectGroup grp = part.ParentGroup; 1861 SceneObjectGroup grp = part.ParentGroup;
1841 1862
1842 deleteIDs.Add(localID);
1843 deleteGroups.Add(grp);
1844
1845 if (remoteClient == null) 1863 if (remoteClient == null)
1846 { 1864 {
1847 // Autoreturn has a null client. Nothing else does. So 1865 // Autoreturn has a null client. Nothing else does. So
@@ -1858,83 +1876,195 @@ namespace OpenSim.Region.Framework.Scenes
1858 } 1876 }
1859 else 1877 else
1860 { 1878 {
1861 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1879 if (action == DeRezAction.TakeCopy)
1880 {
1881 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1882 permissionToTakeCopy = false;
1883 }
1884 else
1885 {
1862 permissionToTakeCopy = false; 1886 permissionToTakeCopy = false;
1863 1887 }
1864 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1888 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1865 permissionToTake = false; 1889 permissionToTake = false;
1866 1890
1867 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1891 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1868 permissionToDelete = false; 1892 permissionToDelete = false;
1869 } 1893 }
1870 }
1871 1894
1872 // Handle god perms 1895 // Handle god perms
1873 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1896 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1874 { 1897 {
1875 permissionToTake = true; 1898 permissionToTake = true;
1876 permissionToTakeCopy = true; 1899 permissionToTakeCopy = true;
1877 permissionToDelete = true; 1900 permissionToDelete = true;
1878 } 1901 }
1879 1902
1880 // If we're re-saving, we don't even want to delete 1903 // If we're re-saving, we don't even want to delete
1881 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1904 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1882 permissionToDelete = false; 1905 permissionToDelete = false;
1883 1906
1884 // if we want to take a copy, we also don't want to delete 1907 // if we want to take a copy, we also don't want to delete
1885 // Note: after this point, the permissionToTakeCopy flag 1908 // Note: after this point, the permissionToTakeCopy flag
1886 // becomes irrelevant. It already includes the permissionToTake 1909 // becomes irrelevant. It already includes the permissionToTake
1887 // permission and after excluding no copy items here, we can 1910 // permission and after excluding no copy items here, we can
1888 // just use that. 1911 // just use that.
1889 if (action == DeRezAction.TakeCopy) 1912 if (action == DeRezAction.TakeCopy)
1890 { 1913 {
1891 // If we don't have permission, stop right here 1914 // If we don't have permission, stop right here
1892 if (!permissionToTakeCopy) 1915 if (!permissionToTakeCopy)
1893 return; 1916 return;
1894 1917
1895 permissionToTake = true; 1918 permissionToTake = true;
1896 // Don't delete 1919 // Don't delete
1897 permissionToDelete = false; 1920 permissionToDelete = false;
1898 } 1921 }
1899 1922
1900 if (action == DeRezAction.Return) 1923 if (action == DeRezAction.Return)
1901 {
1902 if (remoteClient != null)
1903 { 1924 {
1904 if (Permissions.CanReturnObjects( 1925 if (remoteClient != null)
1905 null,
1906 remoteClient.AgentId,
1907 deleteGroups))
1908 { 1926 {
1909 permissionToTake = true; 1927 if (Permissions.CanReturnObjects(
1910 permissionToDelete = true; 1928 null,
1911 1929 remoteClient.AgentId,
1912 foreach (SceneObjectGroup g in deleteGroups) 1930 deleteGroups))
1913 { 1931 {
1914 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 1932 permissionToTake = true;
1933 permissionToDelete = true;
1934
1935 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1915 } 1936 }
1916 } 1937 }
1938 else // Auto return passes through here with null agent
1939 {
1940 permissionToTake = true;
1941 permissionToDelete = true;
1942 }
1917 } 1943 }
1918 else // Auto return passes through here with null agent 1944
1945 if (permissionToTake && (!permissionToDelete))
1946 takeGroups.Add(grp);
1947
1948 if (permissionToDelete)
1919 { 1949 {
1920 permissionToTake = true; 1950 if (permissionToTake)
1921 permissionToDelete = true; 1951 deleteGroups.Add(grp);
1952 deleteIDs.Add(grp.LocalId);
1922 } 1953 }
1923 } 1954 }
1924 1955
1925 if (permissionToTake) 1956 SendKillObject(deleteIDs);
1957
1958 if (deleteGroups.Count > 0)
1926 { 1959 {
1960 foreach (SceneObjectGroup g in deleteGroups)
1961 deleteIDs.Remove(g.LocalId);
1962
1927 m_asyncSceneObjectDeleter.DeleteToInventory( 1963 m_asyncSceneObjectDeleter.DeleteToInventory(
1928 action, destinationID, deleteGroups, remoteClient, 1964 action, destinationID, deleteGroups, remoteClient,
1929 permissionToDelete); 1965 true);
1966 }
1967 if (takeGroups.Count > 0)
1968 {
1969 m_asyncSceneObjectDeleter.DeleteToInventory(
1970 action, destinationID, takeGroups, remoteClient,
1971 false);
1930 } 1972 }
1931 else if (permissionToDelete) 1973 if (deleteIDs.Count > 0)
1932 { 1974 {
1933 foreach (SceneObjectGroup g in deleteGroups) 1975 foreach (SceneObjectGroup g in deleteGroups)
1934 DeleteSceneObject(g, false); 1976 DeleteSceneObject(g, true);
1935 } 1977 }
1936 } 1978 }
1937 1979
1980 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
1981 {
1982 itemID = UUID.Zero;
1983 if (grp != null)
1984 {
1985 Vector3 inventoryStoredPosition = new Vector3
1986 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
1987 ? 250
1988 : grp.AbsolutePosition.X)
1989 ,
1990 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
1991 ? 250
1992 : grp.AbsolutePosition.X,
1993 grp.AbsolutePosition.Z);
1994
1995 Vector3 originalPosition = grp.AbsolutePosition;
1996
1997 grp.AbsolutePosition = inventoryStoredPosition;
1998
1999 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
2000
2001 grp.AbsolutePosition = originalPosition;
2002
2003 AssetBase asset = CreateAsset(
2004 grp.GetPartName(grp.LocalId),
2005 grp.GetPartDescription(grp.LocalId),
2006 (sbyte)AssetType.Object,
2007 Utils.StringToBytes(sceneObjectXml),
2008 remoteClient.AgentId);
2009 AssetService.Store(asset);
2010
2011 InventoryItemBase item = new InventoryItemBase();
2012 item.CreatorId = grp.RootPart.CreatorID.ToString();
2013 item.CreatorData = grp.RootPart.CreatorData;
2014 item.Owner = remoteClient.AgentId;
2015 item.ID = UUID.Random();
2016 item.AssetID = asset.FullID;
2017 item.Description = asset.Description;
2018 item.Name = asset.Name;
2019 item.AssetType = asset.Type;
2020 item.InvType = (int)InventoryType.Object;
2021
2022 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
2023 if (folder != null)
2024 item.Folder = folder.ID;
2025 else // oopsies
2026 item.Folder = UUID.Zero;
2027
2028 // Set up base perms properly
2029 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2030 permsBase &= grp.RootPart.BaseMask;
2031 permsBase |= (uint)PermissionMask.Move;
2032
2033 // Make sure we don't lock it
2034 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2035
2036 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
2037 {
2038 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
2039 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
2040 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2041 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
2042 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
2043 }
2044 else
2045 {
2046 item.BasePermissions = permsBase;
2047 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
2048 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2049 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
2050 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
2051 }
2052 item.CreationDate = Util.UnixTimeSinceEpoch();
2053
2054 // sets itemID so client can show item as 'attached' in inventory
2055 grp.SetFromItemID(item.ID);
2056
2057 if (AddInventoryItem(item))
2058 remoteClient.SendInventoryItemCreateUpdate(item, 0);
2059 else
2060 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
2061
2062 itemID = item.ID;
2063 return item.AssetID;
2064 }
2065 return UUID.Zero;
2066 }
2067
1938 /// <summary> 2068 /// <summary>
1939 /// Event Handler Rez an object into a scene 2069 /// Event Handler Rez an object into a scene
1940 /// Calls the non-void event handler 2070 /// Calls the non-void event handler
@@ -2061,6 +2191,9 @@ namespace OpenSim.Region.Framework.Scenes
2061 2191
2062 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2192 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2063 { 2193 {
2194 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2195 return;
2196
2064 SceneObjectPart part = GetSceneObjectPart(objectID); 2197 SceneObjectPart part = GetSceneObjectPart(objectID);
2065 if (part == null) 2198 if (part == null)
2066 return; 2199 return;