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