From 7dfd1468cc53b622257808fa445519244b1b0716 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 15:38:10 -0800 Subject: Converted the SunModule to the new region module interface. (39 to go...) --- OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 46 +++++++++++++---------- OpenSim/Region/Framework/Interfaces/ISunModule.cs | 2 +- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 9a954b8..df025bf 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -267,13 +267,12 @@ namespace OpenSim.Region.CoreModules return GetCurrentSunHour() + 6.0f; } - #region IRegion Methods + #region INonSharedRegion Methods // Called immediately after the module is loaded for a given region // i.e. Immediately after instance creation. - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - m_scene = scene; m_frame = 0; // This one puts an entry in the main help screen @@ -358,15 +357,6 @@ namespace OpenSim.Region.CoreModules HorizonShift = m_HorizonShift; // Z axis translation // HoursToRadians = (SunCycle/24)*VWTimeRatio; - // Insert our event handling hooks - - scene.EventManager.OnFrame += SunUpdate; - scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; - scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; - scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; - - ready = true; - m_log.Debug("[SUN]: Mode is " + m_RegionMode); m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); @@ -376,14 +366,29 @@ namespace OpenSim.Region.CoreModules break; } - scene.RegisterModuleInterface(this); } - public void PostInitialise() + public Type ReplaceableInterface { + get { return null; } } - public void Close() + public void AddRegion(Scene scene) + { + m_scene = scene; + // Insert our event handling hooks + + scene.EventManager.OnFrame += SunUpdate; + scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; + scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; + scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; + + scene.RegisterModuleInterface(this); + + ready = true; + } + + public void RemoveRegion(Scene scene) { ready = false; @@ -394,14 +399,17 @@ namespace OpenSim.Region.CoreModules m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; } - public string Name + public void RegionLoaded(Scene scene) { - get { return "SunModule"; } } - public bool IsSharedModule + public void Close() { - get { return false; } + } + + public string Name + { + get { return "SunModule"; } } #endregion diff --git a/OpenSim/Region/Framework/Interfaces/ISunModule.cs b/OpenSim/Region/Framework/Interfaces/ISunModule.cs index 819ae11..8231716 100644 --- a/OpenSim/Region/Framework/Interfaces/ISunModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISunModule.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { - public interface ISunModule : IRegionModule + public interface ISunModule : INonSharedRegionModule { double GetSunParameter(string param); -- cgit v1.1 From 19aab3e6fea9c14d28c952c4e1f38919a4cc4363 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 16:28:30 -0800 Subject: Converted the WindModule to the new region module interface (38 to go). Also added both the WindModule and the SunModule to the Plugin manifest. --- .../Resources/CoreModulePlugin.addin.xml | 2 + OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 16 +- .../Region/CoreModules/World/Wind/WindModule.cs | 182 +++++++++++---------- OpenSim/Region/Framework/Interfaces/IWindModule.cs | 2 +- 4 files changed, 107 insertions(+), 95 deletions(-) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 6c73d91..2ddd0b6 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -38,6 +38,8 @@ + + diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index df025bf..bdbf273 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -278,14 +278,6 @@ namespace OpenSim.Region.CoreModules // This one puts an entry in the main help screen // m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); - // This one enables the ability to type just "sun" without any parameters -// m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); - foreach (KeyValuePair kvp in GetParamList()) - { - string sunCommand = string.Format("sun {0}", kvp.Key); - m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} []", sunCommand), kvp.Value, "", HandleSunConsoleCommand); - } - TimeZone local = TimeZone.CurrentTimeZone; TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); @@ -385,6 +377,14 @@ namespace OpenSim.Region.CoreModules scene.RegisterModuleInterface(this); + // This one enables the ability to type just "sun" without any parameters + // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); + foreach (KeyValuePair kvp in GetParamList()) + { + string sunCommand = string.Format("sun {0}", kvp.Key); + m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} []", sunCommand), kvp.Value, "", HandleSunConsoleCommand); + } + ready = true; } diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 7b6fbda..0186a41 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -52,31 +52,31 @@ namespace OpenSim.Region.CoreModules private bool m_ready = false; private bool m_enabled = false; - + private IConfig m_windConfig; private IWindModelPlugin m_activeWindPlugin = null; - private const string m_dWindPluginName = "SimpleRandomWind"; + private string m_dWindPluginName = "SimpleRandomWind"; private Dictionary m_availableWindPlugins = new Dictionary(); // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m private Vector2[] windSpeeds = new Vector2[16 * 16]; - #region IRegion Methods + #region INonSharedRegionModule Methods - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - IConfig windConfig = config.Configs["Wind"]; + m_windConfig = config.Configs["Wind"]; string desiredWindPlugin = m_dWindPluginName; - if (windConfig != null) + if (m_windConfig != null) { - m_enabled = windConfig.GetBoolean("enabled", true); + m_enabled = m_windConfig.GetBoolean("enabled", true); - m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150); + m_frameUpdateRate = m_windConfig.GetInt("wind_update_rate", 150); // Determine which wind model plugin is desired - if (windConfig.Contains("wind_plugin")) + if (m_windConfig.Contains("wind_plugin")) { - desiredWindPlugin = windConfig.GetString("wind_plugin"); + m_dWindPluginName = m_windConfig.GetString("wind_plugin", m_dWindPluginName); } } @@ -84,104 +84,111 @@ namespace OpenSim.Region.CoreModules { m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate); - m_scene = scene; - m_frame = 0; - - // Register all the Wind Model Plug-ins - foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) - { - m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name); - m_availableWindPlugins.Add(windPlugin.Name, windPlugin); - } + } - // Check for desired plugin - if (m_availableWindPlugins.ContainsKey(desiredWindPlugin)) - { - m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin]; + } - m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin); + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; - if (windConfig != null) - { - m_activeWindPlugin.Initialise(); - m_activeWindPlugin.WindConfig(m_scene, windConfig); - } - } + m_scene = scene; + m_frame = 0; + // Register all the Wind Model Plug-ins + foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) + { + m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name); + m_availableWindPlugins.Add(windPlugin.Name, windPlugin); + } - // if the plug-in wasn't found, default to no wind. - if (m_activeWindPlugin == null) - { - m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin); - m_log.ErrorFormat("[WIND] Defaulting to no wind."); - } + // Check for desired plugin + if (m_availableWindPlugins.ContainsKey(m_dWindPluginName)) + { + m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName]; - // This one puts an entry in the main help screen -// m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind [value] - Get or Update Wind paramaters", null); - - // This one enables the ability to type just the base command without any parameters -// m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand); + m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName); - // Get a list of the parameters for each plugin - foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) + if (m_windConfig != null) { -// m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); - m_scene.AddCommand( - "Regions", - this, - "wind base wind_update_rate", - "wind base wind_update_rate []", - "Get or set the wind update rate.", - "", - HandleConsoleBaseCommand); - - foreach (KeyValuePair kvp in windPlugin.WindParams()) - { - string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key); - m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} []", windCommand), kvp.Value, "", HandleConsoleParamCommand); - } + m_activeWindPlugin.Initialise(); + m_activeWindPlugin.WindConfig(m_scene, m_windConfig); } + } - // Register event handlers for when Avatars enter the region, and frame ticks - m_scene.EventManager.OnFrame += WindUpdate; - m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; - // Register the wind module - m_scene.RegisterModuleInterface(this); + // if the plug-in wasn't found, default to no wind. + if (m_activeWindPlugin == null) + { + m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName); + m_log.ErrorFormat("[WIND] Defaulting to no wind."); + } - // Generate initial wind values - GenWindPos(); + // This one puts an entry in the main help screen + // m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind [value] - Get or Update Wind paramaters", null); - // Mark Module Ready for duty - m_ready = true; + // This one enables the ability to type just the base command without any parameters + // m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand); + // Get a list of the parameters for each plugin + foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) + { + // m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); + m_scene.AddCommand( + "Regions", + this, + "wind base wind_update_rate", + "wind base wind_update_rate []", + "Get or set the wind update rate.", + "", + HandleConsoleBaseCommand); + + foreach (KeyValuePair kvp in windPlugin.WindParams()) + { + string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key); + m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} []", windCommand), kvp.Value, "", HandleConsoleParamCommand); + } } - } + // Register event handlers for when Avatars enter the region, and frame ticks + m_scene.EventManager.OnFrame += WindUpdate; + m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; - public void PostInitialise() - { + // Register the wind module + m_scene.RegisterModuleInterface(this); + + // Generate initial wind values + GenWindPos(); + + // Mark Module Ready for duty + m_ready = true; } - public void Close() + public void RemoveRegion(Scene scene) { - if (m_enabled) + if (!m_enabled) + return; + + m_ready = false; + + // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? + m_activeWindPlugin = null; + foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) { - m_ready = false; + windPlugin.Dispose(); + } - // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? - m_activeWindPlugin = null; - foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) - { - windPlugin.Dispose(); - } + m_availableWindPlugins.Clear(); - m_availableWindPlugins.Clear(); + // Remove our hooks + m_scene.EventManager.OnFrame -= WindUpdate; + m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; - // Remove our hooks - m_scene.EventManager.OnFrame -= WindUpdate; - m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; - } + } + + public void Close() + { } public string Name @@ -189,11 +196,14 @@ namespace OpenSim.Region.CoreModules get { return "WindModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return false; } + get { return null; } } + public void RegionLoaded(Scene scene) + { + } #endregion diff --git a/OpenSim/Region/Framework/Interfaces/IWindModule.cs b/OpenSim/Region/Framework/Interfaces/IWindModule.cs index 10ecc32..4a26a71 100644 --- a/OpenSim/Region/Framework/Interfaces/IWindModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWindModule.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { - public interface IWindModule : IRegionModule + public interface IWindModule : INonSharedRegionModule { /// -- cgit v1.1 From 2540132a5401b567bebd2e11059ec8b65e02972e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 16:40:55 -0800 Subject: MapSearchModule also converted to new region module interface (37 to go). --- .../Resources/CoreModulePlugin.addin.xml | 1 + .../CoreModules/World/WorldMap/MapSearchModule.cs | 27 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 2ddd0b6..8fc70e2 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -40,6 +40,7 @@ + diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index f37dd94..7de1bb2 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -24,6 +24,7 @@ * (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.Reflection; using log4net; @@ -37,7 +38,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.World.WorldMap { - public class MapSearchModule : IRegionModule + public class MapSearchModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -45,8 +46,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap Scene m_scene = null; // only need one for communication with GridService List m_scenes = new List(); - #region IRegionModule Members - public void Initialise(Scene scene, IConfigSource source) + #region ISharedRegionModule Members + public void Initialise(IConfigSource source) + { + } + + public void AddRegion(Scene scene) { if (m_scene == null) { @@ -57,6 +62,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap scene.EventManager.OnNewClient += OnNewClient; } + public void RemoveRegion(Scene scene) + { + m_scenes.Remove(scene); + if (m_scene == scene && m_scenes.Count > 0) + m_scene = m_scenes[0]; + + scene.EventManager.OnNewClient -= OnNewClient; + } + public void PostInitialise() { } @@ -72,11 +86,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap get { return "MapSearchModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } + public void RegionLoaded(Scene scene) + { + } #endregion private void OnNewClient(IClientAPI client) -- cgit v1.1 From 4f9825961743684dfb76827e2353497182a83d8a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 20:39:55 -0800 Subject: Minor improvement in the MapSearchModule. Stop blocking the client thread if the search takes too long. --- .../CoreModules/World/WorldMap/MapSearchModule.cs | 74 ++++++++++++++++------ 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 7de1bb2..8f1a35d 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap Scene m_scene = null; // only need one for communication with GridService List m_scenes = new List(); + List m_Clients; #region ISharedRegionModule Members public void Initialise(IConfigSource source) @@ -60,6 +61,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scenes.Add(scene); scene.EventManager.OnNewClient += OnNewClient; + m_Clients = new List(); } public void RemoveRegion(Scene scene) @@ -98,17 +100,51 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private void OnNewClient(IClientAPI client) { - client.OnMapNameRequest += OnMapNameRequest; + client.OnMapNameRequest += OnMapNameRequestHandler; + } + + private void OnMapNameRequestHandler(IClientAPI remoteClient, string mapName, uint flags) + { + lock (m_Clients) + { + if (m_Clients.Contains(remoteClient.AgentId)) + return; + + m_Clients.Add(remoteClient.AgentId); + } + + Util.FireAndForget(delegate + { + try + { + OnMapNameRequest(remoteClient, mapName, flags); + } + finally + { + lock (m_Clients) + m_Clients.Remove(remoteClient.AgentId); + } + }); + } private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) { - if (mapName.Length < 3) + List blocks = new List(); + MapBlockData data; + if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) { + // final block, closing the search result + AddFinalBlock(blocks); + + // flags are agent flags sent from the viewer. + // they have different values depending on different viewers, apparently + remoteClient.SendMapBlock(blocks, flags); remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); return; } + //m_log.DebugFormat("MAP NAME=({0})", mapName); // Hack to get around the fact that ll V3 now drops the port from the @@ -129,13 +165,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // try to fetch from GridServer List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); - if (regionInfos.Count == 0) - remoteClient.SendAlertMessage("Hyperlink could not be established."); m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); - List blocks = new List(); - - MapBlockData data; if (regionInfos.Count > 0) { foreach (GridRegion info in regionInfos) @@ -162,16 +193,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } // final block, closing the search result - data = new MapBlockData(); - data.Agents = 0; - data.Access = 255; - data.MapImageId = UUID.Zero; - data.Name = ""; // mapName; - data.RegionFlags = 0; - data.WaterHeight = 0; // not used - data.X = 0; - data.Y = 0; - blocks.Add(data); + AddFinalBlock(blocks); // flags are agent flags sent from the viewer. // they have different values depending on different viewers, apparently @@ -183,12 +205,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (flags == 2) { if (regionInfos.Count == 0) - remoteClient.SendAgentAlertMessage("No regions found with that name.", true); + remoteClient.SendAlertMessage("No regions found with that name."); else if (regionInfos.Count == 1) - remoteClient.SendAgentAlertMessage("Region found!", false); + remoteClient.SendAlertMessage("Region found!"); } } + private void AddFinalBlock(List blocks) + { + // final block, closing the search result + MapBlockData data = new MapBlockData(); + data.Agents = 0; + data.Access = 255; + data.MapImageId = UUID.Zero; + data.Name = ""; + data.RegionFlags = 0; + data.WaterHeight = 0; // not used + data.X = 0; + data.Y = 0; + blocks.Add(data); + } // private Scene GetClientScene(IClientAPI client) // { // foreach (Scene s in m_scenes) -- cgit v1.1 From c94240ba5b0f3ca77abc42245b3f2c6d0af9a138 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 10 Nov 2012 05:43:57 +0000 Subject: Uncomment SceneObjectBasicTests.TestDeleteSceneObjectAsyncToUserInventory() and make it compile again Not currently in test suite since not yet working. Also add method doc to Scene.DeRezObjects() --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 15 +++- .../Scenes/Tests/SceneObjectBasicTests.cs | 90 ++++++++++++++-------- 2 files changed, 70 insertions(+), 35 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b23ddb4..ad40d6b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1909,8 +1909,19 @@ namespace OpenSim.Region.Framework.Scenes } } - public virtual void DeRezObjects(IClientAPI remoteClient, List localIDs, - UUID groupID, DeRezAction action, UUID destinationID) + /// + /// Derez one or more objects from the scene. + /// + /// + /// Won't actually remove the scene object in the case where the object is being copied to a user inventory. + /// + /// Client requesting derez + /// Local ids of root parts of objects to delete. + /// Not currently used. Here because the client passes this to us. + /// DeRezAction + /// User folder ID to place derezzed object + public virtual void DeRezObjects( + IClientAPI remoteClient, List localIDs, UUID groupID, DeRezAction action, UUID destinationID) { // First, see of we can perform the requested action and // build a list of eligible objects diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 3398a53..5b334c6 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Reflection; using System.Threading; using NUnit.Framework; @@ -33,6 +34,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -42,7 +44,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Basic scene object tests (create, read and delete but not update). /// [TestFixture] - public class SceneObjectBasicTests + public class SceneObjectBasicTests : OpenSimTestCase { // [TearDown] // public void TearDown() @@ -237,38 +239,60 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// /// Test deleting an object asynchronously to user inventory. /// - //[Test] - //public void TestDeleteSceneObjectAsyncToUserInventory() - //{ - // TestHelper.InMethod(); - // //log4net.Config.XmlConfigurator.Configure(); - - // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - // string myObjectName = "Fred"; - - // TestScene scene = SceneSetupHelpers.SetupScene(); - // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName); - - // Assert.That( - // scene.CommsManager.UserAdminService.AddUser( - // "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), - // Is.EqualTo(agentId)); - - // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); - - // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId); - // Assert.That(userInfo, Is.Not.Null); - // Assert.That(userInfo.RootFolder, Is.Not.Null); - - // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); - - // // Check that we now have the taken part in our inventory - // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name)); - - // // Check that the taken part has actually disappeared - // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); - // Assert.That(retrievedPart, Is.Null); - //} +// [Test] + public void TestDeleteSceneObjectAsyncToUserInventory() + { + TestHelpers.InMethod(); + TestHelpers.EnableLogging(); + + UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + string myObjectName = "Fred"; + + TestScene scene = new SceneHelpers().SetupScene(); + + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. + AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; + sogd.Enabled = false; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId); + +// Assert.That( +// scene.CommsManager.UserAdminService.AddUser( +// "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), +// Is.EqualTo(agentId)); + + UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); + InventoryFolderBase folder1 + = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1"); + + IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; + scene.DeRezObjects(client, new List() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); + + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(so.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + + Assert.That(so.IsDeleted, Is.True); + + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Null); + +// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); + + InventoryItemBase retrievedItem + = UserInventoryHelpers.GetInventoryItem( + scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName); + + // Check that we now have the taken part in our inventory + Assert.That(retrievedItem, Is.Not.Null); + + // Check that the taken part has actually disappeared +// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); +// Assert.That(retrievedPart, Is.Null); + } /// /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not -- cgit v1.1 From 492515cf3f22d7f4ebdf96c924e51f7462eb0aa8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 21:58:39 -0800 Subject: One more module converted: Vegetation. --- .../Resources/CoreModulePlugin.addin.xml | 1 + .../World/Vegetation/VegetationModule.cs | 26 +++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 8fc70e2..14dc22a 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -41,6 +41,7 @@ + diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs index f5f35bb..528da0e3 100644 --- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs +++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs @@ -36,7 +36,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.Vegetation { - public class VegetationModule : IRegionModule, IVegetationModule + public class VegetationModule : INonSharedRegionModule, IVegetationModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -45,16 +45,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree }; public PCode[] CreationCapabilities { get { return creationCapabilities; } } - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) + { + } + + public void AddRegion(Scene scene) { m_scene = scene; m_scene.RegisterModuleInterface(this); } - - public void PostInitialise() {} + + public void RemoveRegion(Scene scene) + { + m_scene.UnregisterModuleInterface(this); + } + public void Close() {} public string Name { get { return "Vegetation Module"; } } - public bool IsSharedModule { get { return false; } } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void RegionLoaded(Scene scene) + { + } public SceneObjectGroup AddTree( UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree) -- cgit v1.1 From a4fee98352c7d38bdb00298dd709a488b9f2ca39 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 22:09:08 -0800 Subject: One more module converted: TreePopulator. --- .../Resources/OptionalModules.addin.xml | 1 + .../World/TreePopulator/TreePopulatorModule.cs | 30 ++++++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml index 8691343..a372d37 100644 --- a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml +++ b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml @@ -14,5 +14,6 @@ + diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index 51b0592..6ebdf4d 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator /// /// Version 2.02 - Still hacky /// - public class TreePopulatorModule : IRegionModule, ICommandableModule, IVegetationModule + public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule, IVegetationModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly Commander m_commander = new Commander("tree"); @@ -170,13 +170,9 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator #region IRegionModule Members - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - m_scene = scene; - m_scene.RegisterModuleInterface(this); - m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; - // ini file settings try { @@ -201,7 +197,20 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator m_log.Debug("[TREES]: Initialised tree module"); } - public void PostInitialise() + public void AddRegion(Scene scene) + { + m_scene = scene; + //m_scene.RegisterModuleInterface(this); + m_scene.RegisterModuleCommander(m_commander); + m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; + + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) { ReloadCopse(); if (m_copse.Count > 0) @@ -220,11 +229,12 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator get { return "TreePopulatorModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return false; } + get { return null; } } + #endregion //-------------------------------------------------------------- @@ -448,8 +458,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator m_commander.RegisterCommand("reload", treeReloadCommand); m_commander.RegisterCommand("remove", treeRemoveCommand); m_commander.RegisterCommand("statistics", treeStatisticsCommand); - - m_scene.RegisterModuleCommander(m_commander); } /// -- cgit v1.1 From 86b22604fa5d6b27421d87b6fb04baf01ed74ca5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Nov 2012 22:21:11 -0800 Subject: One more more converted: IPBanModule. --- .../Region/CoreModules/Agent/IPBan/IPBanModule.cs | 24 ++++++++++++++++------ .../Resources/CoreModulePlugin.addin.xml | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs index bfe2a71..1749dcf 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs @@ -36,13 +36,17 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Agent.IPBan { - public class IPBanModule : IRegionModule + public class IPBanModule : ISharedRegionModule { - #region Implementation of IRegionModule + #region Implementation of ISharedRegionModule private List m_bans = new List(); - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) + { + } + + public void AddRegion(Scene scene) { new SceneBanner(scene, m_bans); @@ -50,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan { foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) { - if (!String.IsNullOrEmpty(ban.BannedHostIPMask)) + if (!String.IsNullOrEmpty(ban.BannedHostIPMask)) m_bans.Add(ban.BannedHostIPMask); if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) m_bans.Add(ban.BannedHostNameMask); @@ -58,6 +62,14 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan } } + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + } + public void PostInitialise() { if (File.Exists("bans.txt")) @@ -80,9 +92,9 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan get { return "IPBanModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } #endregion diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 14dc22a..5a413a9 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -42,6 +42,7 @@ + -- cgit v1.1 From 791c4d5b9fe831cab3dd984184714e6e674918f9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 08:10:43 -0800 Subject: One more module converted: J2KDecoderModule. --- .../Agent/TextureSender/J2KDecoderModule.cs | 42 ++++++++++++++++------ .../Resources/CoreModulePlugin.addin.xml | 1 + 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index a1a2501..2879154 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { public delegate void J2KDecodeDelegate(UUID assetID); - public class J2KDecoderModule : IRegionModule, IJ2KDecoder + public class J2KDecoderModule : ISharedRegionModule, IJ2KDecoder { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -56,26 +56,21 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// Cache that will store decoded JPEG2000 layer boundary data private IImprovedAssetCache m_cache; /// Reference to a scene (doesn't matter which one as long as it can load the cache module) + private UUID m_CreatorID = UUID.Zero; private Scene m_scene; - #region IRegionModule + #region ISharedRegionModule private bool m_useCSJ2K = true; public string Name { get { return "J2KDecoderModule"; } } - public bool IsSharedModule { get { return true; } } public J2KDecoderModule() { } - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) { - if (m_scene == null) - m_scene = scene; - - scene.RegisterModuleInterface(this); - IConfig startupConfig = source.Configs["Startup"]; if (startupConfig != null) { @@ -83,6 +78,24 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender } } + public void AddRegion(Scene scene) + { + if (m_scene == null) + { + m_scene = scene; + m_CreatorID = scene.RegionInfo.RegionID; + } + + scene.RegisterModuleInterface(this); + + } + + public void RemoveRegion(Scene scene) + { + if (m_scene == scene) + m_scene = null; + } + public void PostInitialise() { m_cache = m_scene.RequestModuleInterface(); @@ -92,6 +105,15 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { } + public void RegionLoaded(Scene scene) + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + #endregion IRegionModule #region IJ2KDecoder @@ -279,7 +301,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { string assetID = "j2kCache_" + AssetId.ToString(); - AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID.ToString()); + AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_CreatorID.ToString()); layerDecodeAsset.Local = true; layerDecodeAsset.Temporary = true; diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 5a413a9..820f11b 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -43,6 +43,7 @@ + -- cgit v1.1 From ee3d06220ef8ddbbc8af24981e147494110ed5c1 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 4 Nov 2012 10:57:15 +0000 Subject: Documenting parameters of methods on the IDialogModule interface --- .../Region/Framework/Interfaces/IDialogModule.cs | 106 ++++++++++++++------- 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index be9764a..d1e9df0 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs @@ -36,59 +36,75 @@ namespace OpenSim.Region.Framework.Interfaces /// Send a non-modal alert message to a particular user. This can disappear from the user's view after a /// small interval. /// - /// - /// + /// + /// IClientAPI object representing the user. + /// + /// Message text to send to the user. void SendAlertToUser(IClientAPI client, string message); /// /// Send an alert message to a particular user. /// - /// - /// - /// + /// + /// IClientAPI object representing the user. + /// + /// Message text to send to the user. + /// Flag to control modality. void SendAlertToUser(IClientAPI client, string message, bool modal); /// /// Send a non-modal alert message to a particular user. /// - /// - /// + /// UUID of agent representing the user. + /// Message text to send to the user. void SendAlertToUser(UUID agentID, string message); /// /// Send an alert message to a particular user. /// - /// - /// - /// + /// UUID of agent representing the user. + /// Message text to send to the user. + /// Flag to control modality. void SendAlertToUser(UUID agentID, string message, bool modal); /// /// Send an alert message to a particular user. /// - /// - /// - /// - /// + /// Account first name + /// Account last name + /// Message text to send to the user. + /// Flag to control modality. void SendAlertToUser(string firstName, string lastName, string message, bool modal); /// /// Send an alert message to all users in the scene. /// - /// + /// Message text to send to all users. void SendGeneralAlert(string message); /// /// Send a dialog box to a particular user. /// - /// - /// - /// - /// - /// - /// - /// - /// + /// + /// UUID of the avatar representing the user. + /// + /// + /// Name of the object sending the dialog. + /// + /// + /// UUID of the object sending the dialog. + /// + /// + /// UUID of the user that owns the object. + /// + /// Message text to send to the user. + /// + /// Texture UUID to pass along with the dialog. + /// + /// + /// Channel on which the selected button text should be broadcast. + /// + /// Dialog button text. void SendDialogToUser( UUID avatarID, string objectName, UUID objectID, UUID ownerID, string message, UUID textureID, int ch, string[] buttonlabels); @@ -96,13 +112,23 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Send a url to a particular user. /// - /// - /// - /// - /// - /// - /// - /// + /// + /// UUID of the avatar representing the user. + /// + /// + /// Name of the object sending the dialog. + /// + /// + /// UUID of the object sending the dialog. + /// + /// + /// UUID of the user that owns the object. + /// + /// + /// Flag indicating whether or not the object is group-owned. + /// + /// Message text to send to the user. + /// Url to send to the user. void SendUrlToUser( UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url); @@ -110,18 +136,32 @@ namespace OpenSim.Region.Framework.Interfaces /// Send a notification to all users in the scene. This notification should remain around until the /// user explicitly dismisses it. /// - /// + /// /// On the Linden Labs Second Client (as of 1.21), this is a big blue box message on the upper right of the /// screen. - /// + /// /// The user sending the message /// The name of the user doing the sending /// The message being sent to the user void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message); - + /// /// Send a textbox entry for the client to respond to /// + /// + /// UUID of the avatar representing the user. + /// + /// Message text to send to the user. + /// + /// Chat channel that the user's input should be broadcast on. + /// + /// Name of the object sending the dialog. + /// + /// UUID of the object sending the dialog. + /// + /// + /// UUID of the user that owns the object. + /// void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); } } -- cgit v1.1 From d0742cea3ef1fc24fadab66756d1a5c94bcfe171 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 4 Nov 2012 11:02:21 +0000 Subject: 80 character-width terminal formatting of IDialogModule interface, removing superfluous whitespace & line-endings. --- .../Region/Framework/Interfaces/IDialogModule.cs | 51 ++++++++++++---------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index d1e9df0..4d35c1c 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs @@ -33,15 +33,15 @@ namespace OpenSim.Region.Framework.Interfaces public interface IDialogModule { /// - /// Send a non-modal alert message to a particular user. This can disappear from the user's view after a - /// small interval. + /// Send a non-modal alert message to a particular user. This can + /// disappear from the user's view after a small interval. /// /// /// IClientAPI object representing the user. /// /// Message text to send to the user. void SendAlertToUser(IClientAPI client, string message); - + /// /// Send an alert message to a particular user. /// @@ -51,14 +51,14 @@ namespace OpenSim.Region.Framework.Interfaces /// Message text to send to the user. /// Flag to control modality. void SendAlertToUser(IClientAPI client, string message, bool modal); - + /// /// Send a non-modal alert message to a particular user. /// /// UUID of agent representing the user. /// Message text to send to the user. void SendAlertToUser(UUID agentID, string message); - + /// /// Send an alert message to a particular user. /// @@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Message text to send to the user. /// Flag to control modality. void SendAlertToUser(UUID agentID, string message, bool modal); - + /// /// Send an alert message to a particular user. /// @@ -74,14 +74,15 @@ namespace OpenSim.Region.Framework.Interfaces /// Account last name /// Message text to send to the user. /// Flag to control modality. - void SendAlertToUser(string firstName, string lastName, string message, bool modal); - + void SendAlertToUser(string firstName, string lastName, + string message, bool modal); + /// /// Send an alert message to all users in the scene. /// /// Message text to send to all users. void SendGeneralAlert(string message); - + /// /// Send a dialog box to a particular user. /// @@ -105,10 +106,10 @@ namespace OpenSim.Region.Framework.Interfaces /// Channel on which the selected button text should be broadcast. /// /// Dialog button text. - void SendDialogToUser( - UUID avatarID, string objectName, UUID objectID, UUID ownerID, - string message, UUID textureID, int ch, string[] buttonlabels); - + void SendDialogToUser(UUID avatarID, string objectName, UUID objectID, + UUID ownerID, string message, UUID textureID, int ch, + string[] buttonlabels); + /// /// Send a url to a particular user. /// @@ -129,21 +130,24 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Message text to send to the user. /// Url to send to the user. - void SendUrlToUser( - UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url); - + void SendUrlToUser(UUID avatarID, string objectName, UUID objectID, + UUID ownerID, bool groupOwned, string message, string url); + /// - /// Send a notification to all users in the scene. This notification should remain around until the - /// user explicitly dismisses it. + /// Send a notification to all users in the scene. This notification + /// should remain around until the user explicitly dismisses it. /// /// - /// On the Linden Labs Second Client (as of 1.21), this is a big blue box message on the upper right of the - /// screen. + /// On the Linden Labs Second Client (as of 1.21), this is a big blue + /// box message on the upper right of the screen. /// /// The user sending the message - /// The name of the user doing the sending + /// + /// The name of the user doing the sending + /// /// The message being sent to the user - void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message); + void SendNotificationToUsersInRegion(UUID fromAvatarID, + string fromAvatarName, string message); /// /// Send a textbox entry for the client to respond to @@ -162,6 +166,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// UUID of the user that owns the object. /// - void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); + void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, + string name, UUID objectid, UUID ownerid); } } -- cgit v1.1 From 5cba04e2d6a7dd59a299e95d0e30faa7a5f9747e Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 10 Nov 2012 08:59:27 +0000 Subject: Converting DialogModule to INonSharedRegionModule --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 325067c..2fe708f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -32,6 +32,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; +using Mono.Addins; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -39,16 +40,27 @@ using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Dialog { - public class DialogModule : IRegionModule, IDialogModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class DialogModule : IDialogModule, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_scene; - - public void Initialise(Scene scene, IConfigSource source) + + public void Initialise(IConfigSource source) { } + + public Type ReplaceableInterface { get { return null; } } + + public void AddRegion(Scene scene) { m_scene = scene; m_scene.RegisterModuleInterface(this); + } + + public void RegionLoaded(Scene scene) + { + if(scene != m_scene) + return; m_scene.AddCommand( "Users", this, "alert", "alert ", @@ -60,11 +72,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog "Send an alert to a user", HandleAlertConsoleCommand); } + + public void RemoveRegion(Scene scene) + { + if(scene != m_scene) + return; + + m_scene.UnregisterModuleInterface(this); + } - public void PostInitialise() {} public void Close() {} public string Name { get { return "Dialog Module"; } } - public bool IsSharedModule { get { return false; } } public void SendAlertToUser(IClientAPI client, string message) { -- cgit v1.1 From fb7bbe167ace2954a961714881e5b0bc3b0dab77 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 10 Nov 2012 09:05:32 +0000 Subject: formatting DialogModule for 80-character width terminal --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 120 +++++++++++++-------- 1 file changed, 73 insertions(+), 47 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 2fe708f..d85a6e3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -42,9 +42,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class DialogModule : IDialogModule, INonSharedRegionModule - { + { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + protected Scene m_scene; public void Initialise(IConfigSource source) { } @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void RegionLoaded(Scene scene) { - if(scene != m_scene) + if (scene != m_scene) return; m_scene.AddCommand( @@ -68,52 +68,59 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog HandleAlertConsoleCommand); m_scene.AddCommand( - "Users", this, "alert-user", "alert-user ", + "Users", this, "alert-user", + "alert-user ", "Send an alert to a user", HandleAlertConsoleCommand); } public void RemoveRegion(Scene scene) { - if(scene != m_scene) + if (scene != m_scene) return; m_scene.UnregisterModuleInterface(this); } - - public void Close() {} + + public void Close() { } public string Name { get { return "Dialog Module"; } } - + public void SendAlertToUser(IClientAPI client, string message) { SendAlertToUser(client, message, false); } - - public void SendAlertToUser(IClientAPI client, string message, bool modal) + + public void SendAlertToUser(IClientAPI client, string message, + bool modal) { client.SendAgentAlertMessage(message, modal); - } - + } + public void SendAlertToUser(UUID agentID, string message) { SendAlertToUser(agentID, message, false); } - + public void SendAlertToUser(UUID agentID, string message, bool modal) { ScenePresence sp = m_scene.GetScenePresence(agentID); - + if (sp != null) sp.ControllingClient.SendAgentAlertMessage(message, modal); } - - public void SendAlertToUser(string firstName, string lastName, string message, bool modal) + + public void SendAlertToUser(string firstName, string lastName, + string message, bool modal) { - ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); + ScenePresence presence = m_scene.GetScenePresence(firstName, + lastName); if (presence != null) - presence.ControllingClient.SendAgentAlertMessage(message, modal); + { + presence.ControllingClient.SendAgentAlertMessage(message, + modal); + } } - + public void SendGeneralAlert(string message) { m_scene.ForEachRootClient(delegate(IClientAPI client) @@ -122,11 +129,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog }); } - public void SendDialogToUser( - UUID avatarID, string objectName, UUID objectID, UUID ownerID, - string message, UUID textureID, int ch, string[] buttonlabels) + public void SendDialogToUser(UUID avatarID, string objectName, + UUID objectID, UUID ownerID, string message, UUID textureID, + int ch, string[] buttonlabels) { - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); + UserAccount account = m_scene.UserAccountService.GetUserAccount( + m_scene.RegionInfo.ScopeID, ownerID); string ownerFirstName, ownerLastName; if (account != null) { @@ -141,29 +149,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog ScenePresence sp = m_scene.GetScenePresence(avatarID); if (sp != null) - sp.ControllingClient.SendDialog( - objectName, objectID, ownerID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); + { + sp.ControllingClient.SendDialog(objectName, objectID, ownerID, + ownerFirstName, ownerLastName, message, textureID, ch, + buttonlabels); + } } - public void SendUrlToUser( - UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) + public void SendUrlToUser(UUID avatarID, string objectName, + UUID objectID, UUID ownerID, bool groupOwned, string message, + string url) { ScenePresence sp = m_scene.GetScenePresence(avatarID); - + if (sp != null) - sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); + { + sp.ControllingClient.SendLoadURL(objectName, objectID, + ownerID, groupOwned, message, url); + } } - - public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) + + public void SendTextBoxToUser(UUID avatarid, string message, + int chatChannel, string name, UUID objectid, UUID ownerid) { - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); + UserAccount account = m_scene.UserAccountService.GetUserAccount( + m_scene.RegionInfo.ScopeID, ownerid); string ownerFirstName, ownerLastName; - UUID ownerID = UUID.Zero; + UUID ownerID = UUID.Zero; if (account != null) { ownerFirstName = account.FirstName; ownerLastName = account.LastName; - ownerID = account.PrincipalID; + ownerID = account.PrincipalID; } else { @@ -172,29 +189,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog } ScenePresence sp = m_scene.GetScenePresence(avatarid); - + if (sp != null) - sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerID, ownerFirstName, ownerLastName, objectid); + { + sp.ControllingClient.SendTextBoxRequest(message, chatChannel, + name, ownerID, ownerFirstName, ownerLastName, + objectid); + } } - public void SendNotificationToUsersInRegion( - UUID fromAvatarID, string fromAvatarName, string message) + public void SendNotificationToUsersInRegion(UUID fromAvatarID, + string fromAvatarName, string message) { m_scene.ForEachRootClient(delegate(IClientAPI client) { - client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); + client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, + message); }); } - + /// /// Handle an alert command from the console. /// /// /// - public void HandleAlertConsoleCommand(string module, string[] cmdparams) + public void HandleAlertConsoleCommand(string module, + string[] cmdparams) { - if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) + if (m_scene.ConsoleScene() != null && + m_scene.ConsoleScene() != m_scene) + { return; + } string message = string.Empty; @@ -202,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog { message = CombineParams(cmdparams, 1); m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", - m_scene.RegionInfo.RegionName, message); + m_scene.RegionInfo.RegionName, message); SendGeneralAlert(message); } else if (cmdparams.Length > 3) @@ -210,9 +236,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog string firstName = cmdparams[1]; string lastName = cmdparams[2]; message = CombineParams(cmdparams, 3); - m_log.InfoFormat( - "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", - m_scene.RegionInfo.RegionName, firstName, lastName, message); + m_log.InfoFormat("[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", + m_scene.RegionInfo.RegionName, firstName, lastName, + message); SendAlertToUser(firstName, lastName, message, false); } else @@ -230,7 +256,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog { result += commandParams[i] + " "; } - + return result; } } -- cgit v1.1 From 4ac857f9025a8308b0e14adbddffd89b467caf17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 08:48:31 -0800 Subject: One more module: EventQueueGetModule. Also making it non-optional for this dll. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 91 +++++++++------------- bin/OpenSimDefaults.ini | 3 - 2 files changed, 38 insertions(+), 56 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 47cb049..b96b1db 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -55,8 +55,8 @@ namespace OpenSim.Region.ClientStack.Linden public OSDMap body; } - //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class EventQueueGetModule : IEventQueue, IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class EventQueueGetModule : IEventQueue, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -66,8 +66,6 @@ namespace OpenSim.Region.ClientStack.Linden public int DebugLevel { get; set; } protected Scene m_scene; - private IConfigSource m_gConfig; - bool enabledYN; private Dictionary m_ids = new Dictionary(); @@ -75,60 +73,46 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_QueueUUIDAvatarMapping = new Dictionary(); private Dictionary m_AvatarQueueUUIDMapping = new Dictionary(); - #region IRegionModule methods - public virtual void Initialise(Scene scene, IConfigSource config) + #region INonSharedRegionModule methods + public virtual void Initialise(IConfigSource config) { - m_gConfig = config; - - IConfig startupConfig = m_gConfig.Configs["Startup"]; - - ReadConfigAndPopulate(scene, startupConfig, "Startup"); - - if (enabledYN) - { - m_scene = scene; - scene.RegisterModuleInterface(this); - - // Register fallback handler - // Why does EQG Fail on region crossings! - - //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); - -// scene.EventManager.OnNewClient += OnNewClient; - - // TODO: Leaving these open, or closing them when we - // become a child is incorrect. It messes up TP in a big - // way. CAPS/EQ need to be active as long as the UDP - // circuit is there. + } - scene.EventManager.OnClientClosed += ClientClosed; - - scene.EventManager.OnMakeChildAgent += MakeChildAgent; - scene.EventManager.OnRegisterCaps += OnRegisterCaps; - - MainConsole.Instance.Commands.AddCommand( - "Debug", - false, - "debug eq", - "debug eq [0|1|2]", - "Turn on event queue debugging\n" - + " <= 0 - turns off all event queue logging\n" - + " >= 1 - turns on outgoing event logging\n" - + " >= 2 - turns on poll notification", - HandleDebugEq); - } - else - { - m_gConfig = null; - } + public void AddRegion(Scene scene) + { + m_scene = scene; + scene.RegisterModuleInterface(this); + + scene.EventManager.OnClientClosed += ClientClosed; + scene.EventManager.OnMakeChildAgent += MakeChildAgent; + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + + MainConsole.Instance.Commands.AddCommand( + "Debug", + false, + "debug eq", + "debug eq [0|1|2]", + "Turn on event queue debugging\n" + + " <= 0 - turns off all event queue logging\n" + + " >= 1 - turns on outgoing event logging\n" + + " >= 2 - turns on poll notification", + HandleDebugEq); } - private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) + public void RemoveRegion(Scene scene) { - enabledYN = startupConfig.GetBoolean("EventQueue", true); + if (m_scene != scene) + return; + + scene.EventManager.OnClientClosed -= ClientClosed; + scene.EventManager.OnMakeChildAgent -= MakeChildAgent; + scene.EventManager.OnRegisterCaps -= OnRegisterCaps; + + scene.UnregisterModuleInterface(this); + m_scene = null; } - public void PostInitialise() + public void RegionLoaded(Scene scene) { } @@ -141,10 +125,11 @@ namespace OpenSim.Region.ClientStack.Linden get { return "EventQueueGetModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return false; } + get { return null; } } + #endregion protected void HandleDebugEq(string module, string[] args) diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index fa284bd..4b58985 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -57,9 +57,6 @@ ; ## CLIENTS ; ## - ; Enables EventQueueGet Service. - EventQueue = true - ; Set this to the DLL containing the client stack to use. clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll" -- cgit v1.1 From 26a94610fc88846aeab8e6e2ac09ebcf85a89122 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 10:21:37 -0800 Subject: Fix Unit tests -- the module contract was not being honored in the set up of scenes. --- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index fc49169..6d67b67 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -385,18 +385,18 @@ namespace OpenSim.Tests.Common foreach (IRegionModuleBase module in newModules) { - if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); - } - - foreach (IRegionModuleBase module in newModules) - { foreach (Scene scene in scenes) { module.AddRegion(scene); scene.AddRegionModule(module.Name, module); } } - + + foreach (IRegionModuleBase module in newModules) + { + if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); + } + // RegionLoaded is fired after all modules have been appropriately added to all scenes foreach (IRegionModuleBase module in newModules) foreach (Scene scene in scenes) -- cgit v1.1 From 3a5e317f659c7bec1a9b271c2e35f25ca16d7d63 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 10:35:27 -0800 Subject: One more module converted: ObjectAdd. --- .../Linden/Caps/ObjectCaps/ObjectAdd.cs | 117 ++++++++++++--------- 1 file changed, 66 insertions(+), 51 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs index 4ccfc43..642d8b4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs @@ -32,6 +32,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenMetaverse.StructuredData; +using Mono.Addins; using OpenSim.Framework; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; @@ -41,30 +42,60 @@ using Caps=OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Region.ClientStack.Linden { - public class ObjectAdd : IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class ObjectAdd : INonSharedRegionModule { // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; - #region IRegionModule Members - public void Initialise(Scene pScene, IConfigSource pSource) + #region INonSharedRegionModule Members + + public void Initialise(IConfigSource pSource) + { + } + + public void AddRegion(Scene scene) { - m_scene = pScene; + m_scene = scene; m_scene.EventManager.OnRegisterCaps += RegisterCaps; } - public void PostInitialise() + public void RemoveRegion(Scene scene) { - + if (m_scene == scene) + { + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } } + public void RegionLoaded(Scene scene) + { + } + + public void Close() + { + } + + public string Name + { + get { return "ObjectAddModule"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + #endregion + public void RegisterCaps(UUID agentID, Caps caps) { UUID capuuid = UUID.Random(); - -// m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/"); + + // m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/"); caps.RegisterHandler( "ObjectAdd", @@ -73,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden "/CAPS/OA/" + capuuid + "/", httpMethod => ProcessAdd(httpMethod, agentID, caps), "ObjectAdd", - agentID.ToString()));; + agentID.ToString())); ; } public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) @@ -84,7 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden responsedata["keepalive"] = false; responsedata["str_response_string"] = "Request wasn't what was expected"; ScenePresence avatar; - + if (!m_scene.TryGetScenePresence(AgentId, out avatar)) return responsedata; @@ -127,7 +158,7 @@ namespace OpenSim.Region.ClientStack.Linden if (r.Type != OSDType.Map) // not a proper req return responsedata; - + OSDMap rm = (OSDMap)r; if (rm.ContainsKey("ObjectData")) //v2 @@ -138,7 +169,7 @@ namespace OpenSim.Region.ClientStack.Linden return responsedata; } - OSDMap ObjMap = (OSDMap) rm["ObjectData"]; + OSDMap ObjMap = (OSDMap)rm["ObjectData"]; bypass_raycast = ObjMap["BypassRaycast"].AsBoolean(); everyone_mask = readuintval(ObjMap["EveryoneMask"]); @@ -181,7 +212,7 @@ namespace OpenSim.Region.ClientStack.Linden responsedata["str_response_string"] = "Has Profile key, but data not in expected format"; return responsedata; } - + OSDMap ProfileMap = (OSDMap)ObjMap["Profile"]; profile_begin = ProfileMap["Begin"].AsInteger(); @@ -190,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden hollow = ProfileMap["Hollow"].AsInteger(); } ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean(); - + ray_target_id = ObjMap["RayTargetId"].AsUUID(); state = ObjMap["State"].AsInteger(); try { - ray_end = ((OSDArray) ObjMap["RayEnd"]).AsVector3(); - ray_start = ((OSDArray) ObjMap["RayStart"]).AsVector3(); - scale = ((OSDArray) ObjMap["Scale"]).AsVector3(); + ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3(); + ray_start = ((OSDArray)ObjMap["RayStart"]).AsVector3(); + scale = ((OSDArray)ObjMap["Scale"]).AsVector3(); rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion(); } catch (Exception) @@ -214,7 +245,7 @@ namespace OpenSim.Region.ClientStack.Linden return responsedata; } - OSDMap AgentDataMap = (OSDMap) rm["AgentData"]; + OSDMap AgentDataMap = (OSDMap)rm["AgentData"]; //session_id = AgentDataMap["SessionId"].AsUUID(); group_id = AgentDataMap["GroupId"].AsUUID(); @@ -251,21 +282,21 @@ namespace OpenSim.Region.ClientStack.Linden profile_begin = rm["profile_begin"].AsInteger(); profile_curve = rm["profile_curve"].AsInteger(); profile_end = rm["profile_end"].AsInteger(); - + ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean(); - + ray_target_id = rm["ray_target_id"].AsUUID(); - - + + //session_id = rm["session_id"].AsUUID(); state = rm["state"].AsInteger(); - try + try { ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); ray_start = ((OSDArray)rm["ray_start"]).AsVector3(); rotation = ((OSDArray)rm["rotation"]).AsQuaternion(); scale = ((OSDArray)rm["scale"]).AsVector3(); - } + } catch (Exception) { responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format"; @@ -273,9 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden } } - - Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); + + Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); @@ -286,17 +317,17 @@ namespace OpenSim.Region.ClientStack.Linden pbs.PathRevolutions = (byte)path_revolutions; pbs.PathScaleX = (byte)path_scale_x; pbs.PathScaleY = (byte)path_scale_y; - pbs.PathShearX = (byte) path_shear_x; + pbs.PathShearX = (byte)path_shear_x; pbs.PathShearY = (byte)path_shear_y; pbs.PathSkew = (sbyte)path_skew; pbs.PathTaperX = (sbyte)path_taper_x; pbs.PathTaperY = (sbyte)path_taper_y; pbs.PathTwist = (sbyte)path_twist; pbs.PathTwistBegin = (sbyte)path_twist_begin; - pbs.HollowShape = (HollowShape) hollow; + pbs.HollowShape = (HollowShape)hollow; pbs.PCode = (byte)p_code; - pbs.ProfileBegin = (ushort) profile_begin; - pbs.ProfileCurve = (byte) profile_curve; + pbs.ProfileBegin = (ushort)profile_begin; + pbs.ProfileCurve = (byte)profile_curve; pbs.ProfileEnd = (ushort)profile_end; pbs.Scale = scale; pbs.State = (byte)state; @@ -306,7 +337,7 @@ namespace OpenSim.Region.ClientStack.Linden if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) { // rez ON the ground, not IN the ground - // pos.Z += 0.25F; + // pos.Z += 0.25F; obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs); } @@ -323,13 +354,13 @@ namespace OpenSim.Region.ClientStack.Linden rootpart.GroupMask = group_mask; rootpart.NextOwnerMask = next_owner_mask; rootpart.Material = (byte)material; - + m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); - + responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; - responsedata["str_response_string"] = String.Format("local_id{0}",ConvertUintToBytes(obj.LocalId)); + responsedata["str_response_string"] = String.Format("local_id{0}", ConvertUintToBytes(obj.LocalId)); return responsedata; } @@ -347,24 +378,8 @@ namespace OpenSim.Region.ClientStack.Linden byte[] resultbytes = Utils.UIntToBytes(val); if (BitConverter.IsLittleEndian) Array.Reverse(resultbytes); - return String.Format("{0}",Convert.ToBase64String(resultbytes)); - } - - public void Close() - { - - } - - public string Name - { - get { return "ObjectAddModule"; } - } - - public bool IsSharedModule - { - get { return false; } + return String.Format("{0}", Convert.ToBase64String(resultbytes)); } - #endregion } } -- cgit v1.1 From b3574d23e465e6219e732ab6c28772f1359452ca Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 11:26:03 -0800 Subject: One more module converted: DataSnapshot. --- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 158 ++++++++++++--------- .../DataSnapshot/Interfaces/IDataSnapshot.cs | 1 - 2 files changed, 87 insertions(+), 72 deletions(-) diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 5540656..defbadc 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -35,15 +35,20 @@ using System.Xml; using log4net; using Nini.Config; using OpenMetaverse; +using Mono.Addins; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.DataSnapshot.Interfaces; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +[assembly: Addin("LindenCaps", "0.1")] +[assembly: AddinDependency("OpenSim", "0.5")] + namespace OpenSim.Region.DataSnapshot { - public class DataSnapshotManager : IRegionModule, IDataSnapshot + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot { #region Class members //Information from config @@ -95,7 +100,7 @@ namespace OpenSim.Region.DataSnapshot #region IRegionModule - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { if (!m_configLoaded) { @@ -133,82 +138,121 @@ namespace OpenSim.Region.DataSnapshot m_enabled = false; return; } - } - if (m_enabled) - { - //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer - new DataRequestHandler(scene, this); + if (m_enabled) + m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); + } - m_hostname = scene.RegionInfo.ExternalHostName; - m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); + } - MakeEverythingStale(); + } - if (m_dataServices != "" && m_dataServices != "noservices") - NotifyDataServices(m_dataServices, "online"); - } - } + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; - if (m_enabled) - { - m_log.Info("[DATASNAPSHOT]: Scene added to module."); + m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); - m_snapStore.AddScene(scene); - m_scenes.Add(scene); + m_snapStore.AddScene(scene); + m_scenes.Add(scene); - Assembly currentasm = Assembly.GetExecutingAssembly(); + Assembly currentasm = Assembly.GetExecutingAssembly(); - foreach (Type pluginType in currentasm.GetTypes()) + foreach (Type pluginType in currentasm.GetTypes()) + { + if (pluginType.IsPublic) { - if (pluginType.IsPublic) + if (!pluginType.IsAbstract) { - if (!pluginType.IsAbstract) + if (pluginType.GetInterface("IDataSnapshotProvider") != null) { - if (pluginType.GetInterface("IDataSnapshotProvider") != null) - { - IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); - module.Initialize(scene, this); - module.OnStale += MarkDataStale; + IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); + module.Initialize(scene, this); + module.OnStale += MarkDataStale; - m_dataproviders.Add(module); - m_snapStore.AddProvider(module); + m_dataproviders.Add(module); + m_snapStore.AddProvider(module); - m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); - } + m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); } } } + } + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + + m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing"); + Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID); + + m_scenes.Remove(restartedScene); + m_snapStore.RemoveScene(restartedScene); - //scene.OnRestart += OnSimRestart; - scene.EventManager.OnShutdown += delegate() { OnSimRestart(scene.RegionInfo); }; + //Getting around the fact that we can't remove objects from a collection we are enumerating over + List providersToRemove = new List(); + + foreach (IDataSnapshotProvider provider in m_dataproviders) + { + if (provider.GetParentScene == restartedScene) + { + providersToRemove.Add(provider); + } } - else + + foreach (IDataSnapshotProvider provider in providersToRemove) { - //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); + m_dataproviders.Remove(provider); + m_snapStore.RemoveProvider(provider); } + + m_snapStore.RemoveScene(restartedScene); } - public void Close() + public void PostInitialise() { - if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") - NotifyDataServices(m_dataServices, "offline"); + if (!m_enabled) + return; + + //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer + new DataRequestHandler(m_scenes[0], this); + + m_hostname = m_scenes[0].RegionInfo.ExternalHostName; + + if (m_dataServices != "" && m_dataServices != "noservices") + NotifyDataServices(m_dataServices, "online"); } + public void RegionLoaded(Scene scene) + { + if (!m_enabled) + return; + + m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); + m_snapStore.ForceSceneStale(scene); + } - public bool IsSharedModule + public void Close() { - get { return true; } + if (!m_enabled) + return; + + if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") + NotifyDataServices(m_dataServices, "offline"); } + public string Name { get { return "External Data Generator"; } } - public void PostInitialise() + public Type ReplaceableInterface { - + get { return null; } } #endregion @@ -399,35 +443,7 @@ namespace OpenSim.Region.DataSnapshot m_snapStore.ForceSceneStale(scene); } } - #endregion - public void OnSimRestart(RegionInfo thisRegion) - { - m_log.Info("[DATASNAPSHOT]: Region " + thisRegion.RegionName + " is restarting, removing from indexing"); - Scene restartedScene = SceneForUUID(thisRegion.RegionID); - - m_scenes.Remove(restartedScene); - m_snapStore.RemoveScene(restartedScene); - - //Getting around the fact that we can't remove objects from a collection we are enumerating over - List providersToRemove = new List(); - - foreach (IDataSnapshotProvider provider in m_dataproviders) - { - if (provider.GetParentScene == restartedScene) - { - providersToRemove.Add(provider); - } - } - - foreach (IDataSnapshotProvider provider in providersToRemove) - { - m_dataproviders.Remove(provider); - m_snapStore.RemoveProvider(provider); - } - - m_snapStore.RemoveScene(restartedScene); - } } } diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs index 59cdab9..3b3db65 100644 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs @@ -32,6 +32,5 @@ namespace OpenSim.Region.DataSnapshot.Interfaces public interface IDataSnapshot { XmlDocument GetSnapshot(string regionName); - void MakeEverythingStale(); } } -- cgit v1.1 From e10d61ea8cde802b925db54c6717ada718db49db Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 11:59:08 -0800 Subject: One more module converted: CloudModule. --- .../Resources/CoreModulePlugin.addin.xml | 1 + .../Region/CoreModules/World/Cloud/CloudModule.cs | 53 +++++++++++++--------- .../Region/Framework/Interfaces/ICloudModule.cs | 2 +- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 820f11b..81f1ff6 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -44,6 +44,7 @@ + diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs index 5fa3dc2..2ec6ff9 100644 --- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs +++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs @@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules { - public class CloudModule : ICloudModule + public class CloudModule : ICloudModule, INonSharedRegionModule { // private static readonly log4net.ILog m_log // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules private float m_cloudDensity = 1.0F; private float[] cloudCover = new float[16 * 16]; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { IConfig cloudConfig = config.Configs["Cloud"]; @@ -59,21 +59,40 @@ namespace OpenSim.Region.CoreModules m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000); } - if (m_enabled) - { + } - m_scene = scene; + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; - scene.EventManager.OnNewClient += CloudsToClient; - scene.RegisterModuleInterface(this); - scene.EventManager.OnFrame += CloudUpdate; + m_scene = scene; - GenerateCloudCover(); + scene.EventManager.OnNewClient += CloudsToClient; + scene.RegisterModuleInterface(this); + scene.EventManager.OnFrame += CloudUpdate; - m_ready = true; + GenerateCloudCover(); - } + m_ready = true; + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + m_ready = false; + // Remove our hooks + m_scene.EventManager.OnNewClient -= CloudsToClient; + m_scene.EventManager.OnFrame -= CloudUpdate; + m_scene.UnregisterModuleInterface(this); + + m_scene = null; + } + + public void RegionLoaded(Scene scene) + { } public void PostInitialise() @@ -82,13 +101,6 @@ namespace OpenSim.Region.CoreModules public void Close() { - if (m_enabled) - { - m_ready = false; - // Remove our hooks - m_scene.EventManager.OnNewClient -= CloudsToClient; - m_scene.EventManager.OnFrame -= CloudUpdate; - } } public string Name @@ -96,12 +108,11 @@ namespace OpenSim.Region.CoreModules get { return "CloudModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return false; } + get { return null; } } - public float CloudCover(int x, int y, int z) { float cover = 0f; diff --git a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs index 7296ac3..54172bd 100644 --- a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs @@ -27,7 +27,7 @@ namespace OpenSim.Region.Framework.Interfaces { - public interface ICloudModule : IRegionModule + public interface ICloudModule { /// /// Retrieves the cloud density at the given region coordinates -- cgit v1.1 From 5fb5758103c46de2abbc50b6503706eadcd37bfd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 15:54:11 -0800 Subject: Cleaning up some confusion with Addin names introduced in a prior commit. Also the Flotsam cache module was being given a different Addin name, I removed that. --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 4 ++-- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 8aa173a..b77bc59 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -49,8 +49,8 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -[assembly: Addin("FlotsamAssetCache", "1.1")] -[assembly: AddinDependency("OpenSim", "0.5")] +//[assembly: Addin("FlotsamAssetCache", "1.1")] +//[assembly: AddinDependency("OpenSim", "0.5")] namespace OpenSim.Region.CoreModules.Asset { diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index defbadc..9794549 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -42,7 +42,7 @@ using OpenSim.Region.DataSnapshot.Interfaces; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -[assembly: Addin("LindenCaps", "0.1")] +[assembly: Addin("DataSnapshot", "0.1")] [assembly: AddinDependency("OpenSim", "0.5")] namespace OpenSim.Region.DataSnapshot -- cgit v1.1 From 74dd38db70e88c5bf771774b6cc2ec80ab2ba215 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 16:24:15 -0800 Subject: One more module converted: AvatarFactoryModule. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index b5b0082..c3e4679 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -39,9 +39,12 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { - public class AvatarFactoryModule : IAvatarFactoryModule, IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class AvatarFactoryModule : IAvatarFactoryModule, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -61,10 +64,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory #region IRegionModule - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - scene.RegisterModuleInterface(this); - scene.EventManager.OnNewClient += SubscribeToClientEvents; IConfig appearanceConfig = config.Configs["Appearance"]; if (appearanceConfig != null) @@ -74,11 +75,29 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); } + } + + public void AddRegion(Scene scene) + { if (m_scene == null) - m_scene = scene; + m_scene = scene; + + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += SubscribeToClientEvents; } - public void PostInitialise() + public void RemoveRegion(Scene scene) + { + if (scene == m_scene) + { + scene.UnregisterModuleInterface(this); + scene.EventManager.OnNewClient -= SubscribeToClientEvents; + } + + m_scene = null; + } + + public void RegionLoaded(Scene scene) { m_updateTimer.Enabled = false; m_updateTimer.AutoReset = true; @@ -100,6 +119,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory get { return false; } } + public Type ReplaceableInterface + { + get { return null; } + } + + private void SubscribeToClientEvents(IClientAPI client) { client.OnRequestWearables += Client_OnRequestWearables; -- cgit v1.1 From fe2fa70c74b1806df237f92be633a1552e8b9548 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 16:42:52 -0800 Subject: One more module converted: Combat/CombatModule. --- .../CoreModules/Avatar/Combat/CombatModule.cs | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 3a91465..c1a22bf 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -33,9 +33,12 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenMetaverse; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule { - public class CombatModule : IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class CombatModule : ISharedRegionModule { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -54,7 +57,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule /// /// /// - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) + { + } + + public void AddRegion(Scene scene) { lock (m_scenel) { @@ -72,6 +79,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; } + public void RemoveRegion(Scene scene) + { + if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) + m_scenel.Remove(scene.RegionInfo.RegionHandle); + + scene.EventManager.OnAvatarKilled -= KillAvatar; + scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; + } + + public void RegionLoaded(Scene scene) + { + } + public void PostInitialise() { } @@ -85,11 +105,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule get { return "CombatModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } + private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) { string deadAvatarMessage; -- cgit v1.1 From a87c4c7d8924138896ab93828cd8e7d8442fbaf7 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 11 Nov 2012 00:21:10 +0000 Subject: Converting WorldCommModule to INonSharedRegionModule Signed-off-by: Diva Canto --- .../Scripting/WorldComm/WorldCommModule.cs | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 401ff6c..2c26e63 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; using Nini.Config; +using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -86,7 +87,8 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.WorldComm { - public class WorldCommModule : IRegionModule, IWorldComm + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class WorldCommModule : IWorldComm, INonSharedRegionModule { // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -99,9 +101,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private int m_saydistance = 20; private int m_shoutdistance = 100; - #region IRegionModule Members + #region INonSharedRegionModule Members - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { // wrap this in a try block so that defaults will work if // the config file doesn't specify otherwise. @@ -120,18 +122,33 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } if (maxlisteners < 1) maxlisteners = int.MaxValue; if (maxhandles < 1) maxhandles = int.MaxValue; + m_listenerManager = new ListenerManager(maxlisteners, maxhandles); + m_pendingQ = new Queue(); + m_pending = Queue.Synchronized(m_pendingQ); + } + public void PostInitialise() + { + } + + public void AddRegion(Scene scene) + { m_scene = scene; m_scene.RegisterModuleInterface(this); - m_listenerManager = new ListenerManager(maxlisteners, maxhandles); m_scene.EventManager.OnChatFromClient += DeliverClientMessage; m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; - m_pendingQ = new Queue(); - m_pending = Queue.Synchronized(m_pendingQ); } - public void PostInitialise() + public void RegionLoaded(Scene scene) { } + + public void RemoveRegion(Scene scene) { + if (scene != m_scene) + return; + + m_scene.UnregisterModuleInterface(this); + m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage; + m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage; } public void Close() @@ -143,10 +160,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm get { return "WorldCommModule"; } } - public bool IsSharedModule - { - get { return false; } - } + public Type ReplaceableInterface { get { return null; } } #endregion -- cgit v1.1 From b3dddd7447c42a60f1e4a2452e6a6c6dbe9d5618 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 11 Nov 2012 00:38:27 +0000 Subject: document & 80-character width terminal formatting Signed-off-by: Diva Canto --- .../Scripting/WorldComm/WorldCommModule.cs | 170 ++++++++++++++------- 1 file changed, 114 insertions(+), 56 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 2c26e63..c88be82 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -29,9 +29,12 @@ using System; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; + using Nini.Config; using Mono.Addins; + using OpenMetaverse; + using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -111,11 +114,16 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm int maxhandles = 64; try { - m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); - m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); - m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); - maxlisteners = config.Configs["LL-Functions"].GetInt("max_listens_per_region", maxlisteners); - maxhandles = config.Configs["LL-Functions"].GetInt("max_listens_per_script", maxhandles); + m_whisperdistance = config.Configs["Chat"].GetInt( + "whisper_distance", m_whisperdistance); + m_saydistance = config.Configs["Chat"].GetInt( + "say_distance", m_saydistance); + m_shoutdistance = config.Configs["Chat"].GetInt( + "shout_distance", m_shoutdistance); + maxlisteners = config.Configs["LL-Functions"].GetInt( + "max_listens_per_region", maxlisteners); + maxhandles = config.Configs["LL-Functions"].GetInt( + "max_listens_per_script", maxhandles); } catch (Exception) { @@ -269,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm if ((source = m_scene.GetSceneObjectPart(id)) != null) position = source.AbsolutePosition; - else if ((avatar = m_scene.GetScenePresence(id)) != null) + else if ((avatar = m_scene.GetScenePresence(id)) != null) position = avatar.AbsolutePosition; else if (ChatTypeEnum.Region == type) position = CenterOfRegion; @@ -292,7 +300,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// name of sender (object or avatar) /// key of sender (object or avatar) /// msg to sent - public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) + public void DeliverMessage(ChatTypeEnum type, int channel, + string name, UUID id, string msg, Vector3 position) { // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", // type, channel, name, id, msg); @@ -300,17 +309,21 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm // Determine which listen event filters match the given set of arguments, this results // in a limited set of listeners, each belonging a host. If the host is in range, add them // to the pending queue. - foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + foreach (ListenerInfo li + in m_listenerManager.GetListeners(UUID.Zero, channel, + name, id, msg)) { // Dont process if this message is from yourself! if (li.GetHostID().Equals(id)) continue; - SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); + SceneObjectPart sPart = m_scene.GetSceneObjectPart( + li.GetHostID()); if (sPart == null) continue; - double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position); + double dis = Util.GetDistanceTo(sPart.AbsolutePosition, + position); switch (type) { case ChatTypeEnum.Whisper: @@ -353,14 +366,16 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// /// Message. /// - public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) + public void DeliverMessageTo(UUID target, int channel, Vector3 pos, + string name, UUID id, string msg) { // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { - // ignore if a child agent this is restricted to inside one region + // ignore if a child agent this is restricted to inside one + // region if (sp.IsChildAgent) return; @@ -369,8 +384,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm // non zero channel messages only go to the attachments if (channel == 0) { - m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); - } + m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), + pos, name, id, false); + } else { List attachments = sp.GetAttachments(); @@ -386,13 +402,18 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } // Need to check each attachment - foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + foreach (ListenerInfo li + in m_listenerManager.GetListeners(UUID.Zero, + channel, name, id, msg)) { if (li.GetHostID().Equals(id)) continue; - if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) + if (m_scene.GetSceneObjectPart( + li.GetHostID()) == null) + { continue; + } if (targets.Contains(li.GetHostID())) QueueMessage(new ListenerInfo(li, name, id, msg)); @@ -403,17 +424,20 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } // No avatar found so look for an object - foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + foreach (ListenerInfo li + in m_listenerManager.GetListeners(UUID.Zero, channel, + name, id, msg)) { // Dont process if this message is from yourself! if (li.GetHostID().Equals(id)) continue; - SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); + SceneObjectPart sPart = m_scene.GetSceneObjectPart( + li.GetHostID()); if (sPart == null) continue; - if ( li.GetHostID().Equals(target)) + if (li.GetHostID().Equals(target)) { QueueMessage(new ListenerInfo(li, name, id, msg)); break; @@ -467,9 +491,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private void DeliverClientMessage(Object sender, OSChatMessage e) { if (null != e.Sender) - DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position); + { + DeliverMessage(e.Type, e.Channel, e.Sender.Name, + e.Sender.AgentId, e.Message, e.Position); + } else - DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position); + { + DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, + e.Message, e.Position); + } } public Object[] GetSerializationData(UUID itemID) @@ -486,7 +516,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm public class ListenerManager { - private Dictionary> m_listeners = new Dictionary>(); + private Dictionary> m_listeners = + new Dictionary>(); private int m_maxlisteners; private int m_maxhandles; private int m_curlisteners; @@ -544,14 +575,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm itemID, hostID, channel, name, id, msg, regexBitfield); - List listeners; - if (!m_listeners.TryGetValue(channel,out listeners)) - { - listeners = new List(); - m_listeners.Add(channel, listeners); - } - listeners.Add(li); - m_curlisteners++; + List listeners; + if (!m_listeners.TryGetValue( + channel, out listeners)) + { + listeners = new List(); + m_listeners.Add(channel, listeners); + } + listeners.Add(li); + m_curlisteners++; return newHandle; } @@ -564,11 +596,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm { lock (m_listeners) { - foreach (KeyValuePair> lis in m_listeners) + foreach (KeyValuePair> lis + in m_listeners) { foreach (ListenerInfo li in lis.Value) { - if (li.GetItemID().Equals(itemID) && li.GetHandle().Equals(handle)) + if (li.GetItemID().Equals(itemID) && + li.GetHandle().Equals(handle)) { lis.Value.Remove(li); if (lis.Value.Count == 0) @@ -591,13 +625,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm lock (m_listeners) { - foreach (KeyValuePair> lis in m_listeners) + foreach (KeyValuePair> lis + in m_listeners) { foreach (ListenerInfo li in lis.Value) { if (li.GetItemID().Equals(itemID)) { - // store them first, else the enumerated bails on us + // store them first, else the enumerated bails on + // us removedListeners.Add(li); } } @@ -624,11 +660,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm { lock (m_listeners) { - foreach (KeyValuePair> lis in m_listeners) + foreach (KeyValuePair> lis + in m_listeners) { foreach (ListenerInfo li in lis.Value) { - if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) + if (li.GetItemID().Equals(itemID) && + li.GetHandle() == handle) { li.Activate(); // only one, bail out @@ -643,11 +681,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm { lock (m_listeners) { - foreach (KeyValuePair> lis in m_listeners) + foreach (KeyValuePair> lis + in m_listeners) { foreach (ListenerInfo li in lis.Value) { - if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) + if (li.GetItemID().Equals(itemID) && + li.GetHandle() == handle) { li.Deactivate(); // only one, bail out @@ -658,19 +698,24 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } - // non-locked access, since its always called in the context of the lock + /// + /// non-locked access, since its always called in the context of the + /// lock + /// + /// + /// private int GetNewHandle(UUID itemID) { List handles = new List(); // build a list of used keys for this specific itemID... - foreach (KeyValuePair> lis in m_listeners) + foreach (KeyValuePair> lis in m_listeners) { - foreach (ListenerInfo li in lis.Value) - { - if (li.GetItemID().Equals(itemID)) - handles.Add(li.GetHandle()); - } + foreach (ListenerInfo li in lis.Value) + { + if (li.GetItemID().Equals(itemID)) + handles.Add(li.GetHandle()); + } } // Note: 0 is NOT a valid handle for llListen() to return @@ -709,7 +754,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm lock (m_listeners) { List listeners; - if (!m_listeners.TryGetValue(channel,out listeners)) + if (!m_listeners.TryGetValue(channel, out listeners)) { return collection; } @@ -720,7 +765,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm { continue; } - if (!itemID.Equals(UUID.Zero) && !li.GetItemID().Equals(itemID)) + if (!itemID.Equals(UUID.Zero) && + !li.GetItemID().Equals(itemID)) { continue; } @@ -785,11 +831,14 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm lock (m_listeners) { if (!m_listeners.ContainsKey((int)item[2])) - m_listeners.Add((int)item[2], new List()); + { + m_listeners.Add((int)item[2], + new List()); + } m_listeners[(int)item[2]].Add(info); } - idx+=dataItemLength; + idx += dataItemLength; } } } @@ -820,17 +869,23 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm message, regexBitfield); } - public ListenerInfo(ListenerInfo li, string name, UUID id, string message) + public ListenerInfo(ListenerInfo li, string name, UUID id, + string message) { - Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, 0); + Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, + li.m_channel, name, id, message, 0); } - public ListenerInfo(ListenerInfo li, string name, UUID id, string message, int regexBitfield) + public ListenerInfo(ListenerInfo li, string name, UUID id, + string message, int regexBitfield) { - Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, regexBitfield); + Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, + li.m_channel, name, id, message, regexBitfield); } - private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message, int regexBitfield) + private void Initialise(int handle, uint localID, UUID ItemID, + UUID hostID, int channel, string name, UUID id, + string message, int regexBitfield) { m_active = true; m_handle = handle; @@ -859,9 +914,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm return data; } - public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data) + public static ListenerInfo FromData(uint localID, UUID ItemID, + UUID hostID, Object[] data) { - ListenerInfo linfo = new ListenerInfo((int)data[1], localID, ItemID, hostID, (int)data[2], (string)data[3], (UUID)data[4], (string)data[5]); + ListenerInfo linfo = new ListenerInfo((int)data[1], localID, + ItemID, hostID, (int)data[2], (string)data[3], + (UUID)data[4], (string)data[5]); linfo.m_active = (bool)data[0]; if (data.Length >= 7) { -- cgit v1.1 From d5f9f5c9c347f6d858bf91de87a5ba71ba06082a Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 11 Nov 2012 00:39:10 +0000 Subject: document, 80-character width terminal formatting converting comments to documentation for IDE & doxygen goodness Signed-off-by: Diva Canto --- .../Scripting/WorldComm/WorldCommModule.cs | 80 ++++++++++++++++++---- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index c88be82..2d2ea2f 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -744,10 +744,23 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm #endregion - // Theres probably a more clever and efficient way to - // do this, maybe with regex. - // PM2008: Ha, one could even be smart and define a specialized Enumerator. - public List GetListeners(UUID itemID, int channel, string name, UUID id, string msg) + /// + /// Get listeners matching the input parameters. + /// + /// + /// Theres probably a more clever and efficient way to do this, maybe + /// with regex. + /// PM2008: Ha, one could even be smart and define a specialized + /// Enumerator. + /// + /// + /// + /// + /// + /// + /// + public List GetListeners(UUID itemID, int channel, + string name, UUID id, string msg) { List collection = new List(); @@ -845,17 +858,54 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm public class ListenerInfo : IWorldCommListenerInfo { - private bool m_active; // Listener is active or not - private int m_handle; // Assigned handle of this listener - private uint m_localID; // Local ID from script engine - private UUID m_itemID; // ID of the host script engine - private UUID m_hostID; // ID of the host/scene part - private int m_channel; // Channel - private UUID m_id; // ID to filter messages from - private string m_name; // Object name to filter messages from - private string m_message; // The message - - public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message) + /// + /// Listener is active or not + /// + private bool m_active; + + /// + /// Assigned handle of this listener + /// + private int m_handle; + + /// + /// Local ID from script engine + /// + private uint m_localID; + + /// + /// ID of the host script engine + /// + private UUID m_itemID; + + /// + /// ID of the host/scene part + /// + private UUID m_hostID; + + /// + /// Channel + /// + private int m_channel; + + /// + /// ID to filter messages from + /// + private UUID m_id; + + /// + /// Object name to filter messages from + /// + private string m_name; + + /// + /// The message + /// + private string m_message; + + public ListenerInfo(int handle, uint localID, UUID ItemID, + UUID hostID, int channel, string name, UUID id, + string message) { Initialise(handle, localID, ItemID, hostID, channel, name, id, message, 0); -- cgit v1.1 From cdcb67a952610e155ff4c385d954be22c16ce159 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 17:21:09 -0800 Subject: One more module converted: GesturesModule. --- .../CoreModules/Avatar/Gestures/GesturesModule.cs | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs index 7df2beb..de70dba 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Reflection; using log4net; using Nini.Config; @@ -35,26 +36,46 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Avatar.Gestures { - public class GesturesModule : IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class GesturesModule : INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_scene; - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) + { + } + + public void AddRegion(Scene scene) { m_scene = scene; - + m_scene.EventManager.OnNewClient += OnNewClient; } + + public void RegionLoaded(Scene scene) + { + } + + public void RemoveRegion(Scene scene) + { + m_scene.EventManager.OnNewClient -= OnNewClient; + m_scene = null; + } - public void PostInitialise() {} public void Close() {} public string Name { get { return "Gestures Module"; } } - public bool IsSharedModule { get { return false; } } - + + public Type ReplaceableInterface + { + get { return null; } + } + private void OnNewClient(IClientAPI client) { client.OnActivateGesture += ActivateGesture; -- cgit v1.1 From 562c585bc6fb1e659ab395089cf497a390f03b33 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 17:34:42 -0800 Subject: One more module converted: GodsModule. --- .../Region/CoreModules/Avatar/Gods/GodsModule.cs | 68 ++++++++++++++++------ OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 6 +- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 81ce268..2d3585a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using Nini.Config; using OpenMetaverse; @@ -32,29 +33,59 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Avatar.Gods { - public class GodsModule : IRegionModule, IGodsModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class GodsModule : INonSharedRegionModule, IGodsModule { /// Special UUID for actions that apply to all agents private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); protected Scene m_scene; protected IDialogModule m_dialogModule; - - public void Initialise(Scene scene, IConfigSource source) + protected IDialogModule DialogModule + { + get + { + if (m_dialogModule == null) + m_dialogModule = m_scene.RequestModuleInterface(); + + return m_dialogModule; + } + } + + public void Initialise(IConfigSource source) + { + } + + public void AddRegion(Scene scene) { m_scene = scene; - m_dialogModule = m_scene.RequestModuleInterface(); m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += SubscribeToClientEvents; } - - public void PostInitialise() {} + + public void RemoveRegion(Scene scene) + { + m_scene.UnregisterModuleInterface(this); + m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; + m_scene = null; + } + + public void RegionLoaded(Scene scene) + { + } + public void Close() {} public string Name { get { return "Gods Module"; } } - public bool IsSharedModule { get { return false; } } - + + public Type ReplaceableInterface + { + get { return null; } + } + public void SubscribeToClientEvents(IClientAPI client) { client.OnGodKickUser += KickUser; @@ -96,8 +127,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods } else { - if (m_dialogModule != null) - m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); + if (DialogModule != null) + DialogModule.SendAlertToUser(agentID, "Request for god powers denied"); } } } @@ -121,7 +152,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods if (sp != null || agentID == kickUserID) { - m_dialogModule = m_scene.RequestModuleInterface(); if (m_scene.Permissions.IsGod(godID)) { if (kickflags == 0) @@ -163,27 +193,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods if (kickflags == 1) { sp.AllowMovement = false; - if (m_dialogModule != null) + if (DialogModule != null) { - m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); - m_dialogModule.SendAlertToUser(godID, "User Frozen"); + DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); + DialogModule.SendAlertToUser(godID, "User Frozen"); } } if (kickflags == 2) { sp.AllowMovement = true; - if (m_dialogModule != null) + if (DialogModule != null) { - m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); - m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); + DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); + DialogModule.SendAlertToUser(godID, "User Unfrozen"); } } } else { - if (m_dialogModule != null) - m_dialogModule.SendAlertToUser(godID, "Kick request denied"); + if (DialogModule != null) + DialogModule.SendAlertToUser(godID, "Kick request denied"); } } } diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 6d67b67..f9c1ac2 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -141,9 +141,9 @@ namespace OpenSim.Tests.Common TestScene testScene = new TestScene( regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null); - IRegionModule godsModule = new GodsModule(); - godsModule.Initialise(testScene, new IniConfigSource()); - testScene.AddModule(godsModule.Name, godsModule); + INonSharedRegionModule godsModule = new GodsModule(); + godsModule.Initialise(new IniConfigSource()); + godsModule.AddRegion(testScene); // Add scene to services m_assetService.AddRegion(testScene); -- cgit v1.1 From 2ef00626644334091c16c38fb3262bcd6515ddc4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 17:48:04 -0800 Subject: One more module converted: XferModule. --- .../Region/CoreModules/Agent/Xfer/XferModule.cs | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index b8e2820..0ab5ed5 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs @@ -35,9 +35,12 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Agent.Xfer { - public class XferModule : IRegionModule, IXfer + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class XferModule : INonSharedRegionModule, IXfer { private Scene m_scene; private Dictionary NewFiles = new Dictionary(); @@ -59,9 +62,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer public int Count; } - #region IRegionModule Members + #region INonSharedRegionModule Members + + public void Initialise(IConfigSource config) + { + } - public void Initialise(Scene scene, IConfigSource config) + public void AddRegion(Scene scene) { m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; @@ -69,22 +76,30 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer m_scene.RegisterModuleInterface(this); } - public void PostInitialise() + public void RemoveRegion(Scene scene) { + m_scene.EventManager.OnNewClient -= NewClient; + + m_scene.UnregisterModuleInterface(this); + m_scene = null; } - public void Close() + public void RegionLoaded(Scene scene) { } - public string Name + public Type ReplaceableInterface { - get { return "XferModule"; } + get { return null; } } - public bool IsSharedModule + public void Close() { - get { return false; } + } + + public string Name + { + get { return "XferModule"; } } #endregion -- cgit v1.1 From 09deaa890d32319cdba715f41ea4e46722d19791 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 17:56:25 -0800 Subject: One more module converted: GroupsModule. --- .../CoreModules/Avatar/Groups/GroupsModule.cs | 50 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs index b258e13..27f94ea 100644 --- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.Reflection; using log4net; @@ -34,9 +35,12 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Avatar.Groups { - public class GroupsModule : IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class GroupsModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -55,9 +59,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups private static GroupMembershipData osGroup = new GroupMembershipData(); - #region IRegionModule Members + private bool m_Enabled = false; + + #region ISharedRegionModule Members - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { IConfig groupsConfig = config.Configs["Groups"]; @@ -67,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups } else { - if (!groupsConfig.GetBoolean("Enabled", false)) + m_Enabled = groupsConfig.GetBoolean("Enabled", false); + if (!m_Enabled) { m_log.Info("[GROUPS]: Groups disabled in configuration"); return; @@ -77,6 +84,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups return; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + lock (m_SceneList) { if (!m_SceneList.Contains(scene)) @@ -96,7 +110,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnClientClosed += OnClientClosed; -// scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; + // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + lock (m_SceneList) + { + if (m_SceneList.Contains(scene)) + m_SceneList.Remove(scene); + } + + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnClientClosed -= OnClientClosed; + } + + public void RegionLoaded(Scene scene) + { } public void PostInitialise() @@ -105,6 +138,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups public void Close() { + if (!m_Enabled) + return; + // m_log.Debug("[GROUPS]: Shutting down group module."); lock (m_ClientMap) @@ -123,9 +159,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups get { return "GroupsModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } #endregion -- cgit v1.1 From 79d51c27bb4a38040216b607eb0dac8e25167727 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 11 Nov 2012 07:31:25 -0800 Subject: One more module converted: InventoryArchiverModule. --- .../Inventory/Archiver/InventoryArchiverModule.cs | 39 +++++++++++++++++----- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index fdba682..f5a146d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -39,20 +39,18 @@ using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using Mono.Addins; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { /// /// This module loads and saves OpenSimulator inventory archives /// - public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class InventoryArchiverModule : ISharedRegionModule, IInventoryArchiverModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string Name { get { return "Inventory Archiver Module"; } } - - public bool IsSharedModule { get { return true; } } - /// /// Enable or disable checking whether the iar user is actually logged in /// @@ -99,9 +97,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // public InventoryArchiverModule(bool disablePresenceChecks) // { // DisablePresenceChecks = disablePresenceChecks; -// } + // } + + #region ISharedRegionModule - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) + { + } + + public void AddRegion(Scene scene) { if (m_scenes.Count == 0) { @@ -144,10 +148,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_scenes[scene.RegionInfo.RegionID] = scene; } - public void PostInitialise() {} + public void RemoveRegion(Scene scene) + { + } public void Close() {} + public void RegionLoaded(Scene scene) + { + } + + public void PostInitialise() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name { get { return "Inventory Archiver Module"; } } + + #endregion + /// /// Trigger the inventory archive saved event. /// -- cgit v1.1 From f85d054bc6770ee133b6f86e4736432d555106e5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 11 Nov 2012 07:46:12 -0800 Subject: One more module converted: MonitorModule. --- .../Framework/Monitoring/MonitorModule.cs | 211 ++++++++++++--------- 1 file changed, 117 insertions(+), 94 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index e411585..d2198f1 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -38,10 +38,12 @@ using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts; using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; namespace OpenSim.Region.CoreModules.Framework.Monitoring { - public class MonitorModule : IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class MonitorModule : INonSharedRegionModule { /// /// Is this module enabled? @@ -62,14 +64,14 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring private readonly List m_alerts = new List(); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - #region Implementation of IRegionModule - public MonitorModule() { Enabled = true; } - public void Initialise(Scene scene, IConfigSource source) + #region Implementation of INonSharedRegionModule + + public void Initialise(IConfigSource source) { IConfig cnfg = source.Configs["Monitoring"]; @@ -79,6 +81,13 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring if (!Enabled) return; + } + + public void AddRegion(Scene scene) + { + if (!Enabled) + return; + m_scene = scene; m_scene.AddCommand("General", this, "monitor report", @@ -89,101 +98,42 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage); MainServer.Instance.AddHTTPHandler( "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName), StatsPage); + + AddMonitors(); } - public void DebugMonitors(string module, string[] args) + public void RemoveRegion(Scene scene) { - foreach (IMonitor monitor in m_staticMonitors) - { - MainConsole.Instance.OutputFormat( - "[MONITOR MODULE]: {0} reports {1} = {2}", - m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue()); - } + if (!Enabled) + return; - foreach (KeyValuePair tuple in m_scene.StatsReporter.GetExtraSimStats()) - { - MainConsole.Instance.OutputFormat( - "[MONITOR MODULE]: {0} reports {1} = {2}", - m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value); - } + MainServer.Instance.RemoveHTTPHandler("GET", "/monitorstats/" + m_scene.RegionInfo.RegionID); + MainServer.Instance.RemoveHTTPHandler("GET", "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName)); + m_scene = null; } - public void TestAlerts() + public void Close() { - foreach (IAlert alert in m_alerts) - { - alert.Test(); - } } - public Hashtable StatsPage(Hashtable request) + public string Name { - // If request was for a specific monitor - // eg url/?monitor=Monitor.Name - if (request.ContainsKey("monitor")) - { - string monID = (string) request["monitor"]; - - foreach (IMonitor monitor in m_staticMonitors) - { - string elemName = monitor.ToString(); - if (elemName.StartsWith(monitor.GetType().Namespace)) - elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); - - if (elemName == monID || monitor.ToString() == monID) - { - Hashtable ereply3 = new Hashtable(); - - ereply3["int_response_code"] = 404; // 200 OK - ereply3["str_response_string"] = monitor.GetValue().ToString(); - ereply3["content_type"] = "text/plain"; - - return ereply3; - } - } - - // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code - // is even doing. Why are we inspecting the type of the monitor??? - - // No monitor with that name - Hashtable ereply2 = new Hashtable(); - - ereply2["int_response_code"] = 404; // 200 OK - ereply2["str_response_string"] = "No such monitor"; - ereply2["content_type"] = "text/plain"; - - return ereply2; - } - - string xml = ""; - foreach (IMonitor monitor in m_staticMonitors) - { - string elemName = monitor.GetName(); - xml += "<" + elemName + ">" + monitor.GetValue().ToString() + ""; -// m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); - } - - foreach (KeyValuePair tuple in m_scene.StatsReporter.GetExtraSimStats()) - { - xml += "<" + tuple.Key + ">" + tuple.Value + ""; - } - - xml += ""; - - Hashtable ereply = new Hashtable(); - - ereply["int_response_code"] = 200; // 200 OK - ereply["str_response_string"] = xml; - ereply["content_type"] = "text/xml"; + get { return "Region Health Monitoring Module"; } + } - return ereply; + public void RegionLoaded(Scene scene) + { } - public void PostInitialise() + public Type ReplaceableInterface { - if (!Enabled) - return; + get { return null; } + } + + #endregion + public void AddMonitors() + { m_staticMonitors.Add(new AgentCountMonitor(m_scene)); m_staticMonitors.Add(new ChildAgentCountMonitor(m_scene)); m_staticMonitors.Add(new GCMemoryMonitor()); @@ -196,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring m_staticMonitors.Add(new EventFrameMonitor(m_scene)); m_staticMonitors.Add(new LandFrameMonitor(m_scene)); m_staticMonitors.Add(new LastFrameTimeMonitor(m_scene)); - + m_staticMonitors.Add( new GenericMonitor( m_scene, @@ -357,25 +307,98 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring } } - void OnTriggerAlert(System.Type reporter, string reason, bool fatal) + public void DebugMonitors(string module, string[] args) { - m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); + foreach (IMonitor monitor in m_staticMonitors) + { + MainConsole.Instance.OutputFormat( + "[MONITOR MODULE]: {0} reports {1} = {2}", + m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue()); + } + + foreach (KeyValuePair tuple in m_scene.StatsReporter.GetExtraSimStats()) + { + MainConsole.Instance.OutputFormat( + "[MONITOR MODULE]: {0} reports {1} = {2}", + m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value); + } } - public void Close() + public void TestAlerts() { + foreach (IAlert alert in m_alerts) + { + alert.Test(); + } } - public string Name + public Hashtable StatsPage(Hashtable request) { - get { return "Region Health Monitoring Module"; } + // If request was for a specific monitor + // eg url/?monitor=Monitor.Name + if (request.ContainsKey("monitor")) + { + string monID = (string) request["monitor"]; + + foreach (IMonitor monitor in m_staticMonitors) + { + string elemName = monitor.ToString(); + if (elemName.StartsWith(monitor.GetType().Namespace)) + elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); + + if (elemName == monID || monitor.ToString() == monID) + { + Hashtable ereply3 = new Hashtable(); + + ereply3["int_response_code"] = 404; // 200 OK + ereply3["str_response_string"] = monitor.GetValue().ToString(); + ereply3["content_type"] = "text/plain"; + + return ereply3; + } + } + + // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code + // is even doing. Why are we inspecting the type of the monitor??? + + // No monitor with that name + Hashtable ereply2 = new Hashtable(); + + ereply2["int_response_code"] = 404; // 200 OK + ereply2["str_response_string"] = "No such monitor"; + ereply2["content_type"] = "text/plain"; + + return ereply2; + } + + string xml = ""; + foreach (IMonitor monitor in m_staticMonitors) + { + string elemName = monitor.GetName(); + xml += "<" + elemName + ">" + monitor.GetValue().ToString() + ""; +// m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); + } + + foreach (KeyValuePair tuple in m_scene.StatsReporter.GetExtraSimStats()) + { + xml += "<" + tuple.Key + ">" + tuple.Value + ""; + } + + xml += ""; + + Hashtable ereply = new Hashtable(); + + ereply["int_response_code"] = 200; // 200 OK + ereply["str_response_string"] = xml; + ereply["content_type"] = "text/xml"; + + return ereply; } - public bool IsSharedModule + void OnTriggerAlert(System.Type reporter, string reason, bool fatal) { - get { return false; } + m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); } - - #endregion + } } -- cgit v1.1 From d589a8bc0443049aab6f984d2eddde092f1f2d87 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 11 Nov 2012 08:14:58 -0800 Subject: Deleted 2 obsolete modules: OGSRadmin and OpenGridProtocol. They were still IRegionModule's and they have been dead for a very long time, so no need to drag them along in this revamping of region modules. --- OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | 150 --- .../InterGrid/OpenGridProtocolModule.cs | 1297 -------------------- 2 files changed, 1447 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs delete mode 100644 OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs deleted file mode 100644 index 2cc0a07..0000000 --- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Net; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.InterGrid -{ - public class OGSRadmin : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private readonly List m_scenes = new List(); - private IConfigSource m_settings; - - #region Implementation of IRegionModuleBase - - public string Name - { - get { return "OGS Supporting RAdmin"; } - } - - - public void Initialise(IConfigSource source) - { - m_settings = source; - } - - public void Close() - { - - } - - public void AddRegion(Scene scene) - { - lock (m_scenes) - m_scenes.Add(scene); - } - - public void RemoveRegion(Scene scene) - { - lock (m_scenes) - m_scenes.Remove(scene); - } - - public void RegionLoaded(Scene scene) - { - - } - - public void PostInitialise() - { - if (m_settings.Configs["Startup"].GetBoolean("gridmode", false)) - { - MainServer.Instance.AddXmlRPCHandler("grid_message", GridWideMessage); - } - } - - #endregion - - #region IRegionModule - - public void Initialise(Scene scene, IConfigSource source) - { - m_settings = source; - - lock (m_scenes) - m_scenes.Add(scene); - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - public XmlRpcResponse GridWideMessage(XmlRpcRequest req, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - - Hashtable requestData = (Hashtable)req.Params[0]; - - // REFACTORING PROBLEM. This authorization needs to be replaced with some other - //if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey)) - //{ - // responseData["accepted"] = false; - // responseData["success"] = false; - // responseData["error"] = "Invalid Key"; - // response.Value = responseData; - // return response; - //} - - string message = (string)requestData["message"]; - string user = (string)requestData["user"]; - m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); - - lock (m_scenes) - foreach (Scene scene in m_scenes) - { - IDialogModule dialogModule = scene.RequestModuleInterface(); - if (dialogModule != null) - dialogModule.SendNotificationToUsersInRegion(UUID.Random(), user, message); - } - - responseData["accepted"] = true; - responseData["success"] = true; - response.Value = responseData; - - return response; - } - } -} diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs deleted file mode 100644 index 4a76b00..0000000 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ /dev/null @@ -1,1297 +0,0 @@ -/* - * 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.Net; -using System.Net.Security; -using System.Reflection; -using System.Security.Cryptography.X509Certificates; -using System.Threading; -using System.Web; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Capabilities; -using OpenSim.Framework.Monitoring; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using Caps=OpenSim.Framework.Capabilities.Caps; -using OSDArray=OpenMetaverse.StructuredData.OSDArray; -using OSDMap=OpenMetaverse.StructuredData.OSDMap; - -namespace OpenSim.Region.CoreModules.InterGrid -{ - public struct OGPState - { - public string first_name; - public string last_name; - public UUID agent_id; - public UUID local_agent_id; - public UUID region_id; - public uint circuit_code; - public UUID secure_session_id; - public UUID session_id; - public bool agent_access; - public string sim_access; - public uint god_level; - public bool god_overide; - public bool identified; - public bool transacted; - public bool age_verified; - public bool allow_redirect; - public int limited_to_estate; - public string inventory_host; - public bool src_can_see_mainland; - public int src_estate_id; - public int src_version; - public int src_parent_estate_id; - public bool visible_to_parent; - public string teleported_into_region; - } - - public class OpenGridProtocolModule : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private List m_scene = new List(); - - private Dictionary CapsLoginID = new Dictionary(); - private Dictionary m_OGPState = new Dictionary(); - private Dictionary m_loginToRegionState = new Dictionary(); - - - private string LastNameSuffix = "_EXTERNAL"; - private string FirstNamePrefix = ""; - private string httpsCN = ""; - private bool httpSSL = false; - private uint httpsslport = 0; -// private bool GridMode = false; - - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) - { - bool enabled = false; - IConfig cfg = null; - IConfig httpcfg = null; -// IConfig startupcfg = null; - try - { - cfg = config.Configs["OpenGridProtocol"]; - } catch (NullReferenceException) - { - enabled = false; - } - - try - { - httpcfg = config.Configs["Network"]; - } - catch (NullReferenceException) - { - - } -// try -// { -// startupcfg = config.Configs["Startup"]; -// } -// catch (NullReferenceException) -// { -// -// } - -// if (startupcfg != null) -// { -// GridMode = enabled = startupcfg.GetBoolean("gridmode", false); -// } - - if (cfg != null) - { - enabled = cfg.GetBoolean("ogp_enabled", false); - LastNameSuffix = cfg.GetString("ogp_lastname_suffix", "_EXTERNAL"); - FirstNamePrefix = cfg.GetString("ogp_firstname_prefix", ""); - if (enabled) - { - m_log.Warn("[OGP]: Open Grid Protocol is on, Listening for Clients on /agent/"); - lock (m_scene) - { - if (m_scene.Count == 0) - { - MainServer.Instance.AddLLSDHandler("/agent/", ProcessAgentDomainMessage); - MainServer.Instance.AddLLSDHandler("/", ProcessRegionDomainSeed); - try - { - ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation; - } - catch (NotImplementedException) - { - try - { -#pragma warning disable 0612, 0618 - // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! - ServicePointManager.CertificatePolicy = new MonoCert(); -#pragma warning restore 0612, 0618 - } - catch (Exception) - { - m_log.Error("[OGP]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); - } - } - - } - // can't pick the region 'agent' because it would conflict with our agent domain handler - // a zero length region name would conflict with are base region seed cap - if (!SceneListDuplicateCheck(scene.RegionInfo.RegionName) && scene.RegionInfo.RegionName.ToLower() != "agent" && scene.RegionInfo.RegionName.Length > 0) - { - MainServer.Instance.AddLLSDHandler( - "/" + HttpUtility.UrlPathEncode(scene.RegionInfo.RegionName.ToLower()), - ProcessRegionDomainSeed); - } - - if (!m_scene.Contains(scene)) - m_scene.Add(scene); - } - } - } - lock (m_scene) - { - if (m_scene.Count == 1) - { - if (httpcfg != null) - { - httpSSL = httpcfg.GetBoolean("http_listener_ssl", false); - httpsCN = httpcfg.GetString("http_listener_cn", scene.RegionInfo.ExternalHostName); - if (httpsCN.Length == 0) - httpsCN = scene.RegionInfo.ExternalHostName; - httpsslport = (uint)httpcfg.GetInt("http_listener_sslport",((int)scene.RegionInfo.HttpPort + 1)); - } - } - } - } - - public void PostInitialise() - { - } - - public void Close() - { - //scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; - } - - public string Name - { - get { return "OpenGridProtocolModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - public OSD ProcessRegionDomainSeed(string path, OSD request, string endpoint) - { - string[] pathSegments = path.Split('/'); - - if (pathSegments.Length <= 1) - { - return GenerateNoHandlerMessage(); - - } - - return GenerateRezAvatarRequestMessage(pathSegments[1]); - - - - //m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", - // path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); - //return new OSDMap(); - - } - - public OSD ProcessAgentDomainMessage(string path, OSD request, string endpoint) - { - // /agent/* - - string[] pathSegments = path.Split('/'); - if (pathSegments.Length <= 1) - { - return GenerateNoHandlerMessage(); - - } - if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0) - { - return GenerateRezAvatarRequestMessage(""); - } - m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", - path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); - - switch (pathSegments[pathSegments.Length - 1]) - { - case "rez_avatar": - return RezAvatarMethod(path, request); - //break; - case "derez_avatar": - return DerezAvatarMethod(path, request); - //break; - - } - if (path.Length < 2) - { - return GenerateNoHandlerMessage(); - } - - switch (pathSegments[pathSegments.Length - 2] + "/" + pathSegments[pathSegments.Length - 1]) - { - case "rez_avatar/rez": - return RezAvatarMethod(path, request); - //break; - case "rez_avatar/request": - return RequestRezAvatarMethod(path, request); - case "rez_avatar/place": - return RequestRezAvatarMethod(path, request); - case "rez_avatar/derez": - return DerezAvatarMethod(path, request); - //break; - default: - return GenerateNoHandlerMessage(); - } - //return null; - } - - private OSD GenerateRezAvatarRequestMessage(string regionname) - { - Scene region = null; - bool usedroot = false; - - if (regionname.Length == 0) - { - region = GetRootScene(); - usedroot = true; - } - else - { - region = GetScene(HttpUtility.UrlDecode(regionname).ToLower()); - } - - // this shouldn't happen since we don't listen for a region that is down.. but - // it might if the region was taken down or is in the middle of restarting - - if (region == null) - { - region = GetRootScene(); - usedroot = true; - } - - UUID statekeeper = UUID.Random(); - - - - - RegionInfo reg = region.RegionInfo; - - OSDMap responseMap = new OSDMap(); - string rezHttpProtocol = "http://"; - //string regionCapsHttpProtocol = "http://"; - string httpaddr = reg.ExternalHostName; - string urlport = reg.HttpPort.ToString(); - string requestpath = "/agent/" + statekeeper + "/rez_avatar/request"; - - if (!usedroot) - { - lock (m_loginToRegionState) - { - if (!m_loginToRegionState.ContainsKey(requestpath)) - { - m_loginToRegionState.Add(requestpath, region.RegionInfo.RegionName.ToLower()); - } - } - } - - if (httpSSL) - { - rezHttpProtocol = "https://"; - //regionCapsHttpProtocol = "https://"; - urlport = httpsslport.ToString(); - - if (httpsCN.Length > 0) - httpaddr = httpsCN; - } - - responseMap["connect"] = OSD.FromBoolean(true); - OSDMap capabilitiesMap = new OSDMap(); - capabilitiesMap["rez_avatar/request"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + requestpath); - responseMap["capabilities"] = capabilitiesMap; - - return responseMap; - } - - // Using OpenSim.Framework.Capabilities.Caps here one time.. - // so the long name is probably better then a using statement - public void OnRegisterCaps(UUID agentID, Caps caps) - { - /* If we ever want to register our own caps here.... - * - string capsBase = "/CAPS/" + caps.CapsObjectPath; - caps.RegisterHandler("CAPNAME", - new RestStreamHandler("POST", capsBase + CAPSPOSTFIX!, - delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return METHODHANDLER(request, path, param, - agentID, caps); - })); - - * - */ - } - - public OSD RequestRezAvatarMethod(string path, OSD request) - { - //m_log.Debug("[REQUESTREZAVATAR]: " + request.ToString()); - - OSDMap requestMap = (OSDMap)request; - - - Scene homeScene = null; - - lock (m_loginToRegionState) - { - if (m_loginToRegionState.ContainsKey(path)) - { - homeScene = GetScene(m_loginToRegionState[path]); - m_loginToRegionState.Remove(path); - - if (homeScene == null) - homeScene = GetRootScene(); - } - else - { - homeScene = GetRootScene(); - } - } - - // Homescene is still null, we must have no regions that are up - if (homeScene == null) - return GenerateNoHandlerMessage(); - - RegionInfo reg = homeScene.RegionInfo; - ulong regionhandle = GetOSCompatibleRegionHandle(reg); - //string RegionURI = reg.ServerURI; - //int RegionPort = (int)reg.HttpPort; - - UUID RemoteAgentID = requestMap["agent_id"].AsUUID(); - - // will be used in the future. The client always connects with the aditi agentid currently - UUID LocalAgentID = RemoteAgentID; - - string FirstName = requestMap["first_name"].AsString(); - string LastName = requestMap["last_name"].AsString(); - - FirstName = FirstNamePrefix + FirstName; - LastName = LastName + LastNameSuffix; - - OGPState userState = GetOGPState(LocalAgentID); - - userState.first_name = requestMap["first_name"].AsString(); - userState.last_name = requestMap["last_name"].AsString(); - userState.age_verified = requestMap["age_verified"].AsBoolean(); - userState.transacted = requestMap["transacted"].AsBoolean(); - userState.agent_access = requestMap["agent_access"].AsBoolean(); - userState.allow_redirect = requestMap["allow_redirect"].AsBoolean(); - userState.identified = requestMap["identified"].AsBoolean(); - userState.god_level = (uint)requestMap["god_level"].AsInteger(); - userState.sim_access = requestMap["sim_access"].AsString(); - userState.agent_id = RemoteAgentID; - userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger(); - userState.src_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean(); - userState.src_estate_id = requestMap["src_estate_id"].AsInteger(); - userState.local_agent_id = LocalAgentID; - userState.teleported_into_region = reg.RegionName.ToLower(); - - UpdateOGPState(LocalAgentID, userState); - - OSDMap responseMap = new OSDMap(); - - if (RemoteAgentID == UUID.Zero) - { - responseMap["connect"] = OSD.FromBoolean(false); - responseMap["message"] = OSD.FromString("No agent ID was specified in rez_avatar/request"); - m_log.Error("[OGP]: rez_avatar/request failed because no avatar UUID was provided in the request body"); - return responseMap; - } - - responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName); - - // DEPRECATED - responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString()); - - responseMap["connect"] = OSD.FromBoolean(true); - responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port); - responseMap["region_x"] = OSD.FromInteger(reg.RegionLocX * (uint)Constants.RegionSize); // LLX - responseMap["region_y"] = OSD.FromInteger(reg.RegionLocY * (uint)Constants.RegionSize); // LLY - responseMap["region_id"] = OSD.FromUUID(reg.originRegionID); - - if (reg.RegionSettings.Maturity == 1) - { - responseMap["sim_access"] = OSD.FromString("Mature"); - } - else if (reg.RegionSettings.Maturity == 2) - { - responseMap["sim_access"] = OSD.FromString("Adult"); - } - else - { - responseMap["sim_access"] = OSD.FromString("PG"); - } - - // Generate a dummy agent for the user so we can get back a CAPS path - AgentCircuitData agentData = new AgentCircuitData(); - agentData.AgentID = LocalAgentID; - agentData.BaseFolder = UUID.Zero; - agentData.CapsPath = CapsUtil.GetRandomCapsObjectPath(); - agentData.child = false; - agentData.circuitcode = (uint)(Util.RandomClass.Next()); - agentData.firstname = FirstName; - agentData.lastname = LastName; - agentData.SecureSessionID = UUID.Random(); - agentData.SessionID = UUID.Random(); - agentData.startpos = new Vector3(128f, 128f, 100f); - - // Pre-Fill our region cache with information on the agent. - UserAgentData useragent = new UserAgentData(); - useragent.AgentIP = "unknown"; - useragent.AgentOnline = true; - useragent.AgentPort = (uint)0; - useragent.Handle = regionhandle; - useragent.InitialRegion = reg.originRegionID; - useragent.LoginTime = Util.UnixTimeSinceEpoch(); - useragent.LogoutTime = 0; - useragent.Position = agentData.startpos; - useragent.Region = reg.originRegionID; - useragent.SecureSessionID = agentData.SecureSessionID; - useragent.SessionID = agentData.SessionID; - - UserProfileData userProfile = new UserProfileData(); - userProfile.AboutText = "OGP User"; - userProfile.CanDoMask = (uint)0; - userProfile.Created = Util.UnixTimeSinceEpoch(); - userProfile.CurrentAgent = useragent; - userProfile.CustomType = "OGP"; - userProfile.FirstLifeAboutText = "I'm testing OpenGrid Protocol"; - userProfile.FirstLifeImage = UUID.Zero; - userProfile.FirstName = agentData.firstname; - userProfile.GodLevel = 0; - userProfile.HomeLocation = agentData.startpos; - userProfile.HomeLocationX = agentData.startpos.X; - userProfile.HomeLocationY = agentData.startpos.Y; - userProfile.HomeLocationZ = agentData.startpos.Z; - userProfile.HomeLookAt = Vector3.Zero; - userProfile.HomeLookAtX = userProfile.HomeLookAt.X; - userProfile.HomeLookAtY = userProfile.HomeLookAt.Y; - userProfile.HomeLookAtZ = userProfile.HomeLookAt.Z; - userProfile.HomeRegion = reg.RegionHandle; - userProfile.HomeRegionID = reg.originRegionID; - userProfile.HomeRegionX = reg.RegionLocX; - userProfile.HomeRegionY = reg.RegionLocY; - userProfile.ID = agentData.AgentID; - userProfile.Image = UUID.Zero; - userProfile.LastLogin = Util.UnixTimeSinceEpoch(); - userProfile.Partner = UUID.Zero; - userProfile.PasswordHash = "$1$"; - userProfile.PasswordSalt = ""; - userProfile.SurName = agentData.lastname; - //userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL; - userProfile.UserFlags = 0; - //userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL; - userProfile.WantDoMask = 0; - userProfile.WebLoginKey = UUID.Random(); - - // !!! REFACTORING PROBLEM. This needs to be changed for 0.7 - // - //// Do caps registration - //// get seed capagentData.firstname = FirstName;agentData.lastname = LastName; - //if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode) - //{ - // homeScene.CommsManager.UserAdminService.AddUser( - // agentData.firstname, agentData.lastname, CreateRandomStr(7), "", - // homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID); - - // UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID); - // if (userProfile2 != null) - // { - // userProfile = userProfile2; - // userProfile.AboutText = "OGP USER"; - // userProfile.FirstLifeAboutText = "OGP USER"; - // homeScene.CommsManager.UserService.UpdateUserProfile(userProfile); - // } - //} - - //// Stick our data in the cache so the region will know something about us - //homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); - - // Call 'new user' event handler - string reason; - if (!homeScene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) - { - responseMap["connect"] = OSD.FromBoolean(false); - responseMap["message"] = OSD.FromString(String.Format("Connection refused: {0}", reason)); - m_log.ErrorFormat("[OGP]: rez_avatar/request failed: {0}", reason); - return responseMap; - } - - - //string raCap = string.Empty; - - UUID AvatarRezCapUUID = LocalAgentID; - string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez"; - string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez"; - // Get a reference to the user's cap so we can pull out the Caps Object Path - Caps userCap - = homeScene.CapsModule.GetCapsForUser(agentData.AgentID); - - string rezHttpProtocol = "http://"; - string regionCapsHttpProtocol = "http://"; - string httpaddr = reg.ExternalHostName; - string urlport = reg.HttpPort.ToString(); - - if (httpSSL) - { - rezHttpProtocol = "https://"; - regionCapsHttpProtocol = "https://"; - urlport = httpsslport.ToString(); - - if (httpsCN.Length > 0) - httpaddr = httpsCN; - } - - // DEPRECATED - responseMap["seed_capability"] - = OSD.FromString( - regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath)); - - // REPLACEMENT - responseMap["region_seed_capability"] - = OSD.FromString( - regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath)); - - responseMap["rez_avatar"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath); - responseMap["rez_avatar/rez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath); - responseMap["rez_avatar/derez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + derezAvatarPath); - - // Add the user to the list of CAPS that are outstanding. - // well allow the caps hosts in this dictionary - lock (CapsLoginID) - { - if (CapsLoginID.ContainsKey(rezAvatarPath)) - { - CapsLoginID[rezAvatarPath] = agentData; - - // This is a joke, if you didn't notice... It's so unlikely to happen, that I'll print this message if it does occur! - m_log.Error("[OGP]: Holy anomoly batman! Caps path already existed! All the UUID Duplication worries were founded!"); - } - else - { - CapsLoginID.Add(rezAvatarPath, agentData); - } - } - - //m_log.Debug("Response:" + responseMap.ToString()); - return responseMap; - } - - public OSD RezAvatarMethod(string path, OSD request) - { - m_log.WarnFormat("[REZAVATAR]: {0}", request.ToString()); - - OSDMap responseMap = new OSDMap(); - - AgentCircuitData userData = null; - - // Only people we've issued a cap can go further - if (TryGetAgentCircuitData(path,out userData)) - { - OSDMap requestMap = (OSDMap)request; - - // take these values to start. There's a few more - UUID SecureSessionID=requestMap["secure_session_id"].AsUUID(); - UUID SessionID = requestMap["session_id"].AsUUID(); - int circuitcode = requestMap["circuit_code"].AsInteger(); - OSDArray Parameter = new OSDArray(); - if (requestMap.ContainsKey("parameter")) - { - Parameter = (OSDArray)requestMap["parameter"]; - } - - //int version = 1; - int estateID = 1; - int parentEstateID = 1; - UUID regionID = UUID.Zero; - bool visibleToParent = true; - - for (int i = 0; i < Parameter.Count; i++) - { - OSDMap item = (OSDMap)Parameter[i]; -// if (item.ContainsKey("version")) -// { -// version = item["version"].AsInteger(); -// } - if (item.ContainsKey("estate_id")) - { - estateID = item["estate_id"].AsInteger(); - } - if (item.ContainsKey("parent_estate_id")) - { - parentEstateID = item["parent_estate_id"].AsInteger(); - - } - if (item.ContainsKey("region_id")) - { - regionID = item["region_id"].AsUUID(); - - } - if (item.ContainsKey("visible_to_parent")) - { - visibleToParent = item["visible_to_parent"].AsBoolean(); - } - } - //Update our Circuit data with the real values - userData.SecureSessionID = SecureSessionID; - userData.SessionID = SessionID; - - OGPState userState = GetOGPState(userData.AgentID); - - // Locate a home scene suitable for the user. - Scene homeScene = null; - - homeScene = GetScene(userState.teleported_into_region); - - if (homeScene == null) - homeScene = GetRootScene(); - - if (homeScene != null) - { - // Get a referenceokay - to their Cap object so we can pull out the capobjectroot - Caps userCap - = homeScene.CapsModule.GetCapsForUser(userData.AgentID); - - //Update the circuit data in the region so this user is authorized - homeScene.UpdateCircuitData(userData); - homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode); - - // Load state - - - // Keep state changes - userState.first_name = requestMap["first_name"].AsString(); - userState.secure_session_id = requestMap["secure_session_id"].AsUUID(); - userState.age_verified = requestMap["age_verified"].AsBoolean(); - userState.region_id = homeScene.RegionInfo.originRegionID; // replace 0000000 with our regionid - userState.transacted = requestMap["transacted"].AsBoolean(); - userState.agent_access = requestMap["agent_access"].AsBoolean(); - userState.inventory_host = requestMap["inventory_host"].AsString(); - userState.identified = requestMap["identified"].AsBoolean(); - userState.session_id = requestMap["session_id"].AsUUID(); - userState.god_level = (uint)requestMap["god_level"].AsInteger(); - userState.last_name = requestMap["last_name"].AsString(); - userState.god_overide = requestMap["god_override"].AsBoolean(); - userState.circuit_code = (uint)requestMap["circuit_code"].AsInteger(); - userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger(); - userState.src_estate_id = estateID; - userState.region_id = regionID; - userState.src_parent_estate_id = parentEstateID; - userState.visible_to_parent = visibleToParent; - - // Save state changes - UpdateOGPState(userData.AgentID, userState); - - // Get the region information for the home region. - RegionInfo reg = homeScene.RegionInfo; - - // Dummy positional and look at info.. we don't have it. - OSDArray PositionArray = new OSDArray(); - PositionArray.Add(OSD.FromInteger(128)); - PositionArray.Add(OSD.FromInteger(128)); - PositionArray.Add(OSD.FromInteger(40)); - - OSDArray LookAtArray = new OSDArray(); - LookAtArray.Add(OSD.FromInteger(1)); - LookAtArray.Add(OSD.FromInteger(1)); - LookAtArray.Add(OSD.FromInteger(1)); - - // Our region's X and Y position in OpenSimulator space. - uint fooX = reg.RegionLocX; - uint fooY = reg.RegionLocY; - m_log.InfoFormat("[OGP]: region x({0}) region y({1})", fooX, fooY); - m_log.InfoFormat("[OGP]: region http {0} {1}", reg.ServerURI, reg.HttpPort); - m_log.InfoFormat("[OGO]: region UUID {0} ", reg.RegionID); - - // Convert the X and Y position to LL space - responseMap["region_x"] = OSD.FromInteger(fooX * (uint)Constants.RegionSize); // convert it to LL X - responseMap["region_y"] = OSD.FromInteger(fooY * (uint)Constants.RegionSize); // convert it to LL Y - - // Give em a new seed capability - responseMap["seed_capability"] = OSD.FromString("http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + userCap.CapsObjectPath + "0000/"); - responseMap["region"] = OSD.FromUUID(reg.originRegionID); - responseMap["look_at"] = LookAtArray; - - responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port); - responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName);// + ":" + reg.InternalEndPoint.Port.ToString()); - - // DEPRECATED - responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString()); - - responseMap["session_id"] = OSD.FromUUID(SessionID); - responseMap["secure_session_id"] = OSD.FromUUID(SecureSessionID); - responseMap["circuit_code"] = OSD.FromInteger(circuitcode); - - responseMap["position"] = PositionArray; - - responseMap["region_id"] = OSD.FromUUID(reg.originRegionID); - - responseMap["sim_access"] = OSD.FromString("Mature"); - - responseMap["connect"] = OSD.FromBoolean(true); - - - - m_log.InfoFormat("[OGP]: host: {0}, IP {1}", responseMap["sim_host"].ToString(), responseMap["sim_ip"].ToString()); - } - } - - return responseMap; - } - - public OSD DerezAvatarMethod(string path, OSD request) - { - m_log.ErrorFormat("DerezPath: {0}, Request: {1}", path, request.ToString()); - - //LLSD llsdResponse = null; - OSDMap responseMap = new OSDMap(); - - string[] PathArray = path.Split('/'); - m_log.InfoFormat("[OGP]: prefix {0}, uuid {1}, suffix {2}", PathArray[1], PathArray[2], PathArray[3]); - string uuidString = PathArray[2]; - m_log.InfoFormat("[OGP]: Request to Derez avatar with UUID {0}", uuidString); - UUID userUUID = UUID.Zero; - if (UUID.TryParse(uuidString, out userUUID)) - { - UUID RemoteID = (UUID)uuidString; - UUID LocalID = RemoteID; - // FIXME: TODO: Routine to map RemoteUUIDs to LocalUUIds - // would be done already.. but the client connects with the Aditi UUID - // regardless over the UDP stack - - OGPState userState = GetOGPState(LocalID); - if (userState.agent_id != UUID.Zero) - { - //OSDMap outboundRequestMap = new OSDMap(); - OSDMap inboundRequestMap = (OSDMap)request; - string rezAvatarString = inboundRequestMap["rez_avatar"].AsString(); - if (rezAvatarString.Length == 0) - { - rezAvatarString = inboundRequestMap["rez_avatar/rez"].AsString(); - } - OSDArray LookAtArray = new OSDArray(); - LookAtArray.Add(OSD.FromInteger(1)); - LookAtArray.Add(OSD.FromInteger(1)); - LookAtArray.Add(OSD.FromInteger(1)); - - OSDArray PositionArray = new OSDArray(); - PositionArray.Add(OSD.FromInteger(128)); - PositionArray.Add(OSD.FromInteger(128)); - PositionArray.Add(OSD.FromInteger(40)); - - OSDArray lookArray = new OSDArray(); - lookArray.Add(OSD.FromInteger(128)); - lookArray.Add(OSD.FromInteger(128)); - lookArray.Add(OSD.FromInteger(40)); - - responseMap["connect"] = OSD.FromBoolean(true);// it's okay to give this user up - responseMap["look_at"] = LookAtArray; - - m_log.WarnFormat("[OGP]: Invoking rez_avatar on host:{0} for avatar: {1} {2}", rezAvatarString, userState.first_name, userState.last_name); - - OSDMap rezResponseMap = invokeRezAvatarCap(responseMap, rezAvatarString,userState); - - // If invoking it returned an error, parse and end - if (rezResponseMap.ContainsKey("connect")) - { - if (rezResponseMap["connect"].AsBoolean() == false) - { - return responseMap; - } - } - - string rezRespSeedCap = ""; - - // DEPRECATED - if (rezResponseMap.ContainsKey("seed_capability")) - rezRespSeedCap = rezResponseMap["seed_capability"].AsString(); - - // REPLACEMENT - if (rezResponseMap.ContainsKey("region_seed_capability")) - rezRespSeedCap = rezResponseMap["region_seed_capability"].AsString(); - - // REPLACEMENT - if (rezResponseMap.ContainsKey("rez_avatar/rez")) - rezRespSeedCap = rezResponseMap["rez_avatar/rez"].AsString(); - - // DEPRECATED - string rezRespSim_ip = rezResponseMap["sim_ip"].AsString(); - - string rezRespSim_host = rezResponseMap["sim_host"].AsString(); - - int rrPort = rezResponseMap["sim_port"].AsInteger(); - int rrX = rezResponseMap["region_x"].AsInteger(); - int rrY = rezResponseMap["region_y"].AsInteger(); - m_log.ErrorFormat("X:{0}, Y:{1}", rrX, rrY); - UUID rrRID = rezResponseMap["region_id"].AsUUID(); - OSDArray RezResponsePositionArray = null; - string rrAccess = rezResponseMap["sim_access"].AsString(); - if (rezResponseMap.ContainsKey("position")) - { - RezResponsePositionArray = (OSDArray)rezResponseMap["position"]; - } - // DEPRECATED - responseMap["seed_capability"] = OSD.FromString(rezRespSeedCap); - - // REPLACEMENT r3 - responseMap["region_seed_capability"] = OSD.FromString(rezRespSeedCap); - - // DEPRECATED - responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(rezRespSim_ip).ToString()); - - responseMap["sim_host"] = OSD.FromString(rezRespSim_host); - responseMap["sim_port"] = OSD.FromInteger(rrPort); - responseMap["region_x"] = OSD.FromInteger(rrX); - responseMap["region_y"] = OSD.FromInteger(rrY); - responseMap["region_id"] = OSD.FromUUID(rrRID); - responseMap["sim_access"] = OSD.FromString(rrAccess); - - if (RezResponsePositionArray != null) - { - responseMap["position"] = RezResponsePositionArray; - } - responseMap["look_at"] = lookArray; - responseMap["connect"] = OSD.FromBoolean(true); - - ShutdownConnection(LocalID,this); - // PLEASE STOP CHANGING THIS TO an M_LOG, M_LOG DOESN'T WORK ON MULTILINE .TOSTRINGS - Console.WriteLine("RESPONSEDEREZ: " + responseMap.ToString()); - return responseMap; - } - else - { - return GenerateNoStateMessage(LocalID); - } - } - else - { - return GenerateNoHandlerMessage(); - } - - //return responseMap; - } - - private OSDMap invokeRezAvatarCap(OSDMap responseMap, string CapAddress, OGPState userState) - { - Scene reg = GetRootScene(); - - WebRequest DeRezRequest = WebRequest.Create(CapAddress); - DeRezRequest.Method = "POST"; - DeRezRequest.ContentType = "application/xml+llsd"; - - OSDMap RAMap = new OSDMap(); - OSDMap AgentParms = new OSDMap(); - OSDMap RegionParms = new OSDMap(); - - OSDArray Parameter = new OSDArray(2); - - OSDMap version = new OSDMap(); - version["version"] = OSD.FromInteger(userState.src_version); - Parameter.Add(version); - - OSDMap SrcData = new OSDMap(); - SrcData["estate_id"] = OSD.FromInteger(reg.RegionInfo.EstateSettings.EstateID); - SrcData["parent_estate_id"] = OSD.FromInteger((reg.RegionInfo.EstateSettings.ParentEstateID == 100 ? 1 : reg.RegionInfo.EstateSettings.ParentEstateID)); - SrcData["region_id"] = OSD.FromUUID(reg.RegionInfo.originRegionID); - SrcData["visible_to_parent"] = OSD.FromBoolean(userState.visible_to_parent); - Parameter.Add(SrcData); - - AgentParms["first_name"] = OSD.FromString(userState.first_name); - AgentParms["last_name"] = OSD.FromString(userState.last_name); - AgentParms["agent_id"] = OSD.FromUUID(userState.agent_id); - RegionParms["region_id"] = OSD.FromUUID(userState.region_id); - AgentParms["circuit_code"] = OSD.FromInteger(userState.circuit_code); - AgentParms["secure_session_id"] = OSD.FromUUID(userState.secure_session_id); - AgentParms["session_id"] = OSD.FromUUID(userState.session_id); - AgentParms["agent_access"] = OSD.FromBoolean(userState.agent_access); - AgentParms["god_level"] = OSD.FromInteger(userState.god_level); - AgentParms["god_overide"] = OSD.FromBoolean(userState.god_overide); - AgentParms["identified"] = OSD.FromBoolean(userState.identified); - AgentParms["transacted"] = OSD.FromBoolean(userState.transacted); - AgentParms["age_verified"] = OSD.FromBoolean(userState.age_verified); - AgentParms["limited_to_estate"] = OSD.FromInteger(userState.limited_to_estate); - AgentParms["inventory_host"] = OSD.FromString(userState.inventory_host); - - // version 1 - RAMap = AgentParms; - - // Planned for version 2 - // RAMap["agent_params"] = AgentParms; - - RAMap["region_params"] = RegionParms; - RAMap["parameter"] = Parameter; - - string RAMapString = RAMap.ToString(); - m_log.InfoFormat("[OGP] RAMap string {0}", RAMapString); - OSD LLSDofRAMap = RAMap; // RENAME if this works - - m_log.InfoFormat("[OGP]: LLSD of map as string was {0}", LLSDofRAMap.ToString()); - //m_log.InfoFormat("[OGP]: LLSD+XML: {0}", LLSDParser.SerializeXmlString(LLSDofRAMap)); - byte[] buffer = OSDParser.SerializeLLSDXmlBytes(LLSDofRAMap); - - //string bufferDump = System.Text.Encoding.ASCII.GetString(buffer); - //m_log.InfoFormat("[OGP]: buffer form is {0}",bufferDump); - //m_log.InfoFormat("[OGP]: LLSD of map was {0}",buffer.Length); - - Stream os = null; - try - { // send the Post - DeRezRequest.ContentLength = buffer.Length; //Count bytes to send - os = DeRezRequest.GetRequestStream(); - os.Write(buffer, 0, buffer.Length); //Send it - os.Close(); - m_log.InfoFormat("[OGP]: Derez Avatar Posted Rez Avatar request to remote sim {0}", CapAddress); - } - catch (WebException ex) - { - m_log.InfoFormat("[OGP] Bad send on de_rez_avatar {0}", ex.Message); - responseMap["connect"] = OSD.FromBoolean(false); - - return responseMap; - } - - m_log.Info("[OGP] waiting for a reply after rez avatar send"); - string rez_avatar_reply = null; - { // get the response - try - { - WebResponse webResponse = DeRezRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[OGP:] Null reply on rez_avatar post"); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - rez_avatar_reply = sr.ReadToEnd().Trim(); - m_log.InfoFormat("[OGP]: rez_avatar reply was {0} ", rez_avatar_reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[OGP]: exception on read after send of rez avatar {0}", ex.Message); - responseMap["connect"] = OSD.FromBoolean(false); - - return responseMap; - } - OSD rezResponse = null; - try - { - rezResponse = OSDParser.DeserializeLLSDXml(rez_avatar_reply); - - responseMap = (OSDMap)rezResponse; - } - catch (Exception ex) - { - m_log.InfoFormat("[OGP]: exception on parse of rez reply {0}", ex.Message); - responseMap["connect"] = OSD.FromBoolean(false); - - return responseMap; - } - } - return responseMap; - } - - public OSD GenerateNoHandlerMessage() - { - OSDMap map = new OSDMap(); - map["reason"] = OSD.FromString("LLSDRequest"); - map["message"] = OSD.FromString("No handler registered for LLSD Requests"); - map["login"] = OSD.FromString("false"); - map["connect"] = OSD.FromString("false"); - return map; - } - public OSD GenerateNoStateMessage(UUID passedAvatar) - { - OSDMap map = new OSDMap(); - map["reason"] = OSD.FromString("derez failed"); - map["message"] = OSD.FromString("Unable to locate OGP state for avatar " + passedAvatar.ToString()); - map["login"] = OSD.FromString("false"); - map["connect"] = OSD.FromString("false"); - return map; - } - private bool TryGetAgentCircuitData(string path, out AgentCircuitData userdata) - { - userdata = null; - lock (CapsLoginID) - { - if (CapsLoginID.ContainsKey(path)) - { - userdata = CapsLoginID[path]; - DiscardUsedCap(path); - return true; - } - } - return false; - } - - private void DiscardUsedCap(string path) - { - CapsLoginID.Remove(path); - } - - private Scene GetRootScene() - { - Scene ReturnScene = null; - lock (m_scene) - { - if (m_scene.Count > 0) - { - ReturnScene = m_scene[0]; - } - } - - return ReturnScene; - } - - private Scene GetScene(string scenename) - { - Scene ReturnScene = null; - lock (m_scene) - { - foreach (Scene s in m_scene) - { - if (s.RegionInfo.RegionName.ToLower() == scenename) - { - ReturnScene = s; - break; - } - } - } - - return ReturnScene; - } - - private ulong GetOSCompatibleRegionHandle(RegionInfo reg) - { - return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY); - } - - private OGPState InitializeNewState() - { - OGPState returnState = new OGPState(); - returnState.first_name = ""; - returnState.last_name = ""; - returnState.agent_id = UUID.Zero; - returnState.local_agent_id = UUID.Zero; - returnState.region_id = UUID.Zero; - returnState.circuit_code = 0; - returnState.secure_session_id = UUID.Zero; - returnState.session_id = UUID.Zero; - returnState.agent_access = true; - returnState.god_level = 0; - returnState.god_overide = false; - returnState.identified = false; - returnState.transacted = false; - returnState.age_verified = false; - returnState.limited_to_estate = 1; - returnState.inventory_host = "http://inv4.mysql.aditi.lindenlab.com"; - returnState.allow_redirect = true; - returnState.sim_access = ""; - returnState.src_can_see_mainland = true; - returnState.src_estate_id = 1; - returnState.src_version = 1; - returnState.src_parent_estate_id = 1; - returnState.visible_to_parent = true; - returnState.teleported_into_region = ""; - - return returnState; - } - - private OGPState GetOGPState(UUID agentId) - { - lock (m_OGPState) - { - if (m_OGPState.ContainsKey(agentId)) - { - return m_OGPState[agentId]; - } - else - { - return InitializeNewState(); - } - } - } - - public void DeleteOGPState(UUID agentId) - { - lock (m_OGPState) - { - if (m_OGPState.ContainsKey(agentId)) - m_OGPState.Remove(agentId); - } - } - - private void UpdateOGPState(UUID agentId, OGPState state) - { - lock (m_OGPState) - { - if (m_OGPState.ContainsKey(agentId)) - { - m_OGPState[agentId] = state; - } - else - { - m_OGPState.Add(agentId,state); - } - } - } - private bool SceneListDuplicateCheck(string str) - { - // no lock, called from locked space! - bool found = false; - - foreach (Scene s in m_scene) - { - if (s.RegionInfo.RegionName == str) - { - found = true; - break; - } - } - - return found; - } - - public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod) - { - Scene homeScene = GetRootScene(); - ScenePresence avatar = null; - if (homeScene.TryGetScenePresence(avatarId,out avatar)) - { - KillAUser ku = new KillAUser(avatar,mod); - Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true, true); - } - } - -// private string CreateRandomStr(int len) -// { -// Random rnd = new Random(Environment.TickCount); -// string returnstring = ""; -// string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; -// -// for (int i = 0; i < len; i++) -// { -// returnstring += chars.Substring(rnd.Next(chars.Length), 1); -// } -// return returnstring; -// } - - // Temporary hack to allow teleporting to and from Vaak - private static bool customXertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) - { - //if (cert.Subject == "E=root@lindenlab.com, CN=*.vaak.lindenlab.com, O=\"Linden Lab, Inc.\", L=San Francisco, S=California, C=US") - //{ - return true; - //} - - //return false; - } - } - - public class KillAUser - { - private ScenePresence avToBeKilled = null; - private OpenGridProtocolModule m_mod = null; - - public KillAUser(ScenePresence avatar, OpenGridProtocolModule mod) - { - avToBeKilled = avatar; - m_mod = mod; - } - - public void ShutdownNoLogout() - { - UUID avUUID = UUID.Zero; - - if (avToBeKilled != null) - { - avUUID = avToBeKilled.UUID; - avToBeKilled.MakeChildAgent(); - - avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false; - - int sleepMS = 30000; - while (sleepMS > 0) - { - Watchdog.UpdateThread(); - Thread.Sleep(1000); - sleepMS -= 1000; - } - - // test for child agent because they might have come back - if (avToBeKilled.IsChildAgent) - { - m_mod.DeleteOGPState(avUUID); - avToBeKilled.ControllingClient.Close(); - } - } - - Watchdog.RemoveThread(); - } - - } - - public class MonoCert : ICertificatePolicy - { - #region ICertificatePolicy Members - - public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) - { - return true; - } - - #endregion - } -} -- cgit v1.1