aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs91
1 files changed, 31 insertions, 60 deletions
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 90626f4..568170e 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -46,6 +46,7 @@ using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
48using Caps = OpenSim.Framework.Capabilities.Caps; 48using Caps = OpenSim.Framework.Capabilities.Caps;
49using OSDMap = OpenMetaverse.StructuredData.OSDMap;
49 50
50namespace OpenSim.Region.CoreModules.Media.Moap 51namespace OpenSim.Region.CoreModules.Media.Moap
51{ 52{
@@ -59,7 +60,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap
59 60
60 protected Scene m_scene; 61 protected Scene m_scene;
61 62
62 public void Initialise(IConfigSource config) {} 63 public void Initialise(IConfigSource config)
64 {
65 // TODO: Add config switches to enable/disable this module
66 }
63 67
64 public void AddRegion(Scene scene) 68 public void AddRegion(Scene scene)
65 { 69 {
@@ -73,7 +77,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap
73 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 77 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
74 } 78 }
75 79
76 public void Close() {} 80 public void Close()
81 {
82 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
83 }
77 84
78 public void RegisterCaps(UUID agentID, Caps caps) 85 public void RegisterCaps(UUID agentID, Caps caps)
79 { 86 {
@@ -105,33 +112,26 @@ namespace OpenSim.Region.CoreModules.Media.Moap
105 string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) 112 string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
106 { 113 {
107 m_log.DebugFormat("[MOAP]: Got ObjectMedia raw request [{0}]", request); 114 m_log.DebugFormat("[MOAP]: Got ObjectMedia raw request [{0}]", request);
108 115
109 Hashtable osdParams = new Hashtable(); 116 OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);
110 osdParams = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); 117 ObjectMediaMessage omm = new ObjectMediaMessage();
111 118 omm.Deserialize(osd);
112 foreach (Object key in osdParams.Keys) 119
113 m_log.DebugFormat("[MOAP]: Param {0}={1}", key, osdParams[key]); 120 if (omm.Request is ObjectMediaRequest)
114 121 return HandleObjectMediaRequest(omm.Request as ObjectMediaRequest);
115 string verb = (string)osdParams["verb"]; 122 else if (omm.Request is ObjectMediaUpdate)
116 123 return HandleObjectMediaUpdate(omm.Request as ObjectMediaUpdate);
117 if ("GET" == verb) 124
118 return HandleObjectMediaRequestGet(path, osdParams, httpRequest, httpResponse); 125 throw new Exception(
119 if ("UPDATE" == verb) 126 string.Format(
120 return HandleObjectMediaRequestUpdate(path, osdParams, httpRequest, httpResponse); 127 "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
121 128 omm.Request.GetType()));
122 //NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
123
124 // TODO: Persist in memory
125 // TODO: Tell other agents in the region about the change via the ObjectMediaResponse (?) message
126 // TODO: Persist in database
127
128 return string.Empty;
129 } 129 }
130 130
131 protected string HandleObjectMediaRequestGet( 131 protected string HandleObjectMediaRequest(ObjectMediaRequest omr)
132 string path, Hashtable osdParams, OSHttpRequest httpRequest, OSHttpResponse httpResponse) 132 {
133 { 133 //UUID primId = (UUID)osdParams["object_id"];
134 UUID primId = (UUID)osdParams["object_id"]; 134 UUID primId = omr.PrimID;
135 135
136 SceneObjectPart part = m_scene.GetSceneObjectPart(primId); 136 SceneObjectPart part = m_scene.GetSceneObjectPart(primId);
137 137
@@ -179,10 +179,9 @@ namespace OpenSim.Region.CoreModules.Media.Moap
179 return rawResp; 179 return rawResp;
180 } 180 }
181 181
182 protected string HandleObjectMediaRequestUpdate( 182 protected string HandleObjectMediaUpdate(ObjectMediaUpdate omu)
183 string path, Hashtable osdParams, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
184 { 183 {
185 UUID primId = (UUID)osdParams["object_id"]; 184 UUID primId = omu.PrimID;
186 185
187 SceneObjectPart part = m_scene.GetSceneObjectPart(primId); 186 SceneObjectPart part = m_scene.GetSceneObjectPart(primId);
188 187
@@ -194,37 +193,9 @@ namespace OpenSim.Region.CoreModules.Media.Moap
194 return string.Empty; 193 return string.Empty;
195 } 194 }
196 195
197 List<MediaEntry> cookedMediaEntries = new List<MediaEntry>(); 196 m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
198
199 ArrayList rawMediaEntries = (ArrayList)osdParams["object_media_data"];
200 foreach (Object obj in rawMediaEntries)
201 {
202 Hashtable rawMe = (Hashtable)obj;
203
204 // TODO: Yeah, I know this is silly. Very soon use existing better code in libomv to do this.
205 MediaEntry cookedMe = new MediaEntry();
206 cookedMe.EnableAlterntiveImage = (bool)rawMe["alt_image_enable"];
207 cookedMe.AutoLoop = (bool)rawMe["auto_loop"];
208 cookedMe.AutoPlay = (bool)rawMe["auto_play"];
209 cookedMe.AutoScale = (bool)rawMe["auto_scale"];
210 cookedMe.AutoZoom = (bool)rawMe["auto_zoom"];
211 cookedMe.InteractOnFirstClick = (bool)rawMe["first_click_interact"];
212 cookedMe.Controls = (MediaControls)rawMe["controls"];
213 cookedMe.HomeURL = (string)rawMe["home_url"];
214 cookedMe.CurrentURL = (string)rawMe["current_url"];
215 cookedMe.Height = (int)rawMe["height_pixels"];
216 cookedMe.Width = (int)rawMe["width_pixels"];
217 cookedMe.ControlPermissions = (MediaPermission)Enum.Parse(typeof(MediaPermission), rawMe["perms_control"].ToString());
218 cookedMe.InteractPermissions = (MediaPermission)Enum.Parse(typeof(MediaPermission), rawMe["perms_interact"].ToString());
219 cookedMe.EnableWhiteList = (bool)rawMe["whitelist_enable"];
220 //cookedMe.WhiteList = (string[])rawMe["whitelist"];
221
222 cookedMediaEntries.Add(cookedMe);
223 }
224
225 m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", cookedMediaEntries.Count, primId);
226 197
227 part.Shape.Media = cookedMediaEntries; 198 part.Shape.Media = new List<MediaEntry>(omu.FaceMedia);
228 199
229 return string.Empty; 200 return string.Empty;
230 } 201 }