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.cs194
1 files changed, 61 insertions, 133 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 80f71b3..cd91e8c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -558,24 +558,9 @@ namespace OpenSim.Region.Framework.Scenes
558 558
559 if (item == null) 559 if (item == null)
560 { 560 {
561 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); 561 item = InventoryService.QueryItem(new InventoryItemBase(oldItemID));
562 if (userInfo == null)
563 {
564 m_log.Error("[AGENT INVENTORY]: Failed to find user " + oldAgentID.ToString());
565 return;
566 }
567
568 if (userInfo.RootFolder != null)
569 {
570 item = userInfo.RootFolder.FindItem(oldItemID);
571 562
572 if (item == null) 563 if (item == null)
573 {
574 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
575 return;
576 }
577 }
578 else
579 { 564 {
580 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); 565 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
581 return; 566 return;
@@ -822,28 +807,15 @@ namespace OpenSim.Region.Framework.Scenes
822 /// <param name="folderID"></param> 807 /// <param name="folderID"></param>
823 private void RemoveInventoryFolder(IClientAPI remoteClient, UUID folderID) 808 private void RemoveInventoryFolder(IClientAPI remoteClient, UUID folderID)
824 { 809 {
825 CachedUserInfo userInfo 810 // Unclear is this handler is ever called by the Linden client, but it might
826 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
827
828 if (userInfo == null)
829 {
830 m_log.Warn("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
831 return;
832 }
833 811
834 if (userInfo.RootFolder != null) 812 InventoryFolderBase folder = new InventoryFolderBase(folderID);
813 folder.Owner = remoteClient.AgentId;
814 InventoryFolderBase trash = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder);
815 if (trash != null)
835 { 816 {
836 InventoryItemBase folder = userInfo.RootFolder.FindItem(folderID); 817 folder.ParentID = trash.ID;
837 818 InventoryService.MoveFolder(folder);
838 if (folder != null)
839 {
840 m_log.WarnFormat(
841 "[AGENT INVENTORY]: Remove folder not implemented in request by {0} {1} for {2}",
842 remoteClient.Name, remoteClient.AgentId, folderID);
843
844 // doesn't work just yet, commented out. will fix in next patch.
845 // userInfo.DeleteItem(folder);
846 }
847 } 819 }
848 } 820 }
849 821
@@ -1060,20 +1032,7 @@ namespace OpenSim.Region.Framework.Scenes
1060 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); 1032 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
1061 } 1033 }
1062 else 1034 else
1063 { 1035 {
1064 CachedUserInfo profile = CommsManager.UserProfileCacheService.GetUserDetails(avatarId);
1065 if (profile == null || profile.RootFolder == null)
1066 {
1067 m_log.ErrorFormat(
1068 "[PRIM INVENTORY]: " +
1069 "Avatar {0} cannot be found to add item",
1070 avatarId);
1071 return null;
1072 }
1073
1074 if (!profile.HasReceivedInventory)
1075 profile.FetchInventory();
1076
1077 InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); 1036 InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId);
1078 1037
1079 if (agentItem == null) 1038 if (agentItem == null)
@@ -1265,39 +1224,33 @@ namespace OpenSim.Region.Framework.Scenes
1265 UUID copyID = UUID.Random(); 1224 UUID copyID = UUID.Random();
1266 if (itemID != UUID.Zero) 1225 if (itemID != UUID.Zero)
1267 { 1226 {
1268 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 1227 InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
1269 1228
1270 if (userInfo != null && userInfo.RootFolder != null) 1229 // Try library
1230 if (null == item)
1271 { 1231 {
1272 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); 1232 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
1273 1233 }
1274 // Try library
1275 // XXX clumsy, possibly should be one call
1276 if (null == item)
1277 {
1278 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
1279 }
1280 1234
1281 if (item != null) 1235 if (item != null)
1282 { 1236 {
1283 part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); 1237 part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
1284 m_log.InfoFormat( 1238 m_log.InfoFormat(
1285 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1239 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1286 item.Name, primLocalID, remoteClient.Name); 1240 item.Name, primLocalID, remoteClient.Name);
1287 part.GetProperties(remoteClient); 1241 part.GetProperties(remoteClient);
1288 if (!Permissions.BypassPermissions()) 1242 if (!Permissions.BypassPermissions())
1289 {
1290 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1291 RemoveInventoryItem(remoteClient, itemID);
1292 }
1293 }
1294 else
1295 { 1243 {
1296 m_log.ErrorFormat( 1244 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1297 "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!", 1245 RemoveInventoryItem(remoteClient, itemID);
1298 itemID, remoteClient.Name);
1299 } 1246 }
1300 } 1247 }
1248 else
1249 {
1250 m_log.ErrorFormat(
1251 "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
1252 itemID, remoteClient.Name);
1253 }
1301 } 1254 }
1302 } 1255 }
1303 else // Updating existing item with new perms etc 1256 else // Updating existing item with new perms etc
@@ -1334,53 +1287,48 @@ namespace OpenSim.Region.Framework.Scenes
1334 1287
1335 if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory 1288 if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory
1336 { 1289 {
1337 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 1290 InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
1338 1291
1339 if (userInfo != null && userInfo.RootFolder != null) 1292 // Try library
1293 // XXX clumsy, possibly should be one call
1294 if (null == item)
1340 { 1295 {
1341 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); 1296 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
1342 1297 }
1343 // Try library
1344 // XXX clumsy, possibly should be one call
1345 if (null == item)
1346 {
1347 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
1348 }
1349 1298
1350 if (item != null) 1299 if (item != null)
1300 {
1301 SceneObjectPart part = GetSceneObjectPart(localID);
1302 if (part != null)
1351 { 1303 {
1352 SceneObjectPart part = GetSceneObjectPart(localID); 1304 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1353 if (part != null) 1305 return;
1354 {
1355 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1356 return;
1357 1306
1358 part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); 1307 part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
1359 // TODO: switch to posting on_rez here when scripts 1308 // TODO: switch to posting on_rez here when scripts
1360 // have state in inventory 1309 // have state in inventory
1361 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); 1310 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
1362 1311
1363 // m_log.InfoFormat("[PRIMINVENTORY]: " + 1312 // m_log.InfoFormat("[PRIMINVENTORY]: " +
1364 // "Rezzed script {0} into prim local ID {1} for user {2}", 1313 // "Rezzed script {0} into prim local ID {1} for user {2}",
1365 // item.inventoryName, localID, remoteClient.Name); 1314 // item.inventoryName, localID, remoteClient.Name);
1366 part.GetProperties(remoteClient); 1315 part.GetProperties(remoteClient);
1367 }
1368 else
1369 {
1370 m_log.ErrorFormat(
1371 "[PRIM INVENTORY]: " +
1372 "Could not rez script {0} into prim local ID {1} for user {2}"
1373 + " because the prim could not be found in the region!",
1374 item.Name, localID, remoteClient.Name);
1375 }
1376 } 1316 }
1377 else 1317 else
1378 { 1318 {
1379 m_log.ErrorFormat( 1319 m_log.ErrorFormat(
1380 "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", 1320 "[PRIM INVENTORY]: " +
1381 itemID, remoteClient.Name); 1321 "Could not rez script {0} into prim local ID {1} for user {2}"
1322 + " because the prim could not be found in the region!",
1323 item.Name, localID, remoteClient.Name);
1382 } 1324 }
1383 } 1325 }
1326 else
1327 {
1328 m_log.ErrorFormat(
1329 "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
1330 itemID, remoteClient.Name);
1331 }
1384 } 1332 }
1385 else // script has been rezzed directly into a prim's inventory 1333 else // script has been rezzed directly into a prim's inventory
1386 { 1334 {
@@ -1670,26 +1618,6 @@ namespace OpenSim.Region.Framework.Scenes
1670 } 1618 }
1671 } 1619 }
1672 1620
1673 private bool WaitForInventory(CachedUserInfo info)
1674 {
1675 // 200 Seconds wait. This is called in the context of the
1676 // background delete thread, so we can afford to waste time
1677 // here.
1678 //
1679 int count = 200;
1680
1681 while (count > 0)
1682 {
1683 System.Threading.Thread.Sleep(100);
1684 count--;
1685 if (info.HasReceivedInventory)
1686 return true;
1687 }
1688 m_log.DebugFormat("Timed out waiting for inventory of user {0}",
1689 info.UserProfile.ID.ToString());
1690 return false;
1691 }
1692
1693 /// <summary> 1621 /// <summary>
1694 /// Delete a scene object from a scene and place in the given avatar's inventory. 1622 /// Delete a scene object from a scene and place in the given avatar's inventory.
1695 /// Returns the UUID of the newly created asset. 1623 /// Returns the UUID of the newly created asset.