diff options
author | Adam Frisby | 2008-04-29 14:04:55 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-29 14:04:55 +0000 |
commit | 375163a6fece8b3a57c7555246abe8338223a599 (patch) | |
tree | 163001ca96a4b4d08589e9772f78510677d5d0dc /OpenSim/Framework/TaskInventoryItem.cs | |
parent | Patch from Melanie: 0001087: Crash to bash de-linking objects. Thanks Melanie! (diff) | |
download | opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.zip opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.tar.gz opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.tar.bz2 opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.tar.xz |
* Spring cleaning.
* Added new generic "Location" class to handle 2D integer locations. Going to use it to replace all RegionHandle and X,Y coordinate references throughout the entire project. You have been warned.
Diffstat (limited to 'OpenSim/Framework/TaskInventoryItem.cs')
-rw-r--r-- | OpenSim/Framework/TaskInventoryItem.cs | 225 |
1 files changed, 119 insertions, 106 deletions
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 615644b..d01c4c1 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs | |||
@@ -35,19 +35,38 @@ using libsecondlife; | |||
35 | using log4net; | 35 | using log4net; |
36 | 36 | ||
37 | namespace OpenSim.Framework | 37 | namespace OpenSim.Framework |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// A dictionary for task inventory. | 40 | /// A dictionary for task inventory. |
41 | /// | 41 | /// |
42 | /// This class is not thread safe. Callers must synchronize on Dictionary methods. | 42 | /// This class is not thread safe. Callers must synchronize on Dictionary methods. |
43 | /// </summary> | 43 | /// </summary> |
44 | public class TaskInventoryDictionary : Dictionary<LLUUID, TaskInventoryItem>, | 44 | public class TaskInventoryDictionary : Dictionary<LLUUID, TaskInventoryItem>, |
45 | ICloneable, IXmlSerializable | 45 | ICloneable, IXmlSerializable |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private static XmlSerializer tiiSerializer = new XmlSerializer(typeof(TaskInventoryItem)); | 49 | private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); |
50 | 50 | ||
51 | #region ICloneable Members | ||
52 | |||
53 | public Object Clone() | ||
54 | { | ||
55 | TaskInventoryDictionary clone = new TaskInventoryDictionary(); | ||
56 | |||
57 | lock (this) | ||
58 | { | ||
59 | foreach (LLUUID uuid in Keys) | ||
60 | { | ||
61 | clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone()); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | return clone; | ||
66 | } | ||
67 | |||
68 | #endregion | ||
69 | |||
51 | // The alternative of simply serializing the list doesn't appear to work on mono, since | 70 | // The alternative of simply serializing the list doesn't appear to work on mono, since |
52 | // we get a | 71 | // we get a |
53 | // | 72 | // |
@@ -58,43 +77,46 @@ namespace OpenSim.Framework | |||
58 | // ... | 77 | // ... |
59 | // private static XmlSerializer tiiSerializer | 78 | // private static XmlSerializer tiiSerializer |
60 | // = new XmlSerializer(typeof(Dictionary<LLUUID, TaskInventoryItem>.ValueCollection)); | 79 | // = new XmlSerializer(typeof(Dictionary<LLUUID, TaskInventoryItem>.ValueCollection)); |
61 | 80 | ||
62 | // see IXmlSerializable | 81 | // see IXmlSerializable |
82 | |||
83 | #region IXmlSerializable Members | ||
84 | |||
63 | public XmlSchema GetSchema() | 85 | public XmlSchema GetSchema() |
64 | { | 86 | { |
65 | return null; | 87 | return null; |
66 | } | 88 | } |
67 | 89 | ||
68 | // see IXmlSerializable | 90 | // see IXmlSerializable |
69 | public void ReadXml(XmlReader reader) | 91 | public void ReadXml(XmlReader reader) |
70 | { | 92 | { |
71 | m_log.DebugFormat("[TASK INVENTORY]: ReadXml current node before actions, {0}", reader.Name); | 93 | m_log.DebugFormat("[TASK INVENTORY]: ReadXml current node before actions, {0}", reader.Name); |
72 | 94 | ||
73 | if (!reader.IsEmptyElement) | 95 | if (!reader.IsEmptyElement) |
74 | { | 96 | { |
75 | reader.Read(); | 97 | reader.Read(); |
76 | while (tiiSerializer.CanDeserialize(reader)) | 98 | while (tiiSerializer.CanDeserialize(reader)) |
77 | { | 99 | { |
78 | TaskInventoryItem item = (TaskInventoryItem)tiiSerializer.Deserialize(reader); | 100 | TaskInventoryItem item = (TaskInventoryItem) tiiSerializer.Deserialize(reader); |
79 | Add(item.ItemID, item); | 101 | Add(item.ItemID, item); |
80 | 102 | ||
81 | m_log.DebugFormat("[TASK INVENTORY]: Instanted prim item {0}, {1} from xml", item.Name, item.ItemID); | 103 | m_log.DebugFormat("[TASK INVENTORY]: Instanted prim item {0}, {1} from xml", item.Name, item.ItemID); |
82 | } | 104 | } |
83 | 105 | ||
84 | m_log.DebugFormat("[TASK INVENTORY]: Instantiated {0} prim items in total from xml", Count); | 106 | m_log.DebugFormat("[TASK INVENTORY]: Instantiated {0} prim items in total from xml", Count); |
85 | } | 107 | } |
86 | else | 108 | else |
87 | { | 109 | { |
88 | m_log.DebugFormat("[TASK INVENTORY]: Skipping empty element {0}", reader.Name); | 110 | m_log.DebugFormat("[TASK INVENTORY]: Skipping empty element {0}", reader.Name); |
89 | } | 111 | } |
90 | 112 | ||
91 | // For some .net implementations, this last read is necessary so that we advance beyond the end tag | 113 | // For some .net implementations, this last read is necessary so that we advance beyond the end tag |
92 | // of the element wrapping this object so that the rest of the serialization can complete normally. | 114 | // of the element wrapping this object so that the rest of the serialization can complete normally. |
93 | reader.Read(); | 115 | reader.Read(); |
94 | 116 | ||
95 | m_log.DebugFormat("[TASK INVENTORY]: ReadXml current node after actions, {0}", reader.Name); | 117 | m_log.DebugFormat("[TASK INVENTORY]: ReadXml current node after actions, {0}", reader.Name); |
96 | } | 118 | } |
97 | 119 | ||
98 | // see IXmlSerializable | 120 | // see IXmlSerializable |
99 | public void WriteXml(XmlWriter writer) | 121 | public void WriteXml(XmlWriter writer) |
100 | { | 122 | { |
@@ -105,27 +127,15 @@ namespace OpenSim.Framework | |||
105 | tiiSerializer.Serialize(writer, item); | 127 | tiiSerializer.Serialize(writer, item); |
106 | } | 128 | } |
107 | } | 129 | } |
108 | 130 | ||
109 | //tiiSerializer.Serialize(writer, Values); | 131 | //tiiSerializer.Serialize(writer, Values); |
110 | } | 132 | } |
111 | 133 | ||
134 | #endregion | ||
135 | |||
112 | // see ICloneable | 136 | // see ICloneable |
113 | public Object Clone() | ||
114 | { | ||
115 | TaskInventoryDictionary clone = new TaskInventoryDictionary(); | ||
116 | |||
117 | lock (this) | ||
118 | { | ||
119 | foreach (LLUUID uuid in Keys) | ||
120 | { | ||
121 | clone.Add(uuid, (TaskInventoryItem)this[uuid].Clone()); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | return clone; | ||
126 | } | ||
127 | } | 137 | } |
128 | 138 | ||
129 | /// <summary> | 139 | /// <summary> |
130 | /// Represents an item in a task inventory | 140 | /// Represents an item in a task inventory |
131 | /// </summary> | 141 | /// </summary> |
@@ -135,90 +145,99 @@ namespace OpenSim.Framework | |||
135 | /// XXX This should really be factored out into some constants class. | 145 | /// XXX This should really be factored out into some constants class. |
136 | /// </summary> | 146 | /// </summary> |
137 | private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; | 147 | private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; |
138 | 148 | ||
139 | /// <summary> | 149 | /// <summary> |
140 | /// Inventory types | 150 | /// Inventory types |
141 | /// </summary> | 151 | /// </summary> |
142 | public static string[] InvTypes = new string[] | 152 | public static string[] InvTypes = new string[] |
143 | { | 153 | { |
144 | "texture", | 154 | "texture", |
145 | "sound", | 155 | "sound", |
146 | "calling_card", | 156 | "calling_card", |
147 | "landmark", | 157 | "landmark", |
148 | String.Empty, | 158 | String.Empty, |
149 | String.Empty, | 159 | String.Empty, |
150 | "object", | 160 | "object", |
151 | "notecard", | 161 | "notecard", |
152 | String.Empty, | 162 | String.Empty, |
153 | String.Empty, | 163 | String.Empty, |
154 | "lsl_text", | 164 | "lsl_text", |
155 | String.Empty, | 165 | String.Empty, |
156 | String.Empty, | 166 | String.Empty, |
157 | "bodypart", | 167 | "bodypart", |
158 | String.Empty, | 168 | String.Empty, |
159 | "snapshot", | 169 | "snapshot", |
160 | String.Empty, | 170 | String.Empty, |
161 | String.Empty, | 171 | String.Empty, |
162 | "wearable", | 172 | "wearable", |
163 | "animation", | 173 | "animation", |
164 | "gesture" | 174 | "gesture" |
165 | 175 | }; | |
166 | }; | 176 | |
167 | |||
168 | /// <summary> | 177 | /// <summary> |
169 | /// Asset types | 178 | /// Asset types |
170 | /// </summary> | 179 | /// </summary> |
171 | public static string[] Types = new string[] | 180 | public static string[] Types = new string[] |
172 | { | 181 | { |
173 | "texture", | 182 | "texture", |
174 | "sound", | 183 | "sound", |
175 | "callcard", | 184 | "callcard", |
176 | "landmark", | 185 | "landmark", |
177 | "clothing", // Deprecated | 186 | "clothing", // Deprecated |
178 | "clothing", | 187 | "clothing", |
179 | "object", | 188 | "object", |
180 | "notecard", | 189 | "notecard", |
181 | "category", | 190 | "category", |
182 | "root", | 191 | "root", |
183 | "lsltext", | 192 | "lsltext", |
184 | "lslbyte", | 193 | "lslbyte", |
185 | "txtr_tga", | 194 | "txtr_tga", |
186 | "bodypart", | 195 | "bodypart", |
187 | "trash", | 196 | "trash", |
188 | "snapshot", | 197 | "snapshot", |
189 | "lstndfnd", | 198 | "lstndfnd", |
190 | "snd_wav", | 199 | "snd_wav", |
191 | "img_tga", | 200 | "img_tga", |
192 | "jpeg", | 201 | "jpeg", |
193 | "animatn", | 202 | "animatn", |
194 | "gesture" | 203 | "gesture" |
195 | }; | 204 | }; |
196 | 205 | ||
197 | public LLUUID ItemID = LLUUID.Zero; | 206 | public LLUUID AssetID = LLUUID.Zero; |
198 | public LLUUID ParentID = LLUUID.Zero; //parent folder id | ||
199 | 207 | ||
200 | public uint BaseMask = FULL_MASK_PERMISSIONS_GENERAL; | 208 | public uint BaseMask = FULL_MASK_PERMISSIONS_GENERAL; |
201 | public uint OwnerMask = FULL_MASK_PERMISSIONS_GENERAL; | 209 | public uint CreationDate = 0; |
202 | public uint GroupMask = FULL_MASK_PERMISSIONS_GENERAL; | ||
203 | public uint EveryoneMask = FULL_MASK_PERMISSIONS_GENERAL; | ||
204 | public uint NextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; | ||
205 | public LLUUID CreatorID = LLUUID.Zero; | 210 | public LLUUID CreatorID = LLUUID.Zero; |
206 | public LLUUID OwnerID = LLUUID.Zero; | 211 | public string Description = String.Empty; |
207 | public LLUUID LastOwnerID = LLUUID.Zero; | 212 | public uint EveryoneMask = FULL_MASK_PERMISSIONS_GENERAL; |
213 | public uint Flags = 0; | ||
208 | public LLUUID GroupID = LLUUID.Zero; | 214 | public LLUUID GroupID = LLUUID.Zero; |
215 | public uint GroupMask = FULL_MASK_PERMISSIONS_GENERAL; | ||
209 | 216 | ||
210 | public LLUUID AssetID = LLUUID.Zero; | ||
211 | public int Type = 0; | ||
212 | public int InvType = 0; | 217 | public int InvType = 0; |
213 | public uint Flags = 0; | 218 | public LLUUID ItemID = LLUUID.Zero; |
219 | public LLUUID LastOwnerID = LLUUID.Zero; | ||
214 | public string Name = String.Empty; | 220 | public string Name = String.Empty; |
215 | public string Description = String.Empty; | 221 | public uint NextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; |
216 | public uint CreationDate = 0; | 222 | public LLUUID OwnerID = LLUUID.Zero; |
223 | public uint OwnerMask = FULL_MASK_PERMISSIONS_GENERAL; | ||
224 | public LLUUID ParentID = LLUUID.Zero; //parent folder id | ||
225 | public LLUUID ParentPartID = LLUUID.Zero; | ||
217 | public LLUUID PermsGranter; | 226 | public LLUUID PermsGranter; |
218 | public int PermsMask; | 227 | public int PermsMask; |
228 | public int Type = 0; | ||
229 | |||
230 | // See ICloneable | ||
231 | |||
232 | #region ICloneable Members | ||
233 | |||
234 | public Object Clone() | ||
235 | { | ||
236 | return MemberwiseClone(); | ||
237 | } | ||
238 | |||
239 | #endregion | ||
219 | 240 | ||
220 | public LLUUID ParentPartID = LLUUID.Zero; | ||
221 | |||
222 | /// <summary> | 241 | /// <summary> |
223 | /// Reset the LLUUIDs for this item. | 242 | /// Reset the LLUUIDs for this item. |
224 | /// </summary> | 243 | /// </summary> |
@@ -227,12 +246,6 @@ namespace OpenSim.Framework | |||
227 | { | 246 | { |
228 | ItemID = LLUUID.Random(); | 247 | ItemID = LLUUID.Random(); |
229 | ParentPartID = partID; | 248 | ParentPartID = partID; |
230 | } | ||
231 | |||
232 | // See ICloneable | ||
233 | public Object Clone() | ||
234 | { | ||
235 | return MemberwiseClone(); | ||
236 | } | 249 | } |
237 | } | 250 | } |
238 | } | 251 | } \ No newline at end of file |