aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs93
1 files changed, 61 insertions, 32 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 933d40a..4c629f4 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
48 /// <summary> 48 /// <summary>
49 /// Child folders that are contained in this folder 49 /// Child folders that are contained in this folder
50 /// </summary> 50 /// </summary>
51 public Dictionary<UUID, InventoryFolderImpl> SubFolders = new Dictionary<UUID, InventoryFolderImpl>(); 51 protected Dictionary<UUID, InventoryFolderImpl> m_childFolders = new Dictionary<UUID, InventoryFolderImpl>();
52 52
53 // Constructors 53 // Constructors
54 public InventoryFolderImpl(InventoryFolderBase folderbase) 54 public InventoryFolderImpl(InventoryFolderBase folderbase)
@@ -74,9 +74,9 @@ namespace OpenSim.Framework.Communications.Cache
74 /// <returns>The newly created subfolder. Returns null if the folder already exists</returns> 74 /// <returns>The newly created subfolder. Returns null if the folder already exists</returns>
75 public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type) 75 public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
76 { 76 {
77 lock (SubFolders) 77 lock (m_childFolders)
78 { 78 {
79 if (!SubFolders.ContainsKey(folderID)) 79 if (!m_childFolders.ContainsKey(folderID))
80 { 80 {
81 InventoryFolderImpl subFold = new InventoryFolderImpl(); 81 InventoryFolderImpl subFold = new InventoryFolderImpl();
82 subFold.Name = folderName; 82 subFold.Name = folderName;
@@ -84,7 +84,7 @@ namespace OpenSim.Framework.Communications.Cache
84 subFold.Type = (short) type; 84 subFold.Type = (short) type;
85 subFold.ParentID = this.ID; 85 subFold.ParentID = this.ID;
86 subFold.Owner = Owner; 86 subFold.Owner = Owner;
87 SubFolders.Add(subFold.ID, subFold); 87 m_childFolders.Add(subFold.ID, subFold);
88 88
89 return subFold; 89 return subFold;
90 } 90 }
@@ -99,14 +99,24 @@ namespace OpenSim.Framework.Communications.Cache
99 /// <param name="folder"></param> 99 /// <param name="folder"></param>
100 public void AddChildFolder(InventoryFolderImpl folder) 100 public void AddChildFolder(InventoryFolderImpl folder)
101 { 101 {
102 lock (SubFolders) 102 lock (m_childFolders)
103 { 103 {
104 folder.ParentID = ID; 104 folder.ParentID = ID;
105 SubFolders[folder.ID] = folder; 105 m_childFolders[folder.ID] = folder;
106 } 106 }
107 } 107 }
108 108
109 /// <summary> 109 /// <summary>
110 /// Does this folder contain the given child folder?
111 /// </summary>
112 /// <param name="folderID"></param>
113 /// <returns></returns>
114 public bool ContainsChildFolder(UUID folderID)
115 {
116 return m_childFolders.ContainsKey(folderID);
117 }
118
119 /// <summary>
110 /// Get a child folder 120 /// Get a child folder
111 /// </summary> 121 /// </summary>
112 /// <param name="folderID"></param> 122 /// <param name="folderID"></param>
@@ -115,9 +125,9 @@ namespace OpenSim.Framework.Communications.Cache
115 { 125 {
116 InventoryFolderImpl folder = null; 126 InventoryFolderImpl folder = null;
117 127
118 lock (SubFolders) 128 lock (m_childFolders)
119 { 129 {
120 SubFolders.TryGetValue(folderID, out folder); 130 m_childFolders.TryGetValue(folderID, out folder);
121 } 131 }
122 132
123 return folder; 133 return folder;
@@ -134,12 +144,12 @@ namespace OpenSim.Framework.Communications.Cache
134 { 144 {
135 InventoryFolderImpl removedFolder = null; 145 InventoryFolderImpl removedFolder = null;
136 146
137 lock (SubFolders) 147 lock (m_childFolders)
138 { 148 {
139 if (SubFolders.ContainsKey(folderID)) 149 if (m_childFolders.ContainsKey(folderID))
140 { 150 {
141 removedFolder = SubFolders[folderID]; 151 removedFolder = m_childFolders[folderID];
142 SubFolders.Remove(folderID); 152 m_childFolders.Remove(folderID);
143 } 153 }
144 } 154 }
145 155
@@ -151,12 +161,12 @@ namespace OpenSim.Framework.Communications.Cache
151 /// </summary> 161 /// </summary>
152 public void Purge() 162 public void Purge()
153 { 163 {
154 foreach (InventoryFolderImpl folder in SubFolders.Values) 164 foreach (InventoryFolderImpl folder in m_childFolders.Values)
155 { 165 {
156 folder.Purge(); 166 folder.Purge();
157 } 167 }
158 168
159 SubFolders.Clear(); 169 m_childFolders.Clear();
160 Items.Clear(); 170 Items.Clear();
161 } 171 }
162 172
@@ -175,9 +185,9 @@ namespace OpenSim.Framework.Communications.Cache
175 } 185 }
176 } 186 }
177 187
178 lock (SubFolders) 188 lock (m_childFolders)
179 { 189 {
180 foreach (InventoryFolderImpl folder in SubFolders.Values) 190 foreach (InventoryFolderImpl folder in m_childFolders.Values)
181 { 191 {
182 InventoryItemBase item = folder.FindItem(itemID); 192 InventoryItemBase item = folder.FindItem(itemID);
183 193
@@ -202,9 +212,9 @@ namespace OpenSim.Framework.Communications.Cache
202 } 212 }
203 } 213 }
204 214
205 lock (SubFolders) 215 lock (m_childFolders)
206 { 216 {
207 foreach (InventoryFolderImpl folder in SubFolders.Values) 217 foreach (InventoryFolderImpl folder in m_childFolders.Values)
208 { 218 {
209 InventoryItemBase item = folder.FindAsset(assetID); 219 InventoryItemBase item = folder.FindAsset(assetID);
210 220
@@ -236,9 +246,9 @@ namespace OpenSim.Framework.Communications.Cache
236 } 246 }
237 } 247 }
238 248
239 lock (SubFolders) 249 lock (m_childFolders)
240 { 250 {
241 foreach (InventoryFolderImpl folder in SubFolders.Values) 251 foreach (InventoryFolderImpl folder in m_childFolders.Values)
242 { 252 {
243 found = folder.DeleteItem(itemID); 253 found = folder.DeleteItem(itemID);
244 254
@@ -262,9 +272,9 @@ namespace OpenSim.Framework.Communications.Cache
262 if (folderID == ID) 272 if (folderID == ID)
263 return this; 273 return this;
264 274
265 lock (SubFolders) 275 lock (m_childFolders)
266 { 276 {
267 foreach (InventoryFolderImpl folder in SubFolders.Values) 277 foreach (InventoryFolderImpl folder in m_childFolders.Values)
268 { 278 {
269 InventoryFolderImpl returnFolder = folder.FindFolder(folderID); 279 InventoryFolderImpl returnFolder = folder.FindFolder(folderID);
270 280
@@ -274,7 +284,26 @@ namespace OpenSim.Framework.Communications.Cache
274 } 284 }
275 285
276 return null; 286 return null;
277 } 287 }
288
289 /// <summary>
290 /// Look through all child subfolders for a folder marked as one for a particular asset type, and return it.
291 /// </summary>
292 /// <param name="type"></param>
293 /// <returns>Returns null if no such folder is found</returns>
294 public InventoryFolderImpl FindFolderForType(int type)
295 {
296 lock (m_childFolders)
297 {
298 foreach (InventoryFolderImpl f in m_childFolders.Values)
299 {
300 if (f.Type == type)
301 return f;
302 }
303 }
304
305 return null;
306 }
278 307
279 /// <summary> 308 /// <summary>
280 /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder 309 /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder
@@ -297,9 +326,9 @@ namespace OpenSim.Framework.Communications.Cache
297 326
298 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 327 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
299 328
300 lock (SubFolders) 329 lock (m_childFolders)
301 { 330 {
302 foreach (InventoryFolderImpl folder in SubFolders.Values) 331 foreach (InventoryFolderImpl folder in m_childFolders.Values)
303 { 332 {
304 if (folder.Name == components[0]) 333 if (folder.Name == components[0])
305 if (components.Length > 1) 334 if (components.Length > 1)
@@ -344,9 +373,9 @@ namespace OpenSim.Framework.Communications.Cache
344 } 373 }
345 else 374 else
346 { 375 {
347 lock (SubFolders) 376 lock (m_childFolders)
348 { 377 {
349 foreach (InventoryFolderImpl folder in SubFolders.Values) 378 foreach (InventoryFolderImpl folder in m_childFolders.Values)
350 { 379 {
351 if (folder.Name == components[0]) 380 if (folder.Name == components[0])
352 return folder.FindItemByPath(components[1]); 381 return folder.FindItemByPath(components[1]);
@@ -385,9 +414,9 @@ namespace OpenSim.Framework.Communications.Cache
385 { 414 {
386 List<InventoryFolderBase> folderList = new List<InventoryFolderBase>(); 415 List<InventoryFolderBase> folderList = new List<InventoryFolderBase>();
387 416
388 lock (SubFolders) 417 lock (m_childFolders)
389 { 418 {
390 foreach (InventoryFolderBase folder in SubFolders.Values) 419 foreach (InventoryFolderBase folder in m_childFolders.Values)
391 { 420 {
392 folderList.Add(folder); 421 folderList.Add(folder);
393 } 422 }
@@ -400,9 +429,9 @@ namespace OpenSim.Framework.Communications.Cache
400 { 429 {
401 List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>(); 430 List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>();
402 431
403 lock (SubFolders) 432 lock (m_childFolders)
404 { 433 {
405 foreach (InventoryFolderImpl folder in SubFolders.Values) 434 foreach (InventoryFolderImpl folder in m_childFolders.Values)
406 { 435 {
407 folderList.Add(folder); 436 folderList.Add(folder);
408 } 437 }
@@ -421,7 +450,7 @@ namespace OpenSim.Framework.Communications.Cache
421 { 450 {
422 int total = Items.Count; 451 int total = Items.Count;
423 452
424 foreach (InventoryFolderImpl folder in SubFolders.Values) 453 foreach (InventoryFolderImpl folder in m_childFolders.Values)
425 { 454 {
426 total = total + folder.TotalCount; 455 total = total + folder.TotalCount;
427 } 456 }