some changes to RequestInventoryFile()

LSLKeyTest
UbitUmarov 2016-07-09 00:20:51 +01:00
parent 11a8a722df
commit fa9a4a9a2b
1 changed files with 38 additions and 40 deletions

View File

@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private byte[] m_inventoryFileData = new byte[0];
private byte[] m_inventoryFileNameBytes = new byte[0];
private string m_inventoryFileName = "";
private uint m_inventoryFileNameSerial = 0;
private bool m_inventoryPrivileged = false;
private object m_inventoryFileLock = new object();
@ -1112,18 +1114,34 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="xferManager"></param>
public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
{
lock (m_inventoryFileLock)
{
string filename = "inventory_" + UUID.Random().ToString() + ".tmp";
bool changed = false;
if (m_inventoryFileNameSerial < m_inventorySerial)
Items.LockItemsForRead(true);
if (m_inventorySerial == 0) // No inventory
{
Items.LockItemsForRead(false);
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return;
}
if (m_items.Count == 0) // No inventory
{
Items.LockItemsForRead(false);
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return;
}
if (m_inventoryFileNameSerial != m_inventorySerial)
{
m_inventoryFileNameSerial = m_inventorySerial;
changed = true;
}
Items.LockItemsForRead(false);
if (m_inventoryFileData.Length < 2)
changed = true;
@ -1134,32 +1152,11 @@ namespace OpenSim.Region.Framework.Scenes
if (m_inventoryPrivileged != includeAssets)
changed = true;
Items.LockItemsForRead(true);
if (m_inventorySerial == 0) // No inventory
{
Items.LockItemsForRead(false);
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return;
}
if (m_items.Count == 0) // No inventory
{
Items.LockItemsForRead(false);
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return;
}
if (!changed)
{
Items.LockItemsForRead(false);
xferManager.AddNewFile(filename,
m_inventoryFileData);
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
Util.StringToBytes256(filename));
m_inventoryFileNameBytes);
return;
}
@ -1168,6 +1165,8 @@ namespace OpenSim.Region.Framework.Scenes
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
Items.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_items.Values)
{
UUID ownerID = item.OwnerID;
@ -1222,9 +1221,10 @@ namespace OpenSim.Region.Framework.Scenes
if (m_inventoryFileData.Length > 2)
{
xferManager.AddNewFile(filename, m_inventoryFileData);
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
Util.StringToBytes256(filename));
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
m_inventoryFileNameBytes = Util.StringToBytes256(m_inventoryFileName);
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,m_inventoryFileNameBytes);
return;
}
@ -1267,26 +1267,22 @@ namespace OpenSim.Region.Framework.Scenes
AddNameValueLine("obj_id", folderID.ToString());
AddNameValueLine("parent_id", parentID.ToString());
AddNameValueLine("type", "category");
AddNameValueLine("name", "Contents|");
AddSectionEnd();
AddNameValueLine("name", "Contents|\n\t}");
}
public void AddItemStart()
{
BuildString.Append("\tinv_item\t0\n");
AddSectionStart();
BuildString.Append("\tinv_item\t0\n\t{\n");
}
public void AddPermissionsStart()
{
BuildString.Append("\tpermissions 0\n");
AddSectionStart();
BuildString.Append("\tpermissions 0\n\t{\n");
}
public void AddSaleStart()
{
BuildString.Append("\tsale_info\t0\n");
AddSectionStart();
BuildString.Append("\tsale_info\t0\n\t{\n");
}
protected void AddSectionStart()
@ -1307,8 +1303,10 @@ namespace OpenSim.Region.Framework.Scenes
public void AddNameValueLine(string name, string value)
{
BuildString.Append("\t\t");
BuildString.Append(name + "\t");
BuildString.Append(value + "\n");
BuildString.Append(name);
BuildString.Append("\t");
BuildString.Append(value);
BuildString.Append("\n");
}
public String GetString()