aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-01 20:47:33 +0000
committerJustin Clarke Casey2008-05-01 20:47:33 +0000
commit1de6cffa28348975a2492ce1e8a85c365df4dfaf (patch)
tree6431e5598defd603a4b2a8c5020b65d7df5a56a7 /OpenSim/Framework
parentcreate pass through of UserManagerBase to plugin calls (diff)
downloadopensim-SC-1de6cffa28348975a2492ce1e8a85c365df4dfaf.zip
opensim-SC-1de6cffa28348975a2492ce1e8a85c365df4dfaf.tar.gz
opensim-SC-1de6cffa28348975a2492ce1e8a85c365df4dfaf.tar.bz2
opensim-SC-1de6cffa28348975a2492ce1e8a85c365df4dfaf.tar.xz
* Refactor: Remove the unused userID parameter that was being passed into almost every inventory method
* This allows lots of redundant inventory methods with only slightly different names to be eliminated.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs81
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs13
-rw-r--r--OpenSim/Framework/Communications/IInventoryServices.cs32
-rw-r--r--OpenSim/Framework/Communications/InventoryServiceBase.cs79
4 files changed, 104 insertions, 101 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 7902240..adf01b9 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -166,12 +166,12 @@ namespace OpenSim.Framework.Communications.Cache
166 { 166 {
167 foreach (InventoryFolderImpl folder in folders) 167 foreach (InventoryFolderImpl folder in folders)
168 { 168 {
169 FolderReceive(userID, folder); 169 FolderReceive(folder);
170 } 170 }
171 171
172 foreach (InventoryItemBase item in items) 172 foreach (InventoryItemBase item in items)
173 { 173 {
174 ItemReceive(userID, item); 174 ItemReceive(item);
175 } 175 }
176 } 176 }
177 catch (Exception e) 177 catch (Exception e)
@@ -198,56 +198,53 @@ namespace OpenSim.Framework.Communications.Cache
198 /// </summary> 198 /// </summary>
199 /// <param name="userID"></param> 199 /// <param name="userID"></param>
200 /// <param name="folderInfo"></param> 200 /// <param name="folderInfo"></param>
201 private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) 201 private void FolderReceive(InventoryFolderImpl folderInfo)
202 { 202 {
203// m_log.DebugFormat( 203// m_log.DebugFormat(
204// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", 204// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}",
205// folderInfo.Name, folderInfo.ID, userID); 205// folderInfo.Name, folderInfo.ID, userID);
206 206
207 if (userID == UserProfile.ID) 207 if (RootFolder == null)
208 { 208 {
209 if (RootFolder == null) 209 if (folderInfo.ParentID == LLUUID.Zero)
210 { 210 {
211 if (folderInfo.ParentID == LLUUID.Zero) 211 m_rootFolder = folderInfo;
212 {
213 m_rootFolder = folderInfo;
214 }
215 } 212 }
216 else if (RootFolder.ID == folderInfo.ParentID) 213 }
214 else if (RootFolder.ID == folderInfo.ParentID)
215 {
216 lock (RootFolder.SubFolders)
217 { 217 {
218 lock (RootFolder.SubFolders) 218 if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID))
219 { 219 {
220 if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) 220 RootFolder.SubFolders.Add(folderInfo.ID, folderInfo);
221 {
222 RootFolder.SubFolders.Add(folderInfo.ID, folderInfo);
223 }
224 else
225 {
226 AddPendingFolder(folderInfo);
227 }
228 } 221 }
222 else
223 {
224 AddPendingFolder(folderInfo);
225 }
229 } 226 }
230 else 227 }
228 else
229 {
230 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID);
231 lock (folder.SubFolders)
231 { 232 {
232 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); 233 if (folder != null)
233 lock (folder.SubFolders)
234 { 234 {
235 if (folder != null) 235 if (!folder.SubFolders.ContainsKey(folderInfo.ID))
236 { 236 {
237 if (!folder.SubFolders.ContainsKey(folderInfo.ID)) 237 folder.SubFolders.Add(folderInfo.ID, folderInfo);
238 {
239 folder.SubFolders.Add(folderInfo.ID, folderInfo);
240 }
241 }
242 else
243 {
244 AddPendingFolder(folderInfo);
245 } 238 }
246 } 239 }
240 else
241 {
242 AddPendingFolder(folderInfo);
243 }
247 } 244 }
248
249 ResolvePendingFolders(folderInfo);
250 } 245 }
246
247 ResolvePendingFolders(folderInfo);
251 } 248 }
252 249
253 /// <summary> 250 /// <summary>
@@ -256,15 +253,14 @@ namespace OpenSim.Framework.Communications.Cache
256 /// We're assuming here that items are always received after all the folders have been 253 /// We're assuming here that items are always received after all the folders have been
257 /// received. 254 /// received.
258 /// </summary> 255 /// </summary>
259 /// <param name="userID"></param>
260 /// <param name="folderInfo"></param> 256 /// <param name="folderInfo"></param>
261 private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) 257 private void ItemReceive(InventoryItemBase itemInfo)
262 { 258 {
263// m_log.DebugFormat( 259// m_log.DebugFormat(
264// "[INVENTORY CACHE]: Received item {0} {1} for user {2}", 260// "[INVENTORY CACHE]: Received item {0} {1} for user {2}",
265// itemInfo.Name, itemInfo.ID, userID); 261// itemInfo.Name, itemInfo.ID, userID);
266 262
267 if ((userID == UserProfile.ID) && (RootFolder != null)) 263 if (RootFolder != null)
268 { 264 {
269 if (itemInfo.Folder == RootFolder.ID) 265 if (itemInfo.Folder == RootFolder.ID)
270 { 266 {
@@ -305,14 +301,13 @@ namespace OpenSim.Framework.Communications.Cache
305 /// <summary> 301 /// <summary>
306 /// Add an item to the user's inventory 302 /// Add an item to the user's inventory
307 /// </summary> 303 /// </summary>
308 /// <param name="userID"></param>
309 /// <param name="itemInfo"></param> 304 /// <param name="itemInfo"></param>
310 public void AddItem(LLUUID userID, InventoryItemBase itemInfo) 305 public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
311 { 306 {
312 if ((userID == UserProfile.ID) && HasInventory) 307 if (HasInventory)
313 { 308 {
314 ItemReceive(userID, itemInfo); 309 ItemReceive(itemInfo);
315 m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); 310 m_commsManager.InventoryService.AddItem(itemInfo);
316 } 311 }
317 } 312 }
318 313
@@ -325,7 +320,7 @@ namespace OpenSim.Framework.Communications.Cache
325 { 320 {
326 if ((userID == UserProfile.ID) && HasInventory) 321 if ((userID == UserProfile.ID) && HasInventory)
327 { 322 {
328 m_commsManager.InventoryService.UpdateInventoryItem(userID, itemInfo); 323 m_commsManager.InventoryService.UpdateItem(itemInfo);
329 } 324 }
330 } 325 }
331 326
@@ -343,7 +338,7 @@ namespace OpenSim.Framework.Communications.Cache
343 result = RootFolder.DeleteItem(item.ID); 338 result = RootFolder.DeleteItem(item.ID);
344 if (result) 339 if (result)
345 { 340 {
346 m_commsManager.InventoryService.DeleteInventoryItem(userID, item); 341 m_commsManager.InventoryService.DeleteItem(item);
347 } 342 }
348 } 343 }
349 344
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index 392d796..befb6c7 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -181,7 +181,8 @@ namespace OpenSim.Framework.Communications.Cache
181 createdBaseFolder.ParentID = createdFolder.ParentID; 181 createdBaseFolder.ParentID = createdFolder.ParentID;
182 createdBaseFolder.Type = createdFolder.Type; 182 createdBaseFolder.Type = createdFolder.Type;
183 createdBaseFolder.Version = createdFolder.Version; 183 createdBaseFolder.Version = createdFolder.Version;
184 m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); 184
185 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
185 } 186 }
186 else 187 else
187 { 188 {
@@ -207,7 +208,7 @@ namespace OpenSim.Framework.Communications.Cache
207 createdBaseFolder.Type = createdFolder.Type; 208 createdBaseFolder.Type = createdFolder.Type;
208 createdBaseFolder.Version = createdFolder.Version; 209 createdBaseFolder.Version = createdFolder.Version;
209 210
210 m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); 211 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
211 } 212 }
212 else 213 else
213 { 214 {
@@ -265,7 +266,8 @@ namespace OpenSim.Framework.Communications.Cache
265 baseFolder.ParentID = parentID; 266 baseFolder.ParentID = parentID;
266 baseFolder.Type = (short) type; 267 baseFolder.Type = (short) type;
267 baseFolder.Version = userProfile.RootFolder.Version; 268 baseFolder.Version = userProfile.RootFolder.Version;
268 m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); 269
270 m_commsManager.InventoryService.AddFolder(baseFolder);
269 } 271 }
270 else 272 else
271 { 273 {
@@ -299,7 +301,8 @@ namespace OpenSim.Framework.Communications.Cache
299 baseFolder.Owner = remoteClient.AgentId; 301 baseFolder.Owner = remoteClient.AgentId;
300 baseFolder.ID = folderID; 302 baseFolder.ID = folderID;
301 baseFolder.ParentID = parentID; 303 baseFolder.ParentID = parentID;
302 m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); 304
305 m_commsManager.InventoryService.MoveFolder(baseFolder);
303 } 306 }
304 else 307 else
305 { 308 {
@@ -544,7 +547,7 @@ namespace OpenSim.Framework.Communications.Cache
544 purgedBaseFolder.Type = purgedFolder.Type; 547 purgedBaseFolder.Type = purgedFolder.Type;
545 purgedBaseFolder.Version = purgedFolder.Version; 548 purgedBaseFolder.Version = purgedFolder.Version;
546 549
547 m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder); 550 m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder);
548 551
549 purgedFolder.Purge(); 552 purgedFolder.Purge();
550 } 553 }
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs
index c82c946..5907c38 100644
--- a/OpenSim/Framework/Communications/IInventoryServices.cs
+++ b/OpenSim/Framework/Communications/IInventoryServices.cs
@@ -50,46 +50,46 @@ namespace OpenSim.Framework.Communications
50 void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); 50 void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
51 51
52 /// <summary> 52 /// <summary>
53 /// Add a new folder to the given user's inventory 53 /// Add a new folder to the user's inventory
54 /// </summary> 54 /// </summary>
55 /// <param name="userID"></param>
56 /// <param name="folder"></param> 55 /// <param name="folder"></param>
57 void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); 56 /// <returns>true if the folder was successfully added</returns>
57 bool AddFolder(InventoryFolderBase folder);
58 58
59 /// <summary> 59 /// <summary>
60 /// Move an inventory folder to a new location 60 /// Move an inventory folder to a new location
61 /// </summary> 61 /// </summary>
62 /// <param name="userID"></param>
63 /// <param name="folder">A folder containing the details of the new location</param> 62 /// <param name="folder">A folder containing the details of the new location</param>
64 void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); 63 /// <returns>true if the folder was successfully moved</returns>
64 bool MoveFolder(InventoryFolderBase folder);
65 65
66 /// <summary> 66 /// <summary>
67 /// Purge an inventory folder of all its items and subfolders. 67 /// Purge an inventory folder of all its items and subfolders.
68 /// </summary> 68 /// </summary>
69 /// <param name="userID"></param>
70 /// <param name="folder"></param> 69 /// <param name="folder"></param>
71 void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder); 70 /// <returns>true if the folder was successfully purged</returns>
71 bool PurgeFolder(InventoryFolderBase folder);
72 72
73 /// <summary> 73 /// <summary>
74 /// Add a new item to the given user's inventory 74 /// Add a new item to the user's inventory
75 /// </summary> 75 /// </summary>
76 /// <param name="userID"></param>
77 /// <param name="item"></param> 76 /// <param name="item"></param>
78 void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); 77 /// <returns>true if the item was successfully added</returns>
78 bool AddItem(InventoryItemBase item);
79 79
80 /// <summary> 80 /// <summary>
81 /// Update an item in the given user's inventory 81 /// Update an item in the user's inventory
82 /// </summary> 82 /// </summary>
83 /// <param name="userID"></param>
84 /// <param name="item"></param> 83 /// <param name="item"></param>
85 void UpdateInventoryItem(LLUUID userID, InventoryItemBase item); 84 /// <returns>true if the item was successfully updated</returns>
85 bool UpdateItem(InventoryItemBase item);
86 86
87 /// <summary> 87 /// <summary>
88 /// Delete an item from the given user's inventory 88 /// Delete an item from the user's inventory
89 /// </summary> 89 /// </summary>
90 /// <param name="userID"></param>
91 /// <param name="item"></param> 90 /// <param name="item"></param>
92 void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); 91 /// <returns>true if the item was successfully deleted</returns>
92 bool DeleteItem(InventoryItemBase item);
93 93
94 /// <summary> 94 /// <summary>
95 /// Create a new inventory for the given user. 95 /// Create a new inventory for the given user.
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index dab6a16..1601963 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -106,16 +106,6 @@ namespace OpenSim.Framework.Communications
106 106
107 return userFolders; 107 return userFolders;
108 } 108 }
109
110 // See IInventoryServices
111 public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
112 {
113 // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin
114 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
115 {
116 plugin.Value.moveInventoryFolder(folder);
117 }
118 }
119 109
120 // See IInventoryServices 110 // See IInventoryServices
121 public virtual bool HasInventoryForUser(LLUUID userID) 111 public virtual bool HasInventoryForUser(LLUUID userID)
@@ -159,25 +149,7 @@ namespace OpenSim.Framework.Communications
159 } 149 }
160 150
161 // See IInventoryServices 151 // See IInventoryServices
162 public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); 152 public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
163
164 // See IInventoryServices
165 public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
166
167 // See IInventoryServices
168 public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
169
170 // See IInventoryServices
171 public abstract void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder);
172
173 // See IInventoryServices
174 public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
175
176 // See IInventoryServices
177 public abstract void UpdateInventoryItem(LLUUID userID, InventoryItemBase item);
178
179 // See IInventoryServices
180 public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
181 153
182 #endregion 154 #endregion
183 155
@@ -206,47 +178,74 @@ namespace OpenSim.Framework.Communications
206 178
207 #endregion 179 #endregion
208 180
209 protected void AddFolder(InventoryFolderBase folder) 181 public bool AddFolder(InventoryFolderBase folder)
210 { 182 {
211 m_log.DebugFormat( 183 m_log.DebugFormat(
212 "[INVENTORY SERVICE BASE]: Adding folder {0}, {1} to {2}", folder.Name, folder.ID, folder.ParentID); 184 "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
213 185
214 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 186 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
215 { 187 {
216 plugin.Value.addInventoryFolder(folder); 188 plugin.Value.addInventoryFolder(folder);
217 } 189 }
190
191 // FIXME: Should return false on failure
192 return true;
218 } 193 }
219 194
220 protected void MoveFolder(InventoryFolderBase folder) 195 public bool MoveFolder(InventoryFolderBase folder)
221 { 196 {
197 m_log.DebugFormat(
198 "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
199
222 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 200 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
223 { 201 {
224 plugin.Value.moveInventoryFolder(folder); 202 plugin.Value.moveInventoryFolder(folder);
225 } 203 }
204
205 // FIXME: Should return false on failure
206 return true;
226 } 207 }
227 208
228 protected void AddItem(InventoryItemBase item) 209 public bool AddItem(InventoryItemBase item)
229 { 210 {
211 m_log.DebugFormat(
212 "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder);
213
230 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 214 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
231 { 215 {
232 plugin.Value.addInventoryItem(item); 216 plugin.Value.addInventoryItem(item);
233 } 217 }
218
219 // FIXME: Should return false on failure
220 return true;
234 } 221 }
235 222
236 protected void UpdateItem(InventoryItemBase item) 223 public bool UpdateItem(InventoryItemBase item)
237 { 224 {
225 m_log.InfoFormat(
226 "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
227
238 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 228 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
239 { 229 {
240 plugin.Value.updateInventoryItem(item); 230 plugin.Value.updateInventoryItem(item);
241 } 231 }
232
233 // FIXME: Should return false on failure
234 return true;
242 } 235 }
243 236
244 protected void DeleteItem(InventoryItemBase item) 237 public bool DeleteItem(InventoryItemBase item)
245 { 238 {
239 m_log.InfoFormat(
240 "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder);
241
246 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 242 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
247 { 243 {
248 plugin.Value.deleteInventoryItem(item.ID); 244 plugin.Value.deleteInventoryItem(item.ID);
249 } 245 }
246
247 // FIXME: Should return false on failure
248 return true;
250 } 249 }
251 250
252 /// <summary> 251 /// <summary>
@@ -256,8 +255,11 @@ namespace OpenSim.Framework.Communications
256 /// already know... Needs heavy refactoring. 255 /// already know... Needs heavy refactoring.
257 /// </summary> 256 /// </summary>
258 /// <param name="folder"></param> 257 /// <param name="folder"></param>
259 protected void PurgeFolder(InventoryFolderBase folder) 258 public bool PurgeFolder(InventoryFolderBase folder)
260 { 259 {
260 m_log.DebugFormat(
261 "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
262
261 List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID); 263 List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID);
262 264
263 foreach (InventoryFolderBase subFolder in subFolders) 265 foreach (InventoryFolderBase subFolder in subFolders)
@@ -276,6 +278,9 @@ namespace OpenSim.Framework.Communications
276 { 278 {
277 DeleteItem(item); 279 DeleteItem(item);
278 } 280 }
281
282 // FIXME: Should return false on failure
283 return true;
279 } 284 }
280 285
281 private void AddNewInventorySet(UsersInventory inventory) 286 private void AddNewInventorySet(UsersInventory inventory)
@@ -283,7 +288,7 @@ namespace OpenSim.Framework.Communications
283 foreach (InventoryFolderBase folder in inventory.Folders.Values) 288 foreach (InventoryFolderBase folder in inventory.Folders.Values)
284 { 289 {
285 AddFolder(folder); 290 AddFolder(folder);
286 } 291 }
287 } 292 }
288 293
289 /// <summary> 294 /// <summary>