aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorAdam Frisby2008-04-21 09:38:51 +0000
committerAdam Frisby2008-04-21 09:38:51 +0000
commita0b8c46ef37f6bf44de36ab60fae741076d8a3bf (patch)
tree164d609f67e1cebdd9cf45d0d0de9eecdd8f4178 /OpenSim/Region/Environment/Modules
parent* Formatted ExportSerialiserModule and SvnBackupModule (diff)
downloadopensim-SC-a0b8c46ef37f6bf44de36ab60fae741076d8a3bf.zip
opensim-SC-a0b8c46ef37f6bf44de36ab60fae741076d8a3bf.tar.gz
opensim-SC-a0b8c46ef37f6bf44de36ab60fae741076d8a3bf.tar.bz2
opensim-SC-a0b8c46ef37f6bf44de36ab60fae741076d8a3bf.tar.xz
* Various refactorings.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/AsteriskVoiceModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs48
2 files changed, 36 insertions, 18 deletions
diff --git a/OpenSim/Region/Environment/Modules/AsteriskVoiceModule.cs b/OpenSim/Region/Environment/Modules/AsteriskVoiceModule.cs
index 1b537c2..38c0c1d 100644
--- a/OpenSim/Region/Environment/Modules/AsteriskVoiceModule.cs
+++ b/OpenSim/Region/Environment/Modules/AsteriskVoiceModule.cs
@@ -163,7 +163,7 @@ namespace OpenSim.Region.Environment.Modules
163 // setup response to client 163 // setup response to client
164 Hashtable creds = new Hashtable(); 164 Hashtable creds = new Hashtable();
165 creds["channel_uri"] = String.Format("sip:{0}@{1}", 165 creds["channel_uri"] = String.Format("sip:{0}@{1}",
166 m_scene.RegionInfo.RegionID.ToString(), m_sipDomain); 166 m_scene.RegionInfo.RegionID, m_sipDomain);
167 167
168 string regionName = m_scene.RegionInfo.RegionName; 168 string regionName = m_scene.RegionInfo.RegionName;
169 ScenePresence avatar = m_scene.GetScenePresence(agentID); 169 ScenePresence avatar = m_scene.GetScenePresence(agentID);
@@ -207,8 +207,6 @@ namespace OpenSim.Region.Environment.Modules
207 207
208 return "<llsd>undef</llsd>"; 208 return "<llsd>undef</llsd>";
209 } 209 }
210
211 return null;
212 } 210 }
213 211
214 /// <summary> 212 /// <summary>
@@ -282,8 +280,6 @@ namespace OpenSim.Region.Environment.Modules
282 280
283 return "<llsd>undef</llsd>"; 281 return "<llsd>undef</llsd>";
284 } 282 }
285
286 return null;
287 } 283 }
288 } 284 }
289} 285}
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
index 7e5cf47..277370d 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
@@ -51,6 +51,32 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
51 51
52 public void SaveSerialisedToFile(string fileName, Scene scene) 52 public void SaveSerialisedToFile(string fileName, Scene scene)
53 { 53 {
54 string xmlstream = GetObjectXml(scene);
55
56 MemoryStream stream = ReformatXmlString(xmlstream);
57
58 stream.Seek(0, SeekOrigin.Begin);
59 CreateXmlFile(stream, fileName);
60
61 stream.Seek(0, SeekOrigin.Begin);
62 CreateCompressedXmlFile(stream, fileName);
63 }
64
65 private static MemoryStream ReformatXmlString(string xmlstream)
66 {
67 MemoryStream stream = new MemoryStream();
68 XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8);
69 XmlDocument doc = new XmlDocument();
70
71 doc.LoadXml(xmlstream);
72 formatter.Formatting = Formatting.Indented;
73 doc.WriteContentTo(formatter);
74 formatter.Flush();
75 return stream;
76 }
77
78 private static string GetObjectXml(Scene scene)
79 {
54 string xmlstream = "<scene>"; 80 string xmlstream = "<scene>";
55 81
56 List<EntityBase> EntityList = scene.GetEntities(); 82 List<EntityBase> EntityList = scene.GetEntities();
@@ -69,29 +95,25 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
69 xmlstream += xml; 95 xmlstream += xml;
70 96
71 xmlstream += "</scene>"; 97 xmlstream += "</scene>";
98 return xmlstream;
99 }
72 100
73 MemoryStream stream = new MemoryStream(); 101 private static void CreateXmlFile(MemoryStream xmlStream, string fileName)
74 XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8); 102 {
75 XmlDocument doc = new XmlDocument();
76
77 doc.LoadXml(xmlstream);
78 formatter.Formatting = Formatting.Indented;
79 doc.WriteContentTo(formatter);
80 formatter.Flush();
81
82 stream.Seek(0, SeekOrigin.Begin);
83
84 FileStream objectsFile = new FileStream(fileName, FileMode.Create); 103 FileStream objectsFile = new FileStream(fileName, FileMode.Create);
85 104
86 stream.WriteTo(objectsFile); 105 xmlStream.WriteTo(objectsFile);
87 objectsFile.Flush(); 106 objectsFile.Flush();
88 objectsFile.Close(); 107 objectsFile.Close();
108 }
89 109
110 private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
111 {
90 #region GZip Compressed Version 112 #region GZip Compressed Version
91 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); 113 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
92 MemoryStream gzipMSStream = new MemoryStream(); 114 MemoryStream gzipMSStream = new MemoryStream();
93 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); 115 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
94 stream.WriteTo(gzipStream); 116 xmlStream.WriteTo(gzipStream);
95 gzipMSStream.WriteTo(objectsFileCompressed); 117 gzipMSStream.WriteTo(objectsFileCompressed);
96 objectsFileCompressed.Flush(); 118 objectsFileCompressed.Flush();
97 objectsFileCompressed.Close(); 119 objectsFileCompressed.Close();