From 6569f12d4005551bac44069246f7ecdc59e8fe1a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 19 Oct 2018 03:43:01 +0100 Subject: add initial test support for cap LSLSyntax. This does not seem to work for Opensimulator on viewers, In particular with FireStorm seems impossible to replace its own definitions, viwers do note revert to defaults on tp to a region that does not suport this cap, etc. So possible just a dead end. Disabled by default --- .../Linden/Caps/SimulatorFeaturesModule.cs | 79 ++++++++++++++++++++-- 1 file changed, 73 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index cbcbd2d..8c7fb56 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -28,7 +28,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Reflection; +using System.Text; using log4net; using Nini.Config; using Mono.Addins; @@ -75,12 +77,16 @@ namespace OpenSim.Region.ClientStack.Linden private string m_GridName = string.Empty; private string m_GridURL = string.Empty; + static private UUID m_scriptSyntaxeID = UUID.Zero; + static private string m_scriptSyntaxeXML; + private bool m_doScriptSyntax; + #region ISharedRegionModule Members public void Initialise(IConfigSource source) { IConfig config = source.Configs["SimulatorFeatures"]; - + m_doScriptSyntax = false; if (config != null) { // @@ -103,8 +109,10 @@ namespace OpenSim.Region.ClientStack.Linden if (m_GridName == string.Empty) m_GridName = Util.GetConfigVarFromSections( source, "gridname", new string[] { "GridInfo", "SimulatorFeatures" }, String.Empty); + m_doScriptSyntax = config.GetBoolean("ScriptSyntaxe", m_doScriptSyntax); } + ReadScriptSyntaxe(); AddDefaultFeatures(); } @@ -160,6 +168,9 @@ namespace OpenSim.Region.ClientStack.Linden typesMap["prim"] = true; m_features["PhysicsShapeTypes"] = typesMap; + if(m_doScriptSyntax && m_scriptSyntaxeID != UUID.Zero) + m_features["LSLSyntaxId"] = OSD.FromUUID(m_scriptSyntaxeID); + // Extra information for viewers that want to use it // TODO: Take these out of here into their respective modules, like map-server-url OSDMap extrasMap; @@ -192,12 +203,20 @@ namespace OpenSim.Region.ClientStack.Linden public void RegisterCaps(UUID agentID, Caps caps) { - IRequestHandler reqHandler - = new RestHTTPHandler( + IRequestHandler reqHandler = new RestHTTPHandler( "GET", "/CAPS/" + UUID.Random(), - x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString()); - + x => { return HandleSimulatorFeaturesRequest(x, agentID); }, + "SimulatorFeatures", agentID.ToString()); caps.RegisterHandler("SimulatorFeatures", reqHandler); + + if (m_doScriptSyntax && m_scriptSyntaxeID != UUID.Zero && !String.IsNullOrEmpty(m_scriptSyntaxeXML)) + { + IRequestHandler sreqHandler = new RestHTTPHandler( + "GET", "/CAPS/" + UUID.Random(), + x => { return HandleSyntaxeRequest(x, agentID); }, + "LSLSyntax", agentID.ToString()); + caps.RegisterHandler("LSLSyntax", sreqHandler); + } } public void AddFeature(string name, OSD value) @@ -236,7 +255,7 @@ namespace OpenSim.Region.ClientStack.Linden private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID) { -// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); + // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); OSDMap copy = DeepCopy(); @@ -259,12 +278,21 @@ namespace OpenSim.Region.ClientStack.Linden return responsedata; } + private Hashtable HandleSyntaxeRequest(Hashtable mDhttpMethod, UUID agentID) + { + Hashtable responsedata = new Hashtable(); + responsedata["int_response_code"] = 200; + responsedata["str_response_string"] = m_scriptSyntaxeXML; + return responsedata; + } + /// /// Gets the grid extra features. /// /// /// The URI Robust uses to handle the get_extra_features request /// + private void GetGridExtraFeatures(Scene scene) { Dictionary extraFeatures = scene.GridService.GetExtraFeatures(); @@ -299,5 +327,44 @@ namespace OpenSim.Region.ClientStack.Linden return url; } + + private void ReadScriptSyntaxe() + { + if(!m_doScriptSyntax || m_scriptSyntaxeID != UUID.Zero) + return; + + if(!File.Exists("ScriptSyntaxe.xml")) + return; + + try + { + using (StreamReader sr = File.OpenText("ScriptSyntaxe.xml")) + { + string version = sr.ReadLine(); + if(string.IsNullOrEmpty(version)) + return; + if(!UUID.TryParse(version, out m_scriptSyntaxeID)) + return; + + StringBuilder sb = new StringBuilder(400*1024); + string s=""; + char[] trimc = new char[] {' ','\t', '\n', '\r'}; + while((s = sr.ReadLine()) != null) + { + s = s.Trim(trimc); + if(String.IsNullOrEmpty(s) || s.StartsWith("<--")) + continue; + sb.Append(s); + } + m_scriptSyntaxeXML = sb.ToString(); + } + } + catch + { + m_log.Error("[SIMULATOR FEATURES MODULE] fail read ScriptSyntaxe.xml file"); + m_scriptSyntaxeID = UUID.Zero; + m_scriptSyntaxeXML = ""; + } + } } } -- cgit v1.1