Put a wrapper around the media texture region serialization

THIS WILL BREAK EXISTING MEDIA TEXTURE PERSISTENCE.  Please delete your existing sqlite databases if you are experimenting with this branch.
This wrapper will make it easier to maintain compatibility if the media texture data evolves.
This will also make it easier to store non-sl media texture data.
prebuild-update
Justin Clark-Casey (justincc) 2010-07-26 19:56:55 +01:00
parent 8e8076c947
commit 4736e38e79
1 changed files with 43 additions and 15 deletions

View File

@ -31,6 +31,7 @@ using System.Data;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Xml;
using log4net; using log4net;
using Mono.Data.Sqlite; using Mono.Data.Sqlite;
using OpenMetaverse; using OpenMetaverse;
@ -1862,8 +1863,13 @@ namespace OpenSim.Data.SQLite
if (!(row["Media"] is System.DBNull)) if (!(row["Media"] is System.DBNull))
{ {
string rawMeArray = (string)row["Media"]; using (StringReader sr = new StringReader((string)row["Media"]))
OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(rawMeArray); {
using (XmlTextReader xtr = new XmlTextReader(sr))
{
xtr.ReadStartElement("osmedia");
OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
List<MediaEntry> mediaEntries = new List<MediaEntry>(); List<MediaEntry> mediaEntries = new List<MediaEntry>();
foreach (OSD osdMe in osdMeArray) foreach (OSD osdMe in osdMeArray)
@ -1873,6 +1879,10 @@ namespace OpenSim.Data.SQLite
} }
s.Media = mediaEntries; s.Media = mediaEntries;
xtr.ReadEndElement();
}
}
} }
return s; return s;
@ -1921,6 +1931,15 @@ namespace OpenSim.Data.SQLite
if (null != s.Media) if (null != s.Media)
{ {
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter xtw = new XmlTextWriter(sw))
{
xtw.WriteStartElement("osmedia");
xtw.WriteAttributeString("type", "sl");
xtw.WriteAttributeString("major_version", "0");
xtw.WriteAttributeString("minor_version", "1");
OSDArray meArray = new OSDArray(); OSDArray meArray = new OSDArray();
foreach (MediaEntry me in s.Media) foreach (MediaEntry me in s.Media)
{ {
@ -1928,7 +1947,16 @@ namespace OpenSim.Data.SQLite
meArray.Add(osd); meArray.Add(osd);
} }
row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); xtw.WriteStartElement("osdata");
xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.Flush();
row["Media"] = sw.ToString();
}
}
} }
} }