From 9682e0c73310dae496912d7b8bc54add0fd0c3e7 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') 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 From 43f480864bcca2990b809568eaed04bd27cecf60 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 21:33:27 +0100 Subject: fix problem persisting when only one face had a media texture --- OpenSim/Data/SQLite/SQLiteRegionData.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index fc9667b..51f4cef 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1867,7 +1867,10 @@ namespace OpenSim.Data.SQLite List mediaEntries = new List(); foreach (OSD osdMe in osdMeArray) - mediaEntries.Add(MediaEntry.FromOSD(osdMe)); + { + MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); + mediaEntries.Add(me); + } s.Media = mediaEntries; } @@ -1918,7 +1921,10 @@ namespace OpenSim.Data.SQLite OSDArray meArray = new OSDArray(); foreach (MediaEntry me in s.Media) - meArray.Add(me.GetOSD()); + { + OSD osd = (null == me ? new OSD() : me.GetOSD()); + meArray.Add(osd); + } row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); } -- cgit v1.1 From fc76ce0f466c7dfa2328c08e590c86460b068140 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 Jul 2010 23:48:24 +0100 Subject: fix bug where prim persistence would fail if media had never been set --- OpenSim/Data/SQLite/SQLiteRegionData.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 51f4cef..7acbd22 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1919,14 +1919,17 @@ namespace OpenSim.Data.SQLite row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; - OSDArray meArray = new OSDArray(); - foreach (MediaEntry me in s.Media) + if (null != s.Media) { - OSD osd = (null == me ? new OSD() : me.GetOSD()); - meArray.Add(osd); + OSDArray meArray = new OSDArray(); + foreach (MediaEntry me in s.Media) + { + OSD osd = (null == me ? new OSD() : me.GetOSD()); + meArray.Add(osd); + } + + row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); } - - row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); } /// -- cgit v1.1 From f872a2af116e5e9cdf80efd2313818200b204a04 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Jul 2010 23:28:36 +0100 Subject: add missing regionstore migration file for new fields. D'oh! this should enable persistence now --- OpenSim/Data/SQLite/Resources/020_RegionStore.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 OpenSim/Data/SQLite/Resources/020_RegionStore.sql (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/SQLite/Resources/020_RegionStore.sql b/OpenSim/Data/SQLite/Resources/020_RegionStore.sql new file mode 100644 index 0000000..39cb752 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/020_RegionStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE prims ADD COLUMN MediaURL varchar(255); +ALTER TABLE primshapes ADD COLUMN Media TEXT; + +COMMIT; \ No newline at end of file -- cgit v1.1 From afdbeba4e46f631b320b75bd304197959e650c2e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 19:56:55 +0100 Subject: 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. --- OpenSim/Data/SQLite/SQLiteRegionData.cs | 58 ++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data') 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; using System.Drawing; using System.IO; using System.Reflection; +using System.Xml; using log4net; using Mono.Data.Sqlite; using OpenMetaverse; @@ -1862,17 +1863,26 @@ namespace OpenSim.Data.SQLite 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) + using (StringReader sr = new StringReader((string)row["Media"])) { - MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); - mediaEntries.Add(me); + using (XmlTextReader xtr = new XmlTextReader(sr)) + { + xtr.ReadStartElement("osmedia"); + + OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); + + List mediaEntries = new List(); + foreach (OSD osdMe in osdMeArray) + { + MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); + mediaEntries.Add(me); + } + + s.Media = mediaEntries; + + xtr.ReadEndElement(); + } } - - s.Media = mediaEntries; } return s; @@ -1921,14 +1931,32 @@ namespace OpenSim.Data.SQLite if (null != s.Media) { - OSDArray meArray = new OSDArray(); - foreach (MediaEntry me in s.Media) + using (StringWriter sw = new StringWriter()) { - OSD osd = (null == me ? new OSD() : me.GetOSD()); - meArray.Add(osd); + 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(); + foreach (MediaEntry me in s.Media) + { + OSD osd = (null == me ? new OSD() : me.GetOSD()); + meArray.Add(osd); + } + + xtw.WriteStartElement("osdata"); + xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); + xtw.WriteEndElement(); + + xtw.WriteEndElement(); + + xtw.Flush(); + row["Media"] = sw.ToString(); + } } - - row["Media"] = OSDParser.SerializeLLSDXmlString(meArray); } } -- cgit v1.1 From 412fed975fc0b28c3af111be89a1bcb4aaa05a9b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 21:09:54 +0100 Subject: 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. --- OpenSim/Data/SQLite/SQLiteRegionData.cs | 55 ++------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) (limited to 'OpenSim/Data') 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; using System.Drawing; using System.IO; using System.Reflection; -using System.Xml; using log4net; using Mono.Data.Sqlite; using OpenMetaverse; @@ -1862,28 +1861,7 @@ namespace OpenSim.Data.SQLite s.ExtraParams = (byte[]) row["ExtraParams"]; if (!(row["Media"] is System.DBNull)) - { - using (StringReader sr = new StringReader((string)row["Media"])) - { - using (XmlTextReader xtr = new XmlTextReader(sr)) - { - xtr.ReadStartElement("osmedia"); - - OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); - - List mediaEntries = new List(); - foreach (OSD osdMe in osdMeArray) - { - MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); - mediaEntries.Add(me); - } - - s.Media = mediaEntries; - - xtr.ReadEndElement(); - } - } - } + s.MediaRaw = (string)row["Media"]; return s; } @@ -1928,36 +1906,7 @@ namespace OpenSim.Data.SQLite row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; - - 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(); - foreach (MediaEntry me in s.Media) - { - OSD osd = (null == me ? new OSD() : me.GetOSD()); - meArray.Add(osd); - } - - xtw.WriteStartElement("osdata"); - xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); - xtw.WriteEndElement(); - - xtw.WriteEndElement(); - - xtw.Flush(); - row["Media"] = sw.ToString(); - } - } - } + row["Media"] = s.MediaRaw; } /// -- cgit v1.1 From 849fc0483f02984abf03994967168d6c38174732 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 23:19:31 +0100 Subject: add mysql support for media on a prim --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 ++++++-- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index bfeae12..f17e8ae 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -222,7 +222,7 @@ namespace OpenSim.Data.MySQL "PathTaperX, PathTaperY, PathTwist, " + "PathTwistBegin, ProfileBegin, ProfileEnd, " + "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State) values (?UUID, " + + "ExtraParams, State, Media) values (?UUID, " + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + "?PCode, ?PathBegin, ?PathEnd, " + "?PathScaleX, ?PathScaleY, " + @@ -233,7 +233,7 @@ namespace OpenSim.Data.MySQL "?PathTwistBegin, ?ProfileBegin, " + "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State)"; + "?State, ?Media)"; FillShapeCommand(cmd, prim); @@ -1700,6 +1700,9 @@ namespace OpenSim.Data.MySQL s.ExtraParams = (byte[])row["ExtraParams"]; s.State = (byte)(int)row["State"]; + + if (!(row["Media"] is System.DBNull)) + s.MediaRaw = (string)row["Media"]; return s; } @@ -1743,6 +1746,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); + cmd.Parameters.AddWithValue("Media", s.MediaRaw); } public void StorePrimInventory(UUID primID, ICollection items) diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 3f644f9..1369704 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -1,4 +1,4 @@ - + :VERSION 1 #--------------------- BEGIN; @@ -800,3 +800,10 @@ BEGIN; ALTER TABLE `regionwindlight` CHANGE COLUMN `cloud_scroll_x` `cloud_scroll_x` FLOAT(4,2) NOT NULL DEFAULT '0.20' AFTER `cloud_detail_density`, CHANGE COLUMN `cloud_scroll_y` `cloud_scroll_y` FLOAT(4,2) NOT NULL DEFAULT '0.01' AFTER `cloud_scroll_x_lock`; COMMIT; +:VERSION 35 #--------------------- +-- Added post 0.7 + +BEGIN; +ALTER TABLE prims ADD COLUMN MediaURL varchar(255); +ALTER TABLE primshapes ADD COLUMN Media TEXT; +COMMIT; \ No newline at end of file -- cgit v1.1 From 109ddd1bd5fcabf3155e579fe6eb15e07869b9b8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 23:26:22 +0100 Subject: add mssql support for media on a prim compiles but not tested. please test and correct if necessary! --- OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 10 +++++++--- OpenSim/Data/MSSQL/Resources/RegionStore.migrations | 9 ++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index d6cb91f..e61b4d9 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs @@ -385,7 +385,7 @@ IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, - Texture = @Texture, ExtraParams = @ExtraParams, State = @State + Texture = @Texture, ExtraParams = @ExtraParams, State = @State, Media = @Media WHERE UUID = @UUID END ELSE @@ -394,11 +394,11 @@ ELSE primshapes ( UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, - ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State + ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State, Media ) VALUES ( @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, - @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State + @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State, @Media ) END"; @@ -1180,6 +1180,9 @@ VALUES { } + if (!(shapeRow["Media"] is System.DBNull)) + baseShape.MediaRaw = (string)shapeRow["Media"]; + return baseShape; } @@ -1557,6 +1560,7 @@ VALUES parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry)); parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); parameters.Add(_Database.CreateParameter("State", s.State)); + parameters.Add(_Database.CreateParameter("Media", s.MediaRaw)); return parameters.ToArray(); } diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations index e912d64..e2e8cbb 100644 --- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations @@ -1,4 +1,4 @@ - + :VERSION 1 CREATE TABLE [dbo].[prims]( @@ -925,5 +925,12 @@ ALTER TABLE regionsettings ADD loaded_creation_datetime int NOT NULL default 0 COMMIT +:VERSION 24 +-- Added post 0.7 + +BEGIN TRANSACTION +ALTER TABLE prims ADD COLUMN MediaURL varchar(255) +ALTER TABLE primshapes ADD COLUMN Media TEXT +COMMIT \ No newline at end of file -- cgit v1.1 From 9d8a67fe1348419c41374d1be77737bfa048106c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 16:26:27 +0100 Subject: get rid of PrimitiveBaseShape.MediaRaw staging post using an OSD serialization rather than auto forces serialization code to be placed in OpenSim.Framework this makes the media texture raw data staging post in PrimitiveBaseShape redundant, now we just directly call the code in PrimitiveBaseShape.MediaList itself --- OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 8 +++++--- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 +++++--- OpenSim/Data/SQLite/SQLiteRegionData.cs | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index e61b4d9..9d819b3 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs @@ -1180,8 +1180,8 @@ VALUES { } - if (!(shapeRow["Media"] is System.DBNull)) - baseShape.MediaRaw = (string)shapeRow["Media"]; + if (!(shapeRow["Media"] is System.DBNull)) + baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); return baseShape; } @@ -1560,7 +1560,9 @@ VALUES parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry)); parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); parameters.Add(_Database.CreateParameter("State", s.State)); - parameters.Add(_Database.CreateParameter("Media", s.MediaRaw)); + + if (s.Media != null) + parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); return parameters.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index f17e8ae..50fcd96 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -1701,8 +1701,8 @@ namespace OpenSim.Data.MySQL s.State = (byte)(int)row["State"]; - if (!(row["Media"] is System.DBNull)) - s.MediaRaw = (string)row["Media"]; + if (!(row["Media"] is System.DBNull)) + s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); return s; } @@ -1746,7 +1746,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); - cmd.Parameters.AddWithValue("Media", s.MediaRaw); + + if (s.Media != null) + cmd.Parameters.AddWithValue("Media", s.Media.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index f63d35e..4208050 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1346,7 +1346,7 @@ namespace OpenSim.Data.SQLite if (!(row["MediaURL"] is System.DBNull)) { - m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType()); + //m_log.DebugFormat("[SQLITE]: MediaUrl type [{0}]", row["MediaURL"].GetType()); prim.MediaUrl = (string)row["MediaURL"]; } @@ -1861,7 +1861,7 @@ namespace OpenSim.Data.SQLite s.ExtraParams = (byte[]) row["ExtraParams"]; if (!(row["Media"] is System.DBNull)) - s.MediaRaw = (string)row["Media"]; + s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); return s; } @@ -1906,7 +1906,9 @@ namespace OpenSim.Data.SQLite row["Texture"] = s.TextureEntry; row["ExtraParams"] = s.ExtraParams; - row["Media"] = s.MediaRaw; + + if (s.Media != null) + row["Media"] = s.Media.ToXml(); } /// -- cgit v1.1 From 2a0254f2da3b92f22289815c05bcd03a4032dd40 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 17:54:40 +0100 Subject: Implement MediaUrl persistence for MySQL and MsSQL Not sure how I forgot this. This may resolve problems with media textures not persisting over restart for these databases. --- OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 14 ++++++++++---- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index 9d819b3..05b14bf 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs @@ -327,7 +327,7 @@ IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, - LinkNumber = @LinkNumber + LinkNumber = @LinkNumber, MediaURL = @MediaURL WHERE UUID = @UUID END ELSE @@ -342,7 +342,7 @@ ELSE PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, - ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber + ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL ) VALUES ( @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, @@ -352,7 +352,7 @@ ELSE @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, - @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber + @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL ) END"; @@ -1127,6 +1127,9 @@ VALUES if (Convert.ToInt16(primRow["PassTouches"]) != 0) prim.PassTouches = true; prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); + + if (!(primRow["MediaURL"] is System.DBNull)) + prim.MediaUrl = (string)primRow["MediaURL"]; return prim; } @@ -1512,7 +1515,10 @@ VALUES parameters.Add(_Database.CreateParameter("PassTouches", 1)); else parameters.Add(_Database.CreateParameter("PassTouches", 0)); - parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); + parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); + + if (prim.MediaUrl != null) + parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); return parameters.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 50fcd96..9c67e3a 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -174,7 +174,7 @@ namespace OpenSim.Data.MySQL "ParticleSystem, ClickAction, Material, " + "CollisionSound, CollisionSoundVolume, " + "PassTouches, " + - "LinkNumber) values (" + "?UUID, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + "?CreationDate, ?Name, ?Text, " + "?Description, ?SitName, ?TouchName, " + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + @@ -205,7 +205,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -1184,6 +1184,9 @@ namespace OpenSim.Data.MySQL prim.PassTouches = ((sbyte)row["PassTouches"] != 0); prim.LinkNum = (int)row["LinkNumber"]; + + if (!(row["MediaURL"] is System.DBNull)) + prim.MediaUrl = (string)row["MediaURL"]; return prim; } @@ -1521,6 +1524,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("PassTouches", 0); cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); + + if (prim.MediaUrl != null) + cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); } /// -- cgit v1.1 From 7f3f1bfe885a373d4a74fc13d49236113a69f727 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Aug 2010 20:23:18 +0100 Subject: fix mysql/mssql prim serialization problem --- OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 8 ++------ OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index 05b14bf..7c176c7 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs @@ -1516,9 +1516,7 @@ VALUES else parameters.Add(_Database.CreateParameter("PassTouches", 0)); parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); - - if (prim.MediaUrl != null) - parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); + parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); return parameters.ToArray(); } @@ -1566,9 +1564,7 @@ VALUES parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry)); parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); parameters.Add(_Database.CreateParameter("State", s.State)); - - if (s.Media != null) - parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); + parameters.Add(_Database.CreateParameter("Media", null == s.Media ? null : s.Media.ToXml())); return parameters.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 9c67e3a..d8debc5 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -1524,9 +1524,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("PassTouches", 0); cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); - - if (prim.MediaUrl != null) - cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); } /// @@ -1752,9 +1750,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Texture", s.TextureEntry); cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); - - if (s.Media != null) - cmd.Parameters.AddWithValue("Media", s.Media.ToXml()); + cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) -- cgit v1.1