private void RemoveLink() { CachedUserInfo userInfo = _scene.CommsManager.UserService.GetUserDetails(_avatarID); if (userInfo == null) { return; } InventoryFolderBase CurrentOutfitFolder = GetCurrentOutfitFolder(userInfo); if (CurrentOutfitFolder == null) { return; //No COF, just ignore } userInfo.UpdateFolder(CurrentOutfitFolder); //Update the versionID foreach (InventoryItemBase cofItem in CurrentOutfitFolder.Items) { if (cofItem.AssetID == _wearableInventoryItemID) { userInfo.DeleteItem(cofItem); } } ScenePresence presence; if ((presence = _scene.GetScenePresence(_avatarID)) != null) { presence.ControllingClient.SendInventoryFolderDetails(presence.UUID, CurrentOutfitFolder, GetCurrentOutfitFolder(userInfo).Items, new List <InventoryFolderBase>(), false, true); } }
private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { m_log.InfoFormat("OnInstantMessage {0}", im.dialog); Scene scene = FindClientScene(client.AgentId); if (scene == null) // Something seriously wrong here. { return; } if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) { //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); UUID copyID; // First byte is the asset type AssetType assetType = (AssetType)im.binaryBucket[0]; if (AssetType.Folder == assetType) { UUID folderID = new UUID(im.binaryBucket, 1); m_log.DebugFormat("[AGENT INVENTORY]: Inserting original folder {0} " + "into agent {1}'s inventory", folderID, new UUID(im.toAgentID)); InventoryFolderImpl folderCopy = scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero); if (folderCopy == null) { client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false); return; } // The outgoing binary bucket should contain only the byte which signals an asset folder is // being copied and the following bytes for the copied folder's UUID copyID = folderCopy.ID; byte[] copyIDBytes = copyID.GetBytes(); im.binaryBucket = new byte[1 + copyIDBytes.Length]; im.binaryBucket[0] = (byte)AssetType.Folder; Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); if (user != null && !user.IsChildAgent) { user.ControllingClient.SendBulkUpdateInventory(folderCopy); } } else { // First byte of the array is probably the item type // Next 16 bytes are the UUID m_log.Info("OnInstantMessage - giving item"); UUID itemID = new UUID(im.binaryBucket, 1); m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} " + "into agent {1}'s inventory", itemID, new UUID(im.toAgentID)); InventoryItemBase itemCopy = scene.GiveInventoryItem( new UUID(im.toAgentID), client.AgentId, itemID); if (itemCopy == null) { client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); return; } copyID = itemCopy.ID; Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); if (user != null && !user.IsChildAgent) { user.ControllingClient.SendBulkUpdateInventory(itemCopy); } } // Send the IM to the recipient. The item is already // in their inventory, so it will not be lost if // they are offline. // if (user != null && !user.IsChildAgent) { // And notify. Transaction ID is the item ID. We get that // same ID back on the reply so we know what to act on // user.ControllingClient.SendInstantMessage(im); return; } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); } } } else if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted) { ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); if (user != null) // Local { user.ControllingClient.SendInstantMessage(im); } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); } } } else if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined) { // Here, the recipient is local and we can assume that the // inventory is loaded. Courtesy of the above bulk update, // It will have been pushed to the client, too // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService. GetUserDetails(client.AgentId); if (userInfo != null) { InventoryFolderImpl trashFolder = userInfo.FindFolderForType((int)AssetType.TrashFolder); UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip InventoryItemBase item = userInfo.RootFolder.FindItem(inventoryEntityID); InventoryFolderBase folder = null; if (item != null && trashFolder != null) { item.Folder = trashFolder.ID; userInfo.DeleteItem(inventoryEntityID); scene.AddInventoryItem(client, item); } else { folder = userInfo.RootFolder.FindFolder(inventoryEntityID); if (folder != null & trashFolder != null) { userInfo.MoveFolder(inventoryEntityID, trashFolder.ID); } } if ((null == item && null == folder) | null == trashFolder) { string reason = String.Empty; if (trashFolder == null) { reason += " Trash folder not found."; } if (item == null) { reason += " Item not found."; } if (folder == null) { reason += " Folder not found."; } client.SendAgentAlertMessage("Unable to delete " + "received inventory" + reason, false); } } ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); if (user != null) // Local { user.ControllingClient.SendInstantMessage(im); } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); } } } }