Example #1
0
        /// <summary>
        ///     Serialize all the metadata for the items in this prim's inventory ready for sending to the client
        /// </summary>
        /// <param name="client"></param>
        public void RequestInventoryFile(IClientAPI client)
        {
            IXfer xferManager = client.Scene.RequestModuleInterface <IXfer>();

            if (m_inventorySerial == 0)
            {
                //No inventory, no sending
                client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
                return;
            }
            //If update == true, we need to recreate the file for the client
            bool Update = GetInventoryFileName();

            if (!Update)
            {
                //We don't need to update the fileData, so just send the cached info and exit out of this method
                if (m_fileData.Length > 2)
                {
                    client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
                                             Utils.StringToBytes(m_inventoryFileName));

                    xferManager.AddNewFile(m_inventoryFileName, m_fileData);
                }
                else
                {
                    client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
                }
                return;
            }

            // 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;
            }

            List <TaskInventoryItem> items = m_items.Clone2List();

            foreach (TaskInventoryItem item in items)
            {
                UUID       ownerID      = item.OwnerID;
                const uint everyoneMask = 0;
                uint       baseMask     = item.BasePermissions;
                uint       ownerMask    = item.CurrentPermissions;
                uint       groupMask    = item.GroupPermissions;

                invString.AddItemStart();
                invString.AddNameValueLine("item_id", item.ItemID.ToString());
                invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                invString.AddPermissionsStart();

                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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                invString.AddNameValueLine("owner_id", ownerID.ToString());

                invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                invString.AddNameValueLine("group_id", item.GroupID.ToString());
                invString.AddSectionEnd();

                invString.AddNameValueLine("asset_id", includeAssets ? item.AssetID.ToString() : UUID.Zero.ToString());
                invString.AddNameValueLine("type", TaskInventoryItemHelpers.Types[item.Type]);
                invString.AddNameValueLine("inv_type", TaskInventoryItemHelpers.InvTypes[item.InvType]);
                invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));

                invString.AddSaleStart();
                invString.AddNameValueLine("sale_type", TaskInventoryItemHelpers.SaleTypes[item.SaleType]);
                invString.AddNameValueLine("sale_price", item.SalePrice.ToString());
                invString.AddSectionEnd();

                invString.AddNameValueLine("name", item.Name + "|");
                invString.AddNameValueLine("desc", item.Description + "|");

                invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                invString.AddSectionEnd();
            }
            string str = invString.GetString();

            if (str.Length > 0)
            {
                str = str.Substring(0, str.Length - 1);
            }
            m_fileData = Utils.StringToBytes(str);

            //MainConsole.Instance.Debug(Utils.BytesToString(fileData));
            //MainConsole.Instance.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));

            if (m_fileData.Length > 2)
            {
                client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
                                         Utils.StringToBytes(m_inventoryFileName));
                xferManager.AddNewFile(m_inventoryFileName, m_fileData);
            }
            else
            {
                client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
            }
        }
Example #2
0
        /// <summary>
        /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
        /// </summary>
        /// <param name="xferManager"></param>
        public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
        {
            byte[] fileData = new byte[0];

            // 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)
            {
                foreach (TaskInventoryItem item in m_items.Values)
                {
                    UUID ownerID      = item.OwnerID;
                    uint everyoneMask = 0;
                    uint baseMask     = item.BasePermissions;
                    uint ownerMask    = item.CurrentPermissions;

                    invString.AddItemStart();
                    invString.AddNameValueLine("item_id", item.ItemID.ToString());
                    invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                    invString.AddPermissionsStart();

                    invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
                    invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
                    invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0));
                    invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
                    invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));

                    invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
                    invString.AddNameValueLine("owner_id", ownerID.ToString());

                    invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                    invString.AddNameValueLine("group_id", item.GroupID.ToString());
                    invString.AddSectionEnd();

                    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.AddSaleStart();
                    invString.AddNameValueLine("sale_type", "not");
                    invString.AddNameValueLine("sale_price", "0");
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("name", item.Name + "|");
                    invString.AddNameValueLine("desc", item.Description + "|");

                    invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                    invString.AddSectionEnd();
                }
            }

            fileData = Utils.StringToBytes(invString.BuildString);

            //m_log.Debug(Utils.BytesToString(fileData));
            //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));

            if (fileData.Length > 2)
            {
                xferManager.AddNewFile(m_inventoryFileName, fileData);
            }
        }
Example #3
0
        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;

                InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);

                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;

                        invString.AddItemStart();
                        invString.AddNameValueLine("item_id", item.ItemID.ToString());
                        invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                        invString.AddPermissionsStart();

                        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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                        invString.AddNameValueLine("owner_id", ownerID.ToString());

                        invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                        invString.AddNameValueLine("group_id", item.GroupID.ToString());
                        invString.AddSectionEnd();

                        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.AddSaleStart();
                        invString.AddNameValueLine("sale_type", "not");
                        invString.AddNameValueLine("sale_price", "0");
                        invString.AddSectionEnd();

                        invString.AddNameValueLine("name", item.Name + "|");
                        invString.AddNameValueLine("desc", item.Description + "|");

                        invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                        invString.AddSectionEnd();
                    }
                }

                m_inventoryFileData = Utils.StringToBytes(invString.BuildString);

                return(true);
            }

            // No need to recreate, the existing file is fine
            return(false);
        }
        /// <summary>
        /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
        /// </summary>
        /// <param name="xferManager"></param>
        public void RequestInventoryFile(IClientAPI client)
        {
            IXfer xferManager = client.Scene.RequestModuleInterface<IXfer> ();
            if (m_inventorySerial == 0)
            {
                //No inventory, no sending
                client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
                return;
            }
            //If update == true, we need to recreate the file for the client
            bool Update = GetInventoryFileName();

            client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
                                     Utils.StringToBytes(m_inventoryFileName));

            if (!Update)
            {
                //We don't need to update the fileData, so just send the cached info and exit out of this method
                if (m_fileData.Length > 2)
                {
                    xferManager.AddNewFile(m_inventoryFileName, m_fileData);
                }
                return;
            }

            // 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;

            List<TaskInventoryItem> items = (List<TaskInventoryItem>)m_items.Clone2List();
            lock (items)
            {
                foreach (TaskInventoryItem item in items)
                {
                    UUID ownerID = item.OwnerID;
                    uint everyoneMask = 0;
                    uint baseMask = item.BasePermissions;
                    uint ownerMask = item.CurrentPermissions;
                    uint groupMask = item.GroupPermissions;

                    invString.AddItemStart();
                    invString.AddNameValueLine("item_id", item.ItemID.ToString());
                    invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                    invString.AddPermissionsStart();

                    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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                    invString.AddNameValueLine("owner_id", ownerID.ToString());

                    invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                    invString.AddNameValueLine("group_id", item.GroupID.ToString());
                    invString.AddSectionEnd();

                    if (includeAssets)
                        invString.AddNameValueLine("asset_id", item.AssetID.ToString());
                    else
                        invString.AddNameValueLine("asset_id", UUID.Zero.ToString());
                    invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
                    invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
                    invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));

                    invString.AddSaleStart();
                    invString.AddNameValueLine("sale_type", TaskInventoryItem.SaleTypes[item.SaleType]);
                    invString.AddNameValueLine("sale_price", item.SalePrice.ToString());
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("name", item.Name + "|");
                    invString.AddNameValueLine("desc", item.Description + "|");

                    invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                    invString.AddSectionEnd();
                }
            }
            m_fileData = Utils.StringToBytes(invString.BuildString.ToString());

            //m_log.Debug(Utils.BytesToString(fileData));
            //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));

            if (m_fileData.Length > 2)
            {
                xferManager.AddNewFile(m_inventoryFileName, m_fileData);
            }
        }
        /// <summary>
        /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
        /// </summary>
        /// <param name="xferManager"></param>
        public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
        {
            byte[] fileData = new byte[0];

            // 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)
            {
                foreach (TaskInventoryItem item in m_items.Values)
                {
                    UUID ownerID = item.OwnerID;
                    uint everyoneMask = 0;
                    uint baseMask = item.BasePermissions;
                    uint ownerMask = item.CurrentPermissions;

                    invString.AddItemStart();
                    invString.AddNameValueLine("item_id", item.ItemID.ToString());
                    invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                    invString.AddPermissionsStart();

                    invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
                    invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
                    invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0));
                    invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
                    invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));

                    invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
                    invString.AddNameValueLine("owner_id", ownerID.ToString());

                    invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                    invString.AddNameValueLine("group_id", item.GroupID.ToString());
                    invString.AddSectionEnd();

                    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.AddSaleStart();
                    invString.AddNameValueLine("sale_type", "not");
                    invString.AddNameValueLine("sale_price", "0");
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("name", item.Name + "|");
                    invString.AddNameValueLine("desc", item.Description + "|");

                    invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                    invString.AddSectionEnd();
                }
            }

            fileData = Utils.StringToBytes(invString.BuildString);

            //m_log.Debug(Utils.BytesToString(fileData));
            //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));

            if (fileData.Length > 2)
            {
                xferManager.AddNewFile(m_inventoryFileName, fileData);
            }
        }
        /// <summary>
        /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
        /// </summary>
        /// <param name="xferManager"></param>
        public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
        {
            byte[] fileData = new byte[0];

            if (m_inventorySerial <= 0) // no inventory to send
            {
                client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
                return;   // client notified above
            }

            // 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)
            {
//                int items = 0;
                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;
                    string itemID;
                    string desc;
                    
                    // only the owner of the item can see the UUIDs of Contents and possibly private data
                    if (ownerID == client.AgentId)
                    {
                        itemID = item.AssetID.ToString();
                        desc = item.Description;
//                        m_log.DebugFormat("[ASSETS]: RequestInventoryFile returning item #{0} itemID {1} asset {2}", ++items, item.ItemID, item.AssetID);
                    }
                    else
                    {
                        itemID = UUID.Zero.ToString();
                        desc = "(not owner)";
                    }

                    invString.AddSectionEnd();

                    invString.AddItemStart();
                    invString.AddNameValueLine("item_id", item.ItemID.ToString());
                    invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                    invString.AddPermissionsStart();

                    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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                    invString.AddNameValueLine("owner_id", ownerID.ToString());

                    invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                    invString.AddNameValueLine("group_id", item.GroupID.ToString());
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("asset_id", itemID);
                    invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
                    invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
                    invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));

                    invString.AddSaleStart();
                    invString.AddNameValueLine("sale_type", "not");
                    invString.AddNameValueLine("sale_price", "0");
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("name", item.Name + "|");
                    invString.AddNameValueLine("desc", desc + "|");

                    invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                    invString.AddSectionEnd();
                }
            }
            invString.AddEnd();

            fileData = Utils.StringToBytes(invString.BuildString.ToString());
            if (fileData.Length > 2)
            {
                // There is inventory to send. Allocate temp file.
                UpdateInventoryTempFileName(xferManager);
                // Add the data to the NewFiles list and await the viewer request for it.
                xferManager.AddNewFile(m_inventoryFileName, fileData);
                // Notify the viewer of the available file download.
                client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Utils.StringToBytes(m_inventoryFileName));
            }
        }
        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;

                InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);

                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;

                        invString.AddItemStart();
                        invString.AddNameValueLine("item_id", item.ItemID.ToString());
                        invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                        invString.AddPermissionsStart();

                        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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                        invString.AddNameValueLine("owner_id", ownerID.ToString());

                        invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                        invString.AddNameValueLine("group_id", item.GroupID.ToString());
                        invString.AddSectionEnd();

                        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.AddSaleStart();
                        invString.AddNameValueLine("sale_type", "not");
                        invString.AddNameValueLine("sale_price", "0");
                        invString.AddSectionEnd();

                        invString.AddNameValueLine("name", item.Name + "|");
                        invString.AddNameValueLine("desc", item.Description + "|");

                        invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                        invString.AddSectionEnd();
                    }
                }

                m_inventoryFileData = Utils.StringToBytes(invString.BuildString);

                return true;
            }

            // No need to recreate, the existing file is fine
            return false;
        }
        /// <summary>
        /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
        /// </summary>
        /// <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)
                {
                    m_inventoryFileNameSerial = m_inventorySerial;
                    changed = true;
                }

                if (m_inventoryFileData.Length < 2)
                    changed = true;

                bool includeAssets = false;
                if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
                    includeAssets = true;

                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);
                    client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
                            Util.StringToBytes256(filename));

                    return;
                }

                m_inventoryPrivileged = includeAssets;

                InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);

                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.AddItemStart();
                    invString.AddNameValueLine("item_id", item.ItemID.ToString());
                    invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                    invString.AddPermissionsStart();

                    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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                    invString.AddNameValueLine("owner_id", ownerID.ToString());

                    invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                    invString.AddNameValueLine("group_id", item.GroupID.ToString());
                    invString.AddSectionEnd();

                    if (includeAssets)
                        invString.AddNameValueLine("asset_id", item.AssetID.ToString());
                    else
                        invString.AddNameValueLine("asset_id", UUID.Zero.ToString());
                    invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type));
                    invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType));
                    invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));

                    invString.AddSaleStart();
                    invString.AddNameValueLine("sale_type", "not");
                    invString.AddNameValueLine("sale_price", "0");
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("name", item.Name + "|");
                    invString.AddNameValueLine("desc", item.Description + "|");

                    invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                    invString.AddSectionEnd();
                }

                Items.LockItemsForRead(false);

                m_inventoryFileData = Utils.StringToBytes(invString.BuildString);

                if (m_inventoryFileData.Length > 2)
                {
                    xferManager.AddNewFile(filename, m_inventoryFileData);
                    client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
                            Util.StringToBytes256(filename));
                    return;
                }

                client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
            }
        }
        private bool CreateInventoryFile()
        {
//            m_log.DebugFormat(
//                "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}",
//                m_part.Name, m_part.UUID, m_part.LocalId, m_inventorySerial);

            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;

                InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);

                m_items.ForEach(delegate(TaskInventoryItem item)
                {
//                        m_log.DebugFormat(
//                            "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}",
//                            item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId);

                    UUID ownerID = item.OwnerID;
                    uint everyoneMask = 0;
                    uint baseMask = item.BasePermissions;
                    uint ownerMask = item.CurrentPermissions;
                    uint groupMask = item.GroupPermissions;

                    invString.AddItemStart();
                    invString.AddNameValueLine("item_id", item.ItemID.ToString());
                    invString.AddNameValueLine("parent_id", m_part.UUID.ToString());

                    invString.AddPermissionsStart();

                    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.AddNameValueLine("creator_id", item.CreatorID.ToString());
                    invString.AddNameValueLine("owner_id", ownerID.ToString());

                    invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());

                    invString.AddNameValueLine("group_id", item.GroupID.ToString());
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("asset_id", item.AssetID.ToString());
                    invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type));
                    invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType));
                    invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));

                    invString.AddSaleStart();
                    invString.AddNameValueLine("sale_type", "not");
                    invString.AddNameValueLine("sale_price", "0");
                    invString.AddSectionEnd();

                    invString.AddNameValueLine("name", item.Name + "|");
                    invString.AddNameValueLine("desc", item.Description + "|");

                    invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
                    invString.AddSectionEnd();
                });

                m_inventoryFileData = Utils.StringToBytes(invString.BuildString);

                return true;
            }

            // No need to recreate, the existing file is fine
            return false;
        }