Create Scene.Inventory.cs.AddInventoryItem(InventoryItemBase item)

The agentID in AddInventoryItem(UUID agentID, InventoryItemBase item) is redundant since it's contained in item.Owner, and it doesn't make sense for agentID != item.Owner, hence the method is deprecated.
prebuild-update
Justin Clark-Casey (justincc) 2010-09-04 00:09:53 +01:00
parent d4b572d2a5
commit 107052b23d
3 changed files with 33 additions and 14 deletions

View File

@ -163,7 +163,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryFolderBase objsFolder InventoryFolderBase objsFolder
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
item1.Folder = objsFolder.ID; item1.Folder = objsFolder.ID;
scene.AddInventoryItem(userId, item1); scene.AddInventoryItem(item1);
MemoryStream archiveWriteStream = new MemoryStream(); MemoryStream archiveWriteStream = new MemoryStream();
archiverModule.OnInventoryArchiveSaved += SaveCompleted; archiverModule.OnInventoryArchiveSaved += SaveCompleted;
@ -282,7 +282,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryFolderBase objsFolder InventoryFolderBase objsFolder
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
item1.Folder = objsFolder.ID; item1.Folder = objsFolder.ID;
scene.AddInventoryItem(userId, item1); scene.AddInventoryItem(item1);
MemoryStream archiveWriteStream = new MemoryStream(); MemoryStream archiveWriteStream = new MemoryStream();
archiverModule.OnInventoryArchiveSaved += SaveCompleted; archiverModule.OnInventoryArchiveSaved += SaveCompleted;
@ -485,7 +485,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
InventoryFolderBase objsFolder InventoryFolderBase objsFolder
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
item1.Folder = objsFolder.ID; item1.Folder = objsFolder.ID;
scene.AddInventoryItem(userId, item1); scene.AddInventoryItem(item1);
MemoryStream archiveWriteStream = new MemoryStream(); MemoryStream archiveWriteStream = new MemoryStream();
archiverModule.OnInventoryArchiveSaved += SaveCompleted; archiverModule.OnInventoryArchiveSaved += SaveCompleted;

View File

@ -242,9 +242,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
} }
else else
{ {
// m_log.WarnFormat( m_log.WarnFormat(
// "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified",
// item.Owner, item.Name); item.Owner, item.Name);
return false; return false;
} }
} }

View File

@ -92,25 +92,44 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void AddInventoryItem(UUID AgentID, InventoryItemBase item) /// <summary>
/// Add the given inventory item to a user's inventory.
/// </summary>
/// <param name="item"></param>
public void AddInventoryItem(InventoryItemBase item)
{ {
if (InventoryService.AddItem(item)) if (InventoryService.AddItem(item))
{ {
int userlevel = 0; int userlevel = 0;
if (Permissions.IsGod(AgentID)) if (Permissions.IsGod(item.Owner))
{ {
userlevel = 1; userlevel = 1;
} }
EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel);
} }
else else
{ {
m_log.WarnFormat( m_log.WarnFormat(
"[AGENT INVENTORY]: Agent {0} could not add item {1} {2}", "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}",
AgentID, item.Name, item.ID); item.Owner, item.Name, item.ID);
return; return;
} }
}
/// <summary>
/// Add the given inventory item to a user's inventory.
/// </summary>
/// <param name="AgentID">
/// A <see cref="UUID"/>
/// </param>
/// <param name="item">
/// A <see cref="InventoryItemBase"/>
/// </param>
[Obsolete("Use AddInventoryItem(InventoryItemBase item) instead. This was deprecated in OpenSim 0.7.1")]
public void AddInventoryItem(UUID AgentID, InventoryItemBase item)
{
AddInventoryItem(item);
} }
/// <summary> /// <summary>
@ -121,7 +140,7 @@ namespace OpenSim.Region.Framework.Scenes
/// in which the item is to be placed.</param> /// in which the item is to be placed.</param>
public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
{ {
AddInventoryItem(remoteClient.AgentId, item); AddInventoryItem(item);
remoteClient.SendInventoryItemCreateUpdate(item, 0); remoteClient.SendInventoryItemCreateUpdate(item, 0);
} }
@ -1108,7 +1127,7 @@ namespace OpenSim.Region.Framework.Scenes
agentItem.Folder = folderId; agentItem.Folder = folderId;
AddInventoryItem(avatarId, agentItem); AddInventoryItem(agentItem);
return agentItem; return agentItem;
} }
@ -1232,7 +1251,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
agentItem.Folder = newFolderID; agentItem.Folder = newFolderID;
AddInventoryItem(destID, agentItem); AddInventoryItem(agentItem);
} }
} }