diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index c3ec2a6244..9f7436714f 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -51,7 +51,7 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.CoreModules.Media.Moap { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] - public class MoapModule : INonSharedRegionModule + public class MoapModule : INonSharedRegionModule, IMoapModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -97,7 +97,22 @@ namespace OpenSim.Region.CoreModules.Media.Moap // Even though we're registering for POST we're going to get GETS and UPDATES too caps.RegisterHandler( "ObjectMediaNavigate", new RestStreamHandler("POST", "/CAPS/" + UUID.Random(), HandleObjectMediaNavigateMessage)); - } + } + + public MediaEntry GetMediaEntry(SceneObjectPart part, int face) + { + if (face < 0) + throw new ArgumentException("Face cannot be less than zero"); + + List media = part.Shape.Media; + + if (face > media.Count - 1) + throw new ArgumentException( + string.Format("Face argument was {0} but max is {1}", face, media.Count - 1)); + + // TODO: Really need a proper copy constructor down in libopenmetaverse + return MediaEntry.FromOSD(media[face].GetOSD()); + } /// /// Sets or gets per face media textures. diff --git a/OpenSim/Region/Framework/Interfaces/IMoapModule.cs b/OpenSim/Region/Framework/Interfaces/IMoapModule.cs new file mode 100644 index 0000000000..4447f3475e --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IMoapModule.cs @@ -0,0 +1,47 @@ +/* + * 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 OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.Framework.Interfaces +{ + /// + /// Provides methods from manipulating media-on-a-prim + /// + public interface IMoapModule + { + /// + /// Get the media entry for a given prim face. + /// + /// + /// + /// + MediaEntry GetMediaEntry(SceneObjectPart part, int face); + } +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 417cef4e64..e18e33eb29 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: diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index dba6502f4b..9a64f8c40f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -517,6 +517,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int TOUCH_INVALID_FACE = -1; public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0); public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR; + + // constants for llGetPrimMediaParams + public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0; + public const int PRIM_MEDIA_CONTROLS = 1; + public const int PRIM_MEDIA_CURRENT_URL = 2; + public const int PRIM_MEDIA_HOME_URL = 3; + public const int PRIM_MEDIA_AUTO_LOOP = 4; + public const int PRIM_MEDIA_AUTO_PLAY = 5; + public const int PRIM_MEDIA_AUTO_SCALE = 6; + public const int PRIM_MEDIA_AUTO_ZOOM = 7; + public const int PRIM_MEDIA_FIRST_CLICK_INTERACT = 8; + public const int PRIM_MEDIA_WIDTH_PIXELS = 9; + public const int PRIM_MEDIA_HEIGHT_PIXELS = 10; + public const int PRIM_MEDIA_WHITELIST_ENABLE = 11; + public const int PRIM_MEDIA_WHITELIST = 12; + public const int PRIM_MEDIA_PERMS_INTERACT = 13; + public const int PRIM_MEDIA_PERMS_CONTROL = 14; + + public const int PRIM_MEDIA_CONTROLS_STANDARD = 0; + public const int PRIM_MEDIA_CONTROLS_MINI = 1; + + public const int PRIM_MEDIA_PERM_NONE = 0; + public const int PRIM_MEDIA_PERM_OWNER = 1; + public const int PRIM_MEDIA_PERM_GROUP = 2; + public const int PRIM_MEDIA_PERM_ANYONE = 4; // Constants for default textures public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f";