Make prim inventories a bit more sane
parent
a6a136bd90
commit
043dace118
|
@ -193,13 +193,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>
|
||||
|
|
|
@ -949,23 +949,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)
|
||||
{
|
||||
if (XferManager != null)
|
||||
{
|
||||
group.RequestInventoryFile(remoteClient, primLocalID, XferManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: Inventory requested of prim {0} which doesn't exist", primLocalID);
|
||||
}
|
||||
SceneObjectPart part = GetSceneObjectPart(primLocalID);
|
||||
if (part == null)
|
||||
return;
|
||||
|
||||
if (XferManager != null)
|
||||
part.Inventory.RequestInventoryFile(remoteClient, XferManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -80,49 +80,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>
|
||||
|
|
|
@ -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;
|
||||
|
||||
/// <value>
|
||||
|
@ -765,39 +766,16 @@ 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;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -806,19 +784,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);
|
||||
|
||||
bool includeAssets = false;
|
||||
if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
|
||||
includeAssets = true;
|
||||
|
||||
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;
|
||||
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
UUID ownerID = item.OwnerID;
|
||||
|
@ -868,14 +861,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
fileData = Utils.StringToBytes(invString.BuildString);
|
||||
int count = m_items.Count;
|
||||
|
||||
//m_log.Debug(Utils.BytesToString(fileData));
|
||||
//m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));
|
||||
m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
|
||||
|
||||
if (fileData.Length > 2)
|
||||
if (m_inventoryFileData.Length > 2)
|
||||
{
|
||||
xferManager.AddNewFile(m_inventoryFileName, fileData);
|
||||
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue