aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/External
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Serialization/External')
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs191
-rw-r--r--OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs6
-rw-r--r--OpenSim/Framework/Serialization/External/UserProfileSerializer.cs4
3 files changed, 196 insertions, 5 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
new file mode 100644
index 0000000..a3bc5d1
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -0,0 +1,191 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Text;
32using System.Xml;
33using OpenMetaverse;
34using OpenSim.Framework;
35
36namespace OpenSim.Framework.Serialization.External
37{
38 /// <summary>
39 /// Serialize and deserialize LandData as an external format.
40 /// </summary>
41 public class LandDataSerializer
42 {
43 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
44
45 /// <summary>
46 /// Reify/deserialize landData
47 /// </summary>
48 /// <param name="serializedLandData"></param>
49 /// <returns></returns>
50 /// <exception cref="System.Xml.XmlException"></exception>
51 public static LandData Deserialize(byte[] serializedLandData)
52 {
53 return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length));
54 }
55
56 /// <summary>
57 /// Reify/deserialize landData
58 /// </summary>
59 /// <param name="serializedLandData"></param>
60 /// <returns></returns>
61 /// <exception cref="System.Xml.XmlException"></exception>
62 public static LandData Deserialize(string serializedLandData)
63 {
64 LandData landData = new LandData();
65
66 StringReader sr = new StringReader(serializedLandData);
67 XmlTextReader xtr = new XmlTextReader(sr);
68
69 xtr.ReadStartElement("LandData");
70
71 landData.Area = Convert.ToInt32( xtr.ReadElementString("Area"));
72 landData.AuctionID = Convert.ToUInt32( xtr.ReadElementString("AuctionID"));
73 landData.AuthBuyerID = UUID.Parse( xtr.ReadElementString("AuthBuyerID"));
74 landData.Category = (ParcelCategory)Convert.ToSByte( xtr.ReadElementString("Category"));
75 landData.ClaimDate = Convert.ToInt32( xtr.ReadElementString("ClaimDate"));
76 landData.ClaimPrice = Convert.ToInt32( xtr.ReadElementString("ClaimPrice"));
77 landData.GlobalID = UUID.Parse( xtr.ReadElementString("GlobalID"));
78 landData.GroupID = UUID.Parse( xtr.ReadElementString("GroupID"));
79 landData.IsGroupOwned = Convert.ToBoolean( xtr.ReadElementString("IsGroupOwned"));
80 landData.Bitmap = Convert.FromBase64String( xtr.ReadElementString("Bitmap"));
81 landData.Description = xtr.ReadElementString("Description");
82 landData.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags"));
83 landData.LandingType = Convert.ToByte( xtr.ReadElementString("LandingType"));
84 landData.Name = xtr.ReadElementString("Name");
85 landData.Status = (ParcelStatus)Convert.ToSByte( xtr.ReadElementString("Status"));
86 landData.LocalID = Convert.ToInt32( xtr.ReadElementString("LocalID"));
87 landData.MediaAutoScale = Convert.ToByte( xtr.ReadElementString("MediaAutoScale"));
88 landData.MediaID = UUID.Parse( xtr.ReadElementString("MediaID"));
89 landData.MediaURL = xtr.ReadElementString("MediaURL");
90 landData.MusicURL = xtr.ReadElementString("MusicURL");
91 landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID"));
92
93 landData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
94 xtr.Read();
95 if (xtr.Name != "ParcelAccessList")
96 throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name));
97
98 if (!xtr.IsEmptyElement)
99 {
100 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
101 {
102 ParcelManager.ParcelAccessEntry pae = new ParcelManager.ParcelAccessEntry();
103
104 xtr.ReadStartElement("ParcelAccessEntry");
105 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
106 pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time"));
107 pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList"));
108 xtr.ReadEndElement();
109
110 landData.ParcelAccessList.Add(pae);
111 }
112 }
113 xtr.Read();
114
115 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
116 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
117 landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice"));
118 landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID"));
119 landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation"));
120 landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt"));
121 landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell"));
122 landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime"));
123
124 xtr.ReadEndElement();
125
126 xtr.Close();
127 sr.Close();
128
129 return landData;
130 }
131
132 public static string Serialize(LandData landData)
133 {
134 StringWriter sw = new StringWriter();
135 XmlTextWriter xtw = new XmlTextWriter(sw);
136 xtw.Formatting = Formatting.Indented;
137
138 xtw.WriteStartDocument();
139 xtw.WriteStartElement("LandData");
140
141 xtw.WriteElementString("Area", Convert.ToString(landData.Area));
142 xtw.WriteElementString("AuctionID", Convert.ToString(landData.AuctionID));
143 xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString());
144 xtw.WriteElementString("Category", Convert.ToString((sbyte)landData.Category));
145 xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate));
146 xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice));
147 xtw.WriteElementString("GlobalID", landData.GlobalID.ToString());
148 xtw.WriteElementString("GroupID", landData.GroupID.ToString());
149 xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned));
150 xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap));
151 xtw.WriteElementString("Description", landData.Description);
152 xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags));
153 xtw.WriteElementString("LandingType", Convert.ToString((byte)landData.LandingType));
154 xtw.WriteElementString("Name", landData.Name);
155 xtw.WriteElementString("Status", Convert.ToString((sbyte)landData.Status));
156 xtw.WriteElementString("LocalID", landData.LocalID.ToString());
157 xtw.WriteElementString("MediaAutoScale", Convert.ToString(landData.MediaAutoScale));
158 xtw.WriteElementString("MediaID", landData.MediaID.ToString());
159 xtw.WriteElementString("MediaURL", landData.MediaURL);
160 xtw.WriteElementString("MusicURL", landData.MusicURL);
161 xtw.WriteElementString("OwnerID", landData.OwnerID.ToString());
162
163 xtw.WriteStartElement("ParcelAccessList");
164 foreach (ParcelManager.ParcelAccessEntry pal in landData.ParcelAccessList)
165 {
166 xtw.WriteStartElement("ParcelAccessEntry");
167 xtw.WriteElementString("AgentID", pal.AgentID.ToString());
168 xtw.WriteElementString("Time", pal.Time.ToString("s"));
169 xtw.WriteElementString("AccessList", Convert.ToString((uint)pal.Flags));
170 xtw.WriteEndElement();
171 }
172 xtw.WriteEndElement();
173
174 xtw.WriteElementString("PassHours", Convert.ToString(landData.PassHours));
175 xtw.WriteElementString("PassPrice", Convert.ToString(landData.PassPrice));
176 xtw.WriteElementString("SalePrice", Convert.ToString(landData.SalePrice));
177 xtw.WriteElementString("SnapshotID", landData.SnapshotID.ToString());
178 xtw.WriteElementString("UserLocation", landData.UserLocation.ToString());
179 xtw.WriteElementString("UserLookAt", landData.UserLookAt.ToString());
180 xtw.WriteElementString("Dwell", Convert.ToString(landData.Dwell));
181 xtw.WriteElementString("OtherCleanTime", Convert.ToString(landData.OtherCleanTime));
182
183 xtw.WriteEndElement();
184
185 xtw.Close();
186 sw.Close();
187
188 return sw.ToString();
189 }
190 }
191}
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
index 274f41f..b5901e1 100644
--- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
@@ -158,7 +158,7 @@ namespace OpenSim.Framework.Serialization.External
158 settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString()); 158 settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString());
159 break; 159 break;
160 } 160 }
161 } 161 }
162 162
163 xtr.ReadEndElement(); 163 xtr.ReadEndElement();
164 xtr.ReadStartElement("Terrain"); 164 xtr.ReadStartElement("Terrain");
@@ -200,8 +200,8 @@ namespace OpenSim.Framework.Serialization.External
200 200
201 xtw.WriteStartElement("RegionSettings"); 201 xtw.WriteStartElement("RegionSettings");
202 202
203 xtw.WriteStartElement("General"); 203 xtw.WriteStartElement("General");
204 xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString()); 204 xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString());
205 xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString()); 205 xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString());
206 xtw.WriteElementString("AllowLandJoinDivide", settings.AllowLandJoinDivide.ToString()); 206 xtw.WriteElementString("AllowLandJoinDivide", settings.AllowLandJoinDivide.ToString());
207 xtw.WriteElementString("BlockFly", settings.BlockFly.ToString()); 207 xtw.WriteElementString("BlockFly", settings.BlockFly.ToString());
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
index eb77e65..fb269b7 100644
--- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Framework.Serialization.External
36 /// Serialize and deserialize region settings as an external format. 36 /// Serialize and deserialize region settings as an external format.
37 /// </summary> 37 /// </summary>
38 public class UserProfileSerializer 38 public class UserProfileSerializer
39 { 39 {
40 public const int MAJOR_VERSION = 0; 40 public const int MAJOR_VERSION = 0;
41 public const int MINOR_VERSION = 1; 41 public const int MINOR_VERSION = 1;
42 42
@@ -65,6 +65,6 @@ namespace OpenSim.Framework.Serialization.External
65 sw.Close(); 65 sw.Close();
66 66
67 return sw.ToString(); 67 return sw.ToString();
68 } 68 }
69 } 69 }
70} \ No newline at end of file 70} \ No newline at end of file