aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-04-23 20:15:05 +0000
committerJustin Clarke Casey2009-04-23 20:15:05 +0000
commit1ccc99a3f9d96fbdea478be7e7df427a9e5377a7 (patch)
tree713222af91ebef24e5604efffc9e6b1c68a7700b /OpenSim/Framework
parent* Allow interested user data plugins to store temporary user profiles (diff)
downloadopensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.zip
opensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.tar.gz
opensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.tar.bz2
opensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.tar.xz
* refactor: move archive user inventory item serialization out to a separate file
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs8
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs198
-rw-r--r--OpenSim/Framework/Serialization/External/UserProfileSerializer.cs4
3 files changed, 202 insertions, 8 deletions
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
index 3ee9e1b..232ad4e 100644
--- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
@@ -34,16 +34,14 @@ using OpenSim.Framework;
34namespace OpenSim.Framework.Serialization.External 34namespace OpenSim.Framework.Serialization.External
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// Serialize and deserialize region settings for an archive file format. 37 /// Serialize and deserialize region settings as an external format.
38 /// </summary> 38 /// </summary>
39 /// We didn't simply use automatic .NET serializagion for OpenSim.Framework.RegionSettings since this is really
40 /// a file format rather than an object serialization.
41 public class RegionSettingsSerializer 39 public class RegionSettingsSerializer
42 { 40 {
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 41 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44 42
45 /// <summary> 43 /// <summary>
46 /// Deserialize region settings 44 /// Deserialize settings
47 /// </summary> 45 /// </summary>
48 /// <param name="serializedSettings"></param> 46 /// <param name="serializedSettings"></param>
49 /// <returns></returns> 47 /// <returns></returns>
@@ -54,7 +52,7 @@ namespace OpenSim.Framework.Serialization.External
54 } 52 }
55 53
56 /// <summary> 54 /// <summary>
57 /// Deserialize region settings 55 /// Deserialize settings
58 /// </summary> 56 /// </summary>
59 /// <param name="serializedSettings"></param> 57 /// <param name="serializedSettings"></param>
60 /// <returns></returns> 58 /// <returns></returns>
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
new file mode 100644
index 0000000..d51107d
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -0,0 +1,198 @@
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 OpenSim 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.IO;
30using System.Text;
31using System.Xml;
32using OpenMetaverse;
33using OpenSim.Framework;
34
35namespace OpenSim.Framework.Serialization.External
36{
37 /// <summary>
38 /// Serialize and deserialize user inventory items as an external format.
39 /// </summary>
40 /// XXX: Please do not use yet.
41 public class UserInventoryItemSerializer
42 {
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44
45 /// <summary>
46 /// Deserialize item
47 /// </summary>
48 /// <param name="serializedSettings"></param>
49 /// <returns></returns>
50 /// <exception cref="System.Xml.XmlException"></exception>
51 public static InventoryItemBase Deserialize(byte[] serialization)
52 {
53 return Deserialize(m_asciiEncoding.GetString(serialization, 0, serialization.Length));
54 }
55
56 /// <summary>
57 /// Deserialize settings
58 /// </summary>
59 /// <param name="serializedSettings"></param>
60 /// <returns></returns>
61 /// <exception cref="System.Xml.XmlException"></exception>
62 public static InventoryItemBase Deserialize(string serialization)
63 {
64 InventoryItemBase item = new InventoryItemBase();
65
66 StringReader sr = new StringReader(serialization);
67 XmlTextReader reader = new XmlTextReader(sr);
68
69 reader.ReadStartElement("InventoryItem");
70 reader.ReadStartElement("Name");
71 item.Name = reader.ReadString();
72 reader.ReadEndElement();
73 reader.ReadStartElement("ID");
74 item.ID = UUID.Parse(reader.ReadString());
75 reader.ReadEndElement();
76 reader.ReadStartElement("InvType");
77 item.InvType = Convert.ToInt32(reader.ReadString());
78 reader.ReadEndElement();
79 reader.ReadStartElement("CreatorUUID");
80 item.CreatorId = reader.ReadString();
81 reader.ReadEndElement();
82 reader.ReadStartElement("CreationDate");
83 item.CreationDate = Convert.ToInt32(reader.ReadString());
84 reader.ReadEndElement();
85 reader.ReadStartElement("Owner");
86 item.Owner = UUID.Parse(reader.ReadString());
87 reader.ReadEndElement();
88 reader.ReadElementString("Description");
89 reader.ReadStartElement("AssetType");
90 item.AssetType = Convert.ToInt32(reader.ReadString());
91 reader.ReadEndElement();
92 reader.ReadStartElement("AssetID");
93 item.AssetID = UUID.Parse(reader.ReadString());
94 reader.ReadEndElement();
95 reader.ReadStartElement("SaleType");
96 item.SaleType = Convert.ToByte(reader.ReadString());
97 reader.ReadEndElement();
98 reader.ReadStartElement("SalePrice");
99 item.SalePrice = Convert.ToInt32(reader.ReadString());
100 reader.ReadEndElement();
101 reader.ReadStartElement("BasePermissions");
102 item.BasePermissions = Convert.ToUInt32(reader.ReadString());
103 reader.ReadEndElement();
104 reader.ReadStartElement("CurrentPermissions");
105 item.CurrentPermissions = Convert.ToUInt32(reader.ReadString());
106 reader.ReadEndElement();
107 reader.ReadStartElement("EveryOnePermssions");
108 item.EveryOnePermissions = Convert.ToUInt32(reader.ReadString());
109 reader.ReadEndElement();
110 reader.ReadStartElement("NextPermissions");
111 item.NextPermissions = Convert.ToUInt32(reader.ReadString());
112 reader.ReadEndElement();
113 reader.ReadStartElement("Flags");
114 item.Flags = Convert.ToUInt32(reader.ReadString());
115 reader.ReadEndElement();
116 reader.ReadStartElement("GroupID");
117 item.GroupID = UUID.Parse(reader.ReadString());
118 reader.ReadEndElement();
119 reader.ReadStartElement("GroupOwned");
120 item.GroupOwned = Convert.ToBoolean(reader.ReadString());
121 reader.ReadEndElement();
122
123 return item;
124 }
125
126 public static string Serialize(InventoryItemBase inventoryItem)
127 {
128 StringWriter sw = new StringWriter();
129 XmlTextWriter writer = new XmlTextWriter(sw);
130 writer.Formatting = Formatting.Indented;
131 writer.WriteStartDocument();
132
133 writer.WriteStartElement("InventoryItem");
134
135 writer.WriteStartElement("Name");
136 writer.WriteString(inventoryItem.Name);
137 writer.WriteEndElement();
138 writer.WriteStartElement("ID");
139 writer.WriteString(inventoryItem.ID.ToString());
140 writer.WriteEndElement();
141 writer.WriteStartElement("InvType");
142 writer.WriteString(inventoryItem.InvType.ToString());
143 writer.WriteEndElement();
144 writer.WriteStartElement("CreatorUUID");
145 writer.WriteString(inventoryItem.CreatorId);
146 writer.WriteEndElement();
147 writer.WriteStartElement("CreationDate");
148 writer.WriteString(inventoryItem.CreationDate.ToString());
149 writer.WriteEndElement();
150 writer.WriteStartElement("Owner");
151 writer.WriteString(inventoryItem.Owner.ToString());
152 writer.WriteEndElement();
153 writer.WriteStartElement("Description");
154 writer.WriteString(inventoryItem.Description);
155 writer.WriteEndElement();
156 writer.WriteStartElement("AssetType");
157 writer.WriteString(inventoryItem.AssetType.ToString());
158 writer.WriteEndElement();
159 writer.WriteStartElement("AssetID");
160 writer.WriteString(inventoryItem.AssetID.ToString());
161 writer.WriteEndElement();
162 writer.WriteStartElement("SaleType");
163 writer.WriteString(inventoryItem.SaleType.ToString());
164 writer.WriteEndElement();
165 writer.WriteStartElement("SalePrice");
166 writer.WriteString(inventoryItem.SalePrice.ToString());
167 writer.WriteEndElement();
168 writer.WriteStartElement("BasePermissions");
169 writer.WriteString(inventoryItem.BasePermissions.ToString());
170 writer.WriteEndElement();
171 writer.WriteStartElement("CurrentPermissions");
172 writer.WriteString(inventoryItem.CurrentPermissions.ToString());
173 writer.WriteEndElement();
174 writer.WriteStartElement("EveryOnePermssions");
175 writer.WriteString(inventoryItem.EveryOnePermissions.ToString());
176 writer.WriteEndElement();
177 writer.WriteStartElement("NextPermissions");
178 writer.WriteString(inventoryItem.NextPermissions.ToString());
179 writer.WriteEndElement();
180 writer.WriteStartElement("Flags");
181 writer.WriteString(inventoryItem.Flags.ToString());
182 writer.WriteEndElement();
183 writer.WriteStartElement("GroupID");
184 writer.WriteString(inventoryItem.GroupID.ToString());
185 writer.WriteEndElement();
186 writer.WriteStartElement("GroupOwned");
187 writer.WriteString(inventoryItem.GroupOwned.ToString());
188 writer.WriteEndElement();
189
190 writer.WriteEndElement();
191
192 writer.Close();
193 sw.Close();
194
195 return sw.ToString();
196 }
197 }
198}
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
index 544d13d..6bf56c2 100644
--- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
@@ -33,10 +33,8 @@ using OpenSim.Framework;
33namespace OpenSim.Framework.Serialization.External 33namespace OpenSim.Framework.Serialization.External
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Serialize and deserialize region settings for an archive file format. 36 /// Serialize and deserialize region settings as an external format.
37 /// </summary> 37 /// </summary>
38 /// We didn't use automatic .NET serialization since this is really
39 /// a file format rather than an object serialization.
40 public class UserProfileSerializer 38 public class UserProfileSerializer
41 { 39 {
42 public const int MAJOR_VERSION = 0; 40 public const int MAJOR_VERSION = 0;