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.cs39
1 files changed, 29 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index bb9f457..27cd5c6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes
46{ 46{
47 public partial class Scene 47 public partial class Scene
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 private static readonly string LogHeader = "[SCENE INVENTORY]"; 50 private static readonly string LogHeader = "[SCENE INVENTORY]";
51 51
52 /// <summary> 52 /// <summary>
@@ -534,9 +534,9 @@ namespace OpenSim.Region.Framework.Scenes
534 /// <param name="recipientClient"></param> 534 /// <param name="recipientClient"></param>
535 /// <param name="senderId">ID of the sender of the item</param> 535 /// <param name="senderId">ID of the sender of the item</param>
536 /// <param name="itemId"></param> 536 /// <param name="itemId"></param>
537 public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId) 537 public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId, out string message)
538 { 538 {
539 InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId); 539 InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId, out message);
540 540
541 if (itemCopy != null) 541 if (itemCopy != null)
542 recipientClient.SendBulkUpdateInventory(itemCopy); 542 recipientClient.SendBulkUpdateInventory(itemCopy);
@@ -549,9 +549,9 @@ namespace OpenSim.Region.Framework.Scenes
549 /// <param name="senderId">ID of the sender of the item</param> 549 /// <param name="senderId">ID of the sender of the item</param>
550 /// <param name="itemId"></param> 550 /// <param name="itemId"></param>
551 /// <returns>The inventory item copy given, null if the give was unsuccessful</returns> 551 /// <returns>The inventory item copy given, null if the give was unsuccessful</returns>
552 public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId) 552 public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId, out string message)
553 { 553 {
554 return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero); 554 return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero, out message);
555 } 555 }
556 556
557 /// <summary> 557 /// <summary>
@@ -568,12 +568,15 @@ namespace OpenSim.Region.Framework.Scenes
568 /// The inventory item copy given, null if the give was unsuccessful 568 /// The inventory item copy given, null if the give was unsuccessful
569 /// </returns> 569 /// </returns>
570 public virtual InventoryItemBase GiveInventoryItem( 570 public virtual InventoryItemBase GiveInventoryItem(
571 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) 571 UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId, out string message)
572 { 572 {
573 //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); 573 //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
574 574
575 if (!Permissions.CanTransferUserInventory(itemId, senderId, recipient)) 575 if (!Permissions.CanTransferUserInventory(itemId, senderId, recipient))
576 {
577 message = "Not allowed to transfer this item.";
576 return null; 578 return null;
579 }
577 580
578 InventoryItemBase item = new InventoryItemBase(itemId, senderId); 581 InventoryItemBase item = new InventoryItemBase(itemId, senderId);
579 item = InventoryService.GetItem(item); 582 item = InventoryService.GetItem(item);
@@ -582,6 +585,7 @@ namespace OpenSim.Region.Framework.Scenes
582 { 585 {
583 m_log.WarnFormat( 586 m_log.WarnFormat(
584 "[AGENT INVENTORY]: Failed to find item {0} sent by {1} to {2}", itemId, senderId, recipient); 587 "[AGENT INVENTORY]: Failed to find item {0} sent by {1} to {2}", itemId, senderId, recipient);
588 message = string.Format("Item not found: {0}.", itemId);
585 return null; 589 return null;
586 } 590 }
587 591
@@ -590,6 +594,7 @@ namespace OpenSim.Region.Framework.Scenes
590 m_log.WarnFormat( 594 m_log.WarnFormat(
591 "[AGENT INVENTORY]: Attempt to send item {0} {1} to {2} failed because sender {3} did not match item owner {4}", 595 "[AGENT INVENTORY]: Attempt to send item {0} {1} to {2} failed because sender {3} did not match item owner {4}",
592 item.Name, item.ID, recipient, senderId, item.Owner); 596 item.Name, item.ID, recipient, senderId, item.Owner);
597 message = "Sender did not match item owner.";
593 return null; 598 return null;
594 } 599 }
595 600
@@ -600,7 +605,10 @@ namespace OpenSim.Region.Framework.Scenes
600 if (!Permissions.BypassPermissions()) 605 if (!Permissions.BypassPermissions())
601 { 606 {
602 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) 607 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
608 {
609 message = "Item doesn't have the Transfer permission.";
603 return null; 610 return null;
611 }
604 } 612 }
605 613
606 // Insert a copy of the item into the recipient 614 // Insert a copy of the item into the recipient
@@ -736,9 +744,14 @@ namespace OpenSim.Region.Framework.Scenes
736 InventoryFolderBase root = InventoryService.GetRootFolder(recipient); 744 InventoryFolderBase root = InventoryService.GetRootFolder(recipient);
737 745
738 if (root != null) 746 if (root != null)
747 {
739 itemCopy.Folder = root.ID; 748 itemCopy.Folder = root.ID;
749 }
740 else 750 else
741 return null; // No destination 751 {
752 message = "Can't find a folder to add the item to.";
753 return null;
754 }
742 } 755 }
743 } 756 }
744 757
@@ -763,6 +776,7 @@ namespace OpenSim.Region.Framework.Scenes
763 } 776 }
764 } 777 }
765 778
779 message = null;
766 return itemCopy; 780 return itemCopy;
767 } 781 }
768 782
@@ -780,7 +794,7 @@ namespace OpenSim.Region.Framework.Scenes
780 /// <returns> 794 /// <returns>
781 /// The inventory folder copy given, null if the copy was unsuccessful 795 /// The inventory folder copy given, null if the copy was unsuccessful
782 /// </returns> 796 /// </returns>
783 public virtual InventoryFolderBase GiveInventoryFolder( 797 public virtual InventoryFolderBase GiveInventoryFolder(IClientAPI client,
784 UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId) 798 UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId)
785 { 799 {
786 //// Retrieve the folder from the sender 800 //// Retrieve the folder from the sender
@@ -815,13 +829,18 @@ namespace OpenSim.Region.Framework.Scenes
815 InventoryCollection contents = InventoryService.GetFolderContent(senderId, folderId); 829 InventoryCollection contents = InventoryService.GetFolderContent(senderId, folderId);
816 foreach (InventoryFolderBase childFolder in contents.Folders) 830 foreach (InventoryFolderBase childFolder in contents.Folders)
817 { 831 {
818 GiveInventoryFolder(recipientId, senderId, childFolder.ID, newFolder.ID); 832 GiveInventoryFolder(client, recipientId, senderId, childFolder.ID, newFolder.ID);
819 } 833 }
820 834
821 // Give all the items 835 // Give all the items
822 foreach (InventoryItemBase item in contents.Items) 836 foreach (InventoryItemBase item in contents.Items)
823 { 837 {
824 GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID); 838 string message;
839 if (GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID, out message) == null)
840 {
841 if (client != null)
842 client.SendAgentAlertMessage(message, false);
843 }
825 } 844 }
826 845
827 return newFolder; 846 return newFolder;