From 8f403cb4b87fc99c0274929464229b1497395b86 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 15:47:56 +0100 Subject: Implement llGetPrimMediaParams() Exposes method to get media entry via IMoapModule As yet untested. --- .../Shared/Api/Implementation/LSL_Api.cs | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 417cef4..e18e33e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7808,6 +7808,110 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return res; } + public LSL_List llGetPrimMediaParams(int face, LSL_List rules) + { + m_host.AddScriptLPS(1); + ScriptSleep(1000); + + // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid + // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). + // Assuming silently fail means give back an empty list. Ideally, need to check this. + if (face < 0 || face > m_host.Shape.Media.Count - 1) + return new LSL_List(); + + return GetLinkPrimMediaParams(face, rules); + } + + public LSL_List GetLinkPrimMediaParams(int face, LSL_List rules) + { + IMoapModule module = m_ScriptEngine.World.RequestModuleInterface(); + if (null == module) + throw new Exception("Media on a prim functions not available"); + + MediaEntry me = module.GetMediaEntry(m_host, face); + + LSL_List res = new LSL_List(); + + for (int i = 0; i < rules.Length; i++) + { + int code = (int)rules.GetLSLIntegerItem(i); + + switch (code) + { + case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE: + // Not implemented + res.Add(new LSL_Integer(0)); + break; + + case ScriptBaseClass.PRIM_MEDIA_CONTROLS: + if (me.Controls == MediaControls.Standard) + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD)); + else + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI)); + break; + + case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL: + res.Add(new LSL_String(me.CurrentURL)); + break; + + case ScriptBaseClass.PRIM_MEDIA_HOME_URL: + res.Add(new LSL_String(me.HomeURL)); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP: + res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY: + res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE: + res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM: + res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); + break; + + case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT: + res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); + break; + + case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS: + res.Add(new LSL_Integer(me.Width)); + break; + + case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS: + res.Add(new LSL_Integer(me.Height)); + break; + + case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE: + res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); + break; + + case ScriptBaseClass.PRIM_MEDIA_WHITELIST: + string[] urls = (string[])me.WhiteList.Clone(); + + for (int j = 0; j < urls.Length; j++) + urls[j] = Uri.EscapeDataString(urls[j]); + + res.Add(new LSL_String(string.Join(", ", urls))); + break; + + case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT: + res.Add(new LSL_Integer((int)me.InteractPermissions)); + break; + + case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: + res.Add(new LSL_Integer((int)me.ControlPermissions)); + break; + } + } + + return res; + } + // // // The .NET definition of base 64 is: -- cgit v1.1 From a5ad792e6c90eb9412325e636c6e4eafc4a8a91d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 19:46:23 +0100 Subject: implement llSetPrimMediaParams() Untested --- .../Shared/Api/Implementation/LSL_Api.cs | 113 ++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e18e33e..4d57193 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7816,7 +7816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). // Assuming silently fail means give back an empty list. Ideally, need to check this. - if (face < 0 || face > m_host.Shape.Media.Count - 1) + if (face < 0 || face > m_host.GetNumberOfSides() - 1) return new LSL_List(); return GetLinkPrimMediaParams(face, rules); @@ -7830,6 +7830,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api MediaEntry me = module.GetMediaEntry(m_host, face); + // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams + if (null == me) + return new LSL_List(); + LSL_List res = new LSL_List(); for (int i = 0; i < rules.Length; i++) @@ -7912,6 +7916,113 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return res; } + public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules) + { + m_host.AddScriptLPS(1); + ScriptSleep(1000); + + // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid + // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. + // Don't perform the media check directly + if (face < 0 || face > m_host.GetNumberOfSides() - 1) + return ScriptBaseClass.LSL_STATUS_OK; + + return SetPrimMediaParams(face, rules); + } + + public LSL_Integer SetPrimMediaParams(int face, LSL_List rules) + { + IMoapModule module = m_ScriptEngine.World.RequestModuleInterface(); + if (null == module) + throw new Exception("Media on a prim functions not available"); + + MediaEntry me = module.GetMediaEntry(m_host, face); + if (null == me) + me = new MediaEntry(); + + int i = 0; + + while (i < rules.Length - 1) + { + int code = rules.GetLSLIntegerItem(i++); + + switch (code) + { + case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE: + me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_CONTROLS: + int v = rules.GetLSLIntegerItem(i++); + if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v) + me.Controls = MediaControls.Standard; + else + me.Controls = MediaControls.Mini; + break; + + case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL: + me.CurrentURL = rules.GetLSLStringItem(i++); + break; + + case ScriptBaseClass.PRIM_MEDIA_HOME_URL: + me.HomeURL = rules.GetLSLStringItem(i++); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP: + me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY: + me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE: + me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM: + me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT: + me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS: + me.Width = (int)rules.GetLSLIntegerItem(i++); + break; + + case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS: + me.Height = (int)rules.GetLSLIntegerItem(i++); + break; + + case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE: + me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); + break; + + case ScriptBaseClass.PRIM_MEDIA_WHITELIST: + string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' }); + List whiteListUrls = new List(); + Array.ForEach( + rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); }); + me.WhiteList = whiteListUrls.ToArray(); + break; + + case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT: + me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); + break; + + case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: + me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); + break; + } + } + + module.SetMediaEntry(m_host, face, me); + + return ScriptBaseClass.LSL_STATUS_OK; + } + // // // The .NET definition of base 64 is: -- cgit v1.1 From cfb79cd411d433b82129de6f3a54db4e8a86fab4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 19:48:20 +0100 Subject: minor: correct a few method names and change accessability --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4d57193..f5089aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7819,10 +7819,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (face < 0 || face > m_host.GetNumberOfSides() - 1) return new LSL_List(); - return GetLinkPrimMediaParams(face, rules); + return GetPrimMediaParams(face, rules); } - public LSL_List GetLinkPrimMediaParams(int face, LSL_List rules) + private LSL_List GetPrimMediaParams(int face, LSL_List rules) { IMoapModule module = m_ScriptEngine.World.RequestModuleInterface(); if (null == module) @@ -7930,7 +7930,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return SetPrimMediaParams(face, rules); } - public LSL_Integer SetPrimMediaParams(int face, LSL_List rules) + private LSL_Integer SetPrimMediaParams(int face, LSL_List rules) { IMoapModule module = m_ScriptEngine.World.RequestModuleInterface(); if (null == module) -- cgit v1.1 From 39a38c4901f00eae15c2eed38191944f8f419f8b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 22:00:45 +0100 Subject: implement llClearPrimMedia() untested --- .../Shared/Api/Implementation/LSL_Api.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f5089aa..8903c3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8023,6 +8023,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ScriptBaseClass.LSL_STATUS_OK; } + public LSL_Integer llClearPrimMedia(LSL_Integer face) + { + m_host.AddScriptLPS(1); + ScriptSleep(1000); + + // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid + // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. + // FIXME: Don't perform the media check directly + if (face < 0 || face > m_host.GetNumberOfSides() - 1) + return ScriptBaseClass.LSL_STATUS_OK; + + IMoapModule module = m_ScriptEngine.World.RequestModuleInterface(); + if (null == module) + throw new Exception("Media on a prim functions not available"); + + module.ClearMediaEntry(m_host, face); + + return ScriptBaseClass.LSL_STATUS_OK; + } + // // // The .NET definition of base 64 is: -- cgit v1.1