From d184fef4dce88bed1edb79c53de56744cefffd1e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Jun 2010 12:47:47 -0700 Subject: Inventory offers and subsequent notifications of acceptance/decline now working across the board. --- .../Avatar/InstantMessage/MessageTransferModule.cs | 2 + .../Inventory/Transfer/InventoryTransferModule.cs | 129 +++++---------------- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 3 files changed, 34 insertions(+), 99 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 5d20e63..83209fc 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -268,6 +268,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage fromAgentName = (string)requestData["from_agent_name"]; message = (string)requestData["message"]; + if (message == null) + message = string.Empty; // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them. string requestData1 = (string)requestData["dialog"]; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index be89740..c333812 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -145,10 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { ScenePresence presence = scene.GetScenePresence(agentId); if (presence != null) - { - if (!presence.IsChildAgent) - return scene; - } + return scene; } } return null; @@ -156,7 +153,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { - m_log.InfoFormat("OnInstantMessage {0}", im.dialog); + m_log.InfoFormat("[INVENTORY TRANSFER]: OnInstantMessage {0}", im.dialog); Scene scene = FindClientScene(client.AgentId); if (scene == null) // Something seriously wrong here. @@ -167,8 +164,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer 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 receipientID = new UUID(im.toAgentID); + ScenePresence user = scene.GetScenePresence(receipientID); UUID copyID; // First byte is the asset type @@ -183,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer folderID, new UUID(im.toAgentID)); InventoryFolderBase folderCopy - = scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero); + = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); if (folderCopy == null) { @@ -199,20 +197,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer im.binaryBucket[0] = (byte)AssetType.Folder; Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); - if (user != null && !user.IsChildAgent) + if (user != null) { user.ControllingClient.SendBulkUpdateInventory(folderCopy); } + + // HACK!! + im.imSessionID = folderID.Guid; } 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} "+ + m_log.DebugFormat("[AGENT INVENTORY]: (giving) Inserting item {0} "+ "into agent {1}'s inventory", itemID, new UUID(im.toAgentID)); @@ -229,29 +229,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer copyID = itemCopy.ID; Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); - if (user != null && !user.IsChildAgent) + if (user != null) { user.ControllingClient.SendBulkUpdateInventory(itemCopy); } + + // HACK!! + im.imSessionID = itemID.Guid; } // 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) + if (user != null) { - // 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) {}); + m_TransferModule.SendInstantMessage(im, delegate(bool success) + { + if (!success) + client.SendAlertMessage("User not online. Inventory has been saved"); + }); } } else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) @@ -282,10 +285,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer InventoryFolderBase trashFolder = invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); - - UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip - InventoryItemBase item = new InventoryItemBase(inventoryEntityID, client.AgentId); + UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip + + InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); item = invService.GetItem(item); InventoryFolderBase folder = null; @@ -301,7 +304,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer } else { - folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); + folder = new InventoryFolderBase(inventoryID, client.AgentId); folder = invService.GetFolder(folder); if (folder != null & trashFolder != null) @@ -417,90 +420,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { // Check if this is ours to handle // - m_log.Info("OnFridInstantMessage"); - if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) - return; - - if (msg.binaryBucket.Length < 17) // Invalid - return; + m_log.Info("OnGridInstantMessage"); Scene scene = FindClientScene(new UUID(msg.toAgentID)); + if (scene == null) + return; + // Find agent to deliver to // ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); - if (user == null) // Shouldn't happen - { - m_log.Debug("[INVENTORY TRANSFER] Can't find recipient"); - return; - } - - //CachedUserInfo userInfo = - // scene.CommsManager.UserProfileCacheService. - // GetUserDetails(user.ControllingClient.AgentId); + // Just forward to local handling + OnInstantMessage(user.ControllingClient, msg); - //if (userInfo == null) - //{ - // m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient"); - // return; - //} - - AssetType assetType = (AssetType)msg.binaryBucket[0]; - IInventoryService invService = scene.InventoryService; - - if (AssetType.Folder == assetType) - { - UUID folderID = new UUID(msg.binaryBucket, 1); - InventoryFolderBase folder = new InventoryFolderBase(); - - folder.ID = folderID; - folder.Owner = user.ControllingClient.AgentId; - - // Fetch from service - // - folder = invService.GetFolder(folder); - if (folder == null) - { - m_log.Debug("[INVENTORY TRANSFER] Can't find folder to give"); - return; - } - - user.ControllingClient.SendBulkUpdateInventory(folder); - - //// This unelegant, slow kludge is to reload the folders and - //// items. Since a folder give can transfer subfolders and - //// items, this is the easiest way to pull that stuff in - //// - //userInfo.DropInventory(); - //userInfo.FetchInventory(); - - // Deliver message - // - user.ControllingClient.SendInstantMessage(msg); - } - else - { - UUID itemID = new UUID(msg.binaryBucket, 1); - InventoryItemBase item = new InventoryItemBase(itemID, user.ControllingClient.AgentId); - - // Fetch from service - // - item = invService.GetItem(item); - if (item == null) - { - m_log.Debug("[INVENTORY TRANSFER] Can't find item to give"); - return; - } - - // Update item to viewer (makes it appear in proper folder) - // - user.ControllingClient.SendBulkUpdateInventory(item); - - // Deliver message - // - user.ControllingClient.SendInstantMessage(msg); - } } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4180d5e..64bdc99 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.Framework.Scenes // Update item with new asset item.AssetID = asset.FullID; if (group.UpdateInventoryItem(item)) - remoteClient.SendAgentAlertMessage("Notecard saved", false); + remoteClient.SendAgentAlertMessage("Script saved", false); part.GetProperties(remoteClient); -- cgit v1.1 From 5d099182c3ef563c112a22f2cda5c721214964b7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Jun 2010 13:14:07 -0700 Subject: Reinstated the check on im.binaryBucket.Length, this time on the local handler for inventory offers. --- .../Avatar/Inventory/Transfer/InventoryTransferModule.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index c333812..2f1e9dd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -154,17 +154,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { m_log.InfoFormat("[INVENTORY TRANSFER]: 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])); + if (im.binaryBucket.Length < 17) // Invalid + return; + UUID receipientID = new UUID(im.toAgentID); ScenePresence user = scene.GetScenePresence(receipientID); UUID copyID; @@ -420,8 +423,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { // Check if this is ours to handle // - m_log.Info("OnGridInstantMessage"); - Scene scene = FindClientScene(new UUID(msg.toAgentID)); if (scene == null) -- cgit v1.1