From 697ac7fd9de244cb3b25ff8576838fd323b257c3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 10:17:02 -0700 Subject: Hack around https://jira.secondlife.com/browse/VWR-28570 --- .../Region/CoreModules/World/WorldMap/MapSearchModule.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 657975b..c8c80db 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -92,7 +92,19 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return; } -//m_log.DebugFormat("MAP NAME=({0})", mapName); + //m_log.DebugFormat("MAP NAME=({0})", mapName); + + // Hack to get around the fact that ll V3 now drops the port from the + // map name. See https://jira.secondlife.com/browse/VWR-28570 + // + // Caller, use this form instead: + // secondlife://mygrid.com|8002+Region+Name/128/128 + // the hacks we do with this viewer... + // + if (mapName.Contains("|")) + mapName = mapName.Replace('|', ':'); + if (mapName.Contains("+")) + mapName = mapName.Replace('+', ' '); // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); -- cgit v1.1 From 10731732b4d40ec9d9e7a21f406a3d2b5dfc1075 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 11:04:56 -0700 Subject: More hacking around viewer bug --- OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index c8c80db..2064ce3 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // map name. See https://jira.secondlife.com/browse/VWR-28570 // // Caller, use this form instead: - // secondlife://mygrid.com|8002+Region+Name/128/128 + // secondlife://mygrid.com|8002|Region+Name/128/128 // the hacks we do with this viewer... // if (mapName.Contains("|")) -- cgit v1.1 From e5612553ce57b6e36cfa59db8450473099054da1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 14:36:29 -0700 Subject: Revert "More hacking around viewer bug" This reverts commit 10731732b4d40ec9d9e7a21f406a3d2b5dfc1075. --- OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 2064ce3..c8c80db 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // map name. See https://jira.secondlife.com/browse/VWR-28570 // // Caller, use this form instead: - // secondlife://mygrid.com|8002|Region+Name/128/128 + // secondlife://mygrid.com|8002+Region+Name/128/128 // the hacks we do with this viewer... // if (mapName.Contains("|")) -- cgit v1.1 From 5a9560db288a25799c93a3ecbd3544931149fa2a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 14:36:48 -0700 Subject: Revert "Hack around https://jira.secondlife.com/browse/VWR-28570" This reverts commit 697ac7fd9de244cb3b25ff8576838fd323b257c3. --- .../Region/CoreModules/World/WorldMap/MapSearchModule.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index c8c80db..657975b 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -92,19 +92,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return; } - //m_log.DebugFormat("MAP NAME=({0})", mapName); - - // Hack to get around the fact that ll V3 now drops the port from the - // map name. See https://jira.secondlife.com/browse/VWR-28570 - // - // Caller, use this form instead: - // secondlife://mygrid.com|8002+Region+Name/128/128 - // the hacks we do with this viewer... - // - if (mapName.Contains("|")) - mapName = mapName.Replace('|', ':'); - if (mapName.Contains("+")) - mapName = mapName.Replace('+', ' '); +//m_log.DebugFormat("MAP NAME=({0})", mapName); // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); -- cgit v1.1 From f52917288a04e922edcf28b3184b37d87c3c69ea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 14:54:25 -0700 Subject: These SLURLs are very confusing! -- reverting the revert. Hack is, indeed, needed. Revert "Revert "Hack around https://jira.secondlife.com/browse/VWR-28570"" This reverts commit 5a9560db288a25799c93a3ecbd3544931149fa2a. --- .../Region/CoreModules/World/WorldMap/MapSearchModule.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 657975b..c8c80db 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -92,7 +92,19 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return; } -//m_log.DebugFormat("MAP NAME=({0})", mapName); + //m_log.DebugFormat("MAP NAME=({0})", mapName); + + // Hack to get around the fact that ll V3 now drops the port from the + // map name. See https://jira.secondlife.com/browse/VWR-28570 + // + // Caller, use this form instead: + // secondlife://mygrid.com|8002+Region+Name/128/128 + // the hacks we do with this viewer... + // + if (mapName.Contains("|")) + mapName = mapName.Replace('|', ':'); + if (mapName.Contains("+")) + mapName = mapName.Replace('+', ' '); // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); -- cgit v1.1 From df144eb9e23a1a170605b4045f0602f514efb519 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 14:55:25 -0700 Subject: Revert "Revert "More hacking around viewer bug"" This reverts commit e5612553ce57b6e36cfa59db8450473099054da1. --- OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index c8c80db..2064ce3 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // map name. See https://jira.secondlife.com/browse/VWR-28570 // // Caller, use this form instead: - // secondlife://mygrid.com|8002+Region+Name/128/128 + // secondlife://mygrid.com|8002|Region+Name/128/128 // the hacks we do with this viewer... // if (mapName.Contains("|")) -- cgit v1.1 From 18d1d6d3b4658b2b00c738d54ff4230868c02c6c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 16:03:09 -0700 Subject: More on SLURLs and V3. This is hacky, but it works. Basically, we have to redefine the encoding of HG URLs because the viewer messes them up. Examples of what works and doesn't work: - secondlife://ucigrid00.nacs.uci.edu|8002/128/128 <-- works throughout the viewer - secondlife://http|!!ucigrid00.nacs.uci.edu|8002+Test+Zone+1/128/128 <-- works throughout the viewer - secondlife://http|!!grid.sciencesim.com!grid!hypergrid.php+Yellowstone01+74/128/128 <-- works throughout - secondlife://http%3A%2F%2Fucigrid00.nacs.uci.edu%3A8002%20UCI%20Central%201/128/128 <-- works in chat, but not as URLs in the webkit --- .../Region/CoreModules/World/WorldMap/MapSearchModule.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 2064ce3..83ec6c3 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -97,14 +97,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Hack to get around the fact that ll V3 now drops the port from the // map name. See https://jira.secondlife.com/browse/VWR-28570 // - // Caller, use this form instead: - // secondlife://mygrid.com|8002|Region+Name/128/128 + // Caller, use this magic form instead: + // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 + // or url encode if possible. // the hacks we do with this viewer... // + string mapNameOrig = mapName; if (mapName.Contains("|")) mapName = mapName.Replace('|', ':'); if (mapName.Contains("+")) mapName = mapName.Replace('+', ' '); + if (mapName.Contains("!")) + mapName = mapName.Replace('!', '/'); // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); @@ -126,7 +130,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap data.MapImageId = UUID.Zero; else data.MapImageId = info.TerrainImage; - data.Name = info.RegionName; + // ugh! V2-3 is very sensitive about the result being + // exactly the same as the requested name + if (regionInfos.Count == 1) + data.Name = mapNameOrig; + else + data.Name = info.RegionName; data.RegionFlags = 0; // TODO not used? data.WaterHeight = 0; // not used data.X = (ushort)(info.RegionLocX / Constants.RegionSize); -- cgit v1.1 From a4b01ef38a735ffe70b402061871a9c99f2757ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Mar 2012 00:34:30 +0000 Subject: Replace script-lines-per-second with the script execution time scaled by its measurement period and an idealised frame time. The previous lines-per-second measurement used for top scripts report was inaccurate, since lines executed does not reflect time taken to execute. Also, every fetch of the report would reset all the numbers limiting its usefulness and we weren't even guaranteed to see the top 100. The actual measurement value should be script execution time per frame but XEngine does not work this way. Therefore, we use actual script execution time scaled by the measurement period and an idealised frame time. This is still not ideal but gives reasonable results and allows scripts to be compared. This commit moves script execution time calculations from SceneGraph into IScriptModule implementations. --- .../World/Estate/EstateManagementModule.cs | 77 +++++++++++++--------- 1 file changed, 47 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index c303d6d..d363b15 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -26,8 +26,10 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Reflection; using System.Security; using log4net; @@ -876,52 +878,67 @@ namespace OpenSim.Region.CoreModules.World.Estate if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false)) return; - Dictionary SceneData = new Dictionary(); + Dictionary sceneData = null; List uuidNameLookupList = new List(); if (reportType == 1) { - SceneData = Scene.PhysicsScene.GetTopColliders(); + sceneData = Scene.PhysicsScene.GetTopColliders(); } else if (reportType == 0) { - SceneData = Scene.SceneGraph.GetTopScripts(); + IScriptModule scriptModule = Scene.RequestModuleInterface(); + + if (scriptModule != null) + sceneData = scriptModule.GetObjectScriptsExecutionTimes(); } List SceneReport = new List(); - lock (SceneData) + if (sceneData != null) { - foreach (uint obj in SceneData.Keys) + var sortedSceneData + = sceneData.Select( + item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) }); + + sortedSceneData.OrderBy(item => item.Measurement); + + int items = 0; + + foreach (var entry in sortedSceneData) { - SceneObjectPart prt = Scene.GetSceneObjectPart(obj); - if (prt != null) + if (entry.Part == null) + continue; + + items++; + SceneObjectGroup so = entry.Part.ParentGroup; + + LandStatReportItem lsri = new LandStatReportItem(); + lsri.LocationX = so.AbsolutePosition.X; + lsri.LocationY = so.AbsolutePosition.Y; + lsri.LocationZ = so.AbsolutePosition.Z; + lsri.Score = entry.Measurement; + lsri.TaskID = so.UUID; + lsri.TaskLocalID = so.LocalId; + lsri.TaskName = entry.Part.Name; + lsri.OwnerName = "waiting"; + lock (uuidNameLookupList) + uuidNameLookupList.Add(so.OwnerID); + + if (filter.Length != 0) { - SceneObjectGroup sog = prt.ParentGroup; - LandStatReportItem lsri = new LandStatReportItem(); - lsri.LocationX = sog.AbsolutePosition.X; - lsri.LocationY = sog.AbsolutePosition.Y; - lsri.LocationZ = sog.AbsolutePosition.Z; - lsri.Score = SceneData[obj]; - lsri.TaskID = sog.UUID; - lsri.TaskLocalID = sog.LocalId; - lsri.TaskName = sog.GetPartName(obj); - lsri.OwnerName = "waiting"; - lock (uuidNameLookupList) - uuidNameLookupList.Add(sog.OwnerID); - - if (filter.Length != 0) + if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) { - if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) - { - } - else - { - continue; - } } - - SceneReport.Add(lsri); + else + { + continue; + } } + + SceneReport.Add(lsri); + + if (items >= 100) + break; } } -- cgit v1.1 From 7df4a544fecb336d6f4b9cbc0faea98daf0b9edf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Mar 2012 00:53:36 +0000 Subject: Fix owner name display in "Top Colliders" and "Top Script" region reports. --- .../World/Estate/EstateManagementModule.cs | 46 +--------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index d363b15..1492861 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -47,8 +47,6 @@ namespace OpenSim.Region.CoreModules.World.Estate { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private delegate void LookupUUIDS(List uuidLst); - public Scene Scene { get; private set; } public IUserManagement UserManager { get; private set; } @@ -920,9 +918,7 @@ namespace OpenSim.Region.CoreModules.World.Estate lsri.TaskID = so.UUID; lsri.TaskLocalID = so.LocalId; lsri.TaskName = entry.Part.Name; - lsri.OwnerName = "waiting"; - lock (uuidNameLookupList) - uuidNameLookupList.Add(so.OwnerID); + lsri.OwnerName = UserManager.GetUserName(so.OwnerID); if (filter.Length != 0) { @@ -943,48 +939,8 @@ namespace OpenSim.Region.CoreModules.World.Estate } remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); - - if (uuidNameLookupList.Count > 0) - LookupUUID(uuidNameLookupList); } - private static void LookupUUIDSCompleted(IAsyncResult iar) - { - LookupUUIDS icon = (LookupUUIDS)iar.AsyncState; - icon.EndInvoke(iar); - } - - private void LookupUUID(List uuidLst) - { - LookupUUIDS d = LookupUUIDsAsync; - - d.BeginInvoke(uuidLst, - LookupUUIDSCompleted, - d); - } - - private void LookupUUIDsAsync(List uuidLst) - { - UUID[] uuidarr; - - lock (uuidLst) - { - uuidarr = uuidLst.ToArray(); - } - - for (int i = 0; i < uuidarr.Length; i++) - { - // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); - - IUserManagement userManager = Scene.RequestModuleInterface(); - if (userManager != null) - userManager.GetUserName(uuidarr[i]); - - // we drop it. It gets cached though... so we're ready for the next request. - // diva commnent 11/21/2010: uh?!? wft? - // justincc comment 21/01/2011: A side effect of userManager.GetUserName() I presume. - } - } #endregion #region Outgoing Packets -- cgit v1.1 From 8550a4a07eb581ada9a5dca08b558344d87eebfc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Mar 2012 01:46:21 +0000 Subject: In Top Scripts report, don't show scripts with no or less than 1 microsecond of execution time. This is to make the report clearer and less confusing. --- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 1492861..61d604f 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -904,9 +904,15 @@ namespace OpenSim.Region.CoreModules.World.Estate foreach (var entry in sortedSceneData) { + // The object may have been deleted since we received the data. if (entry.Part == null) continue; + // Don't show scripts that haven't executed or where execution time is below one microsecond in + // order to produce a more readable report. + if (entry.Measurement < 0.001) + continue; + items++; SceneObjectGroup so = entry.Part.ParentGroup; -- cgit v1.1 From 05a1493fffcecb1296add194dbbf244c345c8b2f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 15 Mar 2012 20:22:26 -0700 Subject: More on map search: send extra messages to the user regarding the region being found or not, because the UI is horribly confusing -- places profile is always "loading..." whether the region exists or not. --- OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 83ec6c3..d60909c 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -159,6 +159,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // flags are agent flags sent from the viewer. // they have different values depending on different viewers, apparently remoteClient.SendMapBlock(blocks, flags); + + // send extra user messages for V3 + // because the UI is very confusing + // while we don't fix the hard-coded urls + if (flags == 2) + { + if (regionInfos.Count == 0) + remoteClient.SendAgentAlertMessage("No regions found with that name.", true); + else if (regionInfos.Count == 1) + remoteClient.SendAgentAlertMessage("Region found!", false); + } } // private Scene GetClientScene(IClientAPI client) -- cgit v1.1 From a2009ffe2e71afefad79471811418df8958870ab Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 16 Mar 2012 13:08:05 -0700 Subject: Terrain: added [Terrain] section with an option to load an initial flat terrain. Default is still pinhead island. I much rather have a flat land in the beginning. --- OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index cf000a4..ef9c95c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -86,6 +86,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain private volatile bool m_tainted; private readonly Stack m_undo = new Stack(5); + private String m_InitialTerrain = "pinhead-island"; + /// /// Human readable list of terrain file extensions that are supported. /// @@ -109,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain /// Config for the region public void Initialise(IConfigSource config) { + IConfig terrainConfig = config.Configs["Terrain"]; + if (terrainConfig != null) + m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); } public void AddRegion(Scene scene) @@ -120,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain { if (m_scene.Heightmap == null) { - m_channel = new TerrainChannel(); + m_channel = new TerrainChannel(m_InitialTerrain); m_scene.Heightmap = m_channel; m_revert = new TerrainChannel(); UpdateRevertMap(); -- cgit v1.1 From 1e4180fc931b2d07756519403ed4ae18d136906b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Mar 2012 02:54:19 +0000 Subject: Clean up "save iar" help --- .../Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2154827..ac22c3f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -124,15 +124,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "Archiving", this, "save iar", "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]", "Save user inventory archive (IAR).", - " is the user's first name." + Environment.NewLine - + " is the user's last name." + Environment.NewLine - + " is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine - + "-h|--home= adds the url of the profile service to the saved user information." + Environment.NewLine - + "-c|--creators preserves information about foreign creators." + Environment.NewLine - + "-v|--verbose extra debug messages." + Environment.NewLine - + "--noassets stops assets being saved to the IAR." + " is the user's first name.\n" + + " is the user's last name.\n" + + " is the path inside the user's inventory for the folder/item to be saved.\n" + " is the filesystem path at which to save the IAR." - + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), + + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) + + "-h|--home= adds the url of the profile service to the saved user information.\n" + + "-c|--creators preserves information about foreign creators.\n" + + "-v|--verbose extra debug messages.\n" + + "--noassets stops assets being saved to the IAR.", HandleSaveInvConsoleCommand); m_aScene = scene; -- cgit v1.1 From 33c14cb107ecb67a3e971d6adaab17d173d52747 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 17 Mar 2012 10:00:11 -0700 Subject: Region access control! Region operators can now specify things like DisallowForeigners (means what it says) and DisallowResidents (means that only admins and managers can get into the region). This puts the never-completed AuthorizationService to good use. Note that I didn't implement a grid-wide Authorization service; this service implementation is done entirely locally on the simulator. This can be changed as usual by pluging in a different AuthorizationServicesConnector. --- .../Authorization/AuthorizationService.cs | 124 +++++++++++++++++++++ .../LocalAuthorizationServiceConnector.cs | 43 +++---- 2 files changed, 140 insertions(+), 27 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs new file mode 100644 index 0000000..f0d21e6 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs @@ -0,0 +1,124 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization +{ + public class AuthorizationService : IAuthorizationService + { + private enum AccessFlags + { + None = 0, /* No restrictions */ + DisallowResidents = 1, /* Only gods and managers*/ + DisallowForeigners = 2, /* Only local people */ + } + + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IUserManagement m_UserManagement; + private IGridService m_GridService; + + private Scene m_Scene; + AccessFlags m_accessValue = AccessFlags.None; + + + public AuthorizationService(IConfig config, Scene scene) + { + m_Scene = scene; + m_UserManagement = scene.RequestModuleInterface(); + m_GridService = scene.GridService; + + if (config != null) + { + string accessStr = config.GetString("Region_" + scene.RegionInfo.RegionName.Replace(' ', '_'), String.Empty); + if (accessStr != string.Empty) + { + try + { + m_accessValue = (AccessFlags)Enum.Parse(typeof(AccessFlags), accessStr); + } + catch (ArgumentException) + { + m_log.WarnFormat("[AuthorizationService]: {0} is not a valid access flag", accessStr); + } + } + m_log.DebugFormat("[AuthorizationService]: Region {0} access restrictions: {1}", m_Scene.RegionInfo.RegionName, m_accessValue); + } + + } + + public bool IsAuthorizedForRegion( + string user, string firstName, string lastName, string regionID, out string message) + { + message = "authorized"; + + // This should not happen + if (m_Scene.RegionInfo.RegionID.ToString() != regionID) + { + m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}", + m_Scene.RegionInfo.RegionID, regionID); + return true; + } + + if (m_accessValue == AccessFlags.None) + return true; + + UUID userID = new UUID(user); + bool authorized = true; + if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners) + { + authorized = m_UserManagement.IsLocalGridUser(userID); + if (!authorized) + message = "no foreigner users allowed in this region"; + } + if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents) + { + authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID); + if (!authorized) + message = "only Admins and Managers allowed in this region"; + } + + return authorized; + } + + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs index 18a7177..c982db6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs @@ -39,13 +39,15 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization { - public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService + public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); private IAuthorizationService m_AuthorizationService; + private Scene m_Scene; + private IConfig m_AuthorizationConfig; private bool m_Enabled = false; @@ -69,33 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization string name = moduleConfig.GetString("AuthorizationServices", string.Empty); if (name == Name) { - IConfig authorizationConfig = source.Configs["AuthorizationService"]; - if (authorizationConfig == null) - { - m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini"); - return; - } - - string serviceDll = authorizationConfig.GetString("LocalServiceModule", - String.Empty); - - if (serviceDll == String.Empty) - { - m_log.Error("[AUTHORIZATION CONNECTOR]: No LocalServiceModule named in section AuthorizationService"); - return; - } - - Object[] args = new Object[] { source }; - m_AuthorizationService = - ServerUtils.LoadPlugin(serviceDll, - args); - - if (m_AuthorizationService == null) - { - m_log.Error("[AUTHORIZATION CONNECTOR]: Can't load authorization service"); - return; - } m_Enabled = true; + m_AuthorizationConfig = source.Configs["AuthorizationService"]; m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled"); } } @@ -115,6 +92,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization return; scene.RegisterModuleInterface(this); + m_Scene = scene; + + scene.EventManager.OnLoginsEnabled += new EventManager.LoginsEnabled(OnLoginsEnabled); } public void RemoveRegion(Scene scene) @@ -131,9 +111,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization scene.RegionInfo.RegionName); } + private void OnLoginsEnabled(string regionName) + { + m_AuthorizationService = new AuthorizationService(m_AuthorizationConfig, m_Scene); + } + public bool IsAuthorizedForRegion( string userID, string firstName, string lastName, string regionID, out string message) { + message = ""; + if (!m_Enabled) + return true; + return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); } } -- cgit v1.1 From 1a4fdd26663fc6cfdcc76adb86d9babbd657a55d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 17 Mar 2012 10:48:22 -0700 Subject: Moved HandleAvatarPickerRequest from the generic Scene.PacketHandlers to the UserManagementModule where it belongs. No functional changes. --- .../UserManagement/UserManagementModule.cs | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 554af14..39e0661 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -38,6 +38,7 @@ using OpenSim.Services.Interfaces; using OpenSim.Services.Connectors.Hypergrid; using OpenMetaverse; +using OpenMetaverse.Packets; using log4net; using Nini.Config; @@ -149,7 +150,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement void EventManager_OnNewClient(IClientAPI client) { + client.OnConnectionClosed += new Action(HandleConnectionClosed); client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); + client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest); + } + + void HandleConnectionClosed(IClientAPI client) + { + client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest); + client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); } void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) @@ -170,6 +179,59 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } } + public void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query) + { + //EventManager.TriggerAvatarPickerRequest(); + + List accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); + + if (accounts == null) + return; + + AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); + // TODO: don't create new blocks if recycling an old packet + + AvatarPickerReplyPacket.DataBlock[] searchData = + new AvatarPickerReplyPacket.DataBlock[accounts.Count]; + AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); + + agentData.AgentID = avatarID; + agentData.QueryID = RequestID; + replyPacket.AgentData = agentData; + //byte[] bytes = new byte[AvatarResponses.Count*32]; + + int i = 0; + foreach (UserAccount item in accounts) + { + UUID translatedIDtem = item.PrincipalID; + searchData[i] = new AvatarPickerReplyPacket.DataBlock(); + searchData[i].AvatarID = translatedIDtem; + searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName); + searchData[i].LastName = Utils.StringToBytes((string)item.LastName); + i++; + } + if (accounts.Count == 0) + { + searchData = new AvatarPickerReplyPacket.DataBlock[0]; + } + replyPacket.Data = searchData; + + AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs(); + agent_data.AgentID = replyPacket.AgentData.AgentID; + agent_data.QueryID = replyPacket.AgentData.QueryID; + + List data_args = new List(); + for (i = 0; i < replyPacket.Data.Length; i++) + { + AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs(); + data_arg.AvatarID = replyPacket.Data[i].AvatarID; + data_arg.FirstName = replyPacket.Data[i].FirstName; + data_arg.LastName = replyPacket.Data[i].LastName; + data_args.Add(data_arg); + } + client.SendAvatarPickerReply(agent_data, data_args); + } + #endregion Event Handlers private void CacheCreators(SceneObjectGroup sog) -- cgit v1.1 From 7dfa0309c63263fb15dc9e3883f5717f28e21c0c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 17 Mar 2012 15:36:20 -0700 Subject: More on HG access control. This commit splits the UserManagementModule into the Basic one and the HG one, so that we can do everything that needs to be done for HG ACLs to work without interfering with the vanilla opensim. For the moment, it finds foreign users who have left a trace in the region, e.g. an object. This makes it possible to ban/IM/etc these users using the regular avatar picker. TODO: contact the UAS directly given a name of the form First.Last @foo.com. --- .../UserManagement/HGUserManagementModule.cs | 119 +++++++++++++++++++++ .../UserManagement/UserManagementModule.cs | 102 +++++++++++------- .../Resources/CoreModulePlugin.addin.xml | 1 + 3 files changed, 182 insertions(+), 40 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs new file mode 100644 index 0000000..6543bf2 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs @@ -0,0 +1,119 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors.Hypergrid; + +using OpenMetaverse; +using OpenMetaverse.Packets; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.UserManagement +{ + public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + + #region ISharedRegionModule + + public new void Initialise(IConfigSource config) + { + string umanmod = config.Configs["Modules"].GetString("UserManagementModule", base.Name); + if (umanmod == Name) + { + m_Enabled = true; + RegisterConsoleCmds(); + m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); + } + } + + public override string Name + { + get { return "HGUserManagementModule"; } + } + + #endregion ISharedRegionModule + + protected override void AddAdditionalUsers(UUID avatarID, string query, List users) + { + string[] words = query.Split(new char[] { ' ' }); + + for (int i = 0; i < words.Length; i++) + { + if (words[i].Length < 3) + { + if (i != words.Length - 1) + Array.Copy(words, i + 1, words, i, words.Length - i - 1); + Array.Resize(ref words, words.Length - 1); + } + } + + if (words.Length == 0 || words.Length > 2) + return; + + if (words.Length == 2) // First.Last @foo.com, maybe? + { + bool found = false; + foreach (UserData d in m_UserCache.Values) + { + if (d.LastName.StartsWith("@") && (d.FirstName.Equals(words[0]) || d.LastName.Equals(words[1]))) + { + users.Add(d); + found = true; + break; + } + } + if (!found) // This is it! Let's ask the other world + { + // TODO + //UserAgentServiceConnector uasConn = new UserAgentServiceConnector(words[0]); + //uasConn.GetUserInfo(...); + } + } + else + { + foreach (UserData d in m_UserCache.Values) + { + if (d.LastName.StartsWith("@") && (d.FirstName.StartsWith(query) || d.LastName.StartsWith(query))) + users.Add(d); + } + } + } + + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 39e0661..23ef0fc 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -44,7 +44,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.UserManagement { - class UserData + public class UserData { public UUID Id { get; set; } public string FirstName { get; set; } @@ -57,36 +57,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private List m_Scenes = new List(); + protected bool m_Enabled; + protected List m_Scenes = new List(); // The cache - Dictionary m_UserCache = new Dictionary(); + protected Dictionary m_UserCache = new Dictionary(); #region ISharedRegionModule public void Initialise(IConfigSource config) { - //m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); - //if (m_Enabled) - //{ - // IConfig libConfig = config.Configs["LibraryService"]; - // if (libConfig != null) - // { - // string dllName = libConfig.GetString("LocalServiceModule", string.Empty); - // m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); - // if (dllName != string.Empty) - // { - // Object[] args = new Object[] { config }; - // m_Library = ServerUtils.LoadPlugin(dllName, args); - // } - // } - //} - MainConsole.Instance.Commands.AddCommand("Users", true, - "show names", - "show names", - "Show the bindings between user UUIDs and user names", - String.Empty, - HandleShowUsers); + string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name); + if (umanmod == Name) + { + m_Enabled = true; + RegisterConsoleCmds(); + m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); + } } public bool IsSharedModule @@ -94,9 +81,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement get { return true; } } - public string Name + public virtual string Name { - get { return "UserManagement Module"; } + get { return "BasicUserManagementModule"; } } public Type ReplaceableInterface @@ -106,17 +93,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement public void AddRegion(Scene scene) { - m_Scenes.Add(scene); + if (m_Enabled) + { + m_Scenes.Add(scene); - scene.RegisterModuleInterface(this); - scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); - scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); + scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); + } } public void RemoveRegion(Scene scene) { - scene.UnregisterModuleInterface(this); - m_Scenes.Remove(scene); + if (m_Enabled) + { + scene.UnregisterModuleInterface(this); + m_Scenes.Remove(scene); + } } public void RegionLoaded(Scene s) @@ -183,16 +176,31 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement { //EventManager.TriggerAvatarPickerRequest(); - List accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); + m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query); - if (accounts == null) - return; + List accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); + + List users = new List(); + if (accs != null) + { + m_log.DebugFormat("[USER MANAGEMENT MODULE]: Found {0} users", accs.Count); + foreach (UserAccount acc in accs) + { + UserData ud = new UserData(); + ud.FirstName = acc.FirstName; + ud.LastName = acc.LastName; + ud.Id = acc.PrincipalID; + users.Add(ud); + } + } + + AddAdditionalUsers(avatarID, query, users); AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); // TODO: don't create new blocks if recycling an old packet AvatarPickerReplyPacket.DataBlock[] searchData = - new AvatarPickerReplyPacket.DataBlock[accounts.Count]; + new AvatarPickerReplyPacket.DataBlock[users.Count]; AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); agentData.AgentID = avatarID; @@ -201,16 +209,16 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement //byte[] bytes = new byte[AvatarResponses.Count*32]; int i = 0; - foreach (UserAccount item in accounts) + foreach (UserData item in users) { - UUID translatedIDtem = item.PrincipalID; + UUID translatedIDtem = item.Id; searchData[i] = new AvatarPickerReplyPacket.DataBlock(); searchData[i].AvatarID = translatedIDtem; searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName); searchData[i].LastName = Utils.StringToBytes((string)item.LastName); i++; } - if (accounts.Count == 0) + if (users.Count == 0) { searchData = new AvatarPickerReplyPacket.DataBlock[0]; } @@ -232,6 +240,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement client.SendAvatarPickerReply(agent_data, data_args); } + protected virtual void AddAdditionalUsers(UUID avatarID, string query, List users) + { + } + #endregion Event Handlers private void CacheCreators(SceneObjectGroup sog) @@ -487,13 +499,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement #endregion IUserManagement + protected void RegisterConsoleCmds() + { + MainConsole.Instance.Commands.AddCommand("Users", true, + "show names", + "show names", + "Show the bindings between user UUIDs and user names", + String.Empty, + HandleShowUsers); + } + private void HandleShowUsers(string module, string[] cmd) { lock (m_UserCache) { if (m_UserCache.Count == 0) { - MainConsole.Instance.Output("No users not found"); + MainConsole.Instance.Output("No users found"); return; } diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index e22fd38..dc6efed 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -9,6 +9,7 @@ + -- cgit v1.1 From 441ef301a34ab1968e74038e19066b37e7a74a66 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 17 Mar 2012 19:41:47 -0700 Subject: Amend to previous commit: normalize strings ToLower. --- .../Framework/UserManagement/HGUserManagementModule.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index 6543bf2..8077a7a 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs @@ -91,7 +91,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement bool found = false; foreach (UserData d in m_UserCache.Values) { - if (d.LastName.StartsWith("@") && (d.FirstName.Equals(words[0]) || d.LastName.Equals(words[1]))) + if (d.LastName.StartsWith("@") && + (d.FirstName.ToLower().Equals(words[0].ToLower()) || + d.LastName.ToLower().Equals(words[1].ToLower()))) { users.Add(d); found = true; @@ -109,7 +111,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement { foreach (UserData d in m_UserCache.Values) { - if (d.LastName.StartsWith("@") && (d.FirstName.StartsWith(query) || d.LastName.StartsWith(query))) + if (d.LastName.StartsWith("@") && + (d.FirstName.ToLower().StartsWith(query.ToLower()) || + d.LastName.ToLower().StartsWith(query.ToLower()))) users.Add(d); } } -- cgit v1.1