public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems) { if (this._agentsInventory.ContainsKey(userInfo.AgentID)) { AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; for (int i = 0; i < FetchItems.InventoryData.Length; i++) { if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) { InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); InventoryReply.AgentData.AgentID = userInfo.AgentID; InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); InventoryReply.InventoryData[0].ItemID = Item.ItemID; InventoryReply.InventoryData[0].AssetID = Item.AssetID; InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].Flags = 0; InventoryReply.InventoryData[0].FolderID = Item.FolderID; InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].InvType = Item.InvType; InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].SalePrice = 100; InventoryReply.InventoryData[0].SaleType = 0; InventoryReply.InventoryData[0].Type = Item.Type; InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); userInfo.OutPacket(InventoryReply); } } } }
private void InventoryCallBack(InventoryItemBase item) { Console.WriteLine("[InventoryClient]: InventoryCallBack"); const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); //(FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply); // TODO: don't create new blocks if recycling an old packet inventoryReply.AgentData.AgentID = item.Owner; inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); inventoryReply.InventoryData[0].ItemID = item.ID; inventoryReply.InventoryData[0].AssetID = item.AssetID; inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid; inventoryReply.InventoryData[0].BaseMask = item.BasePermissions; inventoryReply.InventoryData[0].CreationDate = item.CreationDate; inventoryReply.InventoryData[0].Description = StringToPacketBytes(item.Description); inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions; inventoryReply.InventoryData[0].FolderID = item.Folder; inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType; inventoryReply.InventoryData[0].Name = StringToPacketBytes(item.Name); inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions; inventoryReply.InventoryData[0].OwnerID = item.Owner; inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions; inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType; inventoryReply.InventoryData[0].GroupID = item.GroupID; inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned; inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions; inventoryReply.InventoryData[0].Flags = item.Flags; inventoryReply.InventoryData[0].SalePrice = item.SalePrice; inventoryReply.InventoryData[0].SaleType = item.SaleType; inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); inventoryReply.Header.Zerocoded = true; //OutPacket(inventoryReply, ThrottleOutPacketType.Asset); proxy.InjectPacket(inventoryReply, Direction.Incoming); }
void FetchInventoryHandler(Packet packet, LLAgent agent) { FetchInventoryPacket fetch = (FetchInventoryPacket)packet; // Fetch all of the items from the inventory server Dictionary<UUID, InventoryBase> items = FetchInventoryItems(agent, fetch.InventoryData); FetchInventoryReplyPacket reply = new FetchInventoryReplyPacket(); reply.AgentData.AgentID = agent.ID; List<FetchInventoryReplyPacket.InventoryDataBlock> replies = new List<FetchInventoryReplyPacket.InventoryDataBlock>(); for (int i = 0; i < fetch.InventoryData.Length; i++) { UUID itemID = fetch.InventoryData[i].ItemID; InventoryBase obj; if (itemID != UUID.Zero) { FetchInventoryReplyPacket.InventoryDataBlock block = new FetchInventoryReplyPacket.InventoryDataBlock(); block.ItemID = itemID; if (items.TryGetValue(itemID, out obj) && obj is InventoryItem) { LLInventoryItem item = new LLInventoryItem((InventoryItem)obj); Permissions perms = item.Permissions; block.AssetID = item.AssetID; block.BaseMask = (uint)perms.BaseMask; block.CRC = item.CRC(); block.CreationDate = (int)Utils.DateTimeToUnixTime(item.CreationDate); block.CreatorID = item.CreatorID; block.Description = Utils.StringToBytes(item.Description); block.EveryoneMask = (uint)perms.EveryoneMask; block.Flags = item.Flags; block.FolderID = item.ParentID; block.GroupID = item.GroupID; block.GroupMask = (uint)perms.GroupMask; block.GroupOwned = item.GroupOwned; block.InvType = (sbyte)item.InventoryType; block.Name = Utils.StringToBytes(item.Name); block.NextOwnerMask = (uint)perms.NextOwnerMask; block.OwnerID = item.OwnerID; block.OwnerMask = (uint)perms.OwnerMask; block.SalePrice = item.SalePrice; block.SaleType = (byte)item.SaleType; block.Type = (sbyte)item.AssetType; } else { m_log.Warn("FetchInventory failed for item " + itemID); block.Name = Utils.EmptyBytes; block.Description = Utils.EmptyBytes; } replies.Add(block); } } if (replies.Count > 0) { reply.InventoryData = replies.ToArray(); m_udp.SendPacket(agent, reply, ThrottleCategory.Task, true); } }