Show more meaningful error messages when failed to give an item to another user
parent
df49196e17
commit
1e5cff32fc
|
@ -496,12 +496,13 @@ namespace OpenSim.Groups
|
|||
Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp);
|
||||
|
||||
m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId);
|
||||
string message;
|
||||
InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId,
|
||||
giver, notice.noticeData.AttachmentItemID);
|
||||
giver, notice.noticeData.AttachmentItemID, out message);
|
||||
|
||||
if (itemCopy == null)
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
|
||||
remoteClient.SendAgentAlertMessage(message, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -865,18 +865,26 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID));
|
||||
if (item != null)
|
||||
{
|
||||
copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID);
|
||||
if (copyItem != null && client != null)
|
||||
string message;
|
||||
copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message);
|
||||
if (client != null)
|
||||
{
|
||||
m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
|
||||
client.SendBulkUpdateInventory(copyItem);
|
||||
if (copyItem != null)
|
||||
{
|
||||
m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
|
||||
client.SendBulkUpdateInventory(copyItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SendAgentAlertMessage(message, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID);
|
||||
if (client != null)
|
||||
client.SendAlertMessage("Failed to retrieve item");
|
||||
client.SendAgentAlertMessage("Failed to retrieve item", false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -180,8 +180,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
|
|||
"[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
|
||||
folderID, new UUID(im.toAgentID));
|
||||
|
||||
InventoryFolderBase folderCopy
|
||||
= scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero);
|
||||
InventoryFolderBase folderCopy
|
||||
= scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero);
|
||||
|
||||
if (folderCopy == null)
|
||||
{
|
||||
|
@ -217,13 +217,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
|
|||
"into agent {1}'s inventory",
|
||||
itemID, new UUID(im.toAgentID));
|
||||
|
||||
InventoryItemBase itemCopy = scene.GiveInventoryItem(
|
||||
new UUID(im.toAgentID),
|
||||
client.AgentId, itemID);
|
||||
string message;
|
||||
InventoryItemBase itemCopy = scene.GiveInventoryItem(new UUID(im.toAgentID), client.AgentId, itemID, out message);
|
||||
|
||||
if (itemCopy == null)
|
||||
{
|
||||
client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
|
||||
client.SendAgentAlertMessage(message, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
public partial class Scene
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly string LogHeader = "[SCENE INVENTORY]";
|
||||
|
||||
/// <summary>
|
||||
|
@ -534,9 +534,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="recipientClient"></param>
|
||||
/// <param name="senderId">ID of the sender of the item</param>
|
||||
/// <param name="itemId"></param>
|
||||
public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId)
|
||||
public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId, out string message)
|
||||
{
|
||||
InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId);
|
||||
InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId, out message);
|
||||
|
||||
if (itemCopy != null)
|
||||
recipientClient.SendBulkUpdateInventory(itemCopy);
|
||||
|
@ -549,9 +549,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="senderId">ID of the sender of the item</param>
|
||||
/// <param name="itemId"></param>
|
||||
/// <returns>The inventory item copy given, null if the give was unsuccessful</returns>
|
||||
public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId)
|
||||
public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId, out string message)
|
||||
{
|
||||
return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero);
|
||||
return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero, out message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -568,12 +568,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// The inventory item copy given, null if the give was unsuccessful
|
||||
/// </returns>
|
||||
public virtual InventoryItemBase GiveInventoryItem(
|
||||
UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId)
|
||||
UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId, out string message)
|
||||
{
|
||||
//Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
|
||||
|
||||
if (!Permissions.CanTransferUserInventory(itemId, senderId, recipient))
|
||||
{
|
||||
message = "Not allowed to transfer this item.";
|
||||
return null;
|
||||
}
|
||||
|
||||
InventoryItemBase item = new InventoryItemBase(itemId, senderId);
|
||||
item = InventoryService.GetItem(item);
|
||||
|
@ -582,6 +585,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
m_log.WarnFormat(
|
||||
"[AGENT INVENTORY]: Failed to find item {0} sent by {1} to {2}", itemId, senderId, recipient);
|
||||
message = string.Format("Item not found: {0}.", itemId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -590,6 +594,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_log.WarnFormat(
|
||||
"[AGENT INVENTORY]: Attempt to send item {0} {1} to {2} failed because sender {3} did not match item owner {4}",
|
||||
item.Name, item.ID, recipient, senderId, item.Owner);
|
||||
message = "Sender did not match item owner.";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -600,7 +605,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (!Permissions.BypassPermissions())
|
||||
{
|
||||
if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
|
||||
{
|
||||
message = "Item doesn't have the Transfer permission.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert a copy of the item into the recipient
|
||||
|
@ -736,9 +744,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
InventoryFolderBase root = InventoryService.GetRootFolder(recipient);
|
||||
|
||||
if (root != null)
|
||||
{
|
||||
itemCopy.Folder = root.ID;
|
||||
}
|
||||
else
|
||||
return null; // No destination
|
||||
{
|
||||
message = "Can't find a folder to add the item to.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,6 +776,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
message = null;
|
||||
return itemCopy;
|
||||
}
|
||||
|
||||
|
@ -780,7 +794,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <returns>
|
||||
/// The inventory folder copy given, null if the copy was unsuccessful
|
||||
/// </returns>
|
||||
public virtual InventoryFolderBase GiveInventoryFolder(
|
||||
public virtual InventoryFolderBase GiveInventoryFolder(IClientAPI client,
|
||||
UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId)
|
||||
{
|
||||
//// Retrieve the folder from the sender
|
||||
|
@ -815,13 +829,18 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
InventoryCollection contents = InventoryService.GetFolderContent(senderId, folderId);
|
||||
foreach (InventoryFolderBase childFolder in contents.Folders)
|
||||
{
|
||||
GiveInventoryFolder(recipientId, senderId, childFolder.ID, newFolder.ID);
|
||||
GiveInventoryFolder(client, recipientId, senderId, childFolder.ID, newFolder.ID);
|
||||
}
|
||||
|
||||
// Give all the items
|
||||
foreach (InventoryItemBase item in contents.Items)
|
||||
{
|
||||
GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID);
|
||||
string message;
|
||||
if (GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID, out message) == null)
|
||||
{
|
||||
if (client != null)
|
||||
client.SendAgentAlertMessage(message, false);
|
||||
}
|
||||
}
|
||||
|
||||
return newFolder;
|
||||
|
|
|
@ -95,7 +95,9 @@ namespace OpenSim.Region.Framework.Tests
|
|||
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
|
||||
InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
|
||||
|
||||
scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID);
|
||||
string message;
|
||||
|
||||
scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message);
|
||||
|
||||
InventoryItemBase retrievedItem1
|
||||
= UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1");
|
||||
|
@ -103,7 +105,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
Assert.That(retrievedItem1, Is.Not.Null);
|
||||
|
||||
// Try giving back the freshly received item
|
||||
scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID);
|
||||
scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message);
|
||||
|
||||
List<InventoryItemBase> reretrievedItems
|
||||
= UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1");
|
||||
|
@ -123,7 +125,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
InventoryFolderBase folder1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);
|
||||
|
||||
scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
|
||||
scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
|
||||
|
||||
InventoryFolderBase retrievedFolder1
|
||||
= UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1");
|
||||
|
@ -131,7 +133,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
Assert.That(retrievedFolder1, Is.Not.Null);
|
||||
|
||||
// Try giving back the freshly received folder
|
||||
scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero);
|
||||
scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero);
|
||||
|
||||
List<InventoryFolderBase> reretrievedFolders
|
||||
= UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1");
|
||||
|
|
|
@ -560,12 +560,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
|
|||
if (m_debugEnabled)
|
||||
m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId);
|
||||
|
||||
string message;
|
||||
InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId,
|
||||
giver, attachmentUUID);
|
||||
giver, attachmentUUID, out message);
|
||||
|
||||
if (itemCopy == null)
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
|
||||
remoteClient.SendAgentAlertMessage(message, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue