diff options
author | Justin Clark-Casey (justincc) | 2010-07-12 15:47:56 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-12 15:49:09 +0100 |
commit | 7e3c54213c115fd8edb0423a352b2393fae60363 (patch) | |
tree | 291f1f4da9b5c06ea506be0ef67d117c23eac850 | |
parent | Implement media texture persistence over server restarts for sqlite (diff) | |
download | opensim-SC-7e3c54213c115fd8edb0423a352b2393fae60363.zip opensim-SC-7e3c54213c115fd8edb0423a352b2393fae60363.tar.gz opensim-SC-7e3c54213c115fd8edb0423a352b2393fae60363.tar.bz2 opensim-SC-7e3c54213c115fd8edb0423a352b2393fae60363.tar.xz |
Implement llGetPrimMediaParams()
Exposes method to get media entry via IMoapModule
As yet untested.
Diffstat (limited to '')
4 files changed, 193 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index c3ec2a6..9f74367 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; | |||
51 | namespace OpenSim.Region.CoreModules.Media.Moap | 51 | namespace OpenSim.Region.CoreModules.Media.Moap |
52 | { | 52 | { |
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] | 53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] |
54 | public class MoapModule : INonSharedRegionModule | 54 | public class MoapModule : INonSharedRegionModule, IMoapModule |
55 | { | 55 | { |
56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
57 | 57 | ||
@@ -97,7 +97,22 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
97 | // Even though we're registering for POST we're going to get GETS and UPDATES too | 97 | // Even though we're registering for POST we're going to get GETS and UPDATES too |
98 | caps.RegisterHandler( | 98 | caps.RegisterHandler( |
99 | "ObjectMediaNavigate", new RestStreamHandler("POST", "/CAPS/" + UUID.Random(), HandleObjectMediaNavigateMessage)); | 99 | "ObjectMediaNavigate", new RestStreamHandler("POST", "/CAPS/" + UUID.Random(), HandleObjectMediaNavigateMessage)); |
100 | } | 100 | } |
101 | |||
102 | public MediaEntry GetMediaEntry(SceneObjectPart part, int face) | ||
103 | { | ||
104 | if (face < 0) | ||
105 | throw new ArgumentException("Face cannot be less than zero"); | ||
106 | |||
107 | List<MediaEntry> media = part.Shape.Media; | ||
108 | |||
109 | if (face > media.Count - 1) | ||
110 | throw new ArgumentException( | ||
111 | string.Format("Face argument was {0} but max is {1}", face, media.Count - 1)); | ||
112 | |||
113 | // TODO: Really need a proper copy constructor down in libopenmetaverse | ||
114 | return MediaEntry.FromOSD(media[face].GetOSD()); | ||
115 | } | ||
101 | 116 | ||
102 | /// <summary> | 117 | /// <summary> |
103 | /// Sets or gets per face media textures. | 118 | /// 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 0000000..4447f34 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IMoapModule.cs | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Region.Framework.Scenes; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Provides methods from manipulating media-on-a-prim | ||
36 | /// </summary> | ||
37 | public interface IMoapModule | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Get the media entry for a given prim face. | ||
41 | /// </summary> | ||
42 | /// <param name="part"></param> | ||
43 | /// <param name="face"></param> | ||
44 | /// <returns></returns> | ||
45 | MediaEntry GetMediaEntry(SceneObjectPart part, int face); | ||
46 | } | ||
47 | } \ 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 712bd7d..9290fc3 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 | |||
7808 | return res; | 7808 | return res; |
7809 | } | 7809 | } |
7810 | 7810 | ||
7811 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) | ||
7812 | { | ||
7813 | m_host.AddScriptLPS(1); | ||
7814 | ScriptSleep(1000); | ||
7815 | |||
7816 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid | ||
7817 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). | ||
7818 | // Assuming silently fail means give back an empty list. Ideally, need to check this. | ||
7819 | if (face < 0 || face > m_host.Shape.Media.Count - 1) | ||
7820 | return new LSL_List(); | ||
7821 | |||
7822 | return GetLinkPrimMediaParams(face, rules); | ||
7823 | } | ||
7824 | |||
7825 | public LSL_List GetLinkPrimMediaParams(int face, LSL_List rules) | ||
7826 | { | ||
7827 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | ||
7828 | if (null == module) | ||
7829 | throw new Exception("Media on a prim functions not available"); | ||
7830 | |||
7831 | MediaEntry me = module.GetMediaEntry(m_host, face); | ||
7832 | |||
7833 | LSL_List res = new LSL_List(); | ||
7834 | |||
7835 | for (int i = 0; i < rules.Length; i++) | ||
7836 | { | ||
7837 | int code = (int)rules.GetLSLIntegerItem(i); | ||
7838 | |||
7839 | switch (code) | ||
7840 | { | ||
7841 | case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE: | ||
7842 | // Not implemented | ||
7843 | res.Add(new LSL_Integer(0)); | ||
7844 | break; | ||
7845 | |||
7846 | case ScriptBaseClass.PRIM_MEDIA_CONTROLS: | ||
7847 | if (me.Controls == MediaControls.Standard) | ||
7848 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD)); | ||
7849 | else | ||
7850 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI)); | ||
7851 | break; | ||
7852 | |||
7853 | case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL: | ||
7854 | res.Add(new LSL_String(me.CurrentURL)); | ||
7855 | break; | ||
7856 | |||
7857 | case ScriptBaseClass.PRIM_MEDIA_HOME_URL: | ||
7858 | res.Add(new LSL_String(me.HomeURL)); | ||
7859 | break; | ||
7860 | |||
7861 | case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP: | ||
7862 | res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); | ||
7863 | break; | ||
7864 | |||
7865 | case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY: | ||
7866 | res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); | ||
7867 | break; | ||
7868 | |||
7869 | case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE: | ||
7870 | res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); | ||
7871 | break; | ||
7872 | |||
7873 | case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM: | ||
7874 | res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); | ||
7875 | break; | ||
7876 | |||
7877 | case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT: | ||
7878 | res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); | ||
7879 | break; | ||
7880 | |||
7881 | case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS: | ||
7882 | res.Add(new LSL_Integer(me.Width)); | ||
7883 | break; | ||
7884 | |||
7885 | case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS: | ||
7886 | res.Add(new LSL_Integer(me.Height)); | ||
7887 | break; | ||
7888 | |||
7889 | case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE: | ||
7890 | res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE); | ||
7891 | break; | ||
7892 | |||
7893 | case ScriptBaseClass.PRIM_MEDIA_WHITELIST: | ||
7894 | string[] urls = (string[])me.WhiteList.Clone(); | ||
7895 | |||
7896 | for (int j = 0; j < urls.Length; j++) | ||
7897 | urls[j] = Uri.EscapeDataString(urls[j]); | ||
7898 | |||
7899 | res.Add(new LSL_String(string.Join(", ", urls))); | ||
7900 | break; | ||
7901 | |||
7902 | case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT: | ||
7903 | res.Add(new LSL_Integer((int)me.InteractPermissions)); | ||
7904 | break; | ||
7905 | |||
7906 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: | ||
7907 | res.Add(new LSL_Integer((int)me.ControlPermissions)); | ||
7908 | break; | ||
7909 | } | ||
7910 | } | ||
7911 | |||
7912 | return res; | ||
7913 | } | ||
7914 | |||
7811 | // <remarks> | 7915 | // <remarks> |
7812 | // <para> | 7916 | // <para> |
7813 | // The .NET definition of base 64 is: | 7917 | // 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 dba6502..9a64f8c 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 | |||
517 | public const int TOUCH_INVALID_FACE = -1; | 517 | public const int TOUCH_INVALID_FACE = -1; |
518 | public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0); | 518 | public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0); |
519 | public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR; | 519 | public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR; |
520 | |||
521 | // constants for llGetPrimMediaParams | ||
522 | public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0; | ||
523 | public const int PRIM_MEDIA_CONTROLS = 1; | ||
524 | public const int PRIM_MEDIA_CURRENT_URL = 2; | ||
525 | public const int PRIM_MEDIA_HOME_URL = 3; | ||
526 | public const int PRIM_MEDIA_AUTO_LOOP = 4; | ||
527 | public const int PRIM_MEDIA_AUTO_PLAY = 5; | ||
528 | public const int PRIM_MEDIA_AUTO_SCALE = 6; | ||
529 | public const int PRIM_MEDIA_AUTO_ZOOM = 7; | ||
530 | public const int PRIM_MEDIA_FIRST_CLICK_INTERACT = 8; | ||
531 | public const int PRIM_MEDIA_WIDTH_PIXELS = 9; | ||
532 | public const int PRIM_MEDIA_HEIGHT_PIXELS = 10; | ||
533 | public const int PRIM_MEDIA_WHITELIST_ENABLE = 11; | ||
534 | public const int PRIM_MEDIA_WHITELIST = 12; | ||
535 | public const int PRIM_MEDIA_PERMS_INTERACT = 13; | ||
536 | public const int PRIM_MEDIA_PERMS_CONTROL = 14; | ||
537 | |||
538 | public const int PRIM_MEDIA_CONTROLS_STANDARD = 0; | ||
539 | public const int PRIM_MEDIA_CONTROLS_MINI = 1; | ||
540 | |||
541 | public const int PRIM_MEDIA_PERM_NONE = 0; | ||
542 | public const int PRIM_MEDIA_PERM_OWNER = 1; | ||
543 | public const int PRIM_MEDIA_PERM_GROUP = 2; | ||
544 | public const int PRIM_MEDIA_PERM_ANYONE = 4; | ||
520 | 545 | ||
521 | // Constants for default textures | 546 | // Constants for default textures |
522 | public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; | 547 | public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; |