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.cs320
1 files changed, 239 insertions, 81 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b59fd05..e1281a6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Region.Framework.Scenes
156 return false; 156 return false;
157 } 157 }
158 } 158 }
159 159
160 if (InventoryService.AddItem(item)) 160 if (InventoryService.AddItem(item))
161 { 161 {
162 int userlevel = 0; 162 int userlevel = 0;
@@ -311,8 +311,7 @@ namespace OpenSim.Region.Framework.Scenes
311 311
312 // Update item with new asset 312 // Update item with new asset
313 item.AssetID = asset.FullID; 313 item.AssetID = asset.FullID;
314 if (group.UpdateInventoryItem(item)) 314 group.UpdateInventoryItem(item);
315 remoteClient.SendAgentAlertMessage("Script saved", false);
316 315
317 part.SendPropertiesToClient(remoteClient); 316 part.SendPropertiesToClient(remoteClient);
318 317
@@ -323,12 +322,7 @@ namespace OpenSim.Region.Framework.Scenes
323 { 322 {
324 // Needs to determine which engine was running it and use that 323 // Needs to determine which engine was running it and use that
325 // 324 //
326 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 325 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
327 errors = part.Inventory.GetScriptErrors(item.ItemID);
328 }
329 else
330 {
331 remoteClient.SendAgentAlertMessage("Script saved", false);
332 } 326 }
333 327
334 // Tell anyone managing scripts that a script has been reloaded/changed 328 // Tell anyone managing scripts that a script has been reloaded/changed
@@ -396,6 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
396 390
397 if (UUID.Zero == transactionID) 391 if (UUID.Zero == transactionID)
398 { 392 {
393 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
399 item.Name = itemUpd.Name; 394 item.Name = itemUpd.Name;
400 item.Description = itemUpd.Description; 395 item.Description = itemUpd.Description;
401 396
@@ -782,6 +777,8 @@ namespace OpenSim.Region.Framework.Scenes
782 return; 777 return;
783 } 778 }
784 779
780 if (newName == null) newName = item.Name;
781
785 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 782 AssetBase asset = AssetService.Get(item.AssetID.ToString());
786 783
787 if (asset != null) 784 if (asset != null)
@@ -838,6 +835,24 @@ namespace OpenSim.Region.Framework.Scenes
838 } 835 }
839 836
840 /// <summary> 837 /// <summary>
838 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
839 /// </summary>
840 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
841 {
842 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
843 foreach (InventoryItemBase b in items)
844 {
845 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
846 InventoryItemBase n = InventoryService.GetItem(b);
847 n.Folder = destfolder;
848 moveitems.Add(n);
849 remoteClient.SendInventoryItemCreateUpdate(n, 0);
850 }
851
852 MoveInventoryItem(remoteClient, moveitems);
853 }
854
855 /// <summary>
841 /// Move an item within the agent's inventory. 856 /// Move an item within the agent's inventory.
842 /// </summary> 857 /// </summary>
843 /// <param name="remoteClient"></param> 858 /// <param name="remoteClient"></param>
@@ -1180,6 +1195,10 @@ namespace OpenSim.Region.Framework.Scenes
1180 { 1195 {
1181 SceneObjectPart part = GetSceneObjectPart(primLocalId); 1196 SceneObjectPart part = GetSceneObjectPart(primLocalId);
1182 1197
1198 // Can't move a null item
1199 if (itemId == UUID.Zero)
1200 return;
1201
1183 if (null == part) 1202 if (null == part)
1184 { 1203 {
1185 m_log.WarnFormat( 1204 m_log.WarnFormat(
@@ -1284,21 +1303,28 @@ namespace OpenSim.Region.Framework.Scenes
1284 return; 1303 return;
1285 } 1304 }
1286 1305
1287 if (part.OwnerID != destPart.OwnerID) 1306 // Can't transfer this
1307 //
1308 if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
1309 return;
1310
1311 bool overrideNoMod = false;
1312 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1313 overrideNoMod = true;
1314
1315 if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1288 { 1316 {
1289 // Source must have transfer permissions 1317 // object cannot copy items to an object owned by a different owner
1290 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) 1318 // unless llAllowInventoryDrop has been called
1291 return;
1292 1319
1293 // Object cannot copy items to an object owned by a different owner 1320 return;
1294 // unless llAllowInventoryDrop has been called on the destination
1295 if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1296 return;
1297 } 1321 }
1298 1322
1299 // must have both move and modify permission to put an item in an object 1323 // must have both move and modify permission to put an item in an object
1300 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1324 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1325 {
1301 return; 1326 return;
1327 }
1302 1328
1303 TaskInventoryItem destTaskItem = new TaskInventoryItem(); 1329 TaskInventoryItem destTaskItem = new TaskInventoryItem();
1304 1330
@@ -1354,6 +1380,14 @@ namespace OpenSim.Region.Framework.Scenes
1354 1380
1355 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1381 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1356 { 1382 {
1383 SceneObjectPart destPart = GetSceneObjectPart(destID);
1384 if (destPart != null) // Move into a prim
1385 {
1386 foreach(UUID itemID in items)
1387 MoveTaskInventoryItem(destID, host, itemID);
1388 return destID; // Prim folder ID == prim ID
1389 }
1390
1357 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1391 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1358 1392
1359 UUID newFolderID = UUID.Random(); 1393 UUID newFolderID = UUID.Random();
@@ -1536,12 +1570,12 @@ namespace OpenSim.Region.Framework.Scenes
1536 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( 1570 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1537 remoteClient, part, transactionID, currentItem); 1571 remoteClient, part, transactionID, currentItem);
1538 1572
1539 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1573// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1540 remoteClient.SendAgentAlertMessage("Notecard saved", false); 1574// remoteClient.SendAgentAlertMessage("Notecard saved", false);
1541 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) 1575// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1542 remoteClient.SendAgentAlertMessage("Script saved", false); 1576// remoteClient.SendAgentAlertMessage("Script saved", false);
1543 else 1577// else
1544 remoteClient.SendAgentAlertMessage("Item saved", false); 1578// remoteClient.SendAgentAlertMessage("Item saved", false);
1545 } 1579 }
1546 1580
1547 // Base ALWAYS has move 1581 // Base ALWAYS has move
@@ -1724,7 +1758,7 @@ namespace OpenSim.Region.Framework.Scenes
1724 } 1758 }
1725 1759
1726 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1760 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1727 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1761 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1728 agentID); 1762 agentID);
1729 AssetService.Store(asset); 1763 AssetService.Store(asset);
1730 1764
@@ -1880,23 +1914,32 @@ namespace OpenSim.Region.Framework.Scenes
1880 // build a list of eligible objects 1914 // build a list of eligible objects
1881 List<uint> deleteIDs = new List<uint>(); 1915 List<uint> deleteIDs = new List<uint>();
1882 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1916 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1883 1917 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1884 // Start with true for both, then remove the flags if objects
1885 // that we can't derez are part of the selection
1886 bool permissionToTake = true;
1887 bool permissionToTakeCopy = true;
1888 bool permissionToDelete = true;
1889 1918
1890 foreach (uint localID in localIDs) 1919 foreach (uint localID in localIDs)
1891 { 1920 {
1921 // Start with true for both, then remove the flags if objects
1922 // that we can't derez are part of the selection
1923 bool permissionToTake = true;
1924 bool permissionToTakeCopy = true;
1925 bool permissionToDelete = true;
1926
1892 // Invalid id 1927 // Invalid id
1893 SceneObjectPart part = GetSceneObjectPart(localID); 1928 SceneObjectPart part = GetSceneObjectPart(localID);
1894 if (part == null) 1929 if (part == null)
1930 {
1931 //Client still thinks the object exists, kill it
1932 deleteIDs.Add(localID);
1895 continue; 1933 continue;
1934 }
1896 1935
1897 // Already deleted by someone else 1936 // Already deleted by someone else
1898 if (part.ParentGroup.IsDeleted) 1937 if (part.ParentGroup.IsDeleted)
1938 {
1939 //Client still thinks the object exists, kill it
1940 deleteIDs.Add(localID);
1899 continue; 1941 continue;
1942 }
1900 1943
1901 // Can't delete child prims 1944 // Can't delete child prims
1902 if (part != part.ParentGroup.RootPart) 1945 if (part != part.ParentGroup.RootPart)
@@ -1904,9 +1947,6 @@ namespace OpenSim.Region.Framework.Scenes
1904 1947
1905 SceneObjectGroup grp = part.ParentGroup; 1948 SceneObjectGroup grp = part.ParentGroup;
1906 1949
1907 deleteIDs.Add(localID);
1908 deleteGroups.Add(grp);
1909
1910 if (remoteClient == null) 1950 if (remoteClient == null)
1911 { 1951 {
1912 // Autoreturn has a null client. Nothing else does. So 1952 // Autoreturn has a null client. Nothing else does. So
@@ -1923,81 +1963,193 @@ namespace OpenSim.Region.Framework.Scenes
1923 } 1963 }
1924 else 1964 else
1925 { 1965 {
1926 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 1966 if (action == DeRezAction.TakeCopy)
1967 {
1968 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1969 permissionToTakeCopy = false;
1970 }
1971 else
1972 {
1927 permissionToTakeCopy = false; 1973 permissionToTakeCopy = false;
1928 1974 }
1929 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 1975 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1930 permissionToTake = false; 1976 permissionToTake = false;
1931 1977
1932 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 1978 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1933 permissionToDelete = false; 1979 permissionToDelete = false;
1934 } 1980 }
1935 }
1936 1981
1937 // Handle god perms 1982 // Handle god perms
1938 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 1983 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1939 { 1984 {
1940 permissionToTake = true; 1985 permissionToTake = true;
1941 permissionToTakeCopy = true; 1986 permissionToTakeCopy = true;
1942 permissionToDelete = true; 1987 permissionToDelete = true;
1943 } 1988 }
1944 1989
1945 // If we're re-saving, we don't even want to delete 1990 // If we're re-saving, we don't even want to delete
1946 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1991 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1947 permissionToDelete = false; 1992 permissionToDelete = false;
1948 1993
1949 // if we want to take a copy, we also don't want to delete 1994 // if we want to take a copy, we also don't want to delete
1950 // Note: after this point, the permissionToTakeCopy flag 1995 // Note: after this point, the permissionToTakeCopy flag
1951 // becomes irrelevant. It already includes the permissionToTake 1996 // becomes irrelevant. It already includes the permissionToTake
1952 // permission and after excluding no copy items here, we can 1997 // permission and after excluding no copy items here, we can
1953 // just use that. 1998 // just use that.
1954 if (action == DeRezAction.TakeCopy) 1999 if (action == DeRezAction.TakeCopy)
1955 { 2000 {
1956 // If we don't have permission, stop right here 2001 // If we don't have permission, stop right here
1957 if (!permissionToTakeCopy) 2002 if (!permissionToTakeCopy)
1958 return; 2003 return;
1959 2004
1960 permissionToTake = true; 2005 permissionToTake = true;
1961 // Don't delete 2006 // Don't delete
1962 permissionToDelete = false; 2007 permissionToDelete = false;
1963 } 2008 }
1964 2009
1965 if (action == DeRezAction.Return) 2010 if (action == DeRezAction.Return)
1966 {
1967 if (remoteClient != null)
1968 { 2011 {
1969 if (Permissions.CanReturnObjects( 2012 if (remoteClient != null)
1970 null,
1971 remoteClient.AgentId,
1972 deleteGroups))
1973 { 2013 {
1974 permissionToTake = true; 2014 if (Permissions.CanReturnObjects(
1975 permissionToDelete = true; 2015 null,
1976 2016 remoteClient.AgentId,
1977 foreach (SceneObjectGroup g in deleteGroups) 2017 deleteGroups))
1978 { 2018 {
1979 AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 2019 permissionToTake = true;
2020 permissionToDelete = true;
2021
2022 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
1980 } 2023 }
1981 } 2024 }
2025 else // Auto return passes through here with null agent
2026 {
2027 permissionToTake = true;
2028 permissionToDelete = true;
2029 }
1982 } 2030 }
1983 else // Auto return passes through here with null agent 2031
2032 if (permissionToTake && (!permissionToDelete))
2033 takeGroups.Add(grp);
2034
2035 if (permissionToDelete)
1984 { 2036 {
1985 permissionToTake = true; 2037 if (permissionToTake)
1986 permissionToDelete = true; 2038 deleteGroups.Add(grp);
2039 deleteIDs.Add(grp.LocalId);
1987 } 2040 }
1988 } 2041 }
1989 2042
1990 if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) 2043 SendKillObject(deleteIDs);
2044
2045 if (deleteGroups.Count > 0)
1991 { 2046 {
2047 foreach (SceneObjectGroup g in deleteGroups)
2048 deleteIDs.Remove(g.LocalId);
2049
1992 m_asyncSceneObjectDeleter.DeleteToInventory( 2050 m_asyncSceneObjectDeleter.DeleteToInventory(
1993 action, destinationID, deleteGroups, remoteClient, 2051 action, destinationID, deleteGroups, remoteClient,
1994 permissionToDelete); 2052 true);
1995 } 2053 }
1996 else if (permissionToDelete) 2054 if (takeGroups.Count > 0)
2055 {
2056 m_asyncSceneObjectDeleter.DeleteToInventory(
2057 action, destinationID, takeGroups, remoteClient,
2058 false);
2059 }
2060 if (deleteIDs.Count > 0)
1997 { 2061 {
1998 foreach (SceneObjectGroup g in deleteGroups) 2062 foreach (SceneObjectGroup g in deleteGroups)
1999 DeleteSceneObject(g, false); 2063 DeleteSceneObject(g, true);
2064 }
2065 }
2066
2067 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
2068 {
2069 itemID = UUID.Zero;
2070 if (grp != null)
2071 {
2072 Vector3 inventoryStoredPosition = new Vector3
2073 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
2074 ? 250
2075 : grp.AbsolutePosition.X)
2076 ,
2077 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
2078 ? 250
2079 : grp.AbsolutePosition.X,
2080 grp.AbsolutePosition.Z);
2081
2082 Vector3 originalPosition = grp.AbsolutePosition;
2083
2084 grp.AbsolutePosition = inventoryStoredPosition;
2085
2086 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
2087
2088 grp.AbsolutePosition = originalPosition;
2089
2090 AssetBase asset = CreateAsset(
2091 grp.GetPartName(grp.LocalId),
2092 grp.GetPartDescription(grp.LocalId),
2093 (sbyte)AssetType.Object,
2094 Utils.StringToBytes(sceneObjectXml),
2095 remoteClient.AgentId);
2096 AssetService.Store(asset);
2097
2098 InventoryItemBase item = new InventoryItemBase();
2099 item.CreatorId = grp.RootPart.CreatorID.ToString();
2100 item.CreatorData = grp.RootPart.CreatorData;
2101 item.Owner = remoteClient.AgentId;
2102 item.ID = UUID.Random();
2103 item.AssetID = asset.FullID;
2104 item.Description = asset.Description;
2105 item.Name = asset.Name;
2106 item.AssetType = asset.Type;
2107 item.InvType = (int)InventoryType.Object;
2108
2109 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
2110 if (folder != null)
2111 item.Folder = folder.ID;
2112 else // oopsies
2113 item.Folder = UUID.Zero;
2114
2115 // Set up base perms properly
2116 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2117 permsBase &= grp.RootPart.BaseMask;
2118 permsBase |= (uint)PermissionMask.Move;
2119
2120 // Make sure we don't lock it
2121 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2122
2123 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
2124 {
2125 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
2126 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
2127 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2128 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
2129 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
2130 }
2131 else
2132 {
2133 item.BasePermissions = permsBase;
2134 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
2135 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2136 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
2137 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
2138 }
2139 item.CreationDate = Util.UnixTimeSinceEpoch();
2140
2141 // sets itemID so client can show item as 'attached' in inventory
2142 grp.FromItemID = item.ID;
2143
2144 if (AddInventoryItem(item))
2145 remoteClient.SendInventoryItemCreateUpdate(item, 0);
2146 else
2147 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
2148
2149 itemID = item.ID;
2150 return item.AssetID;
2000 } 2151 }
2152 return UUID.Zero;
2001 } 2153 }
2002 2154
2003 /// <summary> 2155 /// <summary>
@@ -2126,6 +2278,9 @@ namespace OpenSim.Region.Framework.Scenes
2126 2278
2127 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2279 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2128 { 2280 {
2281 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2282 return;
2283
2129 SceneObjectPart part = GetSceneObjectPart(objectID); 2284 SceneObjectPart part = GetSceneObjectPart(objectID);
2130 if (part == null) 2285 if (part == null)
2131 return; 2286 return;
@@ -2182,7 +2337,10 @@ namespace OpenSim.Region.Framework.Scenes
2182 } 2337 }
2183 else 2338 else
2184 { 2339 {
2185 if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) 2340 if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId)
2341 continue;
2342
2343 if (!Permissions.CanTransferObject(sog.UUID, groupID))
2186 continue; 2344 continue;
2187 2345
2188 if (sog.GroupID != groupID) 2346 if (sog.GroupID != groupID)