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 4ebae14a53
commit 9682e0c733
3 changed files with 54 additions and 5 deletions

View File

@ -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;
@ -975,6 +976,8 @@ namespace OpenSim.Data.SQLite
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"]};
@ -1340,6 +1344,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);
@ -1675,6 +1684,7 @@ namespace OpenSim.Data.SQLite
else
row["VolumeDetect"] = 0;
row["MediaURL"] = prim.MediaUrl;
}
/// <summary>
@ -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<MediaEntry> mediaEntries = new List<MediaEntry>();
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);
}
/// <summary>
///
/// Persistently store a prim.
/// </summary>
/// <param name="prim"></param>
/// <param name="sceneGroupID"></param>
/// <param name="regionUUID"></param>
private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
{
DataTable prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"];

View File

@ -321,6 +321,11 @@ namespace OpenSim.Region.Framework.Scenes
protected Vector3 m_lastAngularVelocity;
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,
// or sit-camera on vehicles will break on sim-crossing.
private Vector3 m_cameraEyeOffset;
@ -965,6 +970,7 @@ namespace OpenSim.Region.Framework.Scenes
TriggerScriptChangedEvent(Changed.SCALE);
}
}
public byte UpdateFlag
{
get { return m_updateFlag; }
@ -974,7 +980,21 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary>
/// Used for media on a prim
/// </summary>
public string MediaUrl { get; set; }
public string MediaUrl
{
get
{
return m_mediaUrl;
}
set
{
m_mediaUrl = value;
if (ParentGroup != null)
ParentGroup.HasGroupChanged = true;
}
}
[XmlIgnore]
public bool CreateSelected

View File

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