mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Moved the inventory manipulation from HGEntityTransferModule to HGInventoryAccessModule where it belongs. They need to exchange some events, so added those to EventManager. Those events (TeleportStart and TeleportFail) are nice to have anyway.
This commit is contained in:
@@ -561,12 +561,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
// Finally, kill the agent we just created at the destination.
|
||||
m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID);
|
||||
|
||||
sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout);
|
||||
}
|
||||
|
||||
protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
|
||||
{
|
||||
logout = false;
|
||||
return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
|
||||
bool success = m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
|
||||
|
||||
if (success)
|
||||
sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent)
|
||||
|
||||
@@ -51,8 +51,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
private bool m_Initialized = false;
|
||||
|
||||
private bool m_RestrictInventoryAccessAbroad = false;
|
||||
|
||||
private GatekeeperServiceConnector m_GatekeeperConnector;
|
||||
|
||||
#region ISharedRegionModule
|
||||
@@ -71,10 +69,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
if (name == Name)
|
||||
{
|
||||
InitialiseCommon(source);
|
||||
IConfig transferConfig = source.Configs["HGEntityTransferModule"];
|
||||
if (transferConfig != null)
|
||||
m_RestrictInventoryAccessAbroad = transferConfig.GetBoolean("RestrictInventoryAccessAbroad", false);
|
||||
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
|
||||
}
|
||||
}
|
||||
@@ -94,44 +88,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
client.OnTeleportHomeRequest += TeleportHome;
|
||||
client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
|
||||
client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
|
||||
client.OnCompleteMovementToRegion += new Action<IClientAPI, bool>(OnCompleteMovementToRegion);
|
||||
}
|
||||
|
||||
protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2)
|
||||
{
|
||||
// HACK HACK -- just seeing how the viewer responds
|
||||
// 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
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: OnCompleteMovementToRegion of user {0}", client.AgentId);
|
||||
object sp = null;
|
||||
if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
|
||||
{
|
||||
if (sp is ScenePresence)
|
||||
{
|
||||
AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
|
||||
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
|
||||
{
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin");
|
||||
if (m_RestrictInventoryAccessAbroad)
|
||||
{
|
||||
IUserManagement uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>();
|
||||
if (uMan.IsLocalGridUser(client.AgentId))
|
||||
{
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
|
||||
RestoreRootFolderContents(client);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is foreign");
|
||||
RestoreSuitcaseFolderContents(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void RegionLoaded(Scene scene)
|
||||
{
|
||||
base.RegionLoaded(scene);
|
||||
@@ -141,12 +99,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
|
||||
m_Initialized = true;
|
||||
|
||||
scene.AddCommand(
|
||||
"HG", this, "send inventory",
|
||||
"send inventory",
|
||||
"Don't use this",
|
||||
HandleSendInventory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -219,21 +171,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
|
||||
logout = success; // flag for later logout from this grid; this is an HG TP
|
||||
|
||||
if (success && m_RestrictInventoryAccessAbroad)
|
||||
{
|
||||
IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>();
|
||||
if (uMan != null && uMan.IsLocalGridUser(sp.UUID))
|
||||
{
|
||||
// local grid user
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
|
||||
RemoveRootFolderContents(sp.ControllingClient);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is foreign");
|
||||
RemoveSuitcaseFolderContents(sp.ControllingClient);
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout);
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -244,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
}
|
||||
}
|
||||
|
||||
return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
|
||||
return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout);
|
||||
}
|
||||
|
||||
public override void TeleportHome(UUID id, IClientAPI client)
|
||||
@@ -348,15 +287,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
|
||||
}
|
||||
|
||||
protected override void Fail(ScenePresence sp, GridRegion finalDestination, bool logout)
|
||||
{
|
||||
base.Fail(sp, finalDestination, logout);
|
||||
if (logout && m_RestrictInventoryAccessAbroad)
|
||||
{
|
||||
RestoreRootFolderContents(sp.ControllingClient);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IUserAgentVerificationModule
|
||||
@@ -411,71 +341,6 @@ 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<IClientInventory>(out inv))
|
||||
{
|
||||
InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
||||
if (root != null)
|
||||
{
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.Name);
|
||||
InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
|
||||
List<UUID> fids = new List<UUID>();
|
||||
List<UUID> iids = new List<UUID>();
|
||||
List<InventoryFolderBase> keep = new List<InventoryFolderBase>();
|
||||
|
||||
foreach (InventoryFolderBase f in content.Folders)
|
||||
{
|
||||
if (f.Name != "My Suitcase")
|
||||
{
|
||||
f.Name = f.Name + " (Unavailable)";
|
||||
keep.Add(f);
|
||||
}
|
||||
}
|
||||
|
||||
// items directly under the root folder
|
||||
foreach (InventoryItemBase it in content.Items)
|
||||
it.Name = it.Name + " (Unavailable)"; ;
|
||||
|
||||
// Send the new names
|
||||
inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveSuitcaseFolderContents(IClientAPI client)
|
||||
{
|
||||
}
|
||||
|
||||
private void RestoreRootFolderContents(IClientAPI client)
|
||||
{
|
||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root folder");
|
||||
if (client is IClientCore)
|
||||
{
|
||||
IClientCore core = (IClientCore)client;
|
||||
IClientInventory inv;
|
||||
|
||||
if (core.TryGet<IClientInventory>(out inv))
|
||||
{
|
||||
InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
||||
InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
|
||||
|
||||
inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreSuitcaseFolderContents(IClientAPI client)
|
||||
{
|
||||
}
|
||||
|
||||
private GridRegion MakeRegion(AgentCircuitData aCircuit)
|
||||
{
|
||||
@@ -494,13 +359,5 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||
return region;
|
||||
}
|
||||
|
||||
protected void HandleSendInventory(string module, string[] cmd)
|
||||
{
|
||||
m_Scenes[0].ForEachClient(delegate(IClientAPI client)
|
||||
{
|
||||
RestoreRootFolderContents(client);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user