Exemplo n.º 1
0
        internal InventoryItem(InventoryManager manager, InventoryDescendentsPacket.ItemDataBlock itemData)
            : base(manager)
        {
            _Name         = System.Text.Encoding.UTF8.GetString(itemData.Name).Trim().Replace("\0", "");
            _Description  = System.Text.Encoding.UTF8.GetString(itemData.Description).Trim().Replace("\0", "");
            _CreationDate = itemData.CreationDate;

            _InvType = itemData.InvType;
            _Type    = itemData.Type;

            _ItemID   = itemData.ItemID;
            _AssetID  = itemData.AssetID;
            _FolderID = itemData.FolderID;

            _GroupOwned = itemData.GroupOwned;
            _GroupID    = itemData.GroupID;
            _GroupMask  = itemData.GroupMask;

            _CreatorID = itemData.CreatorID;
            _OwnerID   = itemData.OwnerID;
            _OwnerMask = itemData.OwnerMask;


            _Flags         = itemData.Flags;
            _BaseMask      = itemData.BaseMask;
            _EveryoneMask  = itemData.EveryoneMask;
            _NextOwnerMask = itemData.NextOwnerMask;

            _SaleType  = itemData.SaleType;
            _SalePrice = itemData.SalePrice;

            _CRC = itemData.CRC;
        }
Exemplo n.º 2
0
        void FetchInventoryDescendentsHandler(Packet packet, LLAgent agent)
        {
            FetchInventoryDescendentsPacket fetch = (FetchInventoryDescendentsPacket)packet;
            bool sendFolders = fetch.InventoryData.FetchFolders;
            bool sendItems = fetch.InventoryData.FetchItems;
            // TODO: Obey SortOrder
            InventorySortOrder order = (InventorySortOrder)fetch.InventoryData.SortOrder;
            // TODO: Use OwnerID, for library access only

            InventoryBase invObject;
            if (m_inventoryClient.TryGetInventory(agent.ID, fetch.InventoryData.FolderID, out invObject) && invObject is InventoryFolder)
            {
                InventoryFolder folder = (InventoryFolder)invObject;

                List<InventoryItem> items = new List<InventoryItem>();
                List<InventoryFolder> folders = new List<InventoryFolder>();
                int descendCount = folder.Children.Count;
                int version = folder.Version;

                InventoryDescendentsPacket descendents = new InventoryDescendentsPacket();
                descendents.AgentData.AgentID = agent.ID;
                descendents.AgentData.FolderID = folder.ID;
                descendents.AgentData.OwnerID = folder.OwnerID;
                descendents.AgentData.Descendents = descendCount;
                descendents.AgentData.Version = version;

                if (sendItems || sendFolders)
                {
                    // Create a list of all of the folders and items under this folder
                    lock (folder.Children)
                    {
                        foreach (InventoryBase obj in folder.Children.Values)
                        {
                            if (obj is InventoryItem)
                                items.Add((InventoryItem)obj);
                            else
                                folders.Add((InventoryFolder)obj);
                        }
                    }
                }

                if (sendFolders)
                {
                    descendents.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count];
                    for (int i = 0; i < folders.Count; i++)
                    {
                        InventoryFolder currentFolder = folders[i];

                        descendents.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock();
                        descendents.FolderData[i].FolderID = currentFolder.ID;
                        descendents.FolderData[i].Name = Utils.StringToBytes(currentFolder.Name);
                        descendents.FolderData[i].ParentID = currentFolder.ParentID;
                        descendents.FolderData[i].Type = LLUtil.ContentTypeToLLAssetType(currentFolder.PreferredContentType);
                    }
                }
                else
                {
                    descendents.FolderData = new InventoryDescendentsPacket.FolderDataBlock[0];

                    /*descendents.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
                    descendents.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
                    descendents.FolderData[0].FolderID = folder.ID;
                    descendents.FolderData[0].Name = Utils.StringToBytes(folder.Name);
                    descendents.FolderData[0].ParentID = folder.ParentID;
                    descendents.FolderData[0].Type = Util.ContentTypeToLLAssetType(folder.PreferredContentType);*/
                }

                if (sendItems)
                {
                    descendents.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count];
                    for (int i = 0; i < items.Count; i++)
                    {
                        LLInventoryItem currentItem = new LLInventoryItem(items[i]);

                        InventoryDescendentsPacket.ItemDataBlock block = new InventoryDescendentsPacket.ItemDataBlock();
                        block.AssetID = currentItem.AssetID;
                        block.BaseMask = (uint)currentItem.Permissions.BaseMask;
                        block.CRC = currentItem.CRC();
                        block.CreationDate = (int)Utils.DateTimeToUnixTime(currentItem.CreationDate);
                        block.CreatorID = currentItem.CreatorID;
                        block.Description = Utils.StringToBytes(currentItem.Description);
                        block.EveryoneMask = (uint)currentItem.Permissions.EveryoneMask;
                        block.Flags = currentItem.Flags;
                        block.FolderID = currentItem.ParentID;
                        block.GroupID = currentItem.GroupID;
                        block.GroupMask = (uint)currentItem.Permissions.GroupMask;
                        block.GroupOwned = currentItem.GroupOwned;
                        block.InvType = (sbyte)currentItem.InventoryType;
                        block.ItemID = currentItem.ID;
                        block.Name = Utils.StringToBytes(currentItem.Name);
                        block.NextOwnerMask = (uint)currentItem.Permissions.NextOwnerMask;
                        block.OwnerID = currentItem.OwnerID;
                        block.OwnerMask = (uint)currentItem.Permissions.OwnerMask;
                        block.SalePrice = currentItem.SalePrice;
                        block.SaleType = (byte)currentItem.SaleType;
                        block.Type = (sbyte)currentItem.AssetType;

                        // Handle inventory links
                        InventoryType linkedInvType = currentItem.LinkedInventoryType;
                        if (linkedInvType != InventoryType.Unknown)
                            block.InvType = (sbyte)linkedInvType;

                        descendents.ItemData[i] = block;
                    }
                }
                else
                {
                    descendents.ItemData = new InventoryDescendentsPacket.ItemDataBlock[0];
                }

                m_udp.SendPacket(agent, descendents, ThrottleCategory.Task, false);
            }
            else
            {
                m_log.Warn("FetchInventoryDescendents called for an unknown folder " + fetch.InventoryData.FolderID);
            }
        }