Implement media texture persistence over server restarts for sqlite

This is currently persisting media as an OSDArray serialized to LLSD XML.
prebuild-update
Justin Clark-Casey (justincc) 2010-07-01 22:52:31 +01:00
parent ca5d1411a6
commit 53ddcf6d25
3 changed files with 54 additions and 5 deletions

View File

@ -34,6 +34,7 @@ using System.Reflection;
using log4net; using log4net;
using Mono.Data.Sqlite; using Mono.Data.Sqlite;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -975,6 +976,8 @@ namespace OpenSim.Data.SQLite
createCol(prims, "VolumeDetect", typeof(Int16)); createCol(prims, "VolumeDetect", typeof(Int16));
createCol(prims, "MediaURL", typeof(String));
// Add in contraints // Add in contraints
prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]};
@ -1021,6 +1024,7 @@ namespace OpenSim.Data.SQLite
// way to specify this as a blob atm // way to specify this as a blob atm
createCol(shapes, "Texture", typeof (Byte[])); createCol(shapes, "Texture", typeof (Byte[]));
createCol(shapes, "ExtraParams", typeof (Byte[])); createCol(shapes, "ExtraParams", typeof (Byte[]));
createCol(shapes, "Media", typeof(String));
shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]};
@ -1340,6 +1344,12 @@ namespace OpenSim.Data.SQLite
if (Convert.ToInt16(row["VolumeDetect"]) != 0) if (Convert.ToInt16(row["VolumeDetect"]) != 0)
prim.VolumeDetectActive = true; 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; return prim;
} }
@ -1614,7 +1624,6 @@ namespace OpenSim.Data.SQLite
row["PayButton3"] = prim.PayPrice[3]; row["PayButton3"] = prim.PayPrice[3];
row["PayButton4"] = prim.PayPrice[4]; row["PayButton4"] = prim.PayPrice[4];
row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation);
row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem);
@ -1675,6 +1684,7 @@ namespace OpenSim.Data.SQLite
else else
row["VolumeDetect"] = 0; row["VolumeDetect"] = 0;
row["MediaURL"] = prim.MediaUrl;
} }
/// <summary> /// <summary>
@ -1849,6 +1859,19 @@ namespace OpenSim.Data.SQLite
s.TextureEntry = textureEntry; s.TextureEntry = textureEntry;
s.ExtraParams = (byte[]) row["ExtraParams"]; s.ExtraParams = (byte[]) row["ExtraParams"];
if (!(row["Media"] is System.DBNull))
{
string rawMeArray = (string)row["Media"];
OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(rawMeArray);
List<MediaEntry> mediaEntries = new List<MediaEntry>();
foreach (OSD osdMe in osdMeArray)
mediaEntries.Add(MediaEntry.FromOSD(osdMe));
s.Media = mediaEntries;
}
return s; return s;
} }
@ -1892,17 +1915,22 @@ namespace OpenSim.Data.SQLite
row["Texture"] = s.TextureEntry; row["Texture"] = s.TextureEntry;
row["ExtraParams"] = s.ExtraParams; row["ExtraParams"] = s.ExtraParams;
OSDArray meArray = new OSDArray();
foreach (MediaEntry me in s.Media)
meArray.Add(me.GetOSD());
row["Media"] = OSDParser.SerializeLLSDXmlString(meArray);
} }
/// <summary> /// <summary>
/// /// Persistently store a prim.
/// </summary> /// </summary>
/// <param name="prim"></param> /// <param name="prim"></param>
/// <param name="sceneGroupID"></param> /// <param name="sceneGroupID"></param>
/// <param name="regionUUID"></param> /// <param name="regionUUID"></param>
private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
{ {
DataTable prims = ds.Tables["prims"]; DataTable prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"]; DataTable shapes = ds.Tables["primshapes"];

View File

@ -318,6 +318,11 @@ namespace OpenSim.Region.Framework.Scenes
protected Vector3 m_lastAngularVelocity; protected Vector3 m_lastAngularVelocity;
protected int m_lastTerseSent; protected int m_lastTerseSent;
/// <summary>
/// Stores media texture data
/// </summary>
protected string m_mediaUrl;
// TODO: Those have to be changed into persistent properties at some later point, // TODO: Those have to be changed into persistent properties at some later point,
// or sit-camera on vehicles will break on sim-crossing. // or sit-camera on vehicles will break on sim-crossing.
private Vector3 m_cameraEyeOffset; private Vector3 m_cameraEyeOffset;
@ -962,6 +967,7 @@ namespace OpenSim.Region.Framework.Scenes
TriggerScriptChangedEvent(Changed.SCALE); TriggerScriptChangedEvent(Changed.SCALE);
} }
} }
public byte UpdateFlag public byte UpdateFlag
{ {
get { return m_updateFlag; } get { return m_updateFlag; }
@ -971,7 +977,21 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Used for media on a prim /// Used for media on a prim
/// </summary> /// </summary>
public string MediaUrl { get; set; } public string MediaUrl
{
get
{
return m_mediaUrl;
}
set
{
m_mediaUrl = value;
if (ParentGroup != null)
ParentGroup.HasGroupChanged = true;
}
}
[XmlIgnore] [XmlIgnore]
public bool CreateSelected public bool CreateSelected

View File

@ -2238,6 +2238,7 @@
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenMetaverseTypes.dll"/> <Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="Mono.Data.Sqlite"/> <Reference name="Mono.Data.Sqlite"/>
<Reference name="Mono.Addins.dll" /> <Reference name="Mono.Addins.dll" />
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>