aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorOren Hurvitz2014-05-05 11:06:49 +0300
committerOren Hurvitz2014-05-06 07:28:44 +0100
commit1e5cff32fc41356971d6ad601cbee7ad62472c76 (patch)
treebe61c0ae3f814ec2a54d1b0ef63d42f86fce2600 /OpenSim
parentLog whenever an inventory operation is blocked because the item/folder isn't ... (diff)
downloadopensim-SC-1e5cff32fc41356971d6ad601cbee7ad62472c76.zip
opensim-SC-1e5cff32fc41356971d6ad601cbee7ad62472c76.tar.gz
opensim-SC-1e5cff32fc41356971d6ad601cbee7ad62472c76.tar.bz2
opensim-SC-1e5cff32fc41356971d6ad601cbee7ad62472c76.tar.xz
Show more meaningful error messages when failed to give an item to another user
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Addons/Groups/GroupsModule.cs5
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs18
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs39
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs10
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs5
6 files changed, 59 insertions, 29 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index f11606a..2831326 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -496,12 +496,13 @@ namespace OpenSim.Groups
496 Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp); 496 Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp);
497 497
498 m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); 498 m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId);
499 string message;
499 InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, 500 InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId,
500 giver, notice.noticeData.AttachmentItemID); 501 giver, notice.noticeData.AttachmentItemID, out message);
501 502
502 if (itemCopy == null) 503 if (itemCopy == null)
503 { 504 {
504 remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); 505 remoteClient.SendAgentAlertMessage(message, false);
505 return; 506 return;
506 } 507 }
507 508
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 79bc5ef..0eb15f8 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -865,18 +865,26 @@ namespace OpenSim.Region.ClientStack.Linden
865 item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); 865 item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID));
866 if (item != null) 866 if (item != null)
867 { 867 {
868 copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); 868 string message;
869 if (copyItem != null && client != null) 869 copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message);
870 if (client != null)
870 { 871 {
871 m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); 872 if (copyItem != null)
872 client.SendBulkUpdateInventory(copyItem); 873 {
874 m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
875 client.SendBulkUpdateInventory(copyItem);
876 }
877 else
878 {
879 client.SendAgentAlertMessage(message, false);
880 }
873 } 881 }
874 } 882 }
875 else 883 else
876 { 884 {
877 m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); 885 m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID);
878 if (client != null) 886 if (client != null)
879 client.SendAlertMessage("Failed to retrieve item"); 887 client.SendAgentAlertMessage("Failed to retrieve item", false);
880 } 888 }
881 } 889 }
882 catch (Exception e) 890 catch (Exception e)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 0b10dd8..c632798 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -180,8 +180,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
180 "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", 180 "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
181 folderID, new UUID(im.toAgentID)); 181 folderID, new UUID(im.toAgentID));
182 182
183 InventoryFolderBase folderCopy 183 InventoryFolderBase folderCopy
184 = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); 184 = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero);
185 185
186 if (folderCopy == null) 186 if (folderCopy == null)
187 { 187 {
@@ -217,13 +217,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
217 "into agent {1}'s inventory", 217 "into agent {1}'s inventory",
218 itemID, new UUID(im.toAgentID)); 218 itemID, new UUID(im.toAgentID));
219 219
220 InventoryItemBase itemCopy = scene.GiveInventoryItem( 220 string message;
221 new UUID(im.toAgentID), 221 InventoryItemBase itemCopy = scene.GiveInventoryItem(new UUID(im.toAgentID), client.AgentId, itemID, out message);
222 client.AgentId, itemID);
223 222
224 if (itemCopy == null) 223 if (itemCopy == null)
225 { 224 {
226 client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); 225 client.SendAgentAlertMessage(message, false);
227 return; 226 return;
228 } 227 }
229 228
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;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index e50b4da..0736278 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -95,7 +95,9 @@ namespace OpenSim.Region.Framework.Tests
95 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 95 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
96 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); 96 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
97 97
98 scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); 98 string message;
99
100 scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message);
99 101
100 InventoryItemBase retrievedItem1 102 InventoryItemBase retrievedItem1
101 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); 103 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1");
@@ -103,7 +105,7 @@ namespace OpenSim.Region.Framework.Tests
103 Assert.That(retrievedItem1, Is.Not.Null); 105 Assert.That(retrievedItem1, Is.Not.Null);
104 106
105 // Try giving back the freshly received item 107 // Try giving back the freshly received item
106 scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); 108 scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message);
107 109
108 List<InventoryItemBase> reretrievedItems 110 List<InventoryItemBase> reretrievedItems
109 = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); 111 = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1");
@@ -123,7 +125,7 @@ namespace OpenSim.Region.Framework.Tests
123 InventoryFolderBase folder1 125 InventoryFolderBase folder1
124 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false); 126 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);
125 127
126 scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); 128 scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
127 129
128 InventoryFolderBase retrievedFolder1 130 InventoryFolderBase retrievedFolder1
129 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1"); 131 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1");
@@ -131,7 +133,7 @@ namespace OpenSim.Region.Framework.Tests
131 Assert.That(retrievedFolder1, Is.Not.Null); 133 Assert.That(retrievedFolder1, Is.Not.Null);
132 134
133 // Try giving back the freshly received folder 135 // Try giving back the freshly received folder
134 scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); 136 scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero);
135 137
136 List<InventoryFolderBase> reretrievedFolders 138 List<InventoryFolderBase> reretrievedFolders
137 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1"); 139 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1");
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index fc8cae2..f34152c 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -560,12 +560,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
560 if (m_debugEnabled) 560 if (m_debugEnabled)
561 m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); 561 m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId);
562 562
563 string message;
563 InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, 564 InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId,
564 giver, attachmentUUID); 565 giver, attachmentUUID, out message);
565 566
566 if (itemCopy == null) 567 if (itemCopy == null)
567 { 568 {
568 remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); 569 remoteClient.SendAgentAlertMessage(message, false);
569 return; 570 return;
570 } 571 }
571 572