diff options
author | Justin Clark-Casey (justincc) | 2010-07-26 19:56:55 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-26 23:34:22 +0100 |
commit | afdbeba4e46f631b320b75bd304197959e650c2e (patch) | |
tree | 75dd9e2e7b4ea193ca7335486e0f7dc7b1bb9ff7 /OpenSim/Data/SQLite/SQLiteRegionData.cs | |
parent | also add avatar id to an updated media url - not just new ones (diff) | |
download | opensim-SC_OLD-afdbeba4e46f631b320b75bd304197959e650c2e.zip opensim-SC_OLD-afdbeba4e46f631b320b75bd304197959e650c2e.tar.gz opensim-SC_OLD-afdbeba4e46f631b320b75bd304197959e650c2e.tar.bz2 opensim-SC_OLD-afdbeba4e46f631b320b75bd304197959e650c2e.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteRegionData.cs | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 7acbd22..b564419 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs | |||
@@ -31,6 +31,7 @@ using System.Data; | |||
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Xml; | ||
34 | using log4net; | 35 | using log4net; |
35 | using Mono.Data.Sqlite; | 36 | using Mono.Data.Sqlite; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
@@ -1862,17 +1863,26 @@ namespace OpenSim.Data.SQLite | |||
1862 | 1863 | ||
1863 | if (!(row["Media"] is System.DBNull)) | 1864 | if (!(row["Media"] is System.DBNull)) |
1864 | { | 1865 | { |
1865 | string rawMeArray = (string)row["Media"]; | 1866 | using (StringReader sr = new StringReader((string)row["Media"])) |
1866 | OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(rawMeArray); | ||
1867 | |||
1868 | List<MediaEntry> mediaEntries = new List<MediaEntry>(); | ||
1869 | foreach (OSD osdMe in osdMeArray) | ||
1870 | { | 1867 | { |
1871 | MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); | 1868 | using (XmlTextReader xtr = new XmlTextReader(sr)) |
1872 | mediaEntries.Add(me); | 1869 | { |
1870 | xtr.ReadStartElement("osmedia"); | ||
1871 | |||
1872 | OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); | ||
1873 | |||
1874 | List<MediaEntry> mediaEntries = new List<MediaEntry>(); | ||
1875 | foreach (OSD osdMe in osdMeArray) | ||
1876 | { | ||
1877 | MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); | ||
1878 | mediaEntries.Add(me); | ||
1879 | } | ||
1880 | |||
1881 | s.Media = mediaEntries; | ||
1882 | |||
1883 | xtr.ReadEndElement(); | ||
1884 | } | ||
1873 | } | 1885 | } |
1874 | |||
1875 | s.Media = mediaEntries; | ||
1876 | } | 1886 | } |
1877 | 1887 | ||
1878 | return s; | 1888 | return s; |
@@ -1921,14 +1931,32 @@ namespace OpenSim.Data.SQLite | |||
1921 | 1931 | ||
1922 | if (null != s.Media) | 1932 | if (null != s.Media) |
1923 | { | 1933 | { |
1924 | OSDArray meArray = new OSDArray(); | 1934 | using (StringWriter sw = new StringWriter()) |
1925 | foreach (MediaEntry me in s.Media) | ||
1926 | { | 1935 | { |
1927 | OSD osd = (null == me ? new OSD() : me.GetOSD()); | 1936 | using (XmlTextWriter xtw = new XmlTextWriter(sw)) |
1928 | meArray.Add(osd); | 1937 | { |
1938 | xtw.WriteStartElement("osmedia"); | ||
1939 | xtw.WriteAttributeString("type", "sl"); | ||
1940 | xtw.WriteAttributeString("major_version", "0"); | ||
1941 | xtw.WriteAttributeString("minor_version", "1"); | ||
1942 | |||
1943 | OSDArray meArray = new OSDArray(); | ||
1944 | foreach (MediaEntry me in s.Media) | ||
1945 | { | ||
1946 | OSD osd = (null == me ? new OSD() : me.GetOSD()); | ||
1947 | meArray.Add(osd); | ||
1948 | } | ||
1949 | |||
1950 | xtw.WriteStartElement("osdata"); | ||
1951 | xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); | ||
1952 | xtw.WriteEndElement(); | ||
1953 | |||
1954 | xtw.WriteEndElement(); | ||
1955 | |||
1956 | xtw.Flush(); | ||
1957 | row["Media"] = sw.ToString(); | ||
1958 | } | ||
1929 | } | 1959 | } |
1930 | |||
1931 | row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); | ||
1932 | } | 1960 | } |
1933 | } | 1961 | } |
1934 | 1962 | ||