aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authordiva2009-06-07 19:00:55 +0000
committerdiva2009-06-07 19:00:55 +0000
commit1ad237a8a757a0e6074278aff76805d01abf0c0b (patch)
treee6a697dd113aeb90c7dd92ee4d07f278d7ebf8de /OpenSim/Framework
parentSkip lone ident statments or for-loop assignments (diff)
downloadopensim-SC-1ad237a8a757a0e6074278aff76805d01abf0c0b.zip
opensim-SC-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.gz
opensim-SC-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.bz2
opensim-SC-1ad237a8a757a0e6074278aff76805d01abf0c0b.tar.xz
First draft of inventory service connectors, and service implementation. No handlers yet, this is just the OUT part for now. It's not active and nothing in the simulator uses this yet. Just checking it in to start sharing with others. There are a couple of interesting software design points that could use other devs opinions.
Hopefully I added all needed files.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/InventoryFolderImpl.cs (renamed from OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs)936
1 files changed, 466 insertions, 470 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/InventoryFolderImpl.cs
index 71f6f1b..248783f 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/InventoryFolderImpl.cs
@@ -1,470 +1,466 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32//using System.Reflection; 32namespace OpenSim.Framework
33 33{
34//using log4net; 34 public class InventoryFolderImpl : InventoryFolderBase
35 35 {
36namespace OpenSim.Framework.Communications.Cache 36 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
37{ 37
38 public class InventoryFolderImpl : InventoryFolderBase 38 public static readonly string PATH_DELIMITER = "/";
39 { 39
40 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 /// <summary>
41 41 /// Items that are contained in this folder
42 public static readonly string PATH_DELIMITER = "/"; 42 /// </summary>
43 43 public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>();
44 /// <summary> 44
45 /// Items that are contained in this folder 45 /// <summary>
46 /// </summary> 46 /// Child folders that are contained in this folder
47 public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>(); 47 /// </summary>
48 48 protected Dictionary<UUID, InventoryFolderImpl> m_childFolders = new Dictionary<UUID, InventoryFolderImpl>();
49 /// <summary> 49
50 /// Child folders that are contained in this folder 50 // Constructors
51 /// </summary> 51 public InventoryFolderImpl(InventoryFolderBase folderbase)
52 protected Dictionary<UUID, InventoryFolderImpl> m_childFolders = new Dictionary<UUID, InventoryFolderImpl>(); 52 {
53 53 Owner = folderbase.Owner;
54 // Constructors 54 ID = folderbase.ID;
55 public InventoryFolderImpl(InventoryFolderBase folderbase) 55 Name = folderbase.Name;
56 { 56 ParentID = folderbase.ParentID;
57 Owner = folderbase.Owner; 57 Type = folderbase.Type;
58 ID = folderbase.ID; 58 Version = folderbase.Version;
59 Name = folderbase.Name; 59 }
60 ParentID = folderbase.ParentID; 60
61 Type = folderbase.Type; 61 public InventoryFolderImpl()
62 Version = folderbase.Version; 62 {
63 } 63 }
64 64
65 public InventoryFolderImpl() 65 /// <summary>
66 { 66 /// Create a new subfolder.
67 } 67 /// </summary>
68 68 /// <param name="folderID"></param>
69 /// <summary> 69 /// <param name="folderName"></param>
70 /// Create a new subfolder. 70 /// <param name="type"></param>
71 /// </summary> 71 /// <returns>The newly created subfolder. Returns null if the folder already exists</returns>
72 /// <param name="folderID"></param> 72 public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
73 /// <param name="folderName"></param> 73 {
74 /// <param name="type"></param> 74 lock (m_childFolders)
75 /// <returns>The newly created subfolder. Returns null if the folder already exists</returns> 75 {
76 public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type) 76 if (!m_childFolders.ContainsKey(folderID))
77 { 77 {
78 lock (m_childFolders) 78 InventoryFolderImpl subFold = new InventoryFolderImpl();
79 { 79 subFold.Name = folderName;
80 if (!m_childFolders.ContainsKey(folderID)) 80 subFold.ID = folderID;
81 { 81 subFold.Type = (short)type;
82 InventoryFolderImpl subFold = new InventoryFolderImpl(); 82 subFold.ParentID = this.ID;
83 subFold.Name = folderName; 83 subFold.Owner = Owner;
84 subFold.ID = folderID; 84 m_childFolders.Add(subFold.ID, subFold);
85 subFold.Type = (short) type; 85
86 subFold.ParentID = this.ID; 86 return subFold;
87 subFold.Owner = Owner; 87 }
88 m_childFolders.Add(subFold.ID, subFold); 88 }
89 89
90 return subFold; 90 return null;
91 } 91 }
92 } 92
93 93 /// <summary>
94 return null; 94 /// Add a folder that already exists.
95 } 95 /// </summary>
96 96 /// <param name="folder"></param>
97 /// <summary> 97 public void AddChildFolder(InventoryFolderImpl folder)
98 /// Add a folder that already exists. 98 {
99 /// </summary> 99 lock (m_childFolders)
100 /// <param name="folder"></param> 100 {
101 public void AddChildFolder(InventoryFolderImpl folder) 101 folder.ParentID = ID;
102 { 102 m_childFolders[folder.ID] = folder;
103 lock (m_childFolders) 103 }
104 { 104 }
105 folder.ParentID = ID; 105
106 m_childFolders[folder.ID] = folder; 106 /// <summary>
107 } 107 /// Does this folder contain the given child folder?
108 } 108 /// </summary>
109 109 /// <param name="folderID"></param>
110 /// <summary> 110 /// <returns></returns>
111 /// Does this folder contain the given child folder? 111 public bool ContainsChildFolder(UUID folderID)
112 /// </summary> 112 {
113 /// <param name="folderID"></param> 113 return m_childFolders.ContainsKey(folderID);
114 /// <returns></returns> 114 }
115 public bool ContainsChildFolder(UUID folderID) 115
116 { 116 /// <summary>
117 return m_childFolders.ContainsKey(folderID); 117 /// Get a child folder
118 } 118 /// </summary>
119 119 /// <param name="folderID"></param>
120 /// <summary> 120 /// <returns>The folder if it exists, null if it doesn't</returns>
121 /// Get a child folder 121 public InventoryFolderImpl GetChildFolder(UUID folderID)
122 /// </summary> 122 {
123 /// <param name="folderID"></param> 123 InventoryFolderImpl folder = null;
124 /// <returns>The folder if it exists, null if it doesn't</returns> 124
125 public InventoryFolderImpl GetChildFolder(UUID folderID) 125 lock (m_childFolders)
126 { 126 {
127 InventoryFolderImpl folder = null; 127 m_childFolders.TryGetValue(folderID, out folder);
128 128 }
129 lock (m_childFolders) 129
130 { 130 return folder;
131 m_childFolders.TryGetValue(folderID, out folder); 131 }
132 } 132
133 133 /// <summary>
134 return folder; 134 /// Removes the given child subfolder.
135 } 135 /// </summary>
136 136 /// <param name="folderID"></param>
137 /// <summary> 137 /// <returns>
138 /// Removes the given child subfolder. 138 /// The folder removed, or null if the folder was not present.
139 /// </summary> 139 /// </returns>
140 /// <param name="folderID"></param> 140 public InventoryFolderImpl RemoveChildFolder(UUID folderID)
141 /// <returns> 141 {
142 /// The folder removed, or null if the folder was not present. 142 InventoryFolderImpl removedFolder = null;
143 /// </returns> 143
144 public InventoryFolderImpl RemoveChildFolder(UUID folderID) 144 lock (m_childFolders)
145 { 145 {
146 InventoryFolderImpl removedFolder = null; 146 if (m_childFolders.ContainsKey(folderID))
147 147 {
148 lock (m_childFolders) 148 removedFolder = m_childFolders[folderID];
149 { 149 m_childFolders.Remove(folderID);
150 if (m_childFolders.ContainsKey(folderID)) 150 }
151 { 151 }
152 removedFolder = m_childFolders[folderID]; 152
153 m_childFolders.Remove(folderID); 153 return removedFolder;
154 } 154 }
155 } 155
156 156 /// <summary>
157 return removedFolder; 157 /// Delete all the folders and items in this folder.
158 } 158 /// </summary>
159 159 public void Purge()
160 /// <summary> 160 {
161 /// Delete all the folders and items in this folder. 161 foreach (InventoryFolderImpl folder in m_childFolders.Values)
162 /// </summary> 162 {
163 public void Purge() 163 folder.Purge();
164 { 164 }
165 foreach (InventoryFolderImpl folder in m_childFolders.Values) 165
166 { 166 m_childFolders.Clear();
167 folder.Purge(); 167 Items.Clear();
168 } 168 }
169 169
170 m_childFolders.Clear(); 170 /// <summary>
171 Items.Clear(); 171 /// Returns the item if it exists in this folder or in any of this folder's descendant folders
172 } 172 /// </summary>
173 173 /// <param name="itemID"></param>
174 /// <summary> 174 /// <returns>null if the item is not found</returns>
175 /// Returns the item if it exists in this folder or in any of this folder's descendant folders 175 public InventoryItemBase FindItem(UUID itemID)
176 /// </summary> 176 {
177 /// <param name="itemID"></param> 177 lock (Items)
178 /// <returns>null if the item is not found</returns> 178 {
179 public InventoryItemBase FindItem(UUID itemID) 179 if (Items.ContainsKey(itemID))
180 { 180 {
181 lock (Items) 181 return Items[itemID];
182 { 182 }
183 if (Items.ContainsKey(itemID)) 183 }
184 { 184
185 return Items[itemID]; 185 lock (m_childFolders)
186 } 186 {
187 } 187 foreach (InventoryFolderImpl folder in m_childFolders.Values)
188 188 {
189 lock (m_childFolders) 189 InventoryItemBase item = folder.FindItem(itemID);
190 { 190
191 foreach (InventoryFolderImpl folder in m_childFolders.Values) 191 if (item != null)
192 { 192 {
193 InventoryItemBase item = folder.FindItem(itemID); 193 return item;
194 194 }
195 if (item != null) 195 }
196 { 196 }
197 return item; 197
198 } 198 return null;
199 } 199 }
200 } 200
201 201 public InventoryItemBase FindAsset(UUID assetID)
202 return null; 202 {
203 } 203 lock (Items)
204 204 {
205 public InventoryItemBase FindAsset(UUID assetID) 205 foreach (InventoryItemBase item in Items.Values)
206 { 206 {
207 lock (Items) 207 if (item.AssetID == assetID)
208 { 208 return item;
209 foreach (InventoryItemBase item in Items.Values) 209 }
210 { 210 }
211 if (item.AssetID == assetID) 211
212 return item; 212 lock (m_childFolders)
213 } 213 {
214 } 214 foreach (InventoryFolderImpl folder in m_childFolders.Values)
215 215 {
216 lock (m_childFolders) 216 InventoryItemBase item = folder.FindAsset(assetID);
217 { 217
218 foreach (InventoryFolderImpl folder in m_childFolders.Values) 218 if (item != null)
219 { 219 {
220 InventoryItemBase item = folder.FindAsset(assetID); 220 return item;
221 221 }
222 if (item != null) 222 }
223 { 223 }
224 return item; 224
225 } 225 return null;
226 } 226 }
227 } 227
228 228 /// <summary>
229 return null; 229 /// Deletes an item if it exists in this folder or any children
230 } 230 /// </summary>
231 231 /// <param name="folderID"></param>
232 /// <summary> 232 /// <returns></returns>
233 /// Deletes an item if it exists in this folder or any children 233 public bool DeleteItem(UUID itemID)
234 /// </summary> 234 {
235 /// <param name="folderID"></param> 235 bool found = false;
236 /// <returns></returns> 236
237 public bool DeleteItem(UUID itemID) 237 lock (Items)
238 { 238 {
239 bool found = false; 239 if (Items.ContainsKey(itemID))
240 240 {
241 lock (Items) 241 Items.Remove(itemID);
242 { 242 return true;
243 if (Items.ContainsKey(itemID)) 243 }
244 { 244 }
245 Items.Remove(itemID); 245
246 return true; 246 lock (m_childFolders)
247 } 247 {
248 } 248 foreach (InventoryFolderImpl folder in m_childFolders.Values)
249 249 {
250 lock (m_childFolders) 250 found = folder.DeleteItem(itemID);
251 { 251
252 foreach (InventoryFolderImpl folder in m_childFolders.Values) 252 if (found == true)
253 { 253 {
254 found = folder.DeleteItem(itemID); 254 break;
255 255 }
256 if (found == true) 256 }
257 { 257 }
258 break; 258
259 } 259 return found;
260 } 260 }
261 } 261
262 262 /// <summary>
263 return found; 263 /// Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth
264 } 264 /// first.
265 265 /// </summary>
266 /// <summary> 266 /// <returns>The requested folder if it exists, null if it does not.</returns>
267 /// Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth 267 public InventoryFolderImpl FindFolder(UUID folderID)
268 /// first. 268 {
269 /// </summary> 269 if (folderID == ID)
270 /// <returns>The requested folder if it exists, null if it does not.</returns> 270 return this;
271 public InventoryFolderImpl FindFolder(UUID folderID) 271
272 { 272 lock (m_childFolders)
273 if (folderID == ID) 273 {
274 return this; 274 foreach (InventoryFolderImpl folder in m_childFolders.Values)
275 275 {
276 lock (m_childFolders) 276 InventoryFolderImpl returnFolder = folder.FindFolder(folderID);
277 { 277
278 foreach (InventoryFolderImpl folder in m_childFolders.Values) 278 if (returnFolder != null)
279 { 279 return returnFolder;
280 InventoryFolderImpl returnFolder = folder.FindFolder(folderID); 280 }
281 281 }
282 if (returnFolder != null) 282
283 return returnFolder; 283 return null;
284 } 284 }
285 } 285
286 286 /// <summary>
287 return null; 287 /// Look through all child subfolders for a folder marked as one for a particular asset type, and return it.
288 } 288 /// </summary>
289 289 /// <param name="type"></param>
290 /// <summary> 290 /// <returns>Returns null if no such folder is found</returns>
291 /// Look through all child subfolders for a folder marked as one for a particular asset type, and return it. 291 public InventoryFolderImpl FindFolderForType(int type)
292 /// </summary> 292 {
293 /// <param name="type"></param> 293 lock (m_childFolders)
294 /// <returns>Returns null if no such folder is found</returns> 294 {
295 public InventoryFolderImpl FindFolderForType(int type) 295 foreach (InventoryFolderImpl f in m_childFolders.Values)
296 { 296 {
297 lock (m_childFolders) 297 if (f.Type == type)
298 { 298 return f;
299 foreach (InventoryFolderImpl f in m_childFolders.Values) 299 }
300 { 300 }
301 if (f.Type == type) 301
302 return f; 302 return null;
303 } 303 }
304 } 304
305 305 /// <summary>
306 return null; 306 /// Find a folder given a PATH_DELIMITER delimited path starting from this folder
307 } 307 /// </summary>
308 308 ///
309 /// <summary> 309 /// This method does not handle paths that contain multiple delimitors
310 /// Find a folder given a PATH_DELIMITER delimited path starting from this folder 310 ///
311 /// </summary> 311 /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some
312 /// 312 /// XPath like expression
313 /// This method does not handle paths that contain multiple delimitors 313 ///
314 /// 314 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
315 /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some 315 ///
316 /// XPath like expression 316 /// <param name="path">
317 /// 317 /// The path to the required folder.
318 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 318 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
319 /// 319 /// </param>
320 /// <param name="path"> 320 /// <returns>null if the folder is not found</returns>
321 /// The path to the required folder. 321 public InventoryFolderImpl FindFolderByPath(string path)
322 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. 322 {
323 /// </param> 323 if (path == string.Empty)
324 /// <returns>null if the folder is not found</returns> 324 return this;
325 public InventoryFolderImpl FindFolderByPath(string path) 325
326 { 326 path = path.Trim();
327 if (path == string.Empty) 327
328 return this; 328 if (path == PATH_DELIMITER)
329 329 return this;
330 path = path.Trim(); 330
331 331 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
332 if (path == PATH_DELIMITER) 332
333 return this; 333 lock (m_childFolders)
334 334 {
335 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 335 foreach (InventoryFolderImpl folder in m_childFolders.Values)
336 336 {
337 lock (m_childFolders) 337 if (folder.Name == components[0])
338 { 338 if (components.Length > 1)
339 foreach (InventoryFolderImpl folder in m_childFolders.Values) 339 return folder.FindFolderByPath(components[1]);
340 { 340 else
341 if (folder.Name == components[0]) 341 return folder;
342 if (components.Length > 1) 342 }
343 return folder.FindFolderByPath(components[1]); 343 }
344 else 344
345 return folder; 345 // We didn't find a folder with the given name
346 } 346 return null;
347 } 347 }
348 348
349 // We didn't find a folder with the given name 349 /// <summary>
350 return null; 350 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
351 } 351 ///
352 352 /// This method does not handle paths that contain multiple delimitors
353 /// <summary> 353 ///
354 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. 354 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
355 /// 355 /// XPath like expression
356 /// This method does not handle paths that contain multiple delimitors 356 ///
357 /// 357 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
358 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some 358 /// </summary>
359 /// XPath like expression 359 /// <param name="path">
360 /// 360 /// The path to the required item.
361 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 361 /// </param>
362 /// </summary> 362 /// <returns>null if the item is not found</returns>
363 /// <param name="path"> 363 public InventoryItemBase FindItemByPath(string path)
364 /// The path to the required item. 364 {
365 /// </param> 365 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
366 /// <returns>null if the item is not found</returns> 366
367 public InventoryItemBase FindItemByPath(string path) 367 if (components.Length == 1)
368 { 368 {
369 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 369 lock (Items)
370 370 {
371 if (components.Length == 1) 371 foreach (InventoryItemBase item in Items.Values)
372 { 372 {
373 lock (Items) 373 if (item.Name == components[0])
374 { 374 return item;
375 foreach (InventoryItemBase item in Items.Values) 375 }
376 { 376 }
377 if (item.Name == components[0]) 377 }
378 return item; 378 else
379 } 379 {
380 } 380 lock (m_childFolders)
381 } 381 {
382 else 382 foreach (InventoryFolderImpl folder in m_childFolders.Values)
383 { 383 {
384 lock (m_childFolders) 384 if (folder.Name == components[0])
385 { 385 return folder.FindItemByPath(components[1]);
386 foreach (InventoryFolderImpl folder in m_childFolders.Values) 386 }
387 { 387 }
388 if (folder.Name == components[0]) 388 }
389 return folder.FindItemByPath(components[1]); 389
390 } 390 // We didn't find an item or intermediate folder with the given name
391 } 391 return null;
392 } 392 }
393 393
394 // We didn't find an item or intermediate folder with the given name 394 /// <summary>
395 return null; 395 /// Return a copy of the list of child items in this folder. The items themselves are the originals.
396 } 396 /// </summary>
397 397 public List<InventoryItemBase> RequestListOfItems()
398 /// <summary> 398 {
399 /// Return a copy of the list of child items in this folder. The items themselves are the originals. 399 List<InventoryItemBase> itemList = new List<InventoryItemBase>();
400 /// </summary> 400
401 public List<InventoryItemBase> RequestListOfItems() 401 lock (Items)
402 { 402 {
403 List<InventoryItemBase> itemList = new List<InventoryItemBase>(); 403 foreach (InventoryItemBase item in Items.Values)
404 404 {
405 lock (Items) 405 itemList.Add(item);
406 { 406 }
407 foreach (InventoryItemBase item in Items.Values) 407 }
408 { 408
409 itemList.Add(item); 409 //m_log.DebugFormat("[INVENTORY FOLDER IMPL]: Found {0} items", itemList.Count);
410 } 410
411 } 411 return itemList;
412 412 }
413 //m_log.DebugFormat("[INVENTORY FOLDER IMPL]: Found {0} items", itemList.Count); 413
414 414 /// <summary>
415 return itemList; 415 /// Return a copy of the list of child folders in this folder. The folders themselves are the originals.
416 } 416 /// </summary>
417 417 public List<InventoryFolderBase> RequestListOfFolders()
418 /// <summary> 418 {
419 /// Return a copy of the list of child folders in this folder. The folders themselves are the originals. 419 List<InventoryFolderBase> folderList = new List<InventoryFolderBase>();
420 /// </summary> 420
421 public List<InventoryFolderBase> RequestListOfFolders() 421 lock (m_childFolders)
422 { 422 {
423 List<InventoryFolderBase> folderList = new List<InventoryFolderBase>(); 423 foreach (InventoryFolderBase folder in m_childFolders.Values)
424 424 {
425 lock (m_childFolders) 425 folderList.Add(folder);
426 { 426 }
427 foreach (InventoryFolderBase folder in m_childFolders.Values) 427 }
428 { 428
429 folderList.Add(folder); 429 return folderList;
430 } 430 }
431 } 431
432 432 public List<InventoryFolderImpl> RequestListOfFolderImpls()
433 return folderList; 433 {
434 } 434 List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>();
435 435
436 public List<InventoryFolderImpl> RequestListOfFolderImpls() 436 lock (m_childFolders)
437 { 437 {
438 List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>(); 438 foreach (InventoryFolderImpl folder in m_childFolders.Values)
439 439 {
440 lock (m_childFolders) 440 folderList.Add(folder);
441 { 441 }
442 foreach (InventoryFolderImpl folder in m_childFolders.Values) 442 }
443 { 443
444 folderList.Add(folder); 444 return folderList;
445 } 445 }
446 } 446
447 447 /// <value>
448 return folderList; 448 /// The total number of items in this folder and in the immediate child folders (though not from other
449 } 449 /// descendants).
450 450 /// </value>
451 /// <value> 451 public int TotalCount
452 /// The total number of items in this folder and in the immediate child folders (though not from other 452 {
453 /// descendants). 453 get
454 /// </value> 454 {
455 public int TotalCount 455 int total = Items.Count;
456 { 456
457 get 457 foreach (InventoryFolderImpl folder in m_childFolders.Values)
458 { 458 {
459 int total = Items.Count; 459 total = total + folder.TotalCount;
460 460 }
461 foreach (InventoryFolderImpl folder in m_childFolders.Values) 461
462 { 462 return total;
463 total = total + folder.TotalCount; 463 }
464 } 464 }
465 465 }
466 return total; 466}
467 }
468 }
469 }
470}