From 53ddcf6d25b5ff85847f3762b15f22d1dd2f49a5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Jul 2010 22:52:31 +0100 Subject: Implement media texture persistence over server restarts for sqlite This is currently persisting media as an OSDArray serialized to LLSD XML. --- OpenSim/Data/SQLite/SQLiteRegionData.cs | 36 +++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/SQLite/SQLiteRegionData.cs') diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 81d0ac4..fc9667b 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -34,6 +34,7 @@ using System.Reflection; using log4net; using Mono.Data.Sqlite; using OpenMetaverse; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -974,6 +975,8 @@ namespace OpenSim.Data.SQLite createCol(prims, "CollisionSoundVolume", typeof(Double)); createCol(prims, "VolumeDetect", typeof(Int16)); + + createCol(prims, "MediaURL", typeof(String)); // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -1021,6 +1024,7 @@ namespace OpenSim.Data.SQLite // way to specify this as a blob atm createCol(shapes, "Texture", typeof (Byte[])); createCol(shapes, "ExtraParams", typeof (Byte[])); + createCol(shapes, "Media", typeof(String)); shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; @@ -1339,6 +1343,12 @@ namespace OpenSim.Data.SQLite if (Convert.ToInt16(row["VolumeDetect"]) != 0) prim.VolumeDetectActive = true; + + if (!(row["MediaURL"] is System.DBNull)) + { + m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType()); + prim.MediaUrl = (string)row["MediaURL"]; + } return prim; } @@ -1614,7 +1624,6 @@ namespace OpenSim.Data.SQLite row["PayButton3"] = prim.PayPrice[3]; row["PayButton4"] = prim.PayPrice[4]; - row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); @@ -1674,7 +1683,8 @@ namespace OpenSim.Data.SQLite row["VolumeDetect"] = 1; else row["VolumeDetect"] = 0; - + + row["MediaURL"] = prim.MediaUrl; } /// @@ -1849,6 +1859,19 @@ namespace OpenSim.Data.SQLite s.TextureEntry = textureEntry; s.ExtraParams = (byte[]) row["ExtraParams"]; + + if (!(row["Media"] is System.DBNull)) + { + string rawMeArray = (string)row["Media"]; + OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(rawMeArray); + + List mediaEntries = new List(); + foreach (OSD osdMe in osdMeArray) + mediaEntries.Add(MediaEntry.FromOSD(osdMe)); + + s.Media = mediaEntries; + } + return s; } @@ -1892,17 +1915,22 @@ namespace OpenSim.Data.SQLite row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; + + OSDArray meArray = new OSDArray(); + foreach (MediaEntry me in s.Media) + meArray.Add(me.GetOSD()); + + row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); } /// - /// + /// Persistently store a prim. /// /// /// /// private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) { - DataTable prims = ds.Tables["prims"]; DataTable shapes = ds.Tables["primshapes"]; -- cgit v1.1