diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 158 |
1 files changed, 14 insertions, 144 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 4fee4c9..2bf4ea8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -404,31 +404,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
404 | return; | 404 | return; |
405 | } | 405 | } |
406 | 406 | ||
407 | CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 407 | InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); |
408 | 408 | ||
409 | if (null == userProfile) | 409 | if (item != null) |
410 | { | ||
411 | m_log.ErrorFormat( | ||
412 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | ||
413 | remoteClient.Name, remoteClient.AgentId); | ||
414 | return; | ||
415 | } | ||
416 | |||
417 | if (userProfile.HasReceivedInventory) | ||
418 | { | 410 | { |
419 | InventoryItemBase item = null; | 411 | remoteClient.SendInventoryItemDetails(ownerID, item); |
420 | if (userProfile.RootFolder == null) | ||
421 | m_log.ErrorFormat( | ||
422 | "[AGENT INVENTORY]: User {0} {1} does not have a root folder.", | ||
423 | remoteClient.Name, remoteClient.AgentId); | ||
424 | else | ||
425 | item = userProfile.RootFolder.FindItem(itemID); | ||
426 | |||
427 | if (item != null) | ||
428 | { | ||
429 | remoteClient.SendInventoryItemDetails(ownerID, item); | ||
430 | } | ||
431 | } | 412 | } |
413 | // else shouldn't we send an alert message? | ||
432 | } | 414 | } |
433 | 415 | ||
434 | /// <summary> | 416 | /// <summary> |
@@ -457,23 +439,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
457 | return; | 439 | return; |
458 | } | 440 | } |
459 | 441 | ||
460 | CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 442 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
461 | |||
462 | if (null == userProfile) | ||
463 | { | ||
464 | m_log.ErrorFormat( | ||
465 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | ||
466 | remoteClient.Name, remoteClient.AgentId); | ||
467 | return; | ||
468 | } | ||
469 | |||
470 | userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems); | ||
471 | } | 443 | } |
472 | 444 | ||
473 | /// <summary> | 445 | /// <summary> |
474 | /// Handle the caps inventory descendents fetch. | 446 | /// Handle the caps inventory descendents fetch. |
475 | /// | 447 | /// |
476 | /// Since the folder structure is sent to the client on login, I believe we only need to handle items. | 448 | /// Since the folder structure is sent to the client on login, I believe we only need to handle items. |
449 | /// Diva comment 8/13/2009: what if someone gave us a folder in the meantime?? | ||
477 | /// </summary> | 450 | /// </summary> |
478 | /// <param name="agentID"></param> | 451 | /// <param name="agentID"></param> |
479 | /// <param name="folderID"></param> | 452 | /// <param name="folderID"></param> |
@@ -499,59 +472,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
499 | { | 472 | { |
500 | return fold.RequestListOfItems(); | 473 | return fold.RequestListOfItems(); |
501 | } | 474 | } |
502 | |||
503 | CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(agentID); | ||
504 | |||
505 | if (null == userProfile) | ||
506 | { | ||
507 | m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID); | ||
508 | return null; | ||
509 | } | ||
510 | |||
511 | // XXX: When a client crosses into a scene, their entire inventory is fetched | ||
512 | // asynchronously. If the client makes a request before the inventory is received, we need | ||
513 | // to give the inventory a chance to come in. | ||
514 | // | ||
515 | // This is a crude way of dealing with that by retrying the lookup. It's not quite as bad | ||
516 | // in CAPS as doing this with the udp request, since here it won't hold up other packets. | ||
517 | // In fact, here we'll be generous and try for longer. | ||
518 | if (!userProfile.HasReceivedInventory) | ||
519 | { | ||
520 | int attempts = 0; | ||
521 | while (attempts++ < 30) | ||
522 | { | ||
523 | m_log.DebugFormat( | ||
524 | "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", | ||
525 | attempts, folderID, agentID); | ||
526 | |||
527 | Thread.Sleep(2000); | ||
528 | 475 | ||
529 | if (userProfile.HasReceivedInventory) | 476 | InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID); |
530 | { | 477 | return contents.Items; |
531 | break; | ||
532 | } | ||
533 | } | ||
534 | } | ||
535 | 478 | ||
536 | if (userProfile.HasReceivedInventory) | ||
537 | { | ||
538 | if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) | ||
539 | { | ||
540 | return fold.RequestListOfItems(); | ||
541 | } | ||
542 | else | ||
543 | { | ||
544 | m_log.WarnFormat( | ||
545 | "[AGENT INVENTORY]: Could not find folder {0} requested by user {1}", | ||
546 | folderID, agentID); | ||
547 | return null; | ||
548 | } | ||
549 | } | ||
550 | else | ||
551 | { | ||
552 | m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID); | ||
553 | return null; | ||
554 | } | ||
555 | } | 479 | } |
556 | 480 | ||
557 | /// <summary> | 481 | /// <summary> |
@@ -565,19 +489,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, | 489 | public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, |
566 | string folderName, UUID parentID) | 490 | string folderName, UUID parentID) |
567 | { | 491 | { |
568 | CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 492 | InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, remoteClient.AgentId, (short)folderType, parentID, 1); |
569 | 493 | if (!InventoryService.AddFolder(folder)) | |
570 | if (null == userProfile) | ||
571 | { | ||
572 | m_log.ErrorFormat( | ||
573 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | ||
574 | remoteClient.Name, remoteClient.AgentId); | ||
575 | return; | ||
576 | } | ||
577 | |||
578 | if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID)) | ||
579 | { | 494 | { |
580 | m_log.ErrorFormat( | 495 | m_log.WarnFormat( |
581 | "[AGENT INVENTORY]: Failed to move create folder for user {0} {1}", | 496 | "[AGENT INVENTORY]: Failed to move create folder for user {0} {1}", |
582 | remoteClient.Name, remoteClient.AgentId); | 497 | remoteClient.Name, remoteClient.AgentId); |
583 | } | 498 | } |
@@ -620,36 +535,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
620 | } | 535 | } |
621 | } | 536 | } |
622 | 537 | ||
623 | /// <summary> | ||
624 | /// Handle an inventory folder move request from the client. | ||
625 | /// </summary> | ||
626 | /// <param name="remoteClient"></param> | ||
627 | /// <param name="folderID"></param> | ||
628 | /// <param name="parentID"></param> | ||
629 | public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID) | 538 | public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID) |
630 | { | 539 | { |
631 | CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | ||
632 | |||
633 | if (null == userProfile) | ||
634 | { | ||
635 | m_log.ErrorFormat( | ||
636 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | ||
637 | remoteClient.Name, remoteClient.AgentId); | ||
638 | return; | ||
639 | } | ||
640 | |||
641 | if (!userProfile.MoveFolder(folderID, parentID)) | ||
642 | { | ||
643 | m_log.ErrorFormat( | ||
644 | "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}", | ||
645 | folderID, parentID, remoteClient.Name); | ||
646 | } | ||
647 | } | ||
648 | |||
649 | public void HandleMoveInventoryFolder2(IClientAPI remoteClient, UUID folderID, UUID parentID) | ||
650 | { | ||
651 | InventoryFolderBase folder = new InventoryFolderBase(folderID); | 540 | InventoryFolderBase folder = new InventoryFolderBase(folderID); |
652 | folder = InventoryService.QueryFolder(folder); | 541 | folder = InventoryService.GetFolder(folder); |
653 | if (folder != null) | 542 | if (folder != null) |
654 | { | 543 | { |
655 | folder.ParentID = parentID; | 544 | folder.ParentID = parentID; |
@@ -669,27 +558,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
669 | /// </summary> | 558 | /// </summary> |
670 | /// <param name="remoteClient"></param> | 559 | /// <param name="remoteClient"></param> |
671 | /// <param name="folderID"></param> | 560 | /// <param name="folderID"></param> |
672 | public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) | ||
673 | { | ||
674 | CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | ||
675 | |||
676 | if (null == userProfile) | ||
677 | { | ||
678 | m_log.ErrorFormat( | ||
679 | "[AGENT INVENTORY]: Could not find user profile for {0} {1}", | ||
680 | remoteClient.Name, remoteClient.AgentId); | ||
681 | return; | ||
682 | } | ||
683 | |||
684 | if (!userProfile.PurgeFolder(folderID)) | ||
685 | { | ||
686 | m_log.ErrorFormat( | ||
687 | "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}", | ||
688 | remoteClient.Name, remoteClient.AgentId); | ||
689 | } | ||
690 | } | ||
691 | 561 | ||
692 | public void HandlePurgeInventoryDescendents2(IClientAPI remoteClient, UUID folderID) | 562 | public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) |
693 | { | 563 | { |
694 | InventoryFolderBase folder = new InventoryFolderBase(folderID); | 564 | InventoryFolderBase folder = new InventoryFolderBase(folderID); |
695 | 565 | ||