aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-07-26 21:09:54 +0100
committerJustin Clark-Casey (justincc)2010-07-26 23:34:23 +0100
commit412fed975fc0b28c3af111be89a1bcb4aaa05a9b (patch)
tree77020a8befe28229fb8afa75e65ac4c8c6572e4d /OpenSim/Data/SQLite/SQLiteRegionData.cs
parentAdd EventManager.OnSceneObjectPreSave() for future use. This is triggered im... (diff)
downloadopensim-SC_OLD-412fed975fc0b28c3af111be89a1bcb4aaa05a9b.zip
opensim-SC_OLD-412fed975fc0b28c3af111be89a1bcb4aaa05a9b.tar.gz
opensim-SC_OLD-412fed975fc0b28c3af111be89a1bcb4aaa05a9b.tar.bz2
opensim-SC_OLD-412fed975fc0b28c3af111be89a1bcb4aaa05a9b.tar.xz
relocate serialization code from SQLiteRegionData to MoapModule using load and save events.
This is better modularity. It also allows MoapModule to be replaced with some other media module that may behave completely differently in the future. Remaining non-modularity: PrimitiveBaseShape needs explicit Media and MediaRaw fields. MediaRaw is required in order to shuttle the pre-serialization data back and forth from the database layer. The database also needs to know about MediaRaw though not about Media. IMO, it would be extremely nice to remove these hard codings but this is a bridge too far at the present time.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs55
1 files changed, 2 insertions, 53 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index b564419..f63d35e 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -31,7 +31,6 @@ using System.Data;
31using System.Drawing; 31using System.Drawing;
32using System.IO; 32using System.IO;
33using System.Reflection; 33using System.Reflection;
34using System.Xml;
35using log4net; 34using log4net;
36using Mono.Data.Sqlite; 35using Mono.Data.Sqlite;
37using OpenMetaverse; 36using OpenMetaverse;
@@ -1862,28 +1861,7 @@ namespace OpenSim.Data.SQLite
1862 s.ExtraParams = (byte[]) row["ExtraParams"]; 1861 s.ExtraParams = (byte[]) row["ExtraParams"];
1863 1862
1864 if (!(row["Media"] is System.DBNull)) 1863 if (!(row["Media"] is System.DBNull))
1865 { 1864 s.MediaRaw = (string)row["Media"];
1866 using (StringReader sr = new StringReader((string)row["Media"]))
1867 {
1868 using (XmlTextReader xtr = new XmlTextReader(sr))
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 }
1885 }
1886 }
1887 1865
1888 return s; 1866 return s;
1889 } 1867 }
@@ -1928,36 +1906,7 @@ namespace OpenSim.Data.SQLite
1928 1906
1929 row["Texture"] = s.TextureEntry; 1907 row["Texture"] = s.TextureEntry;
1930 row["ExtraParams"] = s.ExtraParams; 1908 row["ExtraParams"] = s.ExtraParams;
1931 1909 row["Media"] = s.MediaRaw;
1932 if (null != s.Media)
1933 {
1934 using (StringWriter sw = new StringWriter())
1935 {
1936 using (XmlTextWriter xtw = new XmlTextWriter(sw))
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 }
1959 }
1960 }
1961 } 1910 }
1962 1911
1963 /// <summary> 1912 /// <summary>