aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-12-10 19:12:59 +0000
committerJustin Clarke Casey2008-12-10 19:12:59 +0000
commitf38c35b60947fd926246fd95cfce5b9674967124 (patch)
treead349b864b99f0b88d236abdb51993e41fbd6b74 /OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
parent* Establish OpenSim.Framework.Communications.Tests beachhead (diff)
downloadopensim-SC-f38c35b60947fd926246fd95cfce5b9674967124.zip
opensim-SC-f38c35b60947fd926246fd95cfce5b9674967124.tar.gz
opensim-SC-f38c35b60947fd926246fd95cfce5b9674967124.tar.bz2
opensim-SC-f38c35b60947fd926246fd95cfce5b9674967124.tar.xz
* refactor: Move inventory handlers out from UserProfileCacheService
* This means that UserProfileCacheService no longer needs to know about IClientAPI and can leave it to callers to do their own error logging * This is also more consistent with the way that item inventory manipulation is handled * I don't really think Scene.PacketHandlers.cs should be a permanent home for these handlers - this is just for convenience
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs279
1 files changed, 0 insertions, 279 deletions
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index 46df2b7..958ef4e 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -185,289 +185,10 @@ namespace OpenSim.Framework.Communications.Cache
185 } 185 }
186 else 186 else
187 { 187 {
188
189 CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData); 188 CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData);
190 m_userProfiles.Add(userID, userInfo); 189 m_userProfiles.Add(userID, userInfo);
191 } 190 }
192 } 191 }
193 } 192 }
194
195 /// <summary>
196 /// Handle an inventory folder creation request from the client.
197 /// </summary>
198 /// <param name="remoteClient"></param>
199 /// <param name="folderID"></param>
200 /// <param name="folderType"></param>
201 /// <param name="folderName"></param>
202 /// <param name="parentID"></param>
203 public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType,
204 string folderName, UUID parentID)
205 {
206 CachedUserInfo userProfile;
207
208 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
209 {
210 if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID))
211 {
212 m_log.ErrorFormat(
213 "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
214 remoteClient.Name, remoteClient.AgentId);
215 }
216 }
217 else
218 {
219 m_log.ErrorFormat(
220 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
221 remoteClient.Name, remoteClient.AgentId);
222 }
223 }
224
225 /// <summary>
226 /// Handle a client request to update the inventory folder
227 /// </summary>
228 ///
229 /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE
230 /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing,
231 /// and needs to be changed.
232 ///
233 /// <param name="remoteClient"></param>
234 /// <param name="folderID"></param>
235 /// <param name="type"></param>
236 /// <param name="name"></param>
237 /// <param name="parentID"></param>
238 public void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name,
239 UUID parentID)
240 {
241// m_log.DebugFormat(
242// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);
243
244 CachedUserInfo userProfile;
245
246 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
247 {
248 if (!userProfile.UpdateFolder(name, folderID, type, parentID))
249 {
250 m_log.ErrorFormat(
251 "[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
252 remoteClient.Name, remoteClient.AgentId);
253 }
254 }
255 else
256 {
257 m_log.ErrorFormat(
258 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
259 remoteClient.Name, remoteClient.AgentId);
260 }
261 }
262
263 /// <summary>
264 /// Handle an inventory folder move request from the client.
265 /// </summary>
266 /// <param name="remoteClient"></param>
267 /// <param name="folderID"></param>
268 /// <param name="parentID"></param>
269 public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
270 {
271 CachedUserInfo userProfile;
272
273 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
274 {
275 if (!userProfile.MoveFolder(folderID, parentID))
276 {
277 m_log.ErrorFormat(
278 "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}",
279 folderID, parentID, remoteClient.Name);
280 }
281 }
282 else
283 {
284 m_log.ErrorFormat(
285 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
286 remoteClient.Name, remoteClient.AgentId);
287 }
288 }
289
290 /// <summary>
291 /// Tell the client about the various child items and folders contained in the requested folder.
292 /// </summary>
293 /// <param name="remoteClient"></param>
294 /// <param name="folderID"></param>
295 /// <param name="ownerID"></param>
296 /// <param name="fetchFolders"></param>
297 /// <param name="fetchItems"></param>
298 /// <param name="sortOrder"></param>
299 public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID,
300 bool fetchFolders, bool fetchItems, int sortOrder)
301 {
302 // FIXME MAYBE: We're not handling sortOrder!
303
304 InventoryFolderImpl fold = null;
305 if ((fold = LibraryRoot.FindFolder(folderID)) != null)
306 {
307 remoteClient.SendInventoryFolderDetails(
308 LibraryRoot.Owner, folderID, fold.RequestListOfItems(),
309 fold.RequestListOfFolders(), fetchFolders, fetchItems);
310
311 return;
312 }
313
314 CachedUserInfo userProfile;
315 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
316 {
317 userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems);
318 }
319 else
320 {
321 m_log.ErrorFormat(
322 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
323 remoteClient.Name, remoteClient.AgentId);
324 }
325 }
326
327 /// <summary>
328 /// Handle the caps inventory descendents fetch.
329 ///
330 /// Since the folder structure is sent to the client on login, I believe we only need to handle items.
331 /// </summary>
332 /// <param name="agentID"></param>
333 /// <param name="folderID"></param>
334 /// <param name="ownerID"></param>
335 /// <param name="fetchFolders"></param>
336 /// <param name="fetchItems"></param>
337 /// <param name="sortOrder"></param>
338 /// <returns>null if the inventory look up failed</returns>
339 public List<InventoryItemBase> HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
340 bool fetchFolders, bool fetchItems, int sortOrder)
341 {
342// m_log.DebugFormat(
343// "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
344// fetchFolders, fetchItems, folderID, agentID);
345
346 // FIXME MAYBE: We're not handling sortOrder!
347
348 InventoryFolderImpl fold;
349 if ((fold = LibraryRoot.FindFolder(folderID)) != null)
350 {
351 return fold.RequestListOfItems();
352 }
353
354 CachedUserInfo userProfile;
355 if (m_userProfiles.TryGetValue(agentID, out userProfile))
356 {
357 // XXX: When a client crosses into a scene, their entire inventory is fetched
358 // asynchronously. If the client makes a request before the inventory is received, we need
359 // to give the inventory a chance to come in.
360 //
361 // This is a crude way of dealing with that by retrying the lookup. It's not quite as bad
362 // in CAPS as doing this with the udp request, since here it won't hold up other packets.
363 // In fact, here we'll be generous and try for longer.
364 if (!userProfile.HasReceivedInventory)
365 {
366 int attempts = 0;
367 while (attempts++ < 30)
368 {
369 m_log.DebugFormat(
370 "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}",
371 attempts, folderID, agentID);
372
373 Thread.Sleep(2000);
374
375 if (userProfile.HasReceivedInventory)
376 {
377 break;
378 }
379 }
380 }
381
382 if (userProfile.HasReceivedInventory)
383 {
384 if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
385 {
386 return fold.RequestListOfItems();
387 }
388 else
389 {
390 m_log.WarnFormat(
391 "[AGENT INVENTORY]: Could not find folder {0} requested by user {1}",
392 folderID, agentID);
393
394 return null;
395 }
396 }
397 else
398 {
399 m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID);
400
401 return null;
402 }
403 }
404 else
405 {
406 m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID);
407
408 return null;
409 }
410 }
411
412 /// <summary>
413 /// This should delete all the items and folders in the given directory.
414 /// </summary>
415 /// <param name="remoteClient"></param>
416 /// <param name="folderID"></param>
417 public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
418 {
419 CachedUserInfo userProfile;
420
421 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
422 {
423 if (!userProfile.PurgeFolder(folderID))
424 {
425 m_log.ErrorFormat(
426 "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}",
427 remoteClient.Name, remoteClient.AgentId);
428 }
429 }
430 else
431 {
432 m_log.ErrorFormat(
433 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
434 remoteClient.Name, remoteClient.AgentId);
435 }
436 }
437
438 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
439 {
440 if (ownerID == LibraryRoot.Owner)
441 {
442 //Console.WriteLine("request info for library item");
443
444 return;
445 }
446
447 CachedUserInfo userProfile;
448 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
449 {
450 if (userProfile.HasReceivedInventory)
451 {
452 InventoryItemBase item = null;
453 if ( userProfile.RootFolder == null )
454 m_log.ErrorFormat(
455 "[AGENT INVENTORY]: User {0} {1} does not have a root folder.",
456 remoteClient.Name, remoteClient.AgentId);
457 else
458 item = userProfile.RootFolder.FindItem(itemID);
459 if (item != null)
460 {
461 remoteClient.SendInventoryItemDetails(ownerID, item);
462 }
463 }
464 }
465 else
466 {
467 m_log.ErrorFormat(
468 "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
469 remoteClient.Name, remoteClient.AgentId);
470 }
471 }
472 } 193 }
473} 194}