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