public GiveInventoryItem ( UUID recipient, UUID senderId, UUID itemId ) : InventoryItemBase | ||
recipient | UUID | |
senderId | UUID | ID of the sender of the item |
itemId | UUID | |
return | InventoryItemBase |
//////////////////////////////////////////////// // User-to-user inventory offers private void UserInventoryOffer(IClientAPI client, Scene scene, GridInstantMessage im) { InventoryFolderBase folder = null; InventoryItemBase item = null; UUID toAgentID = new UUID(im.toAgentID); IMuteListModule m_muteListModule = scene.RequestModuleInterface<IMuteListModule>(); if (m_muteListModule != null) { if (m_muteListModule.IsMuted(client.AgentId, toAgentID)) { client.SendAgentAlertMessage("Inventory offer was automatically declined.", false); return; // recipient has sender muted } } // Unpack the binary bucket AssetType assetType = (AssetType)im.binaryBucket[0]; UUID destID = new UUID(im.binaryBucket, 1); UUID copyID; bool isFolder = (assetType == AssetType.Folder); ScenePresence recipient = scene.GetScenePresence(toAgentID); if (recipient != null && recipient.IsBot) { client.SendAgentAlertMessage("Can't give inventory to bots.", false); return;//can't give objects to bots } if (assetType == AssetType.Folder) { folder = scene.GiveInventoryFolder(toAgentID, client.AgentId, destID, UUID.Zero); if (folder == null) { client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false); return; } copyID = folder.ID; } else { item = scene.GiveInventoryItem(toAgentID, client.AgentId, destID); if (item == null) { client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); return; } copyID = item.ID; } // m_log.InfoFormat("[AGENT INVENTORY]: Offering {0} {1} to user {2} inventory as {3}", isFolder ? "folder" : "item", destID, toAgentID, copyID); // Update the asset type and destination ID into the outgoing IM. im.binaryBucket = new byte[17]; im.binaryBucket[0] = (byte)assetType; Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); // Also stuff the destination ID into the session ID field for retrieval in accept/decline im.imSessionID = copyID.Guid; CachedUserInfo recipientInfo = scene.CommsManager.UserService.GetUserDetails(toAgentID); if (recipientInfo != null && recipient != null) { if ((!isFolder) && (item != null)) { // item offer? recipient.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } if (isFolder && (folder != null)) { // folder offer? folder = recipientInfo.GetFolder(folder.ID); if (folder != null) { recipient.ControllingClient.SendBulkUpdateInventory(folder); recipientInfo.SendInventoryDecendents(recipient.ControllingClient, folder.ID, false, true); } } } // Send the IM to the recipient. The item is already in their inventory, so // it will not be lost if they are offline. Transaction ID is the item ID. // We get that same ID back on the reply so we know what to act on. RelayInventoryOfferIM(scene, recipient, im); }