aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs70
1 files changed, 68 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 263ee57..0e03318 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -32,6 +32,7 @@ using System.Collections.Specialized;
32using System.Reflection; 32using System.Reflection;
33using System.IO; 33using System.IO;
34using System.Web; 34using System.Web;
35using System.Xml;
35using log4net; 36using log4net;
36using Mono.Addins; 37using Mono.Addins;
37using Nini.Config; 38using Nini.Config;
@@ -46,6 +47,7 @@ using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 47using OpenSim.Region.Framework.Scenes;
47using OpenSim.Services.Interfaces; 48using OpenSim.Services.Interfaces;
48using Caps = OpenSim.Framework.Capabilities.Caps; 49using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
49using OSDMap = OpenMetaverse.StructuredData.OSDMap; 51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
50 52
51namespace OpenSim.Region.CoreModules.Media.Moap 53namespace OpenSim.Region.CoreModules.Media.Moap
@@ -162,12 +164,76 @@ namespace OpenSim.Region.CoreModules.Media.Moap
162 public void OnSceneObjectLoaded(SceneObjectGroup so) 164 public void OnSceneObjectLoaded(SceneObjectGroup so)
163 { 165 {
164 m_log.DebugFormat("[MOAP]: OnSceneObjectLoaded fired for {0} {1}", so.Name, so.UUID); 166 m_log.DebugFormat("[MOAP]: OnSceneObjectLoaded fired for {0} {1}", so.Name, so.UUID);
167
168 so.ForEachPart(OnSceneObjectPartLoaded);
165 } 169 }
166 170
167 public void OnSceneObjectPreSave(SceneObjectGroup persistingSo, SceneObjectGroup originalSo) 171 public void OnSceneObjectPreSave(SceneObjectGroup persistingSo, SceneObjectGroup originalSo)
168 { 172 {
169 m_log.DebugFormat("[MOAP]: OnSceneObjectPreSave fired for {0} {1}", persistingSo.Name, persistingSo.UUID); 173 m_log.DebugFormat("[MOAP]: OnSceneObjectPreSave fired for {0} {1}", persistingSo.Name, persistingSo.UUID);
170 } 174
175 persistingSo.ForEachPart(OnSceneObjectPartPreSave);
176 }
177
178 protected void OnSceneObjectPartLoaded(SceneObjectPart part)
179 {
180 if (null == part.Shape.MediaRaw)
181 return;
182
183 using (StringReader sr = new StringReader(part.Shape.MediaRaw))
184 {
185 using (XmlTextReader xtr = new XmlTextReader(sr))
186 {
187 xtr.ReadStartElement("osmedia");
188
189 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
190
191 List<MediaEntry> mediaEntries = new List<MediaEntry>();
192 foreach (OSD osdMe in osdMeArray)
193 {
194 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
195 mediaEntries.Add(me);
196 }
197
198 xtr.ReadEndElement();
199
200 part.Shape.Media = mediaEntries;
201 }
202 }
203 }
204
205 protected void OnSceneObjectPartPreSave(SceneObjectPart part)
206 {
207 if (null == part.Shape.Media)
208 return;
209
210 using (StringWriter sw = new StringWriter())
211 {
212 using (XmlTextWriter xtw = new XmlTextWriter(sw))
213 {
214 xtw.WriteStartElement("osmedia");
215 xtw.WriteAttributeString("type", "sl");
216 xtw.WriteAttributeString("major_version", "0");
217 xtw.WriteAttributeString("minor_version", "1");
218
219 OSDArray meArray = new OSDArray();
220 foreach (MediaEntry me in part.Shape.Media)
221 {
222 OSD osd = (null == me ? new OSD() : me.GetOSD());
223 meArray.Add(osd);
224 }
225
226 xtw.WriteStartElement("osdata");
227 xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
228 xtw.WriteEndElement();
229
230 xtw.WriteEndElement();
231
232 xtw.Flush();
233 part.Shape.MediaRaw = sw.ToString();
234 }
235 }
236 }
171 237
172 public MediaEntry GetMediaEntry(SceneObjectPart part, int face) 238 public MediaEntry GetMediaEntry(SceneObjectPart part, int face)
173 { 239 {