aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization/External
diff options
context:
space:
mode:
authordr scofield (aka dirk husemann)2009-09-29 09:07:00 +0200
committerdr scofield (aka dirk husemann)2009-09-30 16:19:39 +0200
commit33515c75e44421df58a97058a6281eb96e0e50fd (patch)
tree5edb6ce33fb898d15d63241a1327be4b3bbfd660 /OpenSim/Framework/Serialization/External
parentMake create user to the Right Thing with regard to salting user passwords (diff)
downloadopensim-SC_OLD-33515c75e44421df58a97058a6281eb96e0e50fd.zip
opensim-SC_OLD-33515c75e44421df58a97058a6281eb96e0e50fd.tar.gz
opensim-SC_OLD-33515c75e44421df58a97058a6281eb96e0e50fd.tar.bz2
opensim-SC_OLD-33515c75e44421df58a97058a6281eb96e0e50fd.tar.xz
adding LandDataSerializer (not connected anywhere, work-in-progress)
[hi, there, justin!]
Diffstat (limited to 'OpenSim/Framework/Serialization/External')
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs185
1 files changed, 185 insertions, 0 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
new file mode 100644
index 0000000..6bfae41
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -0,0 +1,185 @@
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.ReadStartElement("ParcelAccessList");
95 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
96 {
97 ParcelManager.ParcelAccessEntry pae;
98
99 xtr.ReadStartElement("ParcelAccessEntry");
100 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
101 pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time"));
102 pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList"));
103 xtr.ReadEndElement();
104
105 landData.ParcelAccessList.Add(pae);
106 }
107 xtr.ReadEndElement();
108
109 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
110 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
111 landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice"));
112 landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID"));
113 landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation"));
114 landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt"));
115 landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell"));
116 landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime"));
117
118 xtr.ReadEndElement();
119
120 xtr.Close();
121 sr.Close();
122
123 return landData;
124 }
125
126 public static string Serialize(LandData landData)
127 {
128 StringWriter sw = new StringWriter();
129 XmlTextWriter xtw = new XmlTextWriter(sw);
130 xtw.Formatting = Formatting.Indented;
131
132 xtw.WriteStartDocument();
133 xtw.WriteStartElement("LandData");
134
135 xtw.WriteElementString("Area", landData.Area.ToString());
136 xtw.WriteElementString("AuctionID", landData.AuctionID.ToString());
137 xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString());
138 xtw.WriteElementString("Category", landData.Category.ToString());
139 xtw.WriteElementString("ClaimDate", landData.ClaimDate.ToString());
140 xtw.WriteElementString("ClaimPrice", landData.ClaimPrice.ToString());
141 xtw.WriteElementString("GlobalID", landData.GlobalID.ToString());
142 xtw.WriteElementString("GroupID", landData.GroupID.ToString());
143 xtw.WriteElementString("IsGroupOwned", landData.IsGroupOwned.ToString());
144 xtw.WriteElementString("Bitmap", landData.Bitmap.ToString());
145 xtw.WriteElementString("Description", landData.Description);
146 xtw.WriteElementString("Flags", landData.Flags.ToString());
147 xtw.WriteElementString("LandingType", landData.LandingType.ToString());
148 xtw.WriteElementString("Name", landData.Name);
149 xtw.WriteElementString("Status", landData.Status.ToString());
150 xtw.WriteElementString("LocalID", landData.LocalID.ToString());
151 xtw.WriteElementString("MediaAutoScale", landData.MediaAutoScale.ToString());
152 xtw.WriteElementString("MediaID", landData.MediaID.ToString());
153 xtw.WriteElementString("MediaURL", landData.MediaURL.ToString());
154 xtw.WriteElementString("MusicURL", landData.MusicURL.ToString());
155 xtw.WriteElementString("OwnerID", landData.OwnerID.ToString());
156
157 xtw.WriteStartElement("ParcelAccessList");
158 foreach(ParcelManager.ParcelAccessEntry pal in landData.ParcelAccessList)
159 {
160 xtw.WriteStartElement("ParcelAccessEntry");
161 xtw.WriteElementString("AgentID", pal.AgentID.ToString());
162 xtw.WriteElementString("Time", pal.Time.ToString());
163 xtw.WriteElementString("AccessList", pal.Flags.ToString());
164 xtw.WriteEndElement();
165 }
166 xtw.WriteEndElement();
167
168 xtw.WriteElementString("PassHours", landData.PassHours.ToString());
169 xtw.WriteElementString("PassPrice", landData.PassPrice.ToString());
170 xtw.WriteElementString("SalePrice", landData.SalePrice.ToString());
171 xtw.WriteElementString("SnapshotID", landData.SnapshotID.ToString());
172 xtw.WriteElementString("UserLocation", landData.UserLocation.ToString());
173 xtw.WriteElementString("UserLookAt", landData.UserLookAt.ToString());
174 xtw.WriteElementString("Dwell", landData.Dwell.ToString());
175 xtw.WriteElementString("OtherCleanTime", landData.OtherCleanTime.ToString());
176
177 xtw.WriteEndElement();
178
179 xtw.Close();
180 sw.Close();
181
182 return sw.ToString();
183 }
184 }
185}