diff options
Diffstat (limited to 'OpenSim/Framework')
9 files changed, 370 insertions, 111 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index c4c61ff..5e156f1 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -1243,7 +1243,7 @@ namespace OpenSim.Framework | |||
1243 | void SendEstateCovenantInformation(UUID covenant); | 1243 | void SendEstateCovenantInformation(UUID covenant); |
1244 | 1244 | ||
1245 | void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, | 1245 | void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, |
1246 | uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner); | 1246 | uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner); |
1247 | 1247 | ||
1248 | /// <summary> | 1248 | /// <summary> |
1249 | /// Send land properties to the client. | 1249 | /// Send land properties to the client. |
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index 27fadfa..9a9a6bf 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs | |||
@@ -34,7 +34,7 @@ using OpenMetaverse; | |||
34 | 34 | ||
35 | namespace OpenSim.Framework | 35 | namespace OpenSim.Framework |
36 | { | 36 | { |
37 | public struct LandAccessEntry | 37 | public class LandAccessEntry |
38 | { | 38 | { |
39 | public UUID AgentID; | 39 | public UUID AgentID; |
40 | public int Expires; | 40 | public int Expires; |
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index e668ad5..c142bd9 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs | |||
@@ -413,6 +413,14 @@ namespace OpenSim.Framework | |||
413 | set { m_Covenant = value; } | 413 | set { m_Covenant = value; } |
414 | } | 414 | } |
415 | 415 | ||
416 | private int m_CovenantChanged = 0; | ||
417 | |||
418 | public int CovenantChangedDateTime | ||
419 | { | ||
420 | get { return m_CovenantChanged; } | ||
421 | set { m_CovenantChanged = value; } | ||
422 | } | ||
423 | |||
416 | private int m_LoadedCreationDateTime; | 424 | private int m_LoadedCreationDateTime; |
417 | public int LoadedCreationDateTime | 425 | public int LoadedCreationDateTime |
418 | { | 426 | { |
@@ -514,4 +522,4 @@ namespace OpenSim.Framework | |||
514 | l_SpawnPoints.Clear(); | 522 | l_SpawnPoints.Clear(); |
515 | } | 523 | } |
516 | } | 524 | } |
517 | } | 525 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index 7447ac2..a392af6 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs | |||
@@ -24,11 +24,13 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | |||
27 | using System; | 28 | using System; |
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | ||
30 | using System.Xml; | 32 | using System.Xml; |
31 | 33 | using log4net; | |
32 | using OpenMetaverse; | 34 | using OpenMetaverse; |
33 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
34 | 36 | ||
@@ -39,6 +41,74 @@ namespace OpenSim.Framework.Serialization.External | |||
39 | /// </summary> | 41 | /// </summary> |
40 | public class ExternalRepresentationUtils | 42 | public class ExternalRepresentationUtils |
41 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | /// <summary> | ||
47 | /// Populate a node with data read from xml using a dictinoary of processors | ||
48 | /// </summary> | ||
49 | /// <param name="nodeToFill"></param> | ||
50 | /// <param name="processors">/param> | ||
51 | /// <param name="xtr"></param> | ||
52 | public static void ExecuteReadProcessors<NodeType>( | ||
53 | NodeType nodeToFill, Dictionary<string, Action<NodeType, XmlTextReader>> processors, XmlTextReader xtr) | ||
54 | { | ||
55 | ExecuteReadProcessors( | ||
56 | nodeToFill, | ||
57 | processors, | ||
58 | xtr, | ||
59 | (o, name, e) | ||
60 | => m_log.ErrorFormat( | ||
61 | "[ExternalRepresentationUtils]: Exception while parsing element {0}, continuing. Exception {1}{2}", | ||
62 | name, e.Message, e.StackTrace)); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Populate a node with data read from xml using a dictinoary of processors | ||
67 | /// </summary> | ||
68 | /// <param name="nodeToFill"></param> | ||
69 | /// <param name="processors"></param> | ||
70 | /// <param name="xtr"></param> | ||
71 | /// <param name="parseExceptionAction"> | ||
72 | /// Action to take if there is a parsing problem. This will usually just be to log the exception | ||
73 | /// </param> | ||
74 | public static void ExecuteReadProcessors<NodeType>( | ||
75 | NodeType nodeToFill, | ||
76 | Dictionary<string, Action<NodeType, XmlTextReader>> processors, | ||
77 | XmlTextReader xtr, | ||
78 | Action<NodeType, string, Exception> parseExceptionAction) | ||
79 | { | ||
80 | string nodeName = string.Empty; | ||
81 | while (xtr.NodeType != XmlNodeType.EndElement) | ||
82 | { | ||
83 | nodeName = xtr.Name; | ||
84 | |||
85 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); | ||
86 | |||
87 | Action<NodeType, XmlTextReader> p = null; | ||
88 | if (processors.TryGetValue(xtr.Name, out p)) | ||
89 | { | ||
90 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); | ||
91 | |||
92 | try | ||
93 | { | ||
94 | p(nodeToFill, xtr); | ||
95 | } | ||
96 | catch (Exception e) | ||
97 | { | ||
98 | parseExceptionAction(nodeToFill, nodeName, e); | ||
99 | |||
100 | if (xtr.NodeType == XmlNodeType.EndElement) | ||
101 | xtr.Read(); | ||
102 | } | ||
103 | } | ||
104 | else | ||
105 | { | ||
106 | // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); | ||
107 | xtr.ReadOuterXml(); // ignore | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
42 | /// <summary> | 112 | /// <summary> |
43 | /// Takes a XML representation of a SceneObjectPart and returns another XML representation | 113 | /// Takes a XML representation of a SceneObjectPart and returns another XML representation |
44 | /// with creator data added to it. | 114 | /// with creator data added to it. |
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index 3ae9a8e..a12877a 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |||
@@ -28,8 +28,10 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | ||
31 | using System.Text; | 32 | using System.Text; |
32 | using System.Xml; | 33 | using System.Xml; |
34 | using log4net; | ||
33 | using OpenMetaverse; | 35 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
35 | 37 | ||
@@ -40,8 +42,119 @@ namespace OpenSim.Framework.Serialization.External | |||
40 | /// </summary> | 42 | /// </summary> |
41 | public class LandDataSerializer | 43 | public class LandDataSerializer |
42 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
43 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); | 47 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); |
44 | 48 | ||
49 | private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors | ||
50 | = new Dictionary<string, Action<LandData, XmlTextReader>>(); | ||
51 | |||
52 | private static Dictionary<string, Action<LandAccessEntry, XmlTextReader>> m_laeProcessors | ||
53 | = new Dictionary<string, Action<LandAccessEntry, XmlTextReader>>(); | ||
54 | |||
55 | static LandDataSerializer() | ||
56 | { | ||
57 | // LandData processors | ||
58 | m_ldProcessors.Add( | ||
59 | "Area", (ld, xtr) => ld.Area = Convert.ToInt32(xtr.ReadElementString("Area"))); | ||
60 | m_ldProcessors.Add( | ||
61 | "AuctionID", (ld, xtr) => ld.AuctionID = Convert.ToUInt32(xtr.ReadElementString("AuctionID"))); | ||
62 | m_ldProcessors.Add( | ||
63 | "AuthBuyerID", (ld, xtr) => ld.AuthBuyerID = UUID.Parse(xtr.ReadElementString("AuthBuyerID"))); | ||
64 | m_ldProcessors.Add( | ||
65 | "Category", (ld, xtr) => ld.Category = (ParcelCategory)Convert.ToSByte(xtr.ReadElementString("Category"))); | ||
66 | m_ldProcessors.Add( | ||
67 | "ClaimDate", (ld, xtr) => ld.ClaimDate = Convert.ToInt32(xtr.ReadElementString("ClaimDate"))); | ||
68 | m_ldProcessors.Add( | ||
69 | "ClaimPrice", (ld, xtr) => ld.ClaimPrice = Convert.ToInt32(xtr.ReadElementString("ClaimPrice"))); | ||
70 | m_ldProcessors.Add( | ||
71 | "GlobalID", (ld, xtr) => ld.GlobalID = UUID.Parse(xtr.ReadElementString("GlobalID"))); | ||
72 | m_ldProcessors.Add( | ||
73 | "GroupID", (ld, xtr) => ld.GroupID = UUID.Parse(xtr.ReadElementString("GroupID"))); | ||
74 | m_ldProcessors.Add( | ||
75 | "IsGroupOwned", (ld, xtr) => ld.IsGroupOwned = Convert.ToBoolean(xtr.ReadElementString("IsGroupOwned"))); | ||
76 | m_ldProcessors.Add( | ||
77 | "Bitmap", (ld, xtr) => ld.Bitmap = Convert.FromBase64String(xtr.ReadElementString("Bitmap"))); | ||
78 | m_ldProcessors.Add( | ||
79 | "Description", (ld, xtr) => ld.Description = xtr.ReadElementString("Description")); | ||
80 | m_ldProcessors.Add( | ||
81 | "Flags", (ld, xtr) => ld.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags"))); | ||
82 | m_ldProcessors.Add( | ||
83 | "LandingType", (ld, xtr) => ld.LandingType = Convert.ToByte(xtr.ReadElementString("LandingType"))); | ||
84 | m_ldProcessors.Add( | ||
85 | "Name", (ld, xtr) => ld.Name = xtr.ReadElementString("Name")); | ||
86 | m_ldProcessors.Add( | ||
87 | "Status", (ld, xtr) => ld.Status = (ParcelStatus)Convert.ToSByte(xtr.ReadElementString("Status"))); | ||
88 | m_ldProcessors.Add( | ||
89 | "LocalID", (ld, xtr) => ld.LocalID = Convert.ToInt32(xtr.ReadElementString("LocalID"))); | ||
90 | m_ldProcessors.Add( | ||
91 | "MediaAutoScale", (ld, xtr) => ld.MediaAutoScale = Convert.ToByte(xtr.ReadElementString("MediaAutoScale"))); | ||
92 | m_ldProcessors.Add( | ||
93 | "MediaID", (ld, xtr) => ld.MediaID = UUID.Parse(xtr.ReadElementString("MediaID"))); | ||
94 | m_ldProcessors.Add( | ||
95 | "MediaURL", (ld, xtr) => ld.MediaURL = xtr.ReadElementString("MediaURL")); | ||
96 | m_ldProcessors.Add( | ||
97 | "MusicURL", (ld, xtr) => ld.MusicURL = xtr.ReadElementString("MusicURL")); | ||
98 | |||
99 | m_ldProcessors.Add( | ||
100 | "ParcelAccessList", ProcessParcelAccessList); | ||
101 | |||
102 | m_ldProcessors.Add( | ||
103 | "PassHours", (ld, xtr) => ld.PassHours = Convert.ToSingle(xtr.ReadElementString("PassHours"))); | ||
104 | m_ldProcessors.Add( | ||
105 | "PassPrice", (ld, xtr) => ld.PassPrice = Convert.ToInt32(xtr.ReadElementString("PassPrice"))); | ||
106 | m_ldProcessors.Add( | ||
107 | "SalePrice", (ld, xtr) => ld.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice"))); | ||
108 | m_ldProcessors.Add( | ||
109 | "SnapshotID", (ld, xtr) => ld.SnapshotID = UUID.Parse(xtr.ReadElementString("SnapshotID"))); | ||
110 | m_ldProcessors.Add( | ||
111 | "UserLocation", (ld, xtr) => ld.UserLocation = Vector3.Parse(xtr.ReadElementString("UserLocation"))); | ||
112 | m_ldProcessors.Add( | ||
113 | "UserLookAt", (ld, xtr) => ld.UserLookAt = Vector3.Parse(xtr.ReadElementString("UserLookAt"))); | ||
114 | |||
115 | // No longer used here // | ||
116 | // m_ldProcessors.Add("Dwell", (landData, xtr) => return); | ||
117 | |||
118 | m_ldProcessors.Add( | ||
119 | "OtherCleanTime", (ld, xtr) => ld.OtherCleanTime = Convert.ToInt32(xtr.ReadElementString("OtherCleanTime"))); | ||
120 | |||
121 | // LandAccessEntryProcessors | ||
122 | m_laeProcessors.Add( | ||
123 | "AgentID", (lae, xtr) => lae.AgentID = UUID.Parse(xtr.ReadElementString("AgentID"))); | ||
124 | m_laeProcessors.Add( | ||
125 | "Time", (lae, xtr) => | ||
126 | { | ||
127 | // We really don't care about temp vs perm here and this | ||
128 | // would break on old oars. Assume all bans are perm | ||
129 | xtr.ReadElementString("Time"); | ||
130 | lae.Expires = 0; // Convert.ToUint( xtr.ReadElementString("Time")); | ||
131 | } | ||
132 | ); | ||
133 | m_laeProcessors.Add( | ||
134 | "AccessList", (lae, xtr) => lae.Flags = (AccessList)Convert.ToUInt32(xtr.ReadElementString("AccessList"))); | ||
135 | } | ||
136 | |||
137 | public static void ProcessParcelAccessList(LandData ld, XmlTextReader xtr) | ||
138 | { | ||
139 | if (!xtr.IsEmptyElement) | ||
140 | { | ||
141 | while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) | ||
142 | { | ||
143 | LandAccessEntry lae = new LandAccessEntry(); | ||
144 | |||
145 | xtr.ReadStartElement("ParcelAccessEntry"); | ||
146 | |||
147 | ExternalRepresentationUtils.ExecuteReadProcessors<LandAccessEntry>(lae, m_laeProcessors, xtr); | ||
148 | |||
149 | xtr.ReadEndElement(); | ||
150 | |||
151 | ld.ParcelAccessList.Add(lae); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | xtr.Read(); | ||
156 | } | ||
157 | |||
45 | /// <summary> | 158 | /// <summary> |
46 | /// Reify/deserialize landData | 159 | /// Reify/deserialize landData |
47 | /// </summary> | 160 | /// </summary> |
@@ -63,72 +176,14 @@ namespace OpenSim.Framework.Serialization.External | |||
63 | { | 176 | { |
64 | LandData landData = new LandData(); | 177 | LandData landData = new LandData(); |
65 | 178 | ||
66 | StringReader sr = new StringReader(serializedLandData); | 179 | using (XmlTextReader reader = new XmlTextReader(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<LandAccessEntry>(); | ||
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 | { | 180 | { |
100 | while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) | 181 | reader.ReadStartElement("LandData"); |
101 | { | ||
102 | LandAccessEntry pae = new LandAccessEntry(); | ||
103 | 182 | ||
104 | xtr.ReadStartElement("ParcelAccessEntry"); | 183 | ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader); |
105 | pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID")); | ||
106 | // We really don't care about temp vs perm here and this | ||
107 | // would break on old oars. Assume all bans are perm | ||
108 | xtr.ReadElementString("Time"); | ||
109 | pae.Expires = 0; // Convert.ToUint( xtr.ReadElementString("Time")); | ||
110 | pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList")); | ||
111 | xtr.ReadEndElement(); | ||
112 | 184 | ||
113 | landData.ParcelAccessList.Add(pae); | 185 | reader.ReadEndElement(); |
114 | } | ||
115 | } | 186 | } |
116 | xtr.Read(); | ||
117 | |||
118 | landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours")); | ||
119 | landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice")); | ||
120 | landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice")); | ||
121 | landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID")); | ||
122 | landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation")); | ||
123 | landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt")); | ||
124 | // No longer used here | ||
125 | xtr.ReadElementString("Dwell"); | ||
126 | landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime")); | ||
127 | |||
128 | xtr.ReadEndElement(); | ||
129 | |||
130 | xtr.Close(); | ||
131 | sr.Close(); | ||
132 | 187 | ||
133 | return landData; | 188 | return landData; |
134 | } | 189 | } |
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index f138437..57da7ca 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |||
@@ -41,14 +41,13 @@ namespace OpenSim.Framework.Serialization.External | |||
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Serialize and deserialize user inventory items as an external format. | 43 | /// Serialize and deserialize user inventory items as an external format. |
44 | /// </summary> | 44 | /// </summary> |
45 | /// XXX: Please do not use yet. | ||
46 | public class UserInventoryItemSerializer | 45 | public class UserInventoryItemSerializer |
47 | { | 46 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 48 | ||
50 | private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader); | 49 | private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors |
51 | private static Dictionary<string, InventoryItemXmlProcessor> m_InventoryItemXmlProcessors = new Dictionary<string, InventoryItemXmlProcessor>(); | 50 | = new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>(); |
52 | 51 | ||
53 | #region InventoryItemBase Processor initialization | 52 | #region InventoryItemBase Processor initialization |
54 | static UserInventoryItemSerializer() | 53 | static UserInventoryItemSerializer() |
@@ -205,39 +204,14 @@ namespace OpenSim.Framework.Serialization.External | |||
205 | { | 204 | { |
206 | reader.ReadStartElement("InventoryItem"); | 205 | reader.ReadStartElement("InventoryItem"); |
207 | 206 | ||
208 | string nodeName = string.Empty; | 207 | ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>( |
209 | while (reader.NodeType != XmlNodeType.EndElement) | 208 | item, m_InventoryItemXmlProcessors, reader); |
210 | { | ||
211 | nodeName = reader.Name; | ||
212 | InventoryItemXmlProcessor p = null; | ||
213 | if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p)) | ||
214 | { | ||
215 | //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name); | ||
216 | try | ||
217 | { | ||
218 | p(item, reader); | ||
219 | } | ||
220 | catch (Exception e) | ||
221 | { | ||
222 | m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e); | ||
223 | if (reader.NodeType == XmlNodeType.EndElement) | ||
224 | reader.Read(); | ||
225 | } | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName); | ||
230 | reader.ReadOuterXml(); // ignore | ||
231 | } | ||
232 | |||
233 | } | ||
234 | 209 | ||
235 | reader.ReadEndElement(); // InventoryItem | 210 | reader.ReadEndElement(); // InventoryItem |
236 | } | 211 | } |
237 | 212 | ||
238 | //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); | 213 | //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); |
239 | return item; | 214 | return item; |
240 | |||
241 | } | 215 | } |
242 | 216 | ||
243 | public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService) | 217 | public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService) |
@@ -305,14 +279,14 @@ namespace OpenSim.Framework.Serialization.External | |||
305 | writer.WriteEndElement(); | 279 | writer.WriteEndElement(); |
306 | if (options.ContainsKey("creators") && inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty) | 280 | if (options.ContainsKey("creators") && inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty) |
307 | writer.WriteElementString("CreatorData", inventoryItem.CreatorData); | 281 | writer.WriteElementString("CreatorData", inventoryItem.CreatorData); |
308 | else if (options.ContainsKey("profile")) | 282 | else if (options.ContainsKey("home")) |
309 | { | 283 | { |
310 | if (userAccountService != null) | 284 | if (userAccountService != null) |
311 | { | 285 | { |
312 | UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid); | 286 | UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid); |
313 | if (account != null) | 287 | if (account != null) |
314 | { | 288 | { |
315 | writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName); | 289 | writer.WriteElementString("CreatorData", (string)options["home"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName); |
316 | } | 290 | } |
317 | writer.WriteElementString("CreatorID", inventoryItem.CreatorId); | 291 | writer.WriteElementString("CreatorID", inventoryItem.CreatorId); |
318 | } | 292 | } |
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs index f50b49a..c685a15 100644 --- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs | |||
@@ -33,8 +33,11 @@ using OpenSim.Framework; | |||
33 | namespace OpenSim.Framework.Serialization.External | 33 | namespace OpenSim.Framework.Serialization.External |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// Serialize and deserialize region settings as an external format. | 36 | /// Serialize and deserialize user profiles as an external format. |
37 | /// </summary> | 37 | /// </summary> |
38 | /// <remarks> | ||
39 | /// Currently UNUSED. | ||
40 | /// </remarks> | ||
38 | public class UserProfileSerializer | 41 | public class UserProfileSerializer |
39 | { | 42 | { |
40 | public const int MAJOR_VERSION = 0; | 43 | public const int MAJOR_VERSION = 0; |
diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index 3607ce8..b8ed9e1 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs | |||
@@ -27,11 +27,12 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Framework.Serialization.External; | ||
32 | using OpenMetaverse; | 30 | using OpenMetaverse; |
33 | using OpenMetaverse.StructuredData; | 31 | using OpenMetaverse.StructuredData; |
34 | using NUnit.Framework; | 32 | using NUnit.Framework; |
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Serialization.External; | ||
35 | using OpenSim.Tests.Common; | ||
35 | 36 | ||
36 | namespace OpenSim.Framework.Serialization.Tests | 37 | namespace OpenSim.Framework.Serialization.Tests |
37 | { | 38 | { |
@@ -92,6 +93,8 @@ namespace OpenSim.Framework.Serialization.Tests | |||
92 | [Test] | 93 | [Test] |
93 | public void LandDataSerializerSerializeTest() | 94 | public void LandDataSerializerSerializeTest() |
94 | { | 95 | { |
96 | TestHelpers.InMethod(); | ||
97 | |||
95 | string serialized = LandDataSerializer.Serialize(this.land).Replace("\r\n", "\n"); | 98 | string serialized = LandDataSerializer.Serialize(this.land).Replace("\r\n", "\n"); |
96 | Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string"); | 99 | Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string"); |
97 | 100 | ||
@@ -112,20 +115,32 @@ namespace OpenSim.Framework.Serialization.Tests | |||
112 | /// Test the LandDataSerializer.Deserialize() method | 115 | /// Test the LandDataSerializer.Deserialize() method |
113 | /// </summary> | 116 | /// </summary> |
114 | [Test] | 117 | [Test] |
115 | public void TestLandDataSerializerDeserializeFromStringTest() | 118 | public void TestLandDataDeserializeNoAccessLists() |
119 | { | ||
120 | TestHelpers.InMethod(); | ||
121 | // log4net.Config.XmlConfigurator.Configure(); | ||
122 | |||
123 | LandData ld = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized); | ||
124 | Assert.That(ld != null, "Deserialize(string) returned null"); | ||
125 | Assert.That(ld.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID"); | ||
126 | Assert.That(ld.Name == this.land.Name, "Reified LandData.Name != original LandData.Name"); | ||
127 | } | ||
128 | |||
129 | [Test] | ||
130 | public void TestLandDataDeserializeWithAccessLists() | ||
116 | { | 131 | { |
117 | LandData reifiedLandData = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized); | 132 | TestHelpers.InMethod(); |
118 | Assert.That(reifiedLandData != null, "Deserialize(string) returned null"); | 133 | // log4net.Config.XmlConfigurator.Configure(); |
119 | Assert.That(reifiedLandData.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID"); | ||
120 | Assert.That(reifiedLandData.Name == this.land.Name, "Reified LandData.Name != original LandData.Name"); | ||
121 | 134 | ||
122 | LandData reifiedLandDataWithParcelAccessList = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerializedWithParcelAccessList); | 135 | LandData ld = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerializedWithParcelAccessList); |
123 | Assert.That(reifiedLandDataWithParcelAccessList != null, | 136 | Assert.That(ld != null, |
124 | "Deserialize(string) returned null (pre-serialized with parcel access list)"); | 137 | "Deserialize(string) returned null (pre-serialized with parcel access list)"); |
125 | Assert.That(reifiedLandDataWithParcelAccessList.GlobalID == this.landWithParcelAccessList.GlobalID, | 138 | Assert.That(ld.GlobalID == this.landWithParcelAccessList.GlobalID, |
126 | "Reified LandData.GlobalID != original LandData.GlobalID (pre-serialized with parcel access list)"); | 139 | "Reified LandData.GlobalID != original LandData.GlobalID (pre-serialized with parcel access list)"); |
127 | Assert.That(reifiedLandDataWithParcelAccessList.Name == this.landWithParcelAccessList.Name, | 140 | Assert.That(ld.Name == this.landWithParcelAccessList.Name, |
128 | "Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)"); | 141 | "Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)"); |
142 | Assert.That(ld.ParcelAccessList.Count, Is.EqualTo(2)); | ||
143 | Assert.That(ld.ParcelAccessList[0].AgentID, Is.EqualTo(UUID.Parse("62d65d45-c91a-4f77-862c-46557d978b6c"))); | ||
129 | } | 144 | } |
130 | } | 145 | } |
131 | } | 146 | } |
diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs new file mode 100644 index 0000000..a61e4af --- /dev/null +++ b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs | |||
@@ -0,0 +1,134 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.StructuredData; | ||
32 | using NUnit.Framework; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Serialization.External; | ||
35 | using OpenSim.Tests.Common; | ||
36 | |||
37 | namespace OpenSim.Framework.Serialization.Tests | ||
38 | { | ||
39 | [TestFixture] | ||
40 | public class RegionSettingsSerializerTests | ||
41 | { | ||
42 | private string m_serializedRs = @"<?xml version=""1.0"" encoding=""utf-16""?> | ||
43 | <RegionSettings> | ||
44 | <General> | ||
45 | <AllowDamage>True</AllowDamage> | ||
46 | <AllowLandResell>True</AllowLandResell> | ||
47 | <AllowLandJoinDivide>True</AllowLandJoinDivide> | ||
48 | <BlockFly>True</BlockFly> | ||
49 | <BlockLandShowInSearch>True</BlockLandShowInSearch> | ||
50 | <BlockTerraform>True</BlockTerraform> | ||
51 | <DisableCollisions>True</DisableCollisions> | ||
52 | <DisablePhysics>True</DisablePhysics> | ||
53 | <DisableScripts>True</DisableScripts> | ||
54 | <MaturityRating>1</MaturityRating> | ||
55 | <RestrictPushing>True</RestrictPushing> | ||
56 | <AgentLimit>40</AgentLimit> | ||
57 | <ObjectBonus>1.4</ObjectBonus> | ||
58 | </General> | ||
59 | <GroundTextures> | ||
60 | <Texture1>00000000-0000-0000-0000-000000000020</Texture1> | ||
61 | <Texture2>00000000-0000-0000-0000-000000000040</Texture2> | ||
62 | <Texture3>00000000-0000-0000-0000-000000000060</Texture3> | ||
63 | <Texture4>00000000-0000-0000-0000-000000000080</Texture4> | ||
64 | <ElevationLowSW>1.9</ElevationLowSW> | ||
65 | <ElevationLowNW>15.9</ElevationLowNW> | ||
66 | <ElevationLowSE>49</ElevationLowSE> | ||
67 | <ElevationLowNE>45.3</ElevationLowNE> | ||
68 | <ElevationHighSW>2.1</ElevationHighSW> | ||
69 | <ElevationHighNW>4.5</ElevationHighNW> | ||
70 | <ElevationHighSE>9.2</ElevationHighSE> | ||
71 | <ElevationHighNE>19.2</ElevationHighNE> | ||
72 | </GroundTextures> | ||
73 | <Terrain> | ||
74 | <WaterHeight>23</WaterHeight> | ||
75 | <TerrainRaiseLimit>17.9</TerrainRaiseLimit> | ||
76 | <TerrainLowerLimit>0.4</TerrainLowerLimit> | ||
77 | <UseEstateSun>True</UseEstateSun> | ||
78 | <FixedSun>true</FixedSun> | ||
79 | <SunPosition>12</SunPosition> | ||
80 | </Terrain> | ||
81 | </RegionSettings>"; | ||
82 | |||
83 | private RegionSettings m_rs; | ||
84 | |||
85 | [SetUp] | ||
86 | public void Setup() | ||
87 | { | ||
88 | m_rs = new RegionSettings(); | ||
89 | m_rs.AgentLimit = 17; | ||
90 | m_rs.AllowDamage = true; | ||
91 | m_rs.AllowLandJoinDivide = true; | ||
92 | m_rs.AllowLandResell = true; | ||
93 | m_rs.BlockFly = true; | ||
94 | m_rs.BlockShowInSearch = true; | ||
95 | m_rs.BlockTerraform = true; | ||
96 | m_rs.DisableCollisions = true; | ||
97 | m_rs.DisablePhysics = true; | ||
98 | m_rs.DisableScripts = true; | ||
99 | m_rs.Elevation1NW = 15.9; | ||
100 | m_rs.Elevation1NE = 45.3; | ||
101 | m_rs.Elevation1SE = 49; | ||
102 | m_rs.Elevation1SW = 1.9; | ||
103 | m_rs.Elevation2NW = 4.5; | ||
104 | m_rs.Elevation2NE = 19.2; | ||
105 | m_rs.Elevation2SE = 9.2; | ||
106 | m_rs.Elevation2SW = 2.1; | ||
107 | m_rs.FixedSun = true; | ||
108 | m_rs.SunPosition = 12.0; | ||
109 | m_rs.ObjectBonus = 1.4; | ||
110 | m_rs.RestrictPushing = true; | ||
111 | m_rs.TerrainLowerLimit = 0.4; | ||
112 | m_rs.TerrainRaiseLimit = 17.9; | ||
113 | m_rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
114 | m_rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
115 | m_rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
116 | m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
117 | m_rs.UseEstateSun = true; | ||
118 | m_rs.WaterHeight = 23; | ||
119 | } | ||
120 | |||
121 | [Test] | ||
122 | public void TestRegionSettingsDeserialize() | ||
123 | { | ||
124 | TestHelpers.InMethod(); | ||
125 | // log4net.Config.XmlConfigurator.Configure(); | ||
126 | |||
127 | RegionSettings deserRs = RegionSettingsSerializer.Deserialize(m_serializedRs); | ||
128 | Assert.That(deserRs, Is.Not.Null); | ||
129 | Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2)); | ||
130 | Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics)); | ||
131 | Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit)); | ||
132 | } | ||
133 | } | ||
134 | } | ||