aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs235
1 files changed, 235 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 50ea489..ba1a5f1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7848,6 +7848,241 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7848 return res; 7848 return res;
7849 } 7849 }
7850 7850
7851 public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
7852 {
7853 m_host.AddScriptLPS(1);
7854 ScriptSleep(1000);
7855
7856 // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
7857 // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
7858 // Assuming silently fail means give back an empty list. Ideally, need to check this.
7859 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
7860 return new LSL_List();
7861
7862 return GetPrimMediaParams(face, rules);
7863 }
7864
7865 private LSL_List GetPrimMediaParams(int face, LSL_List rules)
7866 {
7867 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
7868 if (null == module)
7869 throw new Exception("Media on a prim functions not available");
7870
7871 MediaEntry me = module.GetMediaEntry(m_host, face);
7872
7873 // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
7874 if (null == me)
7875 return new LSL_List();
7876
7877 LSL_List res = new LSL_List();
7878
7879 for (int i = 0; i < rules.Length; i++)
7880 {
7881 int code = (int)rules.GetLSLIntegerItem(i);
7882
7883 switch (code)
7884 {
7885 case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
7886 // Not implemented
7887 res.Add(new LSL_Integer(0));
7888 break;
7889
7890 case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
7891 if (me.Controls == MediaControls.Standard)
7892 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
7893 else
7894 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
7895 break;
7896
7897 case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
7898 res.Add(new LSL_String(me.CurrentURL));
7899 break;
7900
7901 case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
7902 res.Add(new LSL_String(me.HomeURL));
7903 break;
7904
7905 case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
7906 res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
7907 break;
7908
7909 case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
7910 res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
7911 break;
7912
7913 case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
7914 res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
7915 break;
7916
7917 case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
7918 res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
7919 break;
7920
7921 case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
7922 res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
7923 break;
7924
7925 case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
7926 res.Add(new LSL_Integer(me.Width));
7927 break;
7928
7929 case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
7930 res.Add(new LSL_Integer(me.Height));
7931 break;
7932
7933 case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
7934 res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
7935 break;
7936
7937 case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
7938 string[] urls = (string[])me.WhiteList.Clone();
7939
7940 for (int j = 0; j < urls.Length; j++)
7941 urls[j] = Uri.EscapeDataString(urls[j]);
7942
7943 res.Add(new LSL_String(string.Join(", ", urls)));
7944 break;
7945
7946 case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
7947 res.Add(new LSL_Integer((int)me.InteractPermissions));
7948 break;
7949
7950 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
7951 res.Add(new LSL_Integer((int)me.ControlPermissions));
7952 break;
7953 }
7954 }
7955
7956 return res;
7957 }
7958
7959 public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
7960 {
7961 m_host.AddScriptLPS(1);
7962 ScriptSleep(1000);
7963
7964 // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
7965 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
7966 // Don't perform the media check directly
7967 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
7968 return ScriptBaseClass.LSL_STATUS_OK;
7969
7970 return SetPrimMediaParams(face, rules);
7971 }
7972
7973 private LSL_Integer SetPrimMediaParams(int face, LSL_List rules)
7974 {
7975 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
7976 if (null == module)
7977 throw new Exception("Media on a prim functions not available");
7978
7979 MediaEntry me = module.GetMediaEntry(m_host, face);
7980 if (null == me)
7981 me = new MediaEntry();
7982
7983 int i = 0;
7984
7985 while (i < rules.Length - 1)
7986 {
7987 int code = rules.GetLSLIntegerItem(i++);
7988
7989 switch (code)
7990 {
7991 case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
7992 me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
7993 break;
7994
7995 case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
7996 int v = rules.GetLSLIntegerItem(i++);
7997 if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
7998 me.Controls = MediaControls.Standard;
7999 else
8000 me.Controls = MediaControls.Mini;
8001 break;
8002
8003 case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
8004 me.CurrentURL = rules.GetLSLStringItem(i++);
8005 break;
8006
8007 case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
8008 me.HomeURL = rules.GetLSLStringItem(i++);
8009 break;
8010
8011 case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
8012 me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8013 break;
8014
8015 case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
8016 me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8017 break;
8018
8019 case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
8020 me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8021 break;
8022
8023 case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
8024 me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8025 break;
8026
8027 case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
8028 me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8029 break;
8030
8031 case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
8032 me.Width = (int)rules.GetLSLIntegerItem(i++);
8033 break;
8034
8035 case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
8036 me.Height = (int)rules.GetLSLIntegerItem(i++);
8037 break;
8038
8039 case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
8040 me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8041 break;
8042
8043 case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
8044 string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
8045 List<string> whiteListUrls = new List<string>();
8046 Array.ForEach(
8047 rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
8048 me.WhiteList = whiteListUrls.ToArray();
8049 break;
8050
8051 case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
8052 me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8053 break;
8054
8055 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
8056 me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8057 break;
8058 }
8059 }
8060
8061 module.SetMediaEntry(m_host, face, me);
8062
8063 return ScriptBaseClass.LSL_STATUS_OK;
8064 }
8065
8066 public LSL_Integer llClearPrimMedia(LSL_Integer face)
8067 {
8068 m_host.AddScriptLPS(1);
8069 ScriptSleep(1000);
8070
8071 // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
8072 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
8073 // FIXME: Don't perform the media check directly
8074 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
8075 return ScriptBaseClass.LSL_STATUS_OK;
8076
8077 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
8078 if (null == module)
8079 throw new Exception("Media on a prim functions not available");
8080
8081 module.ClearMediaEntry(m_host, face);
8082
8083 return ScriptBaseClass.LSL_STATUS_OK;
8084 }
8085
7851 // <remarks> 8086 // <remarks>
7852 // <para> 8087 // <para>
7853 // The .NET definition of base 64 is: 8088 // The .NET definition of base 64 is: