diff options
author | Oren Hurvitz | 2014-05-05 15:59:24 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-05-06 07:28:45 +0100 |
commit | eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f (patch) | |
tree | 22036030b5b13ee158db4dd532d84895f6c04d82 /OpenSim/Region/Framework | |
parent | Show more meaningful error messages when failed to give an item to another user (diff) | |
download | opensim-SC_OLD-eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f.zip opensim-SC_OLD-eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f.tar.gz opensim-SC_OLD-eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f.tar.bz2 opensim-SC_OLD-eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f.tar.xz |
Show more meaningful error messages when failed to move an item from a prim to a user's inventory.
Also, actually show the error to the user in more cases. (Previously, sometimes the operation failed without telling the user anything.)
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 6 |
2 files changed, 46 insertions, 24 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 27cd5c6..4988868 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1167,11 +1167,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1167 | 1167 | ||
1168 | InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); | 1168 | InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); |
1169 | 1169 | ||
1170 | // Move the item to trash. If this is a copiable item, only | 1170 | // Move the item to trash. If this is a copyable item, only |
1171 | // a copy will be moved and we will still need to delete | 1171 | // a copy will be moved and we will still need to delete |
1172 | // the item from the prim. If it was no copy, is will be | 1172 | // the item from the prim. If it was no copy, it will be |
1173 | // deleted by this method. | 1173 | // deleted by this method. |
1174 | MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID); | 1174 | string message; |
1175 | InventoryItemBase item2 = MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID, out message); | ||
1176 | |||
1177 | if (item2 == null) | ||
1178 | { | ||
1179 | m_log.WarnFormat("[SCENE INVENTORY]: RemoveTaskInventory of item {0} failed: {1}", itemID, message); | ||
1180 | remoteClient.SendAgentAlertMessage(message, false); | ||
1181 | return; | ||
1182 | } | ||
1175 | 1183 | ||
1176 | if (group.GetInventoryItem(localID, itemID) != null) | 1184 | if (group.GetInventoryItem(localID, itemID) != null) |
1177 | { | 1185 | { |
@@ -1183,11 +1191,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | 1191 | ||
1184 | group.RemoveInventoryItem(localID, itemID); | 1192 | group.RemoveInventoryItem(localID, itemID); |
1185 | } | 1193 | } |
1194 | |||
1186 | part.SendPropertiesToClient(remoteClient); | 1195 | part.SendPropertiesToClient(remoteClient); |
1187 | } | 1196 | } |
1188 | } | 1197 | } |
1189 | 1198 | ||
1190 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) | 1199 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId, out string message) |
1191 | { | 1200 | { |
1192 | TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); | 1201 | TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); |
1193 | 1202 | ||
@@ -1198,12 +1207,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1198 | + " inventory item from a prim's inventory item " | 1207 | + " inventory item from a prim's inventory item " |
1199 | + " but the required item does not exist in the prim's inventory", | 1208 | + " but the required item does not exist in the prim's inventory", |
1200 | itemId, part.Name, part.UUID); | 1209 | itemId, part.Name, part.UUID); |
1201 | 1210 | message = "Item not found: " + itemId; | |
1202 | return null; | 1211 | return null; |
1203 | } | 1212 | } |
1204 | 1213 | ||
1205 | if ((destAgent != taskItem.OwnerID) && ((taskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | 1214 | if ((destAgent != taskItem.OwnerID) && ((taskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) |
1206 | { | 1215 | { |
1216 | message = "Item doesn't have the Transfer permission."; | ||
1207 | return null; | 1217 | return null; |
1208 | } | 1218 | } |
1209 | 1219 | ||
@@ -1263,6 +1273,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1263 | } | 1273 | } |
1264 | } | 1274 | } |
1265 | 1275 | ||
1276 | message = null; | ||
1266 | return agentItem; | 1277 | return agentItem; |
1267 | } | 1278 | } |
1268 | 1279 | ||
@@ -1273,19 +1284,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1273 | /// <param name="folderID"></param> | 1284 | /// <param name="folderID"></param> |
1274 | /// <param name="part"></param> | 1285 | /// <param name="part"></param> |
1275 | /// <param name="itemID"></param> | 1286 | /// <param name="itemID"></param> |
1276 | public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId) | 1287 | public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId, out string message) |
1277 | { | 1288 | { |
1278 | m_log.DebugFormat( | 1289 | m_log.DebugFormat( |
1279 | "[PRIM INVENTORY]: Adding item {0} from {1} to folder {2} for {3}", | 1290 | "[PRIM INVENTORY]: Adding item {0} from {1} to folder {2} for {3}", |
1280 | itemId, part.Name, folderId, remoteClient.Name); | 1291 | itemId, part.Name, folderId, remoteClient.Name); |
1281 | 1292 | ||
1282 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); | 1293 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId, out message); |
1283 | |||
1284 | if (agentItem == null) | 1294 | if (agentItem == null) |
1285 | return null; | 1295 | return null; |
1286 | 1296 | ||
1287 | agentItem.Folder = folderId; | 1297 | agentItem.Folder = folderId; |
1288 | AddInventoryItem(remoteClient, agentItem); | 1298 | AddInventoryItem(remoteClient, agentItem); |
1299 | message = null; | ||
1289 | return agentItem; | 1300 | return agentItem; |
1290 | } | 1301 | } |
1291 | 1302 | ||
@@ -1336,7 +1347,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1336 | return; | 1347 | return; |
1337 | } | 1348 | } |
1338 | 1349 | ||
1339 | MoveTaskInventoryItem(remoteClient, folderId, part, itemId); | 1350 | string message; |
1351 | InventoryItemBase item = MoveTaskInventoryItem(remoteClient, folderId, part, itemId, out message); | ||
1352 | |||
1353 | if (item == null) | ||
1354 | remoteClient.SendAgentAlertMessage(message, false); | ||
1340 | } | 1355 | } |
1341 | 1356 | ||
1342 | /// <summary> | 1357 | /// <summary> |
@@ -1350,17 +1365,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1350 | /// </param> | 1365 | /// </param> |
1351 | /// <param name="part"></param> | 1366 | /// <param name="part"></param> |
1352 | /// <param name="itemID"></param> | 1367 | /// <param name="itemID"></param> |
1353 | public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId) | 1368 | public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId, out string message) |
1354 | { | 1369 | { |
1355 | ScenePresence avatar; | 1370 | ScenePresence avatar; |
1356 | 1371 | ||
1357 | if (TryGetScenePresence(avatarId, out avatar)) | 1372 | if (TryGetScenePresence(avatarId, out avatar)) |
1358 | { | 1373 | { |
1359 | return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); | 1374 | return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId, out message); |
1360 | } | 1375 | } |
1361 | else | 1376 | else |
1362 | { | 1377 | { |
1363 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); | 1378 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId, out message); |
1364 | 1379 | ||
1365 | if (agentItem == null) | 1380 | if (agentItem == null) |
1366 | return null; | 1381 | return null; |
@@ -1474,6 +1489,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1474 | 1489 | ||
1475 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1490 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1476 | { | 1491 | { |
1492 | ScenePresence avatar; | ||
1493 | IClientAPI remoteClient = null; | ||
1494 | if (TryGetScenePresence(destID, out avatar)) | ||
1495 | remoteClient = avatar.ControllingClient; | ||
1496 | |||
1477 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1497 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1478 | 1498 | ||
1479 | UUID newFolderID = UUID.Random(); | 1499 | UUID newFolderID = UUID.Random(); |
@@ -1483,7 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1483 | 1503 | ||
1484 | foreach (UUID itemID in items) | 1504 | foreach (UUID itemID in items) |
1485 | { | 1505 | { |
1486 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID); | 1506 | string message; |
1507 | InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID, out message); | ||
1487 | 1508 | ||
1488 | if (agentItem != null) | 1509 | if (agentItem != null) |
1489 | { | 1510 | { |
@@ -1491,18 +1512,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1491 | 1512 | ||
1492 | AddInventoryItem(agentItem); | 1513 | AddInventoryItem(agentItem); |
1493 | } | 1514 | } |
1515 | else | ||
1516 | { | ||
1517 | if (remoteClient != null) | ||
1518 | remoteClient.SendAgentAlertMessage(message, false); | ||
1519 | } | ||
1494 | } | 1520 | } |
1495 | 1521 | ||
1496 | ScenePresence avatar = null; | 1522 | if (remoteClient != null) |
1497 | if (TryGetScenePresence(destID, out avatar)) | ||
1498 | { | 1523 | { |
1499 | //profile.SendInventoryDecendents(avatar.ControllingClient, | 1524 | SendInventoryUpdate(remoteClient, rootFolder, true, false); |
1500 | // profile.RootFolder.ID, true, false); | 1525 | SendInventoryUpdate(remoteClient, newFolder, false, true); |
1501 | //profile.SendInventoryDecendents(avatar.ControllingClient, | ||
1502 | // newFolderID, false, true); | ||
1503 | |||
1504 | SendInventoryUpdate(avatar.ControllingClient, rootFolder, true, false); | ||
1505 | SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true); | ||
1506 | } | 1526 | } |
1507 | 1527 | ||
1508 | return newFolderID; | 1528 | return newFolderID; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 6e0ea7d..f809267 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -136,7 +136,8 @@ namespace OpenSim.Region.Framework.Tests | |||
136 | = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; | 136 | = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; |
137 | 137 | ||
138 | // Perform test | 138 | // Perform test |
139 | scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); | 139 | string message; |
140 | scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message); | ||
140 | 141 | ||
141 | InventoryItemBase ncUserItem | 142 | InventoryItemBase ncUserItem |
142 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); | 143 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); |
@@ -165,7 +166,8 @@ namespace OpenSim.Region.Framework.Tests | |||
165 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); | 166 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
166 | 167 | ||
167 | // Perform test | 168 | // Perform test |
168 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); | 169 | string message; |
170 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message); | ||
169 | 171 | ||
170 | InventoryItemBase ncUserItem | 172 | InventoryItemBase ncUserItem |
171 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); | 173 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); |