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 7e31d60..0b73df5 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,9 +1983,6 @@ namespace OpenSim.Region.Framework.Scenes
1940 1983
1941 SceneObjectGroup grp = part.ParentGroup; 1984 SceneObjectGroup grp = part.ParentGroup;
1942 1985
1943 deleteIDs.Add(localID);
1944 deleteGroups.Add(grp);
1945
1946 if (remoteClient == null) 1986 if (remoteClient == null)
1947 { 1987 {
1948 // Autoreturn has a null client. Nothing else does. So 1988 // Autoreturn has a null client. Nothing else does. So
@@ -1959,81 +1999,193 @@ namespace OpenSim.Region.Framework.Scenes
1959 } 1999 }
1960 else 2000 else
1961 { 2001 {
1962 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 2002 if (action == DeRezAction.TakeCopy)
2003 {
2004 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
2005 permissionToTakeCopy = false;
2006 }
2007 else
2008 {
1963 permissionToTakeCopy = false; 2009 permissionToTakeCopy = false;
1964 2010 }
1965 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 2011 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1966 permissionToTake = false; 2012 permissionToTake = false;
1967 2013
1968 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 2014 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1969 permissionToDelete = false; 2015 permissionToDelete = false;
1970 } 2016 }
1971 }
1972 2017
1973 // Handle god perms 2018 // Handle god perms
1974 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) 2019 if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId))
1975 { 2020 {
1976 permissionToTake = true; 2021 permissionToTake = true;
1977 permissionToTakeCopy = true; 2022 permissionToTakeCopy = true;
1978 permissionToDelete = true; 2023 permissionToDelete = true;
1979 } 2024 }
1980 2025
1981 // If we're re-saving, we don't even want to delete 2026 // If we're re-saving, we don't even want to delete
1982 if (action == DeRezAction.SaveToExistingUserInventoryItem) 2027 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1983 permissionToDelete = false; 2028 permissionToDelete = false;
1984 2029
1985 // if we want to take a copy, we also don't want to delete 2030 // if we want to take a copy, we also don't want to delete
1986 // Note: after this point, the permissionToTakeCopy flag 2031 // Note: after this point, the permissionToTakeCopy flag
1987 // becomes irrelevant. It already includes the permissionToTake 2032 // becomes irrelevant. It already includes the permissionToTake
1988 // permission and after excluding no copy items here, we can 2033 // permission and after excluding no copy items here, we can
1989 // just use that. 2034 // just use that.
1990 if (action == DeRezAction.TakeCopy) 2035 if (action == DeRezAction.TakeCopy)
1991 { 2036 {
1992 // If we don't have permission, stop right here 2037 // If we don't have permission, stop right here
1993 if (!permissionToTakeCopy) 2038 if (!permissionToTakeCopy)
1994 return; 2039 return;
1995 2040
1996 permissionToTake = true; 2041 permissionToTake = true;
1997 // Don't delete 2042 // Don't delete
1998 permissionToDelete = false; 2043 permissionToDelete = false;
1999 } 2044 }
2000 2045
2001 if (action == DeRezAction.Return) 2046 if (action == DeRezAction.Return)
2002 {
2003 if (remoteClient != null)
2004 { 2047 {
2005 if (Permissions.CanReturnObjects( 2048 if (remoteClient != null)
2006 null,
2007 remoteClient.AgentId,
2008 deleteGroups))
2009 { 2049 {
2010 permissionToTake = true; 2050 if (Permissions.CanReturnObjects(
2011 permissionToDelete = true; 2051 null,
2012 2052 remoteClient.AgentId,
2013 foreach (SceneObjectGroup g in deleteGroups) 2053 deleteGroups))
2014 { 2054 {
2015 AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); 2055 permissionToTake = true;
2056 permissionToDelete = true;
2057
2058 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
2016 } 2059 }
2017 } 2060 }
2061 else // Auto return passes through here with null agent
2062 {
2063 permissionToTake = true;
2064 permissionToDelete = true;
2065 }
2018 } 2066 }
2019 else // Auto return passes through here with null agent 2067
2068 if (permissionToTake && (!permissionToDelete))
2069 takeGroups.Add(grp);
2070
2071 if (permissionToDelete)
2020 { 2072 {
2021 permissionToTake = true; 2073 if (permissionToTake)
2022 permissionToDelete = true; 2074 deleteGroups.Add(grp);
2075 deleteIDs.Add(grp.LocalId);
2023 } 2076 }
2024 } 2077 }
2025 2078
2026 if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) 2079 SendKillObject(deleteIDs);
2080
2081 if (deleteGroups.Count > 0)
2027 { 2082 {
2083 foreach (SceneObjectGroup g in deleteGroups)
2084 deleteIDs.Remove(g.LocalId);
2085
2028 m_asyncSceneObjectDeleter.DeleteToInventory( 2086 m_asyncSceneObjectDeleter.DeleteToInventory(
2029 action, destinationID, deleteGroups, remoteClient, 2087 action, destinationID, deleteGroups, remoteClient,
2030 permissionToDelete); 2088 true);
2031 } 2089 }
2032 else if (permissionToDelete) 2090 if (takeGroups.Count > 0)
2091 {
2092 m_asyncSceneObjectDeleter.DeleteToInventory(
2093 action, destinationID, takeGroups, remoteClient,
2094 false);
2095 }
2096 if (deleteIDs.Count > 0)
2033 { 2097 {
2034 foreach (SceneObjectGroup g in deleteGroups) 2098 foreach (SceneObjectGroup g in deleteGroups)
2035 DeleteSceneObject(g, false); 2099 DeleteSceneObject(g, true);
2100 }
2101 }
2102
2103 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
2104 {
2105 itemID = UUID.Zero;
2106 if (grp != null)
2107 {
2108 Vector3 inventoryStoredPosition = new Vector3
2109 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
2110 ? 250
2111 : grp.AbsolutePosition.X)
2112 ,
2113 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
2114 ? 250
2115 : grp.AbsolutePosition.X,
2116 grp.AbsolutePosition.Z);
2117
2118 Vector3 originalPosition = grp.AbsolutePosition;
2119
2120 grp.AbsolutePosition = inventoryStoredPosition;
2121
2122 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
2123
2124 grp.AbsolutePosition = originalPosition;
2125
2126 AssetBase asset = CreateAsset(
2127 grp.GetPartName(grp.LocalId),
2128 grp.GetPartDescription(grp.LocalId),
2129 (sbyte)AssetType.Object,
2130 Utils.StringToBytes(sceneObjectXml),
2131 remoteClient.AgentId);
2132 AssetService.Store(asset);
2133
2134 InventoryItemBase item = new InventoryItemBase();
2135 item.CreatorId = grp.RootPart.CreatorID.ToString();
2136 item.CreatorData = grp.RootPart.CreatorData;
2137 item.Owner = remoteClient.AgentId;
2138 item.ID = UUID.Random();
2139 item.AssetID = asset.FullID;
2140 item.Description = asset.Description;
2141 item.Name = asset.Name;
2142 item.AssetType = asset.Type;
2143 item.InvType = (int)InventoryType.Object;
2144
2145 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
2146 if (folder != null)
2147 item.Folder = folder.ID;
2148 else // oopsies
2149 item.Folder = UUID.Zero;
2150
2151 // Set up base perms properly
2152 uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify);
2153 permsBase &= grp.RootPart.BaseMask;
2154 permsBase |= (uint)PermissionMask.Move;
2155
2156 // Make sure we don't lock it
2157 grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move;
2158
2159 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
2160 {
2161 item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask;
2162 item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask;
2163 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2164 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
2165 item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
2166 }
2167 else
2168 {
2169 item.BasePermissions = permsBase;
2170 item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask;
2171 item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask;
2172 item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
2173 item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
2174 }
2175 item.CreationDate = Util.UnixTimeSinceEpoch();
2176
2177 // sets itemID so client can show item as 'attached' in inventory
2178 grp.FromItemID = item.ID;
2179
2180 if (AddInventoryItem(item))
2181 remoteClient.SendInventoryItemCreateUpdate(item, 0);
2182 else
2183 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
2184
2185 itemID = item.ID;
2186 return item.AssetID;
2036 } 2187 }
2188 return UUID.Zero;
2037 } 2189 }
2038 2190
2039 /// <summary> 2191 /// <summary>
@@ -2163,6 +2315,9 @@ namespace OpenSim.Region.Framework.Scenes
2163 2315
2164 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) 2316 public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running)
2165 { 2317 {
2318 if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId))
2319 return;
2320
2166 SceneObjectPart part = GetSceneObjectPart(objectID); 2321 SceneObjectPart part = GetSceneObjectPart(objectID);
2167 if (part == null) 2322 if (part == null)
2168 return; 2323 return;
@@ -2219,7 +2374,10 @@ namespace OpenSim.Region.Framework.Scenes
2219 } 2374 }
2220 else 2375 else
2221 { 2376 {
2222 if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) 2377 if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId)
2378 continue;
2379
2380 if (!Permissions.CanTransferObject(sog.UUID, groupID))
2223 continue; 2381 continue;
2224 2382
2225 if (sog.GroupID != groupID) 2383 if (sog.GroupID != groupID)