diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 168 |
1 files changed, 138 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 8ff20dd..ecaab44 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -175,8 +175,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
175 | if (im.binaryBucket.Length < 17) // Invalid | 175 | if (im.binaryBucket.Length < 17) // Invalid |
176 | return; | 176 | return; |
177 | 177 | ||
178 | UUID receipientID = new UUID(im.toAgentID); | 178 | UUID recipientID = new UUID(im.toAgentID); |
179 | ScenePresence user = scene.GetScenePresence(receipientID); | 179 | ScenePresence user = scene.GetScenePresence(recipientID); |
180 | UUID copyID; | 180 | UUID copyID; |
181 | 181 | ||
182 | // First byte is the asset type | 182 | // First byte is the asset type |
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
191 | folderID, new UUID(im.toAgentID)); | 191 | folderID, new UUID(im.toAgentID)); |
192 | 192 | ||
193 | InventoryFolderBase folderCopy | 193 | InventoryFolderBase folderCopy |
194 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); | 194 | = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero); |
195 | 195 | ||
196 | if (folderCopy == null) | 196 | if (folderCopy == null) |
197 | { | 197 | { |
@@ -244,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
244 | im.imSessionID = itemID.Guid; | 244 | im.imSessionID = itemID.Guid; |
245 | } | 245 | } |
246 | 246 | ||
247 | im.offline = 0; | ||
248 | |||
247 | // Send the IM to the recipient. The item is already | 249 | // Send the IM to the recipient. The item is already |
248 | // in their inventory, so it will not be lost if | 250 | // in their inventory, so it will not be lost if |
249 | // they are offline. | 251 | // they are offline. |
@@ -263,8 +265,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
263 | }); | 265 | }); |
264 | } | 266 | } |
265 | } | 267 | } |
266 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | 268 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || |
269 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
267 | { | 270 | { |
271 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | ||
272 | IInventoryService invService = scene.InventoryService; | ||
273 | |||
274 | // Special case: folder redirect. | ||
275 | // RLV uses this | ||
276 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
277 | { | ||
278 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId); | ||
279 | folder = invService.GetFolder(folder); | ||
280 | |||
281 | if (folder != null) | ||
282 | { | ||
283 | if (im.binaryBucket.Length >= 16) | ||
284 | { | ||
285 | UUID destFolderID = new UUID(im.binaryBucket, 0); | ||
286 | if (destFolderID != UUID.Zero) | ||
287 | { | ||
288 | InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId); | ||
289 | destFolder = invService.GetFolder(destFolder); | ||
290 | if (destFolder != null) | ||
291 | { | ||
292 | if (folder.ParentID != destFolder.ID) | ||
293 | { | ||
294 | folder.ParentID = destFolder.ID; | ||
295 | invService.MoveFolder(folder); | ||
296 | client.SendBulkUpdateInventory(folder); | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | |||
268 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 304 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
269 | 305 | ||
270 | if (user != null) // Local | 306 | if (user != null) // Local |
@@ -274,27 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
274 | else | 310 | else |
275 | { | 311 | { |
276 | if (m_TransferModule != null) | 312 | if (m_TransferModule != null) |
277 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { | 313 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); |
278 | |||
279 | // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 | ||
280 | // and is apparently supposed to fix bulk inventory updates after accepting items. But | ||
281 | // instead it appears to cause two copies of an accepted folder for the receiving user in | ||
282 | // at least some cases. Folder/item update is already done when the offer is made (see code above) | ||
283 | |||
284 | // // Send BulkUpdateInventory | ||
285 | // IInventoryService invService = scene.InventoryService; | ||
286 | // UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
287 | // | ||
288 | // InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
289 | // folder = invService.GetFolder(folder); | ||
290 | // | ||
291 | // ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
292 | // | ||
293 | // // If the user has left the scene by the time the message comes back then we can't send | ||
294 | // // them the update. | ||
295 | // if (fromUser != null) | ||
296 | // fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
297 | }); | ||
298 | } | 314 | } |
299 | } | 315 | } |
300 | 316 | ||
@@ -406,6 +422,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
406 | previousParentFolderID = folder.ParentID; | 422 | previousParentFolderID = folder.ParentID; |
407 | folder.ParentID = trashFolder.ID; | 423 | folder.ParentID = trashFolder.ID; |
408 | invService.MoveFolder(folder); | 424 | invService.MoveFolder(folder); |
425 | client.SendBulkUpdateInventory(folder); | ||
409 | } | 426 | } |
410 | } | 427 | } |
411 | 428 | ||
@@ -516,22 +533,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
516 | /// | 533 | /// |
517 | /// </summary> | 534 | /// </summary> |
518 | /// <param name="msg"></param> | 535 | /// <param name="msg"></param> |
519 | private void OnGridInstantMessage(GridInstantMessage msg) | 536 | private void OnGridInstantMessage(GridInstantMessage im) |
520 | { | 537 | { |
521 | // Check if this is ours to handle | 538 | // Check if this is ours to handle |
522 | // | 539 | // |
523 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | 540 | Scene scene = FindClientScene(new UUID(im.toAgentID)); |
524 | 541 | ||
525 | if (scene == null) | 542 | if (scene == null) |
526 | return; | 543 | return; |
527 | 544 | ||
528 | // Find agent to deliver to | 545 | // Find agent to deliver to |
529 | // | 546 | // |
530 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 547 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
548 | if (user == null) | ||
549 | return; | ||
550 | |||
551 | // This requires a little bit of processing because we have to make the | ||
552 | // new item visible in the recipient's inventory here | ||
553 | // | ||
554 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
555 | { | ||
556 | if (im.binaryBucket.Length < 17) // Invalid | ||
557 | return; | ||
558 | |||
559 | UUID recipientID = new UUID(im.toAgentID); | ||
560 | |||
561 | // First byte is the asset type | ||
562 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
563 | |||
564 | if (AssetType.Folder == assetType) | ||
565 | { | ||
566 | UUID folderID = new UUID(im.binaryBucket, 1); | ||
567 | |||
568 | InventoryFolderBase given = | ||
569 | new InventoryFolderBase(folderID, recipientID); | ||
570 | InventoryFolderBase folder = | ||
571 | scene.InventoryService.GetFolder(given); | ||
572 | |||
573 | if (folder != null) | ||
574 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
575 | } | ||
576 | else | ||
577 | { | ||
578 | UUID itemID = new UUID(im.binaryBucket, 1); | ||
579 | |||
580 | InventoryItemBase given = | ||
581 | new InventoryItemBase(itemID, recipientID); | ||
582 | InventoryItemBase item = | ||
583 | scene.InventoryService.GetItem(given); | ||
584 | |||
585 | if (item != null) | ||
586 | { | ||
587 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
588 | } | ||
589 | } | ||
590 | user.ControllingClient.SendInstantMessage(im); | ||
591 | } | ||
592 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) | ||
593 | { | ||
594 | if (im.binaryBucket.Length < 1) // Invalid | ||
595 | return; | ||
596 | |||
597 | UUID recipientID = new UUID(im.toAgentID); | ||
598 | |||
599 | // Bucket is the asset type | ||
600 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
601 | |||
602 | if (AssetType.Folder == assetType) | ||
603 | { | ||
604 | UUID folderID = new UUID(im.imSessionID); | ||
605 | |||
606 | InventoryFolderBase given = | ||
607 | new InventoryFolderBase(folderID, recipientID); | ||
608 | InventoryFolderBase folder = | ||
609 | scene.InventoryService.GetFolder(given); | ||
610 | |||
611 | if (folder != null) | ||
612 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
613 | } | ||
614 | else | ||
615 | { | ||
616 | UUID itemID = new UUID(im.imSessionID); | ||
531 | 617 | ||
532 | // Just forward to local handling | 618 | InventoryItemBase given = |
533 | OnInstantMessage(user.ControllingClient, msg); | 619 | new InventoryItemBase(itemID, recipientID); |
620 | InventoryItemBase item = | ||
621 | scene.InventoryService.GetItem(given); | ||
534 | 622 | ||
623 | if (item != null) | ||
624 | { | ||
625 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
626 | } | ||
627 | } | ||
628 | |||
629 | // Fix up binary bucket since this may be 17 chars long here | ||
630 | Byte[] bucket = new Byte[1]; | ||
631 | bucket[0] = im.binaryBucket[0]; | ||
632 | im.binaryBucket = bucket; | ||
633 | |||
634 | user.ControllingClient.SendInstantMessage(im); | ||
635 | } | ||
636 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || | ||
637 | im.dialog == (byte) InstantMessageDialog.InventoryDeclined || | ||
638 | im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined || | ||
639 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
640 | { | ||
641 | user.ControllingClient.SendInstantMessage(im); | ||
642 | } | ||
535 | } | 643 | } |
536 | } | 644 | } |
537 | } | 645 | } |