aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-03 15:45:49 +0100
committerJustin Clark-Casey (justincc)2010-08-03 15:45:49 +0100
commit60df76314f89d8a489a7f8a3182277cf1a52925c (patch)
treec3916df4de15bb15b7f3ce04532b742c9bce3aaa
parentadd userExposed parameter to part copy event (diff)
downloadopensim-SC_OLD-60df76314f89d8a489a7f8a3182277cf1a52925c.zip
opensim-SC_OLD-60df76314f89d8a489a7f8a3182277cf1a52925c.tar.gz
opensim-SC_OLD-60df76314f89d8a489a7f8a3182277cf1a52925c.tar.bz2
opensim-SC_OLD-60df76314f89d8a489a7f8a3182277cf1a52925c.tar.xz
serialize media textures to inventory with a largely osd representation rather than .net auto-serialization
THIS WILL BREAK ANY EXISTING MEDIA TEXTURE SERIALIZATIONS. If you're testing this, please start with new databases. This makes media textures serialized in the same way, which is probably better in the long term.
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs90
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs8
2 files changed, 91 insertions, 7 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 03ddb33..de7e42d 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -29,7 +29,10 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.Drawing.Imaging; 31using System.Drawing.Imaging;
32using System.IO;
32using System.Reflection; 33using System.Reflection;
34using System.Xml;
35using System.Xml.Schema;
33using System.Xml.Serialization; 36using System.Xml.Serialization;
34using log4net; 37using log4net;
35using OpenMetaverse; 38using OpenMetaverse;
@@ -183,7 +186,7 @@ namespace OpenSim.Framework
183 /// Entries to store media textures on each face 186 /// Entries to store media textures on each face
184 /// </summary> 187 /// </summary>
185 /// Do not change this value directly - always do it through an IMoapModule. 188 /// Do not change this value directly - always do it through an IMoapModule.
186 public List<MediaEntry> Media { get; set; } 189 public MediaList Media { get; set; }
187 190
188 public PrimitiveBaseShape() 191 public PrimitiveBaseShape()
189 { 192 {
@@ -1221,5 +1224,86 @@ namespace OpenSim.Framework
1221 1224
1222 return prim; 1225 return prim;
1223 } 1226 }
1224 } 1227
1225} 1228 public class MediaList : List<MediaEntry>, IXmlSerializable
1229 {
1230 public const string MEDIA_TEXTURE_TYPE = "sl";
1231
1232 public MediaList() : base() {}
1233 public MediaList(IEnumerable<MediaEntry> collection) : base(collection) {}
1234 public MediaList(int capacity) : base(capacity) {}
1235
1236 public XmlSchema GetSchema()
1237 {
1238 return null;
1239 }
1240
1241 public void WriteXml(XmlWriter writer)
1242 {
1243 lock (this)
1244 {
1245 using (StringWriter sw = new StringWriter())
1246 {
1247 using (XmlTextWriter xtw = new XmlTextWriter(sw))
1248 {
1249 xtw.WriteStartElement("osmedia");
1250 xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE);
1251 xtw.WriteAttributeString("major_version", "0");
1252 xtw.WriteAttributeString("minor_version", "1");
1253
1254 OSDArray meArray = new OSDArray();
1255 foreach (MediaEntry me in this)
1256 {
1257 OSD osd = (null == me ? new OSD() : me.GetOSD());
1258 meArray.Add(osd);
1259 }
1260
1261 xtw.WriteStartElement("osdata");
1262 xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
1263 xtw.WriteEndElement();
1264
1265 xtw.WriteEndElement();
1266
1267 xtw.Flush();
1268 writer.WriteRaw(sw.ToString());
1269 }
1270 }
1271 }
1272 }
1273
1274 public void ReadXml(XmlReader reader)
1275 {
1276 if (reader.IsEmptyElement)
1277 return;
1278
1279 string rawXml = reader.ReadInnerXml();
1280 using (StringReader sr = new StringReader(rawXml))
1281 {
1282 using (XmlTextReader xtr = new XmlTextReader(sr))
1283 {
1284 xtr.MoveToContent();
1285
1286 string type = xtr.GetAttribute("type");
1287 //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
1288
1289 if (type != MEDIA_TEXTURE_TYPE)
1290 return;
1291
1292 xtr.ReadStartElement("osmedia");
1293
1294 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
1295
1296 List<MediaEntry> mediaEntries = new List<MediaEntry>();
1297 foreach (OSD osdMe in osdMeArray)
1298 {
1299 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
1300 Add(me);
1301 }
1302
1303 xtr.ReadEndElement();
1304 }
1305 }
1306 }
1307 }
1308 }
1309} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index e9d723b..339a979 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -219,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
219 219
220 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); 220 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
221 221
222 List<MediaEntry> mediaEntries = new List<MediaEntry>(); 222 PrimitiveBaseShape.MediaList mediaEntries = new PrimitiveBaseShape.MediaList();
223 foreach (OSD osdMe in osdMeArray) 223 foreach (OSD osdMe in osdMeArray)
224 { 224 {
225 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); 225 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
@@ -270,7 +270,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
270 { 270 {
271 if (original.Shape.Media != null) 271 if (original.Shape.Media != null)
272 { 272 {
273 List<MediaEntry> dupeMedia = new List<MediaEntry>(); 273 PrimitiveBaseShape.MediaList dupeMedia = new PrimitiveBaseShape.MediaList();
274 274
275 foreach (MediaEntry me in original.Shape.Media) 275 foreach (MediaEntry me in original.Shape.Media)
276 { 276 {
@@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
315 CheckFaceParam(part, face); 315 CheckFaceParam(part, face);
316 316
317 if (null == part.Shape.Media) 317 if (null == part.Shape.Media)
318 part.Shape.Media = new List<MediaEntry>(new MediaEntry[part.GetNumberOfSides()]); 318 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
319 319
320 part.Shape.Media[face] = me; 320 part.Shape.Media[face] = me;
321 UpdateMediaUrl(part, UUID.Zero); 321 UpdateMediaUrl(part, UUID.Zero);
@@ -439,7 +439,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
439 if (null == media) 439 if (null == media)
440 { 440 {
441// m_log.DebugFormat("[MOAP]: Setting all new media list for {0}", part.Name); 441// m_log.DebugFormat("[MOAP]: Setting all new media list for {0}", part.Name);
442 part.Shape.Media = new List<MediaEntry>(omu.FaceMedia); 442 part.Shape.Media = new PrimitiveBaseShape.MediaList(omu.FaceMedia);
443 443
444 for (int i = 0; i < omu.FaceMedia.Length; i++) 444 for (int i = 0; i < omu.FaceMedia.Length; i++)
445 { 445 {