aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-04-22 20:47:54 +0000
committerJustin Clarke Casey2008-04-22 20:47:54 +0000
commit8d8b4a314f1b7baa657885f490ab6aef9cecfc3b (patch)
tree14ed67f3e65b3ae7031b873d483316ad919bf399 /OpenSim
parentdoh, forgot that hg diffs don't do the adds correctly to svn (diff)
downloadopensim-SC-8d8b4a314f1b7baa657885f490ab6aef9cecfc3b.zip
opensim-SC-8d8b4a314f1b7baa657885f490ab6aef9cecfc3b.tar.gz
opensim-SC-8d8b4a314f1b7baa657885f490ab6aef9cecfc3b.tar.bz2
opensim-SC-8d8b4a314f1b7baa657885f490ab6aef9cecfc3b.tar.xz
* Add DeleteAllContents() method to InventoryFolderImpl - not yet used but will be soon
* Add locking to InventoryFolderImpl class - need more though.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs148
1 files changed, 109 insertions, 39 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 091a6a3..daf9ab5 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -57,99 +57,169 @@ namespace OpenSim.Framework.Communications.Cache
57 { 57 {
58 } 58 }
59 59
60 // Methods
61 public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) 60 public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type)
62 { 61 {
63 if (!SubFolders.ContainsKey(folderID)) 62 lock (SubFolders)
64 { 63 {
65 InventoryFolderImpl subFold = new InventoryFolderImpl(); 64 if (!SubFolders.ContainsKey(folderID))
66 subFold.Name = folderName; 65 {
67 subFold.ID = folderID; 66 InventoryFolderImpl subFold = new InventoryFolderImpl();
68 subFold.Type = (short) type; 67 subFold.Name = folderName;
69 subFold.ParentID = this.ID; 68 subFold.ID = folderID;
70 subFold.Owner = Owner; 69 subFold.Type = (short) type;
71 SubFolders.Add(subFold.ID, subFold); 70 subFold.ParentID = this.ID;
72 return subFold; 71 subFold.Owner = Owner;
72 SubFolders.Add(subFold.ID, subFold);
73 return subFold;
74 }
73 } 75 }
76
74 return null; 77 return null;
75 } 78 }
79
80 /// <summary>
81 /// Delete all the folders and items in this folder.
82 ///
83 /// TODO: This method is not used yet, but will be shortly
84 /// </summary>
85 public void DeleteAllContents()
86 {
87 foreach (InventoryFolderImpl folder in SubFolders.Values)
88 {
89 folder.DeleteAllContents();
90 }
91
92 SubFolders.Clear();
93 Items.Clear();
94 }
76 95
96 /// <summary>
97 /// Does this folder contain the given item?
98 /// </summary>
99 /// <param name="itemID"></param>
100 /// <returns></returns>
77 public InventoryItemBase HasItem(LLUUID itemID) 101 public InventoryItemBase HasItem(LLUUID itemID)
78 { 102 {
79 InventoryItemBase base2 = null; 103 InventoryItemBase base2 = null;
80 if (Items.ContainsKey(itemID)) 104
105 lock (Items)
81 { 106 {
82 return Items[itemID]; 107 if (Items.ContainsKey(itemID))
108 {
109 return Items[itemID];
110 }
83 } 111 }
84 foreach (InventoryFolderImpl folder in SubFolders.Values) 112
113 lock (SubFolders)
85 { 114 {
86 base2 = folder.HasItem(itemID); 115 foreach (InventoryFolderImpl folder in SubFolders.Values)
87 if (base2 != null)
88 { 116 {
89 break; 117 base2 = folder.HasItem(itemID);
118 if (base2 != null)
119 {
120 break;
121 }
90 } 122 }
91 } 123 }
124
92 return base2; 125 return base2;
93 } 126 }
94 127
128 /// <summary>
129 /// Delete an item from the folder.
130 /// </summary>
131 /// <param name="folderID"></param>
132 /// <returns></returns>
95 public bool DeleteItem(LLUUID itemID) 133 public bool DeleteItem(LLUUID itemID)
96 { 134 {
97 bool found = false; 135 bool found = false;
98 if (Items.ContainsKey(itemID)) 136
137 lock (Items)
99 { 138 {
100 Items.Remove(itemID); 139 if (Items.ContainsKey(itemID))
101 return true; 140 {
141 Items.Remove(itemID);
142 return true;
143 }
102 } 144 }
103 foreach (InventoryFolderImpl folder in SubFolders.Values) 145
146 lock (SubFolders)
104 { 147 {
105 found = folder.DeleteItem(itemID); 148 foreach (InventoryFolderImpl folder in SubFolders.Values)
106 if (found == true)
107 { 149 {
108 break; 150 found = folder.DeleteItem(itemID);
151 if (found == true)
152 {
153 break;
154 }
109 } 155 }
110 } 156 }
111 return found; 157 return found;
112 } 158 }
113 159
114 160 /// <summary>
161 /// Does this folder contain the given subfolder?
162 /// </summary>
163 /// <returns></returns>
115 public InventoryFolderImpl HasSubFolder(LLUUID folderID) 164 public InventoryFolderImpl HasSubFolder(LLUUID folderID)
116 { 165 {
117 InventoryFolderImpl returnFolder = null; 166 InventoryFolderImpl returnFolder = null;
118 if (SubFolders.ContainsKey(folderID)) 167
119 { 168 lock (SubFolders)
120 returnFolder = SubFolders[folderID];
121 }
122 else
123 { 169 {
124 foreach (InventoryFolderImpl folder in SubFolders.Values) 170 if (SubFolders.ContainsKey(folderID))
125 { 171 {
126 returnFolder = folder.HasSubFolder(folderID); 172 returnFolder = SubFolders[folderID];
127 if (returnFolder != null) 173 }
174 else
175 {
176 foreach (InventoryFolderImpl folder in SubFolders.Values)
128 { 177 {
129 break; 178 returnFolder = folder.HasSubFolder(folderID);
179 if (returnFolder != null)
180 {
181 break;
182 }
130 } 183 }
131 } 184 }
132 } 185 }
186
133 return returnFolder; 187 return returnFolder;
134 } 188 }
135 189
190 /// <summary>
191 /// Return the list of items in this folder
192 /// </summary>
136 public List<InventoryItemBase> RequestListOfItems() 193 public List<InventoryItemBase> RequestListOfItems()
137 { 194 {
138 List<InventoryItemBase> itemList = new List<InventoryItemBase>(); 195 List<InventoryItemBase> itemList = new List<InventoryItemBase>();
139 foreach (InventoryItemBase item in Items.Values) 196
197 lock (Items)
140 { 198 {
141 itemList.Add(item); 199 foreach (InventoryItemBase item in Items.Values)
200 {
201 itemList.Add(item);
202 }
142 } 203 }
204
143 return itemList; 205 return itemList;
144 } 206 }
145 207
208 /// <summary>
209 /// Return the list of folders in this folder
210 /// </summary>
146 public List<InventoryFolderBase> RequestListOfFolders() 211 public List<InventoryFolderBase> RequestListOfFolders()
147 { 212 {
148 List<InventoryFolderBase> folderList = new List<InventoryFolderBase>(); 213 List<InventoryFolderBase> folderList = new List<InventoryFolderBase>();
149 foreach (InventoryFolderBase folder in SubFolders.Values) 214
215 lock (SubFolders)
150 { 216 {
151 folderList.Add(folder); 217 foreach (InventoryFolderBase folder in SubFolders.Values)
218 {
219 folderList.Add(folder);
220 }
152 } 221 }
222
153 return folderList; 223 return folderList;
154 } 224 }
155 } 225 }