aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-07-12 19:46:23 +0100
committerJustin Clark-Casey (justincc)2010-07-12 19:46:23 +0100
commit4a92046b589a0ced240cbf5b174855daf5504a4f (patch)
tree6e2e993c495f02c5d93e5298d0dbea34ce1ddc31 /OpenSim
parentImplement llGetPrimMediaParams() (diff)
downloadopensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.zip
opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.tar.gz
opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.tar.bz2
opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.tar.xz
implement llSetPrimMediaParams()
Untested
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs54
-rw-r--r--OpenSim/Region/Framework/Interfaces/IMoapModule.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs113
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs12
6 files changed, 184 insertions, 13 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 517dbf6..85638ca 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -176,6 +176,7 @@ namespace OpenSim.Framework
176 /// <summary> 176 /// <summary>
177 /// Entries to store media textures on each face 177 /// Entries to store media textures on each face
178 /// </summary> 178 /// </summary>
179 /// Do not change this value directly - always do it through an IMoapModule.
179 public List<MediaEntry> Media { get; set; } 180 public List<MediaEntry> Media { get; set; }
180 181
181 public PrimitiveBaseShape() 182 public PrimitiveBaseShape()
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 9f74367..064047d 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -102,16 +102,54 @@ namespace OpenSim.Region.CoreModules.Media.Moap
102 public MediaEntry GetMediaEntry(SceneObjectPart part, int face) 102 public MediaEntry GetMediaEntry(SceneObjectPart part, int face)
103 { 103 {
104 if (face < 0) 104 if (face < 0)
105 throw new ArgumentException("Face cannot be less than zero"); 105 throw new ArgumentException("Face cannot be less than zero");
106
107 int maxFaces = part.GetNumberOfSides() - 1;
108 if (face > maxFaces)
109 throw new ArgumentException(
110 string.Format("Face argument was {0} but max is {1}", face, maxFaces));
106 111
107 List<MediaEntry> media = part.Shape.Media; 112 List<MediaEntry> media = part.Shape.Media;
108 113
109 if (face > media.Count - 1) 114 if (null == media)
115 {
116 return null;
117 }
118 else
119 {
120 // TODO: Really need a proper copy constructor down in libopenmetaverse
121 return MediaEntry.FromOSD(media[face].GetOSD());
122 }
123 }
124
125 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
126 {
127 if (face < 0)
128 throw new ArgumentException("Face cannot be less than zero");
129
130 int maxFaces = part.GetNumberOfSides() - 1;
131 if (face > maxFaces)
110 throw new ArgumentException( 132 throw new ArgumentException(
111 string.Format("Face argument was {0} but max is {1}", face, media.Count - 1)); 133 string.Format("Face argument was {0} but max is {1}", face, maxFaces));
112 134
113 // TODO: Really need a proper copy constructor down in libopenmetaverse 135 if (null == part.Shape.Media)
114 return MediaEntry.FromOSD(media[face].GetOSD()); 136 part.Shape.Media = new List<MediaEntry>(maxFaces);
137
138 part.Shape.Media[face] = me;
139
140 if (null == part.MediaUrl)
141 {
142 // TODO: We can't set the last changer until we start tracking which cap we give to which agent id
143 part.MediaUrl = "x-mv:0000000000/" + UUID.Zero;
144 }
145 else
146 {
147 string rawVersion = part.MediaUrl.Substring(5, 10);
148 int version = int.Parse(rawVersion);
149 part.MediaUrl = string.Format("x-mv:{0:D10}/{1}", ++version, UUID.Zero);
150 }
151
152 part.ScheduleFullUpdate();
115 } 153 }
116 154
117 /// <summary> 155 /// <summary>
@@ -140,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
140 throw new Exception( 178 throw new Exception(
141 string.Format( 179 string.Format(
142 "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}", 180 "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
143 omm.Request.GetType())); 181 omm.Request.GetType()));
144 } 182 }
145 183
146 /// <summary> 184 /// <summary>
@@ -233,7 +271,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
233 271
234 m_log.DebugFormat("[MOAP]: Storing media url [{0}] in prim {1} {2}", part.MediaUrl, part.Name, part.UUID); 272 m_log.DebugFormat("[MOAP]: Storing media url [{0}] in prim {1} {2}", part.MediaUrl, part.Name, part.UUID);
235 273
236 // Arguably we don't need to send a full update to the avatar that just changed the texture. 274 // Arguably, we could avoid sending a full update to the avatar that just changed the texture.
237 part.ScheduleFullUpdate(); 275 part.ScheduleFullUpdate();
238 276
239 return string.Empty; 277 return string.Empty;
diff --git a/OpenSim/Region/Framework/Interfaces/IMoapModule.cs b/OpenSim/Region/Framework/Interfaces/IMoapModule.cs
index 4447f34..31bb6d8 100644
--- a/OpenSim/Region/Framework/Interfaces/IMoapModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IMoapModule.cs
@@ -39,9 +39,19 @@ namespace OpenSim.Region.Framework.Interfaces
39 /// <summary> 39 /// <summary>
40 /// Get the media entry for a given prim face. 40 /// Get the media entry for a given prim face.
41 /// </summary> 41 /// </summary>
42 /// A copy of the media entry is returned rather than the original, so this can be altered at will without
43 /// affecting the original settings.
42 /// <param name="part"></param> 44 /// <param name="part"></param>
43 /// <param name="face"></param> 45 /// <param name="face"></param>
44 /// <returns></returns> 46 /// <returns></returns>
45 MediaEntry GetMediaEntry(SceneObjectPart part, int face); 47 MediaEntry GetMediaEntry(SceneObjectPart part, int face);
46 } 48
49 /// <summary>
50 /// Set the media entry for a given prim face.
51 /// </summary>
52 /// <param name="SceneObjectPart"></param>
53 /// <param name="face"></param>
54 /// <param name="me"></param>
55 void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me);
56 }
47} \ No newline at end of file 57} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 1e5133b..8830fb0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -975,8 +975,9 @@ namespace OpenSim.Region.Framework.Scenes
975 } 975 }
976 976
977 /// <summary> 977 /// <summary>
978 /// Used for media on a prim 978 /// Used for media on a prim.
979 /// </summary> 979 /// </summary>
980 /// Do not change this value directly - always do it through an IMoapModule.
980 public string MediaUrl 981 public string MediaUrl
981 { 982 {
982 get 983 get
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9290fc3..2600790 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
7816 // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid 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). 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. 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) 7819 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
7820 return new LSL_List(); 7820 return new LSL_List();
7821 7821
7822 return GetLinkPrimMediaParams(face, rules); 7822 return GetLinkPrimMediaParams(face, rules);
@@ -7830,6 +7830,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7830 7830
7831 MediaEntry me = module.GetMediaEntry(m_host, face); 7831 MediaEntry me = module.GetMediaEntry(m_host, face);
7832 7832
7833 // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
7834 if (null == me)
7835 return new LSL_List();
7836
7833 LSL_List res = new LSL_List(); 7837 LSL_List res = new LSL_List();
7834 7838
7835 for (int i = 0; i < rules.Length; i++) 7839 for (int i = 0; i < rules.Length; i++)
@@ -7912,6 +7916,113 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7912 return res; 7916 return res;
7913 } 7917 }
7914 7918
7919 public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
7920 {
7921 m_host.AddScriptLPS(1);
7922 ScriptSleep(1000);
7923
7924 // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
7925 // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
7926 // Don't perform the media check directly
7927 if (face < 0 || face > m_host.GetNumberOfSides() - 1)
7928 return ScriptBaseClass.LSL_STATUS_OK;
7929
7930 return SetPrimMediaParams(face, rules);
7931 }
7932
7933 public LSL_Integer SetPrimMediaParams(int face, LSL_List rules)
7934 {
7935 IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
7936 if (null == module)
7937 throw new Exception("Media on a prim functions not available");
7938
7939 MediaEntry me = module.GetMediaEntry(m_host, face);
7940 if (null == me)
7941 me = new MediaEntry();
7942
7943 int i = 0;
7944
7945 while (i < rules.Length - 1)
7946 {
7947 int code = rules.GetLSLIntegerItem(i++);
7948
7949 switch (code)
7950 {
7951 case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
7952 me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false);
7953 break;
7954
7955 case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
7956 int v = rules.GetLSLIntegerItem(i++);
7957 if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v)
7958 me.Controls = MediaControls.Standard;
7959 else
7960 me.Controls = MediaControls.Mini;
7961 break;
7962
7963 case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
7964 me.CurrentURL = rules.GetLSLStringItem(i++);
7965 break;
7966
7967 case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
7968 me.HomeURL = rules.GetLSLStringItem(i++);
7969 break;
7970
7971 case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
7972 me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
7973 break;
7974
7975 case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
7976 me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
7977 break;
7978
7979 case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
7980 me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
7981 break;
7982
7983 case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
7984 me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
7985 break;
7986
7987 case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
7988 me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
7989 break;
7990
7991 case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
7992 me.Width = (int)rules.GetLSLIntegerItem(i++);
7993 break;
7994
7995 case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
7996 me.Height = (int)rules.GetLSLIntegerItem(i++);
7997 break;
7998
7999 case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
8000 me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false);
8001 break;
8002
8003 case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
8004 string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' });
8005 List<string> whiteListUrls = new List<string>();
8006 Array.ForEach(
8007 rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); });
8008 me.WhiteList = whiteListUrls.ToArray();
8009 break;
8010
8011 case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
8012 me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8013 break;
8014
8015 case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
8016 me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
8017 break;
8018 }
8019 }
8020
8021 module.SetMediaEntry(m_host, face, me);
8022
8023 return ScriptBaseClass.LSL_STATUS_OK;
8024 }
8025
7915 // <remarks> 8026 // <remarks>
7916 // <para> 8027 // <para>
7917 // The .NET definition of base 64 is: 8028 // 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 9a64f8c..6ef786a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -518,7 +518,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
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 520
521 // constants for llGetPrimMediaParams 521 // constants for llGetPrimMediaParams/llSetPrimMediaParams
522 public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0; 522 public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0;
523 public const int PRIM_MEDIA_CONTROLS = 1; 523 public const int PRIM_MEDIA_CONTROLS = 1;
524 public const int PRIM_MEDIA_CURRENT_URL = 2; 524 public const int PRIM_MEDIA_CURRENT_URL = 2;
@@ -542,6 +542,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
542 public const int PRIM_MEDIA_PERM_OWNER = 1; 542 public const int PRIM_MEDIA_PERM_OWNER = 1;
543 public const int PRIM_MEDIA_PERM_GROUP = 2; 543 public const int PRIM_MEDIA_PERM_GROUP = 2;
544 public const int PRIM_MEDIA_PERM_ANYONE = 4; 544 public const int PRIM_MEDIA_PERM_ANYONE = 4;
545
546 // extra constants for llSetPrimMediaParams
547 public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0);
548 public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000);
549 public static readonly LSLInteger LSL_STATUS_TYPE_MISMATCH = new LSLInteger(1001);
550 public static readonly LSLInteger LSL_STATUS_BOUNDS_ERROR = new LSLInteger(1002);
551 public static readonly LSLInteger LSL_STATUS_NOT_FOUND = new LSLInteger(1003);
552 public static readonly LSLInteger LSL_STATUS_NOT_SUPPORTED = new LSLInteger(1004);
553 public static readonly LSLInteger LSL_STATUS_INTERNAL_ERROR = new LSLInteger(1999);
554 public static readonly LSLInteger LSL_STATUS_WHITELIST_FAILED = new LSLInteger(2001);
545 555
546 // Constants for default textures 556 // Constants for default textures
547 public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; 557 public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f";