aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-03 17:09:20 +0100
committerJustin Clark-Casey (justincc)2010-08-03 17:09:20 +0100
commit99c0f4c9c7820f6340155f7af30ab91745774c93 (patch)
treed59a9f8986b41bb7d60928b9675a6e3b14cb07b9 /OpenSim
parentget rid of PrimitiveBaseShape.MediaRaw staging post (diff)
downloadopensim-SC-99c0f4c9c7820f6340155f7af30ab91745774c93.zip
opensim-SC-99c0f4c9c7820f6340155f7af30ab91745774c93.tar.gz
opensim-SC-99c0f4c9c7820f6340155f7af30ab91745774c93.tar.bz2
opensim-SC-99c0f4c9c7820f6340155f7af30ab91745774c93.tar.xz
Simplify serialized version string. Change element capitalization for consistency
THIS CHANGE ALTERS THE SERIALIZATION FORMAT, HOPEFULLY FOR THE LAST TIME. If you're testing, please start with a new database. This commit also improves locking for manipulation of media entries.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs76
2 files changed, 55 insertions, 36 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 9b52fe6..70a61cc 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -180,6 +180,7 @@ namespace OpenSim.Framework
180 /// Entries to store media textures on each face 180 /// Entries to store media textures on each face
181 /// </summary> 181 /// </summary>
182 /// Do not change this value directly - always do it through an IMoapModule. 182 /// Do not change this value directly - always do it through an IMoapModule.
183 /// Lock before manipulating.
183 public MediaList Media { get; set; } 184 public MediaList Media { get; set; }
184 185
185 public PrimitiveBaseShape() 186 public PrimitiveBaseShape()
@@ -1219,6 +1220,11 @@ namespace OpenSim.Framework
1219 return prim; 1220 return prim;
1220 } 1221 }
1221 1222
1223 /// <summary>
1224 /// Encapsulates a list of media entries.
1225 /// </summary>
1226 /// This class is necessary because we want to replace auto-serialization of MediaEntry with something more
1227 /// OSD like and less vulnerable to change.
1222 public class MediaList : List<MediaEntry>, IXmlSerializable 1228 public class MediaList : List<MediaEntry>, IXmlSerializable
1223 { 1229 {
1224 public const string MEDIA_TEXTURE_TYPE = "sl"; 1230 public const string MEDIA_TEXTURE_TYPE = "sl";
@@ -1240,10 +1246,9 @@ namespace OpenSim.Framework
1240 { 1246 {
1241 using (XmlTextWriter xtw = new XmlTextWriter(sw)) 1247 using (XmlTextWriter xtw = new XmlTextWriter(sw))
1242 { 1248 {
1243 xtw.WriteStartElement("osmedia"); 1249 xtw.WriteStartElement("OSMedia");
1244 xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE); 1250 xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE);
1245 xtw.WriteAttributeString("major_version", "0"); 1251 xtw.WriteAttributeString("version", "0.1");
1246 xtw.WriteAttributeString("minor_version", "1");
1247 1252
1248 OSDArray meArray = new OSDArray(); 1253 OSDArray meArray = new OSDArray();
1249 foreach (MediaEntry me in this) 1254 foreach (MediaEntry me in this)
@@ -1252,7 +1257,7 @@ namespace OpenSim.Framework
1252 meArray.Add(osd); 1257 meArray.Add(osd);
1253 } 1258 }
1254 1259
1255 xtw.WriteStartElement("osdata"); 1260 xtw.WriteStartElement("OSData");
1256 xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); 1261 xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
1257 xtw.WriteEndElement(); 1262 xtw.WriteEndElement();
1258 1263
@@ -1291,7 +1296,7 @@ namespace OpenSim.Framework
1291 if (type != MEDIA_TEXTURE_TYPE) 1296 if (type != MEDIA_TEXTURE_TYPE)
1292 return; 1297 return;
1293 1298
1294 xtr.ReadStartElement("osmedia"); 1299 xtr.ReadStartElement("OSMedia");
1295 1300
1296 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); 1301 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
1297 foreach (OSD osdMe in osdMeArray) 1302 foreach (OSD osdMe in osdMeArray)
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index d7ce184..8549b36 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -185,13 +185,15 @@ namespace OpenSim.Region.CoreModules.Media.Moap
185 if (original.Shape.Media != null) 185 if (original.Shape.Media != null)
186 { 186 {
187 PrimitiveBaseShape.MediaList dupeMedia = new PrimitiveBaseShape.MediaList(); 187 PrimitiveBaseShape.MediaList dupeMedia = new PrimitiveBaseShape.MediaList();
188 188 lock (original.Shape.Media)
189 foreach (MediaEntry me in original.Shape.Media)
190 { 189 {
191 if (me != null) 190 foreach (MediaEntry me in original.Shape.Media)
192 dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); 191 {
193 else 192 if (me != null)
194 dupeMedia.Add(null); 193 dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD()));
194 else
195 dupeMedia.Add(null);
196 }
195 } 197 }
196 198
197 copy.Shape.Media = dupeMedia; 199 copy.Shape.Media = dupeMedia;
@@ -211,8 +213,9 @@ namespace OpenSim.Region.CoreModules.Media.Moap
211 me = null; 213 me = null;
212 } 214 }
213 else 215 else
214 { 216 {
215 me = media[face]; 217 lock (media)
218 me = media[face];
216 219
217 // TODO: Really need a proper copy constructor down in libopenmetaverse 220 // TODO: Really need a proper copy constructor down in libopenmetaverse
218 if (me != null) 221 if (me != null)
@@ -230,11 +233,13 @@ namespace OpenSim.Region.CoreModules.Media.Moap
230 233
231 if (null == part.Shape.Media) 234 if (null == part.Shape.Media)
232 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); 235 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
233 236
234 part.Shape.Media[face] = me; 237 lock (part.Shape.Media)
238 part.Shape.Media[face] = me;
239
235 UpdateMediaUrl(part, UUID.Zero); 240 UpdateMediaUrl(part, UUID.Zero);
236 part.ScheduleFullUpdate(); 241 part.ScheduleFullUpdate();
237 part.TriggerScriptChangedEvent(Changed.MEDIA); 242 part.TriggerScriptChangedEvent(Changed.MEDIA);
238 } 243 }
239 244
240 public void ClearMediaEntry(SceneObjectPart part, int face) 245 public void ClearMediaEntry(SceneObjectPart part, int face)
@@ -296,7 +301,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap
296 ObjectMediaResponse resp = new ObjectMediaResponse(); 301 ObjectMediaResponse resp = new ObjectMediaResponse();
297 302
298 resp.PrimID = primId; 303 resp.PrimID = primId;
299 resp.FaceMedia = part.Shape.Media.ToArray(); 304
305 lock (part.Shape.Media)
306 resp.FaceMedia = part.Shape.Media.ToArray();
307
300 resp.Version = part.MediaUrl; 308 resp.Version = part.MediaUrl;
301 309
302 string rawResp = OSDParser.SerializeLLSDXmlString(resp.Serialize()); 310 string rawResp = OSDParser.SerializeLLSDXmlString(resp.Serialize());
@@ -382,24 +390,27 @@ namespace OpenSim.Region.CoreModules.Media.Moap
382 // directly. 390 // directly.
383 Primitive.TextureEntry te = part.Shape.Textures; 391 Primitive.TextureEntry te = part.Shape.Textures;
384 392
385 for (int i = 0; i < media.Count; i++) 393 lock (media)
386 { 394 {
387 if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i)) 395 for (int i = 0; i < media.Count; i++)
388 { 396 {
389 media[i] = omu.FaceMedia[i]; 397 if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i))
390 398 {
391 // When a face is cleared this is done by setting the MediaFlags in the TextureEntry via a normal 399 media[i] = omu.FaceMedia[i];
392 // texture update, so we don't need to worry about clearing MediaFlags here. 400
393 if (null == media[i]) 401 // When a face is cleared this is done by setting the MediaFlags in the TextureEntry via a normal
394 continue; 402 // texture update, so we don't need to worry about clearing MediaFlags here.
395 403 if (null == media[i])
396 Primitive.TextureEntryFace face = te.CreateFace((uint)i); 404 continue;
397 face.MediaFlags = true; 405
398 406 Primitive.TextureEntryFace face = te.CreateFace((uint)i);
399// m_log.DebugFormat( 407 face.MediaFlags = true;
400// "[MOAP]: Media flags for face {0} is {1}", 408
401// i, face.MediaFlags); 409 // m_log.DebugFormat(
402// m_log.DebugFormat("[MOAP]: Set media entry for face {0} on {1}", i, part.Name); 410 // "[MOAP]: Media flags for face {0} is {1}",
411 // i, face.MediaFlags);
412 // m_log.DebugFormat("[MOAP]: Set media entry for face {0} on {1}", i, part.Name);
413 }
403 } 414 }
404 } 415 }
405 416
@@ -465,7 +476,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap
465 if (null == part.Shape.Media) 476 if (null == part.Shape.Media)
466 return string.Empty; 477 return string.Empty;
467 478
468 MediaEntry me = part.Shape.Media[omn.Face]; 479 MediaEntry me = null;
480
481 lock (part.Shape.Media)
482 me = part.Shape.Media[omn.Face];
469 483
470 // Do the same if media has not been set up for a specific face 484 // Do the same if media has not been set up for a specific face
471 if (null == me) 485 if (null == me)