From 3d736d575ff9670ac813f13eb1cff07dea10328b Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 29 Aug 2012 14:56:51 -0700 Subject: This partially implements the LSL function to set the response type for an HTTP request. Since the "official" LSL function limits the use of the response type, it is implemented as osSetContentType with a string for the content mime type and a threat level of high. With this function you should be able to implement rather functional media-on-a-prim application with much less difficulty. --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 18 +++++++++++++++++- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 6 ++++++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 09fcf50..e245684 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -140,12 +140,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal float m_ScriptDistanceFactor = 1.0f; internal Dictionary m_FunctionPerms = new Dictionary(); + protected IUrlModule m_UrlModule = null; + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { m_ScriptEngine = ScriptEngine; m_host = host; m_item = item; + m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); + if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) m_OSFunctionsEnabled = true; @@ -3358,5 +3362,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); } - } + + /// + /// Sets the response type for an HTTP request/response + /// + /// + public void osSetContentType(LSL_Key id, string type) + { + CheckThreatLevel(ThreatLevel.High,"osSetResponseType"); + if (m_UrlModule != null) + m_UrlModule.HttpContentType(new UUID(id),type); + } + + } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index ce1845c..06729ab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -365,5 +365,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// /// Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown. LSL_Key osGetRezzingObject(); + + /// + /// Sets the response type for an HTTP request/response + /// + /// + void osSetContentType(LSL_Key id, string type); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index e9131e4..ba1ade2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -955,5 +955,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osGetRezzingObject(); } + + public void osSetContentType(LSL_Key id, string type) + { + m_OSSL_Functions.osSetContentType(id,type); + } } } -- cgit v1.1 From 6b277394c080f5ad50d07e94f3e21340da4913b3 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Wed, 29 Aug 2012 17:21:01 +0100 Subject: refactoring as the list funcs either skip invalid values or recall ToDoubleList --- .../Shared/Api/Implementation/LSL_Api.cs | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ae92716..45286c0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10119,31 +10119,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llListStatistics(int operation, LSL_List src) { m_host.AddScriptLPS(1); - LSL_List nums = LSL_List.ToDoubleList(src); switch (operation) { case ScriptBaseClass.LIST_STAT_RANGE: - return nums.Range(); + return src.Range(); case ScriptBaseClass.LIST_STAT_MIN: - return nums.Min(); + return src.Min(); case ScriptBaseClass.LIST_STAT_MAX: - return nums.Max(); + return src.Max(); case ScriptBaseClass.LIST_STAT_MEAN: - return nums.Mean(); + return src.Mean(); case ScriptBaseClass.LIST_STAT_MEDIAN: - return nums.Median(); + return LSL_List.ToDoubleList(src).Median(); case ScriptBaseClass.LIST_STAT_NUM_COUNT: - return nums.NumericLength(); + return src.NumericLength(); case ScriptBaseClass.LIST_STAT_STD_DEV: - return nums.StdDev(); + return src.StdDev(); case ScriptBaseClass.LIST_STAT_SUM: - return nums.Sum(); + return src.Sum(); case ScriptBaseClass.LIST_STAT_SUM_SQUARES: - return nums.SumSqrs(); + return src.SumSqrs(); case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN: - return nums.GeometricMean(); + return src.GeometricMean(); case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN: - return nums.HarmonicMean(); + return src.HarmonicMean(); default: return 0.0; } -- cgit v1.1