diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 119 |
1 files changed, 115 insertions, 4 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index d1e0c24..3d6a905 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -400,11 +400,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
400 | } | 400 | } |
401 | 401 | ||
402 | /// <summary> | 402 | /// <summary> |
403 | /// Give an inventory item from one avatar to another | 403 | /// Give an inventory item from one user to another |
404 | /// </summary> | 404 | /// </summary> |
405 | /// <param name="recipientClient"></param> | 405 | /// <param name="recipientClient"></param> |
406 | /// <param name="senderId">ID of the sender of the item</param> | 406 | /// <param name="senderId">ID of the sender of the item</param> |
407 | /// <param name="itemId"></param> | 407 | /// <param name="itemId"></param> |
408 | public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId) | 408 | public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId) |
409 | { | 409 | { |
410 | InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId); | 410 | InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId); |
@@ -413,8 +413,34 @@ namespace OpenSim.Region.Environment.Scenes | |||
413 | recipientClient.SendBulkUpdateInventory(itemCopy); | 413 | recipientClient.SendBulkUpdateInventory(itemCopy); |
414 | } | 414 | } |
415 | 415 | ||
416 | /// <summary> | ||
417 | /// Give an inventory item from one user to another | ||
418 | /// </summary> | ||
419 | /// <param name="recipient"></param> | ||
420 | /// <param name="senderId">ID of the sender of the item</param> | ||
421 | /// <param name="itemId"></param> | ||
422 | /// <returns>The inventory item copy given, null if the give was unsuccessful</returns> | ||
416 | public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId) | 423 | public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId) |
417 | { | 424 | { |
425 | return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero); | ||
426 | } | ||
427 | |||
428 | /// <summary> | ||
429 | /// Give an inventory item from one user to another | ||
430 | /// </summary> | ||
431 | /// <param name="recipient"></param> | ||
432 | /// <param name="senderId">ID of the sender of the item</param> | ||
433 | /// <param name="itemId"></param> | ||
434 | /// <param name="recipientFolderId"> | ||
435 | /// The id of the folder in which the copy item should go. If UUID.Zero then the item is placed in the most | ||
436 | /// appropriate default folder. | ||
437 | /// </param> | ||
438 | /// <returns> | ||
439 | /// The inventory item copy given, null if the give was unsuccessful | ||
440 | /// </returns> | ||
441 | public virtual InventoryItemBase GiveInventoryItem( | ||
442 | UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) | ||
443 | { | ||
418 | // Retrieve the item from the sender | 444 | // Retrieve the item from the sender |
419 | CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId); | 445 | CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId); |
420 | 446 | ||
@@ -438,7 +464,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
438 | return null; | 464 | return null; |
439 | } | 465 | } |
440 | 466 | ||
441 | // TODO get recipient's root folder | ||
442 | CachedUserInfo recipientUserInfo | 467 | CachedUserInfo recipientUserInfo |
443 | = CommsManager.UserProfileCacheService.GetUserDetails(recipient); | 468 | = CommsManager.UserProfileCacheService.GetUserDetails(recipient); |
444 | 469 | ||
@@ -457,7 +482,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
457 | itemCopy.Name = item.Name; | 482 | itemCopy.Name = item.Name; |
458 | itemCopy.AssetType = item.AssetType; | 483 | itemCopy.AssetType = item.AssetType; |
459 | itemCopy.InvType = item.InvType; | 484 | itemCopy.InvType = item.InvType; |
460 | itemCopy.Folder = UUID.Zero; | 485 | itemCopy.Folder = recipientFolderId; |
486 | |||
461 | if (Permissions.PropagatePermissions()) | 487 | if (Permissions.PropagatePermissions()) |
462 | { | 488 | { |
463 | if (item.InvType == 6) | 489 | if (item.InvType == 6) |
@@ -529,8 +555,93 @@ namespace OpenSim.Region.Environment.Scenes | |||
529 | m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder"); | 555 | m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder"); |
530 | return null; | 556 | return null; |
531 | } | 557 | } |
558 | |||
532 | return null; | 559 | return null; |
533 | } | 560 | } |
561 | |||
562 | /// <summary> | ||
563 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent | ||
564 | /// folders) is given. | ||
565 | /// </summary> | ||
566 | /// <param name="recipientId"></param> | ||
567 | /// <param name="senderId">ID of the sender of the item</param> | ||
568 | /// <param name="folderId"></param> | ||
569 | /// <param name="recipientParentFolderId"> | ||
570 | /// The id of the receipient folder in which the send folder should be placed. If UUID.Zero then the | ||
571 | /// recipient folder is the root folder | ||
572 | /// </param> | ||
573 | /// <returns> | ||
574 | /// The inventory folder copy given, null if the copy was unsuccessful | ||
575 | /// </returns> | ||
576 | public virtual InventoryFolderImpl GiveInventoryFolder( | ||
577 | UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId) | ||
578 | { | ||
579 | // Retrieve the folder from the sender | ||
580 | CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId); | ||
581 | |||
582 | if (null == senderUserInfo) | ||
583 | { | ||
584 | m_log.ErrorFormat( | ||
585 | "[AGENT INVENTORY]: Failed to find sending user {0} for folder {1}", senderId, folderId); | ||
586 | |||
587 | return null; | ||
588 | } | ||
589 | |||
590 | if (!senderUserInfo.HasReceivedInventory) | ||
591 | { | ||
592 | m_log.DebugFormat( | ||
593 | "[AGENT INVENTORY]: Could not give inventory folder - have not yet received inventory for {0}", | ||
594 | senderId); | ||
595 | |||
596 | return null; | ||
597 | } | ||
598 | |||
599 | InventoryFolderImpl folder = senderUserInfo.RootFolder.FindFolder(folderId); | ||
600 | |||
601 | if (null == folder) | ||
602 | { | ||
603 | m_log.ErrorFormat( | ||
604 | "[AGENT INVENTORY]: Could not find inventory folder {0} to give", folderId); | ||
605 | |||
606 | return null; | ||
607 | } | ||
608 | |||
609 | CachedUserInfo recipientUserInfo | ||
610 | = CommsManager.UserProfileCacheService.GetUserDetails(recipientId); | ||
611 | |||
612 | if (null == recipientUserInfo) | ||
613 | { | ||
614 | m_log.ErrorFormat( | ||
615 | "[AGENT INVENTORY]: Failed to find receiving user {0} for folder {1}", recipientId, folderId); | ||
616 | |||
617 | return null; | ||
618 | } | ||
619 | |||
620 | if (recipientParentFolderId == UUID.Zero) | ||
621 | recipientParentFolderId = recipientUserInfo.RootFolder.ID; | ||
622 | |||
623 | UUID newFolderId = UUID.Random(); | ||
624 | recipientUserInfo.CreateFolder(folder.Name, newFolderId, (ushort)folder.Type, recipientParentFolderId); | ||
625 | |||
626 | // XXX: Messy - we should really get this back in the CreateFolder call | ||
627 | InventoryFolderImpl copiedFolder = recipientUserInfo.RootFolder.FindFolder(newFolderId); | ||
628 | |||
629 | // Give all the subfolders | ||
630 | List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls(); | ||
631 | foreach (InventoryFolderImpl childFolder in subFolders) | ||
632 | { | ||
633 | GiveInventoryFolder(recipientId, senderId, childFolder.ID, copiedFolder.ID); | ||
634 | } | ||
635 | |||
636 | // Give all the items | ||
637 | List<InventoryItemBase> items = folder.RequestListOfItems(); | ||
638 | foreach (InventoryItemBase item in items) | ||
639 | { | ||
640 | GiveInventoryItem(recipientId, senderId, item.ID, copiedFolder.ID); | ||
641 | } | ||
642 | |||
643 | return copiedFolder; | ||
644 | } | ||
534 | 645 | ||
535 | public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, UUID oldAgentID, UUID oldItemID, | 646 | public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, UUID oldAgentID, UUID oldItemID, |
536 | UUID newFolderID, string newName) | 647 | UUID newFolderID, string newName) |