From 10a8d2852e529fddb029ae333a3ae6a0f06f0182 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 3 Aug 2014 20:33:40 -0400 Subject: OpenSimExtras Move the experimental extra features functionality into the GridService. This sends default values for map, search and destination guide, plus ExportSupported control to the region on startup. Please watch http://opensimulator.org/wiki/SimulatorFeatures_Extras for changes and documentation. --- .../Linden/Caps/SimulatorFeaturesModule.cs | 74 ++++-------- .../Grid/LocalGridFeaturesServiceInConnector.cs | 129 --------------------- .../Grid/LocalGridServiceConnector.cs | 5 + .../Grid/RemoteGridServiceConnector.cs | 12 ++ 4 files changed, 41 insertions(+), 179 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 9f1eb88..1345bff 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -27,17 +27,18 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Reflection; using log4net; using Nini.Config; using Mono.Addins; using OpenMetaverse; using OpenMetaverse.StructuredData; -using OpenSim.Framework; +//using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; +// using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Region.ClientStack.Linden @@ -63,8 +64,6 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_scene; - bool m_AllowOverride = true; - /// /// Simulator features /// @@ -81,25 +80,11 @@ namespace OpenSim.Region.ClientStack.Linden IConfig config = source.Configs["SimulatorFeatures"]; if (config != null) - { - string featuresURI = config.GetString("ExtraFeaturesServiceURI", string.Empty); - - if (string.IsNullOrEmpty(featuresURI)) - { - m_log.Info("ExtraFeaturesServiceURI is undefined. The grid's ExtraFeatures will not be available to regions in this instance."); - } - else - { - GetGridExtraFeatures(featuresURI); - } - - if (m_AllowOverride) - { - m_SearchURL = config.GetString("SearchServerURI", m_SearchURL); - m_DestinationGuideURL = config.GetString ("DestinationGuideURI", m_DestinationGuideURL); - - m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported); - } + { + // These are normaly set in their respective modules + m_SearchURL = config.GetString("SearchServerURI", m_SearchURL); + m_DestinationGuideURL = config.GetString ("DestinationGuideURI", m_DestinationGuideURL); + m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported); } AddDefaultFeatures(); @@ -120,6 +105,7 @@ namespace OpenSim.Region.ClientStack.Linden public void RegionLoaded(Scene s) { + GetGridExtraFeatures(s); } public void PostInitialise() @@ -169,11 +155,11 @@ namespace OpenSim.Region.ClientStack.Linden else extrasMap = new OSDMap(); - if (m_SearchURL != string.Empty && m_AllowOverride == true) + if (m_SearchURL != string.Empty) extrasMap["search-server-url"] = m_SearchURL; - if (!string.IsNullOrEmpty(m_DestinationGuideURL) && m_AllowOverride == true) + if (!string.IsNullOrEmpty(m_DestinationGuideURL)) extrasMap["destination-guide-url"] = m_DestinationGuideURL; - if (m_ExportSupported && m_AllowOverride == true) + if (m_ExportSupported) extrasMap["ExportSupported"] = true; if (extrasMap.Count > 0) @@ -233,9 +219,7 @@ namespace OpenSim.Region.ClientStack.Linden SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; - // We will not trigger the event if m_AllowOverride == False - // See Robust.ini/Robust.HG.ini [GridExtraFeatures] - AllowRegionOverride - if (handlerOnSimulatorFeaturesRequest != null && m_AllowOverride == true) + if (handlerOnSimulatorFeaturesRequest != null) handlerOnSimulatorFeaturesRequest(agentID, ref copy); //Send back data @@ -255,32 +239,22 @@ namespace OpenSim.Region.ClientStack.Linden /// /// The URI Robust uses to handle the get_extra_features request /// - private void GetGridExtraFeatures(string featuresURI) + private void GetGridExtraFeatures(Scene scene) { - JsonRpcRequestManager rpc = new JsonRpcRequestManager (); - - OSDMap parameters = new OSDMap (); - OSD Params = (OSD)parameters; - if (!rpc.JsonRpcRequest (ref Params, "get_extra_features", featuresURI, UUID.Random ().ToString ())) - { - m_log.Error("[SIMFEATURES]: Could not retrieve extra features from grid. Please check configuration."); - return; - } - parameters = (OSDMap)Params; - OSDMap features = (OSDMap)parameters ["result"]; - - if(features.ContainsKey("region_override")) - m_AllowOverride = features ["region_override"].AsBoolean () ; - else - m_AllowOverride = true; - - OSDMap test = (OSDMap)features ["extra_features"]; + Dictionary extraFeatures = scene.GridService.GetExtraFeatures(); + lock (m_features) { OSDMap extrasMap = new OSDMap(); - foreach (string key in test.Keys) + + foreach(string key in extraFeatures.Keys) { - extrasMap[key] = test[key]; + extrasMap[key] = (string)extraFeatures[key]; + + if (key == "ExportSupported") + { + bool.TryParse(extraFeatures[key].ToString(), out m_ExportSupported); + } } m_features["OpenSimExtras"] = extrasMap; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs deleted file mode 100644 index 6cfb099..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs +++ /dev/null @@ -1,129 +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.Reflection; -using System.Collections.Generic; -using log4net; -using Mono.Addins; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Server.Base; -using OpenSim.Server.Handlers.Base; -using OpenSim.Server.Handlers.Grid; -using OpenSim.Services.Interfaces; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalGridFeaturesServiceInConnector")] - public class LocalGridExtraFeaturesServiceInConnector : ISharedRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool m_Enabled = false; - - private IConfigSource m_Config; - bool m_Registered = false; - - #region Region Module interface - - public void Initialise(IConfigSource config) - { - m_Config = config; - IConfig moduleConfig = config.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("GridExtraFeaturesServiceInConnector", ""); - if (name == Name) - { - m_log.Info("[GridExtraFeatures]: GridExtraFeatures Service In Connector enabled"); - InitializeService(config); - } - } - } - - public void InitializeService(IConfigSource config) - { - GridExtraFeaturesHandlers handler = new GridExtraFeaturesHandlers(config); - - IHttpServer Server = MainServer.Instance; - - Server.AddJsonRPCHandler("get_extra_features", handler.JsonGetGridFeaturesMethod); - - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "LocalGridExtraFeaturesServiceInConnector"; } - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - if (!m_Registered) - { - m_Registered = true; - - m_log.Info("[GRID EXTRA FEATURES]: Starting..."); - - new GridExtraFeaturesServerInConnector(m_Config, MainServer.Instance, "GridExtraFeaturesService"); - } - } -#endregion - - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 731bd28..8e995db 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -278,6 +278,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridService.GetRegionFlags(scopeID, regionID); } + public Dictionary GetExtraFeatures() + { + return m_GridService.GetExtraFeatures(); + } + #endregion public void HandleShowNeighboursCommand(string module, string[] cmdparams) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index ae5081c..f0c4926 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -28,6 +28,7 @@ using log4net; using Mono.Addins; using System; +using System.Collections; using System.Collections.Generic; using System.Reflection; using Nini.Config; @@ -349,6 +350,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return flags; } + + public Dictionary GetExtraFeatures() + { + Dictionary extraFeatures; + extraFeatures = m_LocalGridService.GetExtraFeatures(); + + if (extraFeatures.Count == 0) + extraFeatures = m_RemoteGridService.GetExtraFeatures(); + + return extraFeatures; + } #endregion } } -- cgit v1.1