From 300968e9339786611c9ac5c2ff3b58dec1c0c30e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 27 Mar 2012 19:08:29 -0700 Subject: HG: Switch root folders from under the viewer. Towards HG 2.0. This is guarded by an obscure config that no one but me should be using at this point. --- .../EntityTransfer/HGEntityTransferModule.cs | 54 ++++++++++++++++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 15 ++++-- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index b277095..4cdf303 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; +using OpenSim.Framework.Client; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Connectors.Hypergrid; @@ -177,9 +178,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer logout = success; // flag for later logout from this grid; this is an HG TP if (success && m_RestrictInventoryAccessAbroad) - { - // TODO tell the viewer to remove the root folder - } + RemoveRootFolderContents(sp.ControllingClient); return success; } @@ -299,13 +298,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer base.Fail(sp, finalDestination, logout); if (logout && m_RestrictInventoryAccessAbroad) { - // Restore the user's inventory, because we removed it earlier on - InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(sp.UUID); - if (root != null) - { - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring"); - sp.ControllingClient.SendBulkUpdateInventory(root); - } + RestoreRootFolderContents(sp.ControllingClient); } } @@ -363,6 +356,47 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion + private void RemoveRootFolderContents(IClientAPI client) + { + // TODO tell the viewer to remove the root folder's content + if (client is IClientCore) + { + IClientCore core = (IClientCore)client; + IClientInventory inv; + + if (core.TryGet(out inv)) + { + InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); + if (root != null) + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory"); + InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); + UUID[] ids = new UUID[content.Folders.Count]; + int i = 0; + foreach (InventoryFolderBase f in content.Folders) + ids[i++] = f.ID; + inv.SendRemoveInventoryFolders(ids); + ids = new UUID[content.Items.Count]; + i = 0; + foreach (InventoryItemBase it in content.Items) + ids[i++] = it.ID; + inv.SendRemoveInventoryItems(ids); + } + } + } + } + + private void RestoreRootFolderContents(IClientAPI client) + { + // Restore the user's inventory, because we removed it earlier on + InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); + if (root != null) + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory"); + client.SendBulkUpdateInventory(root); + } + } + private GridRegion MakeRegion(AgentCircuitData aCircuit) { GridRegion region = new GridRegion(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0b31e0c..1f5cddd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2675,12 +2675,19 @@ namespace OpenSim.Region.Framework.Scenes // Cache the user's name CacheUserName(sp, aCircuit); - // Let's send the Suitcase folder for incoming HG agents + // Let's send the Suitcase or the real root folder folder for incoming HG agents + // Visiting agents get their suitcase contents; incoming local users get their real root folder's content if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) { - m_log.DebugFormat("[SCENE]: Sending root folder to viewer..."); - InventoryFolderBase suitcase = InventoryService.GetRootFolder(client.AgentId); - client.SendBulkUpdateInventory(suitcase); + // HACK FOR NOW. JUST TESTING, SO KEEPING EVERYONE ELSE OUT OF THESE TESTS + IConfig config = m_config.Configs["HGEntityTransfer"]; + if (config != null && config.GetBoolean("RestrictInventoryAccessAbroad", false)) + { + m_log.DebugFormat("[SCENE]: Sending root folder to viewer..."); + InventoryFolderBase root = InventoryService.GetRootFolder(client.AgentId); + //InventoryCollection rootContents = InventoryService.GetFolderContent(client.AgentId, root.ID); + client.SendBulkUpdateInventory(root); + } } EventManager.TriggerOnNewClient(client); -- cgit v1.1