aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs198
-rw-r--r--OpenSim/Framework/Util.cs61
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs122
3 files changed, 260 insertions, 121 deletions
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index 862cc72..df9af32 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -26,9 +26,13 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.IO; 30using System.IO;
31using System.Reflection;
30using System.Text; 32using System.Text;
31using System.Xml; 33using System.Xml;
34
35using log4net;
32using OpenMetaverse; 36using OpenMetaverse;
33using OpenSim.Framework; 37using OpenSim.Framework;
34 38
@@ -40,6 +44,133 @@ namespace OpenSim.Framework.Serialization.External
40 /// XXX: Please do not use yet. 44 /// XXX: Please do not use yet.
41 public class UserInventoryItemSerializer 45 public class UserInventoryItemSerializer
42 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader);
50 private static Dictionary<string, InventoryItemXmlProcessor> m_InventoryItemXmlProcessors = new Dictionary<string, InventoryItemXmlProcessor>();
51
52 #region InventoryItemBase Processor initialization
53 static UserInventoryItemSerializer()
54 {
55 m_InventoryItemXmlProcessors.Add("Name", ProcessName);
56 m_InventoryItemXmlProcessors.Add("ID", ProcessID);
57 m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType);
58 m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID);
59 m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate);
60 m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner);
61 m_InventoryItemXmlProcessors.Add("Description", ProcessDescription);
62 m_InventoryItemXmlProcessors.Add("AssetType", ProcessAssetType);
63 m_InventoryItemXmlProcessors.Add("AssetID", ProcessAssetID);
64 m_InventoryItemXmlProcessors.Add("SaleType", ProcessSaleType);
65 m_InventoryItemXmlProcessors.Add("SalePrice", ProcessSalePrice);
66 m_InventoryItemXmlProcessors.Add("BasePermissions", ProcessBasePermissions);
67 m_InventoryItemXmlProcessors.Add("CurrentPermissions", ProcessCurrentPermissions);
68 m_InventoryItemXmlProcessors.Add("EveryOnePermissions", ProcessEveryOnePermissions);
69 m_InventoryItemXmlProcessors.Add("NextPermissions", ProcessNextPermissions);
70 m_InventoryItemXmlProcessors.Add("Flags", ProcessFlags);
71 m_InventoryItemXmlProcessors.Add("GroupID", ProcessGroupID);
72 m_InventoryItemXmlProcessors.Add("GroupOwned", ProcessGroupOwned);
73 }
74 #endregion
75
76 #region InventoryItemBase Processors
77 private static void ProcessName(InventoryItemBase item, XmlTextReader reader)
78 {
79 item.Name = reader.ReadElementContentAsString("Name", String.Empty);
80 }
81
82 private static void ProcessID(InventoryItemBase item, XmlTextReader reader)
83 {
84 item.ID = Util.ReadUUID(reader, "ID");
85 }
86
87 private static void ProcessInvType(InventoryItemBase item, XmlTextReader reader)
88 {
89 item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty);
90 }
91
92 private static void ProcessCreatorUUID(InventoryItemBase item, XmlTextReader reader)
93 {
94 item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty);
95 }
96
97 private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader)
98 {
99 item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
100 }
101
102 private static void ProcessOwner(InventoryItemBase item, XmlTextReader reader)
103 {
104 item.Owner = Util.ReadUUID(reader, "Owner");
105 }
106
107 private static void ProcessDescription(InventoryItemBase item, XmlTextReader reader)
108 {
109 item.Description = reader.ReadElementContentAsString("Description", String.Empty);
110 }
111
112 private static void ProcessAssetType(InventoryItemBase item, XmlTextReader reader)
113 {
114 item.AssetType = reader.ReadElementContentAsInt("AssetType", String.Empty);
115 }
116
117 private static void ProcessAssetID(InventoryItemBase item, XmlTextReader reader)
118 {
119 item.AssetID = Util.ReadUUID(reader, "AssetID");
120 }
121
122 private static void ProcessSaleType(InventoryItemBase item, XmlTextReader reader)
123 {
124 item.SaleType = (byte)reader.ReadElementContentAsInt("SaleType", String.Empty);
125 }
126
127 private static void ProcessSalePrice(InventoryItemBase item, XmlTextReader reader)
128 {
129 item.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
130 }
131
132 private static void ProcessBasePermissions(InventoryItemBase item, XmlTextReader reader)
133 {
134 item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
135 }
136
137 private static void ProcessCurrentPermissions(InventoryItemBase item, XmlTextReader reader)
138 {
139 item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
140 }
141
142 private static void ProcessEveryOnePermissions(InventoryItemBase item, XmlTextReader reader)
143 {
144 item.EveryOnePermissions = (uint)reader.ReadElementContentAsInt("EveryOnePermissions", String.Empty);
145 }
146
147 private static void ProcessNextPermissions(InventoryItemBase item, XmlTextReader reader)
148 {
149 item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
150 }
151
152 private static void ProcessFlags(InventoryItemBase item, XmlTextReader reader)
153 {
154 item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty);
155 }
156
157 private static void ProcessGroupID(InventoryItemBase item, XmlTextReader reader)
158 {
159 item.GroupID = Util.ReadUUID(reader, "GroupID");
160 }
161
162 private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader)
163 {
164 //item.GroupOwned = reader.ReadElementContentAsBoolean("GroupOwned", String.Empty);
165 // We don't do that, because ReadElementContentAsBoolean assumes lower case strings,
166 // and they may not be lower case
167 reader.ReadStartElement(); // GroupOwned
168 item.GroupOwned = Boolean.Parse(reader.ReadContentAsString().ToLower());
169 reader.ReadEndElement();
170 }
171
172 #endregion
173
43 /// <summary> 174 /// <summary>
44 /// Deserialize item 175 /// Deserialize item
45 /// </summary> 176 /// </summary>
@@ -60,37 +191,44 @@ namespace OpenSim.Framework.Serialization.External
60 public static InventoryItemBase Deserialize(string serialization) 191 public static InventoryItemBase Deserialize(string serialization)
61 { 192 {
62 InventoryItemBase item = new InventoryItemBase(); 193 InventoryItemBase item = new InventoryItemBase();
63 194
64 StringReader sr = new StringReader(serialization); 195 using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization)))
65 XmlTextReader xtr = new XmlTextReader(sr); 196 {
66 197 reader.ReadStartElement("InventoryItem");
67 xtr.ReadStartElement("InventoryItem"); 198
68 199 string nodeName = string.Empty;
69 item.Name = xtr.ReadElementString("Name"); 200 while (reader.NodeType != XmlNodeType.EndElement)
70 item.ID = UUID.Parse( xtr.ReadElementString("ID")); 201 {
71 item.InvType = Convert.ToInt32( xtr.ReadElementString("InvType")); 202 nodeName = reader.Name;
72 item.CreatorId = xtr.ReadElementString("CreatorUUID"); 203 InventoryItemXmlProcessor p = null;
73 item.CreationDate = Convert.ToInt32( xtr.ReadElementString("CreationDate")); 204 if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p))
74 item.Owner = UUID.Parse( xtr.ReadElementString("Owner")); 205 {
75 item.Description = xtr.ReadElementString("Description"); 206 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
76 item.AssetType = Convert.ToInt32( xtr.ReadElementString("AssetType")); 207 try
77 item.AssetID = UUID.Parse( xtr.ReadElementString("AssetID")); 208 {
78 item.SaleType = Convert.ToByte( xtr.ReadElementString("SaleType")); 209 p(item, reader);
79 item.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice")); 210 }
80 item.BasePermissions = Convert.ToUInt32( xtr.ReadElementString("BasePermissions")); 211 catch (Exception e)
81 item.CurrentPermissions = Convert.ToUInt32( xtr.ReadElementString("CurrentPermissions")); 212 {
82 item.EveryOnePermissions = Convert.ToUInt32( xtr.ReadElementString("EveryOnePermissions")); 213 m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e);
83 item.NextPermissions = Convert.ToUInt32( xtr.ReadElementString("NextPermissions")); 214 if (reader.NodeType == XmlNodeType.EndElement)
84 item.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags")); 215 reader.Read();
85 item.GroupID = UUID.Parse( xtr.ReadElementString("GroupID")); 216 }
86 item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned")); 217 }
87 218 else
88 xtr.ReadEndElement(); 219 {
89 220 // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName);
90 xtr.Close(); 221 reader.ReadOuterXml(); // ignore
91 sr.Close(); 222 }
92 223
224 }
225
226 reader.ReadEndElement(); // InventoryItem
227 }
228
229 //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID);
93 return item; 230 return item;
231
94 } 232 }
95 233
96 public static string Serialize(InventoryItemBase inventoryItem) 234 public static string Serialize(InventoryItemBase inventoryItem)
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e8f8e01..101ece4 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1558,5 +1558,66 @@ namespace OpenSim.Framework
1558 return string.Empty; 1558 return string.Empty;
1559 } 1559 }
1560 1560
1561 public static UUID ReadUUID(XmlTextReader reader, string name)
1562 {
1563 UUID id;
1564 string idStr;
1565
1566 reader.ReadStartElement(name);
1567
1568 if (reader.Name == "Guid")
1569 idStr = reader.ReadElementString("Guid");
1570 else if (reader.Name == "UUID")
1571 idStr = reader.ReadElementString("UUID");
1572 else // no leading tag
1573 idStr = reader.ReadContentAsString();
1574 UUID.TryParse(idStr, out id);
1575 reader.ReadEndElement();
1576
1577 return id;
1578 }
1579
1580 public static Vector3 ReadVector(XmlTextReader reader, string name)
1581 {
1582 Vector3 vec;
1583
1584 reader.ReadStartElement(name);
1585 vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
1586 vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
1587 vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
1588 reader.ReadEndElement();
1589
1590 return vec;
1591 }
1592
1593 public static Quaternion ReadQuaternion(XmlTextReader reader, string name)
1594 {
1595 Quaternion quat = new Quaternion();
1596
1597 reader.ReadStartElement(name);
1598 while (reader.NodeType != XmlNodeType.EndElement)
1599 {
1600 switch (reader.Name.ToLower())
1601 {
1602 case "x":
1603 quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1604 break;
1605 case "y":
1606 quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1607 break;
1608 case "z":
1609 quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1610 break;
1611 case "w":
1612 quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1613 break;
1614 }
1615 }
1616
1617 reader.ReadEndElement();
1618
1619 return quat;
1620 }
1621
1561 } 1622 }
1562} 1623}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 9cf5a39..da25e80 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -414,7 +414,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
414 414
415 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader) 415 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader)
416 { 416 {
417 obj.CreatorID = ReadUUID(reader, "CreatorID"); 417 obj.CreatorID = Util.ReadUUID(reader, "CreatorID");
418 } 418 }
419 419
420 private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader) 420 private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader)
@@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
424 424
425 private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) 425 private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader)
426 { 426 {
427 obj.FolderID = ReadUUID(reader, "FolderID"); 427 obj.FolderID = Util.ReadUUID(reader, "FolderID");
428 } 428 }
429 429
430 private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader) 430 private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader)
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
439 439
440 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) 440 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader)
441 { 441 {
442 obj.UUID = ReadUUID(reader, "UUID"); 442 obj.UUID = Util.ReadUUID(reader, "UUID");
443 } 443 }
444 444
445 private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader) 445 private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader)
@@ -474,32 +474,32 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
474 474
475 private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader) 475 private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader)
476 { 476 {
477 obj.GroupPosition = ReadVector(reader, "GroupPosition"); 477 obj.GroupPosition = Util.ReadVector(reader, "GroupPosition");
478 } 478 }
479 479
480 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader) 480 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader)
481 { 481 {
482 obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ; 482 obj.OffsetPosition = Util.ReadVector(reader, "OffsetPosition"); ;
483 } 483 }
484 484
485 private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader) 485 private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader)
486 { 486 {
487 obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); 487 obj.RotationOffset = Util.ReadQuaternion(reader, "RotationOffset");
488 } 488 }
489 489
490 private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader) 490 private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader)
491 { 491 {
492 obj.Velocity = ReadVector(reader, "Velocity"); 492 obj.Velocity = Util.ReadVector(reader, "Velocity");
493 } 493 }
494 494
495 private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader) 495 private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader)
496 { 496 {
497 obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); 497 obj.AngularVelocity = Util.ReadVector(reader, "AngularVelocity");
498 } 498 }
499 499
500 private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader) 500 private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader)
501 { 501 {
502 obj.Acceleration = ReadVector(reader, "Acceleration"); 502 obj.Acceleration = Util.ReadVector(reader, "Acceleration");
503 } 503 }
504 504
505 private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader) 505 private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader)
@@ -553,7 +553,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
553 553
554 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) 554 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader)
555 { 555 {
556 obj.Scale = ReadVector(reader, "Scale"); 556 obj.Scale = Util.ReadVector(reader, "Scale");
557 } 557 }
558 558
559 private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader) 559 private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader)
@@ -563,22 +563,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
563 563
564 private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader) 564 private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader)
565 { 565 {
566 obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); 566 obj.SitTargetOrientation = Util.ReadQuaternion(reader, "SitTargetOrientation");
567 } 567 }
568 568
569 private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader) 569 private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader)
570 { 570 {
571 obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); 571 obj.SitTargetPosition = Util.ReadVector(reader, "SitTargetPosition");
572 } 572 }
573 573
574 private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader) 574 private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader)
575 { 575 {
576 obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); 576 obj.SitTargetPositionLL = Util.ReadVector(reader, "SitTargetPositionLL");
577 } 577 }
578 578
579 private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader) 579 private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader)
580 { 580 {
581 obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); 581 obj.SitTargetOrientationLL = Util.ReadQuaternion(reader, "SitTargetOrientationLL");
582 } 582 }
583 583
584 private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader) 584 private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader)
@@ -614,17 +614,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
614 614
615 private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader) 615 private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader)
616 { 616 {
617 obj.GroupID = ReadUUID(reader, "GroupID"); 617 obj.GroupID = Util.ReadUUID(reader, "GroupID");
618 } 618 }
619 619
620 private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader) 620 private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader)
621 { 621 {
622 obj.OwnerID = ReadUUID(reader, "OwnerID"); 622 obj.OwnerID = Util.ReadUUID(reader, "OwnerID");
623 } 623 }
624 624
625 private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader) 625 private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader)
626 { 626 {
627 obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); 627 obj.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID");
628 } 628 }
629 629
630 private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader) 630 private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader)
@@ -663,7 +663,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
663 663
664 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader) 664 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader)
665 { 665 {
666 obj.CollisionSound = ReadUUID(reader, "CollisionSound"); 666 obj.CollisionSound = Util.ReadUUID(reader, "CollisionSound");
667 } 667 }
668 668
669 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader) 669 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader)
@@ -690,7 +690,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
690 #region TaskInventoryXmlProcessors 690 #region TaskInventoryXmlProcessors
691 private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) 691 private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader)
692 { 692 {
693 item.AssetID = ReadUUID(reader, "AssetID"); 693 item.AssetID = Util.ReadUUID(reader, "AssetID");
694 } 694 }
695 695
696 private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader) 696 private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader)
@@ -705,7 +705,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
705 705
706 private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) 706 private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader)
707 { 707 {
708 item.CreatorID = ReadUUID(reader, "CreatorID"); 708 item.CreatorID = Util.ReadUUID(reader, "CreatorID");
709 } 709 }
710 710
711 private static void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader) 711 private static void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader)
@@ -730,7 +730,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
730 730
731 private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) 731 private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader)
732 { 732 {
733 item.GroupID = ReadUUID(reader, "GroupID"); 733 item.GroupID = Util.ReadUUID(reader, "GroupID");
734 } 734 }
735 735
736 private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader) 736 private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader)
@@ -745,20 +745,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
745 745
746 private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader) 746 private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader)
747 { 747 {
748 item.ItemID = ReadUUID(reader, "ItemID"); 748 item.ItemID = Util.ReadUUID(reader, "ItemID");
749 } 749 }
750 750
751 private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) 751 private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
752 { 752 {
753 ReadUUID(reader, "OldItemID"); 753 Util.ReadUUID(reader, "OldItemID");
754 // On deserialization, the old item id MUST BE UUID.Zero!!!!! 754 // On deserialization, the old item id MUST BE UUID.Zero!!!!!
755 // Setting this to the saved value will BREAK script persistence! 755 // Setting this to the saved value will BREAK script persistence!
756 // item.OldItemID = ReadUUID(reader, "OldItemID"); 756 // item.OldItemID = Util.ReadUUID(reader, "OldItemID");
757 } 757 }
758 758
759 private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) 759 private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
760 { 760 {
761 item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); 761 item.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID");
762 } 762 }
763 763
764 private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) 764 private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader)
@@ -773,7 +773,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
773 773
774 private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) 774 private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader)
775 { 775 {
776 item.OwnerID = ReadUUID(reader, "OwnerID"); 776 item.OwnerID = Util.ReadUUID(reader, "OwnerID");
777 } 777 }
778 778
779 private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) 779 private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader)
@@ -783,17 +783,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
783 783
784 private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader) 784 private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader)
785 { 785 {
786 item.ParentID = ReadUUID(reader, "ParentID"); 786 item.ParentID = Util.ReadUUID(reader, "ParentID");
787 } 787 }
788 788
789 private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) 789 private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader)
790 { 790 {
791 item.ParentPartID = ReadUUID(reader, "ParentPartID"); 791 item.ParentPartID = Util.ReadUUID(reader, "ParentPartID");
792 } 792 }
793 793
794 private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) 794 private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader)
795 { 795 {
796 item.PermsGranter = ReadUUID(reader, "PermsGranter"); 796 item.PermsGranter = Util.ReadUUID(reader, "PermsGranter");
797 } 797 }
798 798
799 private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader) 799 private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader)
@@ -922,7 +922,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
922 922
923 private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader) 923 private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader)
924 { 924 {
925 shp.Scale = ReadVector(reader, "Scale"); 925 shp.Scale = Util.ReadVector(reader, "Scale");
926 } 926 }
927 927
928 private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader) 928 private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -950,7 +950,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
950 950
951 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader) 951 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader)
952 { 952 {
953 shp.SculptTexture = ReadUUID(reader, "SculptTexture"); 953 shp.SculptTexture = Util.ReadUUID(reader, "SculptTexture");
954 } 954 }
955 955
956 private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader) 956 private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1459,66 +1459,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1459 return obj; 1459 return obj;
1460 } 1460 }
1461 1461
1462 static UUID ReadUUID(XmlTextReader reader, string name)
1463 {
1464 UUID id;
1465 string idStr;
1466
1467 reader.ReadStartElement(name);
1468
1469 if (reader.Name == "Guid")
1470 idStr = reader.ReadElementString("Guid");
1471 else // UUID
1472 idStr = reader.ReadElementString("UUID");
1473
1474 UUID.TryParse(idStr, out id);
1475 reader.ReadEndElement();
1476
1477 return id;
1478 }
1479
1480 static Vector3 ReadVector(XmlTextReader reader, string name)
1481 {
1482 Vector3 vec;
1483
1484 reader.ReadStartElement(name);
1485 vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
1486 vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
1487 vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
1488 reader.ReadEndElement();
1489
1490 return vec;
1491 }
1492
1493 static Quaternion ReadQuaternion(XmlTextReader reader, string name)
1494 {
1495 Quaternion quat = new Quaternion();
1496
1497 reader.ReadStartElement(name);
1498 while (reader.NodeType != XmlNodeType.EndElement)
1499 {
1500 switch (reader.Name.ToLower())
1501 {
1502 case "x":
1503 quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1504 break;
1505 case "y":
1506 quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1507 break;
1508 case "z":
1509 quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1510 break;
1511 case "w":
1512 quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1513 break;
1514 }
1515 }
1516
1517 reader.ReadEndElement();
1518
1519 return quat;
1520 }
1521
1522 static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) 1462 static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
1523 { 1463 {
1524 TaskInventoryDictionary tinv = new TaskInventoryDictionary(); 1464 TaskInventoryDictionary tinv = new TaskInventoryDictionary();