From 3eaaaa0d994c7c994d471d511127ed0ba66ab9bc Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 24 Dec 2010 08:50:00 -0800
Subject: One more pass at object inventory. This time, fix
SceneObjectPartInventory so that it makes sure that the file is added to
Xfer's before it signals the client to come and get it. This allows the
simplification of the logic of Xfer's.
---
.../Framework/Scenes/SceneObjectPartInventory.cs | 136 ++++++++++-----------
1 file changed, 68 insertions(+), 68 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 1177378..39ebaef 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -766,102 +766,102 @@ namespace OpenSim.Region.Framework.Scenes
return -1;
}
- private bool CreateInventoryFileName()
+ private bool CreateInventoryFile()
{
if (m_inventoryFileName == String.Empty ||
m_inventoryFileNameSerial < m_inventorySerial)
{
+ // Something changed, we need to create a new file
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
m_inventoryFileNameSerial = m_inventorySerial;
- return true;
- }
- return false;
- }
+ InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
- ///
- /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
- ///
- ///
- public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
- {
- bool changed = CreateInventoryFileName();
+ lock (m_items)
+ {
+ foreach (TaskInventoryItem item in m_items.Values)
+ {
+ UUID ownerID = item.OwnerID;
+ uint everyoneMask = 0;
+ uint baseMask = item.BasePermissions;
+ uint ownerMask = item.CurrentPermissions;
+ uint groupMask = item.GroupPermissions;
- InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
+ invString.AddItemStart();
+ invString.AddNameValueLine("item_id", item.ItemID.ToString());
+ invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
- lock (m_items)
- {
- if (m_inventorySerial == 0) // No inventory
- {
- client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
- return;
- }
+ invString.AddPermissionsStart();
- client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
- Util.StringToBytes256(m_inventoryFileName));
+ invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
+ invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
+ invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
+ invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
+ invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
- if (!changed)
- {
- if (m_inventoryFileData.Length > 2)
- {
- xferManager.AddNewFile(m_inventoryFileName,
- m_inventoryFileData);
- return;
- }
- }
+ invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
+ invString.AddNameValueLine("owner_id", ownerID.ToString());
- foreach (TaskInventoryItem item in m_items.Values)
- {
- UUID ownerID = item.OwnerID;
- uint everyoneMask = 0;
- uint baseMask = item.BasePermissions;
- uint ownerMask = item.CurrentPermissions;
- uint groupMask = item.GroupPermissions;
+ invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
- invString.AddItemStart();
- invString.AddNameValueLine("item_id", item.ItemID.ToString());
- invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
+ invString.AddNameValueLine("group_id", item.GroupID.ToString());
+ invString.AddSectionEnd();
- invString.AddPermissionsStart();
+ invString.AddNameValueLine("asset_id", item.AssetID.ToString());
+ invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
+ invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
+ invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
- invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
- invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
- invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
- invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
- invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
+ invString.AddSaleStart();
+ invString.AddNameValueLine("sale_type", "not");
+ invString.AddNameValueLine("sale_price", "0");
+ invString.AddSectionEnd();
- invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
- invString.AddNameValueLine("owner_id", ownerID.ToString());
+ invString.AddNameValueLine("name", item.Name + "|");
+ invString.AddNameValueLine("desc", item.Description + "|");
- invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
+ invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
+ invString.AddSectionEnd();
+ }
+ }
- invString.AddNameValueLine("group_id", item.GroupID.ToString());
- invString.AddSectionEnd();
+ m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
- invString.AddNameValueLine("asset_id", item.AssetID.ToString());
- invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
- invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
- invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
+ return true;
+ }
- invString.AddSaleStart();
- invString.AddNameValueLine("sale_type", "not");
- invString.AddNameValueLine("sale_price", "0");
- invString.AddSectionEnd();
+ // No need to recreate, the existing file is fine
+ return false;
+ }
- invString.AddNameValueLine("name", item.Name + "|");
- invString.AddNameValueLine("desc", item.Description + "|");
+ ///
+ /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
+ ///
+ ///
+ public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
+ {
+ bool changed = CreateInventoryFile();
- invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
- invString.AddSectionEnd();
- }
+ if (m_inventorySerial == 0) // No inventory
+ {
+ client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
+ return;
}
- m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
+ // In principle, we should only do the rest if the inventory changed;
+ // by sending m_inventorySerial to the client, it ought to know
+ // that nothing changed and that it doesn't need to request the file.
+ // Unfortunately, it doesn't look like the client optimizes this;
+ // the client seems to always come back and request the Xfer,
+ // no matter what value m_inventorySerial has.
if (m_inventoryFileData.Length > 2)
- {
+ // Add the file for Xfer
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
- }
+
+ // Tell the client we're ready to Xfer the file
+ client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
+ Util.StringToBytes256(m_inventoryFileName));
}
///
--
cgit v1.1