From d6486fe14a77b74235eaa9e1feab36f923dc6ee9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Dec 2011 00:43:59 +0100 Subject: [PATCH] Fix task inventory giving --- .../InstantMessage/MessageTransferModule.cs | 25 ++++-------- .../InstantMessage/OfflineMessageModule.cs | 3 +- .../Transfer/InventoryTransferModule.cs | 29 +++----------- .../Shared/Api/Implementation/LSL_Api.cs | 38 +++++++++++-------- 4 files changed, 39 insertions(+), 56 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 712632b4f8..6064ddc426 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -146,20 +146,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null && !sp.IsChildAgent) { -// m_log.DebugFormat( -// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", -// toAgentID.ToString(), scene.RegionInfo.RegionName); - - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - if (!user.IsChildAgent) - { - // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client"); - user.ControllingClient.SendInstantMessage(im); + // Local message +// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); - // Message sent - result(true); - return; - } + // Message sent + result(true); + return; } } @@ -172,10 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (sp != null) { // Local message - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - - // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client"); - user.ControllingClient.SendInstantMessage(im); +// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 5ab604fd6a..b27b07df8f 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -212,7 +212,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage im.dialog != (byte)InstantMessageDialog.MessageFromAgent && im.dialog != (byte)InstantMessageDialog.GroupNotice && im.dialog != (byte)InstantMessageDialog.GroupInvitation && - im.dialog != (byte)InstantMessageDialog.InventoryOffered) + im.dialog != (byte)InstantMessageDialog.InventoryOffered && + im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered) { return; } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index aa211ba179..677fab9cfb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -265,7 +265,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer }); } } - else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) + else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || + im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) { ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); @@ -276,30 +277,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer else { if (m_TransferModule != null) - m_TransferModule.SendInstantMessage(im, delegate(bool success) { - - // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 - // and is apparently supposed to fix bulk inventory updates after accepting items. But - // instead it appears to cause two copies of an accepted folder for the receiving user in - // at least some cases. Folder/item update is already done when the offer is made (see code above) - -// // Send BulkUpdateInventory -// IInventoryService invService = scene.InventoryService; -// UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip -// -// InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); -// folder = invService.GetFolder(folder); -// -// ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); -// -// // If the user has left the scene by the time the message comes back then we can't send -// // them the update. -// if (fromUser != null) -// fromUser.ControllingClient.SendBulkUpdateInventory(folder); - }); + m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); } } - else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) + else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined || + im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined) { // Here, the recipient is local and we can assume that the // inventory is loaded. Courtesy of the above bulk update, @@ -335,6 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { folder.ParentID = trashFolder.ID; invService.MoveFolder(folder); + client.SendBulkUpdateInventory(folder); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d2eb46162e..7a56f11c82 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4368,22 +4368,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (agentItem == null) return; - byte[] bucket = new byte[17]; + byte[] bucket = new byte[1]; bucket[0] = (byte)assetType; - byte[] objBytes = agentItem.ID.GetBytes(); - Array.Copy(objBytes, 0, bucket, 1, 16); + //byte[] objBytes = agentItem.ID.GetBytes(); + //Array.Copy(objBytes, 0, bucket, 1, 16); GridInstantMessage msg = new GridInstantMessage(World, - m_host.UUID, m_host.Name+", an object owned by "+ - resolveName(m_host.OwnerID)+",", destId, + m_host.OwnerID, m_host.Name, destId, (byte)InstantMessageDialog.TaskInventoryOffered, - false, objName+"\n"+m_host.Name+" is located at "+ + false, objName+". "+m_host.Name+" is located at "+ World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), agentItem.ID, true, m_host.AbsolutePosition, bucket); - if (m_TransferModule != null) - m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + + ScenePresence sp; + + if (World.TryGetScenePresence(destId, out sp)) + { + sp.ControllingClient.SendInstantMessage(msg); + } + else + { + if (m_TransferModule != null) + m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + } //This delay should only occur when giving inventory to avatars. ScriptSleep(3000); @@ -6708,16 +6717,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (folderID == UUID.Zero) return; - byte[] bucket = new byte[17]; + byte[] bucket = new byte[1]; bucket[0] = (byte)AssetType.Folder; - byte[] objBytes = folderID.GetBytes(); - Array.Copy(objBytes, 0, bucket, 1, 16); + //byte[] objBytes = folderID.GetBytes(); + //Array.Copy(objBytes, 0, bucket, 1, 16); GridInstantMessage msg = new GridInstantMessage(World, - m_host.UUID, m_host.Name+", an object owned by "+ - resolveName(m_host.OwnerID)+",", destID, - (byte)InstantMessageDialog.InventoryOffered, - false, category+"\n"+m_host.Name+" is located at "+ + m_host.OwnerID, m_host.Name, destID, + (byte)InstantMessageDialog.TaskInventoryOffered, + false, category+". "+m_host.Name+" is located at "+ World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), folderID, true, m_host.AbsolutePosition,