replace hand parsing of incoming object media messages with parsing code in libopenmetaverse

prebuild-update
Justin Clark-Casey (justincc) 2010-07-01 18:42:47 +01:00
parent acac47830e
commit c290cdd997
1 changed files with 30 additions and 59 deletions

View File

@ -46,6 +46,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps; using Caps = OpenSim.Framework.Capabilities.Caps;
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
namespace OpenSim.Region.CoreModules.Media.Moap namespace OpenSim.Region.CoreModules.Media.Moap
{ {
@ -59,7 +60,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap
protected Scene m_scene; protected Scene m_scene;
public void Initialise(IConfigSource config) {} public void Initialise(IConfigSource config)
{
// TODO: Add config switches to enable/disable this module
}
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
@ -73,7 +77,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap
m_scene.EventManager.OnRegisterCaps += RegisterCaps; m_scene.EventManager.OnRegisterCaps += RegisterCaps;
} }
public void Close() {} public void Close()
{
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
}
public void RegisterCaps(UUID agentID, Caps caps) public void RegisterCaps(UUID agentID, Caps caps)
{ {
@ -106,32 +113,25 @@ namespace OpenSim.Region.CoreModules.Media.Moap
{ {
m_log.DebugFormat("[MOAP]: Got ObjectMedia raw request [{0}]", request); m_log.DebugFormat("[MOAP]: Got ObjectMedia raw request [{0}]", request);
Hashtable osdParams = new Hashtable(); OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);
osdParams = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); ObjectMediaMessage omm = new ObjectMediaMessage();
omm.Deserialize(osd);
foreach (Object key in osdParams.Keys) if (omm.Request is ObjectMediaRequest)
m_log.DebugFormat("[MOAP]: Param {0}={1}", key, osdParams[key]); return HandleObjectMediaRequest(omm.Request as ObjectMediaRequest);
else if (omm.Request is ObjectMediaUpdate)
return HandleObjectMediaUpdate(omm.Request as ObjectMediaUpdate);
string verb = (string)osdParams["verb"]; throw new Exception(
string.Format(
if ("GET" == verb) "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
return HandleObjectMediaRequestGet(path, osdParams, httpRequest, httpResponse); omm.Request.GetType()));
if ("UPDATE" == verb)
return HandleObjectMediaRequestUpdate(path, osdParams, httpRequest, httpResponse);
//NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
// TODO: Persist in memory
// TODO: Tell other agents in the region about the change via the ObjectMediaResponse (?) message
// TODO: Persist in database
return string.Empty;
} }
protected string HandleObjectMediaRequestGet( protected string HandleObjectMediaRequest(ObjectMediaRequest omr)
string path, Hashtable osdParams, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{ {
UUID primId = (UUID)osdParams["object_id"]; //UUID primId = (UUID)osdParams["object_id"];
UUID primId = omr.PrimID;
SceneObjectPart part = m_scene.GetSceneObjectPart(primId); SceneObjectPart part = m_scene.GetSceneObjectPart(primId);
@ -179,10 +179,9 @@ namespace OpenSim.Region.CoreModules.Media.Moap
return rawResp; return rawResp;
} }
protected string HandleObjectMediaRequestUpdate( protected string HandleObjectMediaUpdate(ObjectMediaUpdate omu)
string path, Hashtable osdParams, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{ {
UUID primId = (UUID)osdParams["object_id"]; UUID primId = omu.PrimID;
SceneObjectPart part = m_scene.GetSceneObjectPart(primId); SceneObjectPart part = m_scene.GetSceneObjectPart(primId);
@ -194,37 +193,9 @@ namespace OpenSim.Region.CoreModules.Media.Moap
return string.Empty; return string.Empty;
} }
List<MediaEntry> cookedMediaEntries = new List<MediaEntry>(); m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
ArrayList rawMediaEntries = (ArrayList)osdParams["object_media_data"]; part.Shape.Media = new List<MediaEntry>(omu.FaceMedia);
foreach (Object obj in rawMediaEntries)
{
Hashtable rawMe = (Hashtable)obj;
// TODO: Yeah, I know this is silly. Very soon use existing better code in libomv to do this.
MediaEntry cookedMe = new MediaEntry();
cookedMe.EnableAlterntiveImage = (bool)rawMe["alt_image_enable"];
cookedMe.AutoLoop = (bool)rawMe["auto_loop"];
cookedMe.AutoPlay = (bool)rawMe["auto_play"];
cookedMe.AutoScale = (bool)rawMe["auto_scale"];
cookedMe.AutoZoom = (bool)rawMe["auto_zoom"];
cookedMe.InteractOnFirstClick = (bool)rawMe["first_click_interact"];
cookedMe.Controls = (MediaControls)rawMe["controls"];
cookedMe.HomeURL = (string)rawMe["home_url"];
cookedMe.CurrentURL = (string)rawMe["current_url"];
cookedMe.Height = (int)rawMe["height_pixels"];
cookedMe.Width = (int)rawMe["width_pixels"];
cookedMe.ControlPermissions = (MediaPermission)Enum.Parse(typeof(MediaPermission), rawMe["perms_control"].ToString());
cookedMe.InteractPermissions = (MediaPermission)Enum.Parse(typeof(MediaPermission), rawMe["perms_interact"].ToString());
cookedMe.EnableWhiteList = (bool)rawMe["whitelist_enable"];
//cookedMe.WhiteList = (string[])rawMe["whitelist"];
cookedMediaEntries.Add(cookedMe);
}
m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", cookedMediaEntries.Count, primId);
part.Shape.Media = cookedMediaEntries;
return string.Empty; return string.Empty;
} }