Make prim inventories a bit more sane

avinationmerge
Melanie 2010-12-21 20:47:00 +00:00
parent 11eabf0e51
commit 2f84f2171f
4 changed files with 39 additions and 110 deletions

View File

@ -195,13 +195,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// in this prim's inventory.</returns>
int RemoveInventoryItem(UUID itemID);
/// <summary>
/// Return the name with which a client can request a xfer of this prim's inventory metadata
/// </summary>
string GetInventoryFileName();
bool GetInventoryFileName(IClientAPI client, uint localID);
/// <summary>
/// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
/// </summary>

View File

@ -951,23 +951,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="primLocalID"></param>
public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
{
SceneObjectGroup group = GetGroupByPrim(primLocalID);
if (group != null)
{
bool fileChange = group.GetPartInventoryFileName(remoteClient, primLocalID);
if (fileChange)
{
SceneObjectPart part = GetSceneObjectPart(primLocalID);
if (part == null)
return;
if (XferManager != null)
{
group.RequestInventoryFile(remoteClient, primLocalID, XferManager);
}
}
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: Inventory requested of prim {0} which doesn't exist", primLocalID);
}
part.Inventory.RequestInventoryFile(remoteClient, XferManager);
}
/// <summary>

View File

@ -76,49 +76,6 @@ namespace OpenSim.Region.Framework.Scenes
parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="localID"></param>
public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
{
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
return part.Inventory.GetInventoryFileName(remoteClient, localID);
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
localID, Name, UUID);
}
return false;
}
/// <summary>
/// Return serialized inventory metadata for the given constituent prim
/// </summary>
/// <param name="localID"></param>
/// <param name="xferManager"></param>
public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager)
{
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
part.Inventory.RequestInventoryFile(client, xferManager);
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't find part {0} in object group {1}, {2} to request inventory data",
localID, Name, UUID);
}
}
/// <summary>
/// Add an inventory item to a prim in this group.
/// </summary>

View File

@ -46,6 +46,7 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_inventoryFileName = String.Empty;
private byte[] m_inventoryFileData = new byte[0];
private int m_inventoryFileNameSerial = 0;
private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
@ -930,40 +931,17 @@ namespace OpenSim.Region.Framework.Scenes
return -1;
}
public string GetInventoryFileName()
private bool CreateInventoryFileName()
{
if (m_inventoryFileName == String.Empty)
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
if (m_inventoryFileNameSerial < m_inventorySerial)
if (m_inventoryFileName == String.Empty ||
m_inventoryFileNameSerial < m_inventorySerial)
{
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
}
return m_inventoryFileName;
}
/// <summary>
/// Return the name with which a client can request a xfer of this prim's inventory metadata
/// </summary>
/// <param name="client"></param>
/// <param name="localID"></param>
public bool GetInventoryFileName(IClientAPI client, uint localID)
{
// m_log.DebugFormat(
// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}",
// client.AgentId, Name, UUID);
if (m_inventorySerial > 0)
{
client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
Utils.StringToBytes(GetInventoryFileName()));
return true;
}
else
{
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return false;
}
}
/// <summary>
/// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
@ -971,19 +949,34 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="xferManager"></param>
public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
{
byte[] fileData = new byte[0];
bool changed = CreateInventoryFileName();
// Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches
// what appears to happen in the Second Life protocol. If this isn't the case. then various functionality
// isn't available (such as drag from prim inventory to agent inventory)
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
lock (m_items)
{
if (m_inventorySerial == 0) // No inventory
{
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return;
}
client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
Util.StringToBytes256(m_inventoryFileName));
if (!changed)
{
if (m_inventoryFileData.Length > 2)
{
xferManager.AddNewFile(m_inventoryFileName,
m_inventoryFileData);
}
}
bool includeAssets = false;
if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
includeAssets = true;
lock (m_items)
{
foreach (TaskInventoryItem item in m_items.Values)
{
UUID ownerID = item.OwnerID;
@ -1032,17 +1025,14 @@ namespace OpenSim.Region.Framework.Scenes
invString.AddSectionEnd();
}
}
int count = m_items.Count;
m_items.LockItemsForRead(false);
fileData = Utils.StringToBytes(invString.BuildString);
m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
//m_log.Debug(Utils.BytesToString(fileData));
//m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));
if (fileData.Length > 2)
if (m_inventoryFileData.Length > 2)
{
xferManager.AddNewFile(m_inventoryFileName, fileData);
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
}
}