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.cs321
1 files changed, 241 insertions, 80 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3b59dc4..863aa49 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
169 return false; 169 return false;
170 } 170 }
171 } 171 }
172 172
173 if (InventoryService.AddItem(item)) 173 if (InventoryService.AddItem(item))
174 { 174 {
175 int userlevel = 0; 175 int userlevel = 0;
@@ -324,8 +324,7 @@ namespace OpenSim.Region.Framework.Scenes
324 324
325 // Update item with new asset 325 // Update item with new asset
326 item.AssetID = asset.FullID; 326 item.AssetID = asset.FullID;
327 if (group.UpdateInventoryItem(item)) 327 group.UpdateInventoryItem(item);
328 remoteClient.SendAgentAlertMessage("Script saved", false);
329 328
330 part.SendPropertiesToClient(remoteClient); 329 part.SendPropertiesToClient(remoteClient);
331 330
@@ -336,12 +335,7 @@ namespace OpenSim.Region.Framework.Scenes
336 { 335 {
337 // Needs to determine which engine was running it and use that 336 // Needs to determine which engine was running it and use that
338 // 337 //
339 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 338 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
340 errors = part.Inventory.GetScriptErrors(item.ItemID);
341 }
342 else
343 {
344 remoteClient.SendAgentAlertMessage("Script saved", false);
345 } 339 }
346 340
347 // Tell anyone managing scripts that a script has been reloaded/changed 341 // Tell anyone managing scripts that a script has been reloaded/changed
@@ -409,6 +403,7 @@ namespace OpenSim.Region.Framework.Scenes
409 403
410 if (UUID.Zero == transactionID) 404 if (UUID.Zero == transactionID)
411 { 405 {
406 item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255);
412 item.Name = itemUpd.Name; 407 item.Name = itemUpd.Name;
413 item.Description = itemUpd.Description; 408 item.Description = itemUpd.Description;
414 409
@@ -795,6 +790,8 @@ namespace OpenSim.Region.Framework.Scenes
795 return; 790 return;
796 } 791 }
797 792
793 if (newName == null) newName = item.Name;
794
798 AssetBase asset = AssetService.Get(item.AssetID.ToString()); 795 AssetBase asset = AssetService.Get(item.AssetID.ToString());
799 796
800 if (asset != null) 797 if (asset != null)
@@ -855,6 +852,24 @@ namespace OpenSim.Region.Framework.Scenes
855 } 852 }
856 853
857 /// <summary> 854 /// <summary>
855 /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit)
856 /// </summary>
857 public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder)
858 {
859 List<InventoryItemBase> moveitems = new List<InventoryItemBase>();
860 foreach (InventoryItemBase b in items)
861 {
862 CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null);
863 InventoryItemBase n = InventoryService.GetItem(b);
864 n.Folder = destfolder;
865 moveitems.Add(n);
866 remoteClient.SendInventoryItemCreateUpdate(n, 0);
867 }
868
869 MoveInventoryItem(remoteClient, moveitems);
870 }
871
872 /// <summary>
858 /// Move an item within the agent's inventory. 873 /// Move an item within the agent's inventory.
859 /// </summary> 874 /// </summary>
860 /// <param name="remoteClient"></param> 875 /// <param name="remoteClient"></param>
@@ -1216,6 +1231,10 @@ namespace OpenSim.Region.Framework.Scenes
1216 { 1231 {
1217 SceneObjectPart part = GetSceneObjectPart(primLocalId); 1232 SceneObjectPart part = GetSceneObjectPart(primLocalId);
1218 1233
1234 // Can't move a null item
1235 if (itemId == UUID.Zero)
1236 return;
1237
1219 if (null == part) 1238 if (null == part)
1220 { 1239 {
1221 m_log.WarnFormat( 1240 m_log.WarnFormat(
@@ -1320,21 +1339,28 @@ namespace OpenSim.Region.Framework.Scenes
1320 return; 1339 return;
1321 } 1340 }
1322 1341
1323 if (part.OwnerID != destPart.OwnerID) 1342 // Can't transfer this
1343 //
1344 if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
1345 return;
1346
1347 bool overrideNoMod = false;
1348 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1349 overrideNoMod = true;
1350
1351 if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1324 { 1352 {
1325 // Source must have transfer permissions 1353 // object cannot copy items to an object owned by a different owner
1326 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) 1354 // unless llAllowInventoryDrop has been called
1327 return;
1328 1355
1329 // Object cannot copy items to an object owned by a different owner 1356 return;
1330 // unless llAllowInventoryDrop has been called on the destination
1331 if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1332 return;
1333 } 1357 }
1334 1358
1335 // must have both move and modify permission to put an item in an object 1359 // must have both move and modify permission to put an item in an object
1336 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1360 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1361 {
1337 return; 1362 return;
1363 }
1338 1364
1339 TaskInventoryItem destTaskItem = new TaskInventoryItem(); 1365 TaskInventoryItem destTaskItem = new TaskInventoryItem();
1340 1366
@@ -1390,6 +1416,14 @@ namespace OpenSim.Region.Framework.Scenes
1390 1416
1391 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) 1417 public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
1392 { 1418 {
1419 SceneObjectPart destPart = GetSceneObjectPart(destID);
1420 if (destPart != null) // Move into a prim
1421 {
1422 foreach(UUID itemID in items)
1423 MoveTaskInventoryItem(destID, host, itemID);
1424 return destID; // Prim folder ID == prim ID
1425 }
1426
1393 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); 1427 InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
1394 1428
1395 UUID newFolderID = UUID.Random(); 1429 UUID newFolderID = UUID.Random();
@@ -1572,12 +1606,12 @@ namespace OpenSim.Region.Framework.Scenes
1572 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( 1606 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1573 remoteClient, part, transactionID, currentItem); 1607 remoteClient, part, transactionID, currentItem);
1574 1608
1575 if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1609// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1576 remoteClient.SendAgentAlertMessage("Notecard saved", false); 1610// remoteClient.SendAgentAlertMessage("Notecard saved", false);
1577 else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) 1611// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1578 remoteClient.SendAgentAlertMessage("Script saved", false); 1612// remoteClient.SendAgentAlertMessage("Script saved", false);
1579 else 1613// else
1580 remoteClient.SendAgentAlertMessage("Item saved", false); 1614// remoteClient.SendAgentAlertMessage("Item saved", false);
1581 } 1615 }
1582 1616
1583 // Base ALWAYS has move 1617 // Base ALWAYS has move
@@ -1760,7 +1794,7 @@ namespace OpenSim.Region.Framework.Scenes
1760 } 1794 }
1761 1795
1762 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1796 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1763 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1797 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"),
1764 agentID); 1798 agentID);
1765 AssetService.Store(asset); 1799 AssetService.Store(asset);
1766 1800
@@ -1916,23 +1950,32 @@ namespace OpenSim.Region.Framework.Scenes
1916 // build a list of eligible objects 1950 // build a list of eligible objects
1917 List<uint> deleteIDs = new List<uint>(); 1951 List<uint> deleteIDs = new List<uint>();
1918 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 1952 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1919 1953 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
1920 // Start with true for both, then remove the flags if objects
1921 // that we can't derez are part of the selection
1922 bool permissionToTake = true;
1923 bool permissionToTakeCopy = true;
1924 bool permissionToDelete = true;
1925 1954
1926 foreach (uint localID in localIDs) 1955 foreach (uint localID in localIDs)
1927 { 1956 {
1957 // Start with true for both, then remove the flags if objects
1958 // that we can't derez are part of the selection
1959 bool permissionToTake = true;
1960 bool permissionToTakeCopy = true;
1961 bool permissionToDelete = true;
1962
1928 // Invalid id 1963 // Invalid id
1929 SceneObjectPart part = GetSceneObjectPart(localID); 1964 SceneObjectPart part = GetSceneObjectPart(localID);
1930 if (part == null) 1965 if (part == null)
1966 {
1967 //Client still thinks the object exists, kill it
1968 deleteIDs.Add(localID);
1931 continue; 1969 continue;
1970 }
1932 1971
1933 // Already deleted by someone else 1972 // Already deleted by someone else
1934 if (part.ParentGroup.IsDeleted) 1973 if (part.ParentGroup.IsDeleted)
1974 {
1975 //Client still thinks the object exists, kill it
1976 deleteIDs.Add(localID);
1935 continue; 1977 continue;
1978 }
1936 1979
1937 // Can't delete child prims 1980 // Can't delete child prims
1938 if (part != part.ParentGroup.RootPart) 1981 if (part != part.ParentGroup.RootPart)
@@ -1940,8 +1983,8 @@ namespace OpenSim.Region.Framework.Scenes
1940 1983
1941 SceneObjectGroup grp = part.ParentGroup; 1984 SceneObjectGroup grp = part.ParentGroup;
1942 1985
1943 deleteIDs.Add(localID); 1986 // If child prims have invalid perms, fix them
1944 deleteGroups.Add(grp); 1987 grp.AdjustChildPrimPermissions();
1945 1988
1946 // If child prims have invalid perms, fix them 1989 // If child prims have invalid perms, fix them
1947 grp.AdjustChildPrimPermissions(); 1990 grp.AdjustChildPrimPermissions();
@@ -1962,81 +2005,193 @@ namespace OpenSim.Region.Framework.Scenes
1962 } 2005 }
1963 else 2006 else
1964 { 2007 {
1965 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 2008 if (action == DeRezAction.TakeCopy)
2009 {
2010 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
2011 permissionToTakeCopy = false;
2012 }
2013 else
2014 {
1966 permissionToTakeCopy = false; 2015 permissionToTakeCopy = false;
1967 2016 }
1968 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 2017 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1969 permissionToTake = false; 2018 permissionToTake = false;
1970 2019
1971 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 2020 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1972 permissionToDelete = false; 2021 permissionToDelete = false;
1973 } 2022 }
1974 }
1975 2023
1976 // Handle god perms 2024 // Handle god perms
1977 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 2025 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1978 { 2026 {
1979 permissionToTake = true; 2027 permissionToTake = true;
1980 permissionToTakeCopy = true; 2028 permissionToTakeCopy = true;
1981 permissionToDelete = true; 2029 permissionToDelete = true;
1982 } 2030 }
1983 2031
1984 // If we're re-saving, we don't even want to delete 2032 // If we're re-saving, we don't even want to delete
1985 if (action == DeRezAction.SaveToExistingUserInventoryItem) 2033 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1986 permissionToDelete = false; 2034 permissionToDelete = false;
1987 2035
1988 // if we want to take a copy, we also don't want to delete 2036 // if we want to take a copy, we also don't want to delete
1989 // Note: after this point, the permissionToTakeCopy flag 2037 // Note: after this point, the permissionToTakeCopy flag
1990 // becomes irrelevant. It already includes the permissionToTake 2038 // becomes irrelevant. It already includes the permissionToTake
1991 // permission and after excluding no copy items here, we can 2039 // permission and after excluding no copy items here, we can
1992 // just use that. 2040 // just use that.
1993 if (action == DeRezAction.TakeCopy) 2041 if (action == DeRezAction.TakeCopy)
1994 { 2042 {
1995 // If we don't have permission, stop right here 2043 // If we don't have permission, stop right here
1996 if (!permissionToTakeCopy) 2044 if (!permissionToTakeCopy)
1997 return; 2045 return;
1998 2046
1999 permissionToTake = true; 2047 permissionToTake = true;
2000 // Don't delete 2048 // Don't delete
2001 permissionToDelete = false; 2049 permissionToDelete = false;
2002 } 2050 }
2003 2051
2004 if (action == DeRezAction.Return) 2052 if (action == DeRezAction.Return)
2005 {
2006 if (remoteClient != null)
2007 { 2053 {
2008 if (Permissions.CanReturnObjects( 2054 if (remoteClient != null)
2009 null,
2010 remoteClient.AgentId,
2011 deleteGroups))
2012 { 2055 {
2013 permissionToTake = true; 2056 if (Permissions.CanReturnObjects(
2014 permissionToDelete = true; 2057 null,
2015 2058 remoteClient.AgentId,
2016 foreach (SceneObjectGroup g in deleteGroups) 2059 new List<SceneObjectGroup>() {grp}))
2017 { 2060 {
2018 AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 2061 permissionToTake = true;
2062 permissionToDelete = true;
2063
2064 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
2019 } 2065 }
2020 } 2066 }
2067 else // Auto return passes through here with null agent
2068 {
2069 permissionToTake = true;
2070 permissionToDelete = true;
2071 }
2021 } 2072 }
2022 else // Auto return passes through here with null agent 2073
2074 if (permissionToTake && (!permissionToDelete))
2075 takeGroups.Add(grp);
2076
2077 if (permissionToDelete)
2023 { 2078 {
2024 permissionToTake = true; 2079 if (permissionToTake)
2025 permissionToDelete = true; 2080 deleteGroups.Add(grp);
2081 deleteIDs.Add(grp.LocalId);
2026 } 2082 }
2027 } 2083 }
2028 2084
2029 if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) 2085 SendKillObject(deleteIDs);
2086
2087 if (deleteGroups.Count > 0)
2030 { 2088 {
2089 foreach (SceneObjectGroup g in deleteGroups)
2090 deleteIDs.Remove(g.LocalId);
2091
2031 m_asyncSceneObjectDeleter.DeleteToInventory( 2092 m_asyncSceneObjectDeleter.DeleteToInventory(
2032 action, destinationID, deleteGroups, remoteClient, 2093 action, destinationID, deleteGroups, remoteClient,
2033 permissionToDelete); 2094 true);
2034 } 2095 }
2035 else if (permissionToDelete) 2096 if (takeGroups.Count > 0)
2097 {
2098 m_asyncSceneObjectDeleter.DeleteToInventory(
2099 action, destinationID, takeGroups, remoteClient,
2100 false);
2101 }
2102 if (deleteIDs.Count > 0)
2036 { 2103 {
2037 foreach (SceneObjectGroup g in deleteGroups) 2104 foreach (SceneObjectGroup g in deleteGroups)
2038 DeleteSceneObject(g, false); 2105 DeleteSceneObject(g, true);
2106 }
2107 }
2108
2109 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
2110 {
2111 itemID = UUID.Zero;
2112 if (grp != null)
2113 {
2114 Vector3 inventoryStoredPosition = new Vector3
2115 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
2116 ? 250
2117 : grp.AbsolutePosition.X)
2118 ,
2119 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
2120 ? 250
2121 : grp.AbsolutePosition.X,
2122 grp.AbsolutePosition.Z);
2123
2124 Vector3 originalPosition = grp.AbsolutePosition;
2125
2126 grp.AbsolutePosition = inventoryStoredPosition;
2127
2128 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
2129
2130 grp.AbsolutePosition = originalPosition;
2131
2132 AssetBase asset = CreateAsset(
2133 grp.GetPartName(grp.LocalId),
2134 grp.GetPartDescription(grp.LocalId),
2135 (sbyte)AssetType.Object,
2136 Utils.StringToBytes(sceneObjectXml),
2137 remoteClient.AgentId);
2138 AssetService.Store(asset);
2139
2140 InventoryItemBase item = new InventoryItemBase();
2141 item.CreatorId = grp.RootPart.CreatorID.ToString();
2142 item.CreatorData = grp.RootPart.CreatorData;
2143 item.Owner = remoteClient.AgentId;
2144 item.ID = UUID.Random();
2145 item.AssetID = asset.FullID;
2146 item.Description = asset.Description;
2147 item.Name = asset.Name;
2148 item.AssetType = asset.Type;
2149 item.InvType = (int)InventoryType.Object;
2150
2151 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
2152 if (folder != null)
2153 item.Folder = folder.ID;
2154 else // oopsies
2155 item.Folder = UUID.Zero;
2156
2157 // Set up base perms properly
2158 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2159 permsBase &= grp.RootPart.BaseMask;
2160 permsBase |= (uint)PermissionMask.Move;
2161
2162 // Make sure we don't lock it
2163 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2164
2165 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
2166 {
2167 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
2168 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
2169 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2170 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
2171 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
2172 }
2173 else
2174 {
2175 item.BasePermissions = permsBase;
2176 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
2177 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2178 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
2179 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
2180 }
2181 item.CreationDate = Util.UnixTimeSinceEpoch();
2182
2183 // sets itemID so client can show item as 'attached' in inventory
2184 grp.FromItemID = item.ID;
2185
2186 if (AddInventoryItem(item))
2187 remoteClient.SendInventoryItemCreateUpdate(item, 0);
2188 else
2189 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
2190
2191 itemID = item.ID;
2192 return item.AssetID;
2039 } 2193 }
2194 return UUID.Zero;
2040 } 2195 }
2041 2196
2042 /// <summary> 2197 /// <summary>
@@ -2166,6 +2321,9 @@ namespace OpenSim.Region.Framework.Scenes
2166 2321
2167 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2322 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2168 { 2323 {
2324 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2325 return;
2326
2169 SceneObjectPart part = GetSceneObjectPart(objectID); 2327 SceneObjectPart part = GetSceneObjectPart(objectID);
2170 if (part == null) 2328 if (part == null)
2171 return; 2329 return;
@@ -2222,7 +2380,10 @@ namespace OpenSim.Region.Framework.Scenes
2222 } 2380 }
2223 else 2381 else
2224 { 2382 {
2225 if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) 2383 if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId)
2384 continue;
2385
2386 if (!Permissions.CanTransferObject(sog.UUID, groupID))
2226 continue; 2387 continue;
2227 2388
2228 if (sog.GroupID != groupID) 2389 if (sog.GroupID != groupID)