diff options
Diffstat (limited to 'OpenSim/Region')
6 files changed, 457 insertions, 54 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3470fa9..9395233 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -1913,7 +1913,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1913 | 1913 | ||
1914 | folderBlock.FolderID = folder.ID; | 1914 | folderBlock.FolderID = folder.ID; |
1915 | folderBlock.ParentID = folder.ParentID; | 1915 | folderBlock.ParentID = folder.ParentID; |
1916 | folderBlock.Type = -1; | 1916 | //folderBlock.Type = -1; |
1917 | folderBlock.Type = (sbyte)folder.Type; | ||
1917 | folderBlock.Name = Util.StringToBytes256(folder.Name); | 1918 | folderBlock.Name = Util.StringToBytes256(folder.Name); |
1918 | 1919 | ||
1919 | return folderBlock; | 1920 | return folderBlock; |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index ec260b4..d85a996 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -114,7 +114,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
114 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin"); | 114 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin"); |
115 | if (m_RestrictInventoryAccessAbroad) | 115 | if (m_RestrictInventoryAccessAbroad) |
116 | { | 116 | { |
117 | RestoreRootFolderContents(client); | 117 | IUserManagement uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>(); |
118 | if (uMan.IsLocalGridUser(client.AgentId)) | ||
119 | { | ||
120 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); | ||
121 | RestoreRootFolderContents(client); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is foreign"); | ||
126 | RestoreSuitcaseFolderContents(client); | ||
127 | } | ||
118 | } | 128 | } |
119 | } | 129 | } |
120 | } | 130 | } |
@@ -210,7 +220,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
210 | logout = success; // flag for later logout from this grid; this is an HG TP | 220 | logout = success; // flag for later logout from this grid; this is an HG TP |
211 | 221 | ||
212 | if (success && m_RestrictInventoryAccessAbroad) | 222 | if (success && m_RestrictInventoryAccessAbroad) |
213 | RemoveRootFolderContents(sp.ControllingClient); | 223 | { |
224 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); | ||
225 | if (uMan != null && uMan.IsLocalGridUser(sp.UUID)) | ||
226 | { | ||
227 | // local grid user | ||
228 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); | ||
229 | RemoveRootFolderContents(sp.ControllingClient); | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is foreign"); | ||
234 | RemoveSuitcaseFolderContents(sp.ControllingClient); | ||
235 | } | ||
236 | } | ||
214 | 237 | ||
215 | return success; | 238 | return success; |
216 | } | 239 | } |
@@ -388,6 +411,36 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
388 | 411 | ||
389 | #endregion | 412 | #endregion |
390 | 413 | ||
414 | // COMPLETE FAIL | ||
415 | //private void RemoveRootFolderContents(IClientAPI client) | ||
416 | //{ | ||
417 | // InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | ||
418 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}, version {1}", client.AgentId, root.Version); | ||
419 | // InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
420 | |||
421 | // List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); | ||
422 | // foreach (InventoryFolderBase f in content.Folders) | ||
423 | // { | ||
424 | // if (f.Type == (short)AssetType.TrashFolder || f.Type == (short)AssetType.Landmark || | ||
425 | // f.Type == (short)AssetType.FavoriteFolder || f.Type == (short)AssetType.CurrentOutfitFolder) | ||
426 | // { | ||
427 | // // Don't remove these because the viewer refuses to exist without them | ||
428 | // // and immediately sends a request to create them again, which makes things | ||
429 | // // very confusing in the viewer. | ||
430 | // // Just change their names | ||
431 | // f.Name = "Home " + f.Name + " (Unavailable)"; | ||
432 | // keep.Add(f); | ||
433 | // } | ||
434 | // else | ||
435 | // { | ||
436 | // m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID); | ||
437 | // } | ||
438 | // } | ||
439 | |||
440 | |||
441 | // client.SendInventoryFolderDetails(client.AgentId, root.ID, new List<InventoryItemBase>(), keep, root.Version + 1, true, true); | ||
442 | //} | ||
443 | |||
391 | private void RemoveRootFolderContents(IClientAPI client) | 444 | private void RemoveRootFolderContents(IClientAPI client) |
392 | { | 445 | { |
393 | // TODO tell the viewer to remove the root folder's content | 446 | // TODO tell the viewer to remove the root folder's content |
@@ -401,25 +454,185 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
401 | InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | 454 | InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); |
402 | if (root != null) | 455 | if (root != null) |
403 | { | 456 | { |
404 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.AgentId); | 457 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.Name); |
458 | InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
459 | List<UUID> fids = new List<UUID>(); | ||
460 | List<UUID> iids = new List<UUID>(); | ||
461 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); | ||
462 | |||
463 | foreach (InventoryFolderBase f in content.Folders) | ||
464 | { | ||
465 | if (f.Name != "My Suitcase") | ||
466 | { | ||
467 | f.Name = f.Name + " (Unavailable)"; | ||
468 | keep.Add(f); | ||
469 | } | ||
470 | } | ||
471 | |||
472 | // items directly under the root folder | ||
473 | foreach (InventoryItemBase it in content.Items) | ||
474 | it.Name = it.Name + " (Unavailable)"; ; | ||
475 | |||
476 | // next, add the subfolders and items of the keep folders | ||
477 | //foreach (InventoryFolderBase f in keep) | ||
478 | //{ | ||
479 | // InventoryCollection c = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, f.ID); | ||
480 | // foreach (InventoryFolderBase sf in c.Folders) | ||
481 | // { | ||
482 | // m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID); | ||
483 | // fids.Add(sf.ID); | ||
484 | // } | ||
485 | // foreach (InventoryItemBase it in c.Items) | ||
486 | // iids.Add(it.ID); | ||
487 | //} | ||
488 | |||
489 | //inv.SendRemoveInventoryFolders(fids.ToArray()); | ||
490 | |||
491 | // Increase the version number | ||
492 | //root.Version += 1; | ||
493 | //m_Scenes[0].InventoryService.UpdateFolder(root); | ||
494 | //foreach (InventoryFolderBase f in keep) | ||
495 | //{ | ||
496 | // f.Version += 1; | ||
497 | // m_Scenes[0].InventoryService.UpdateFolder(f); | ||
498 | //} | ||
499 | |||
500 | // Send the new names and versions | ||
501 | inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); | ||
502 | |||
503 | } | ||
504 | } | ||
505 | } | ||
506 | } | ||
507 | |||
508 | private void RemoveRootFolderContents2(IClientAPI client) | ||
509 | { | ||
510 | // TODO tell the viewer to remove the root folder's content | ||
511 | if (client is IClientCore) | ||
512 | { | ||
513 | IClientCore core = (IClientCore)client; | ||
514 | IClientInventory inv; | ||
515 | |||
516 | if (core.TryGet<IClientInventory>(out inv)) | ||
517 | { | ||
518 | InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | ||
519 | if (root != null) | ||
520 | { | ||
521 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.Name); | ||
405 | InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); | 522 | InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); |
406 | UUID[] ids = new UUID[content.Folders.Count]; | 523 | List<UUID> fids = new List<UUID>(); |
407 | int i = 0; | 524 | List<UUID> iids = new List<UUID>(); |
525 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); | ||
526 | |||
408 | foreach (InventoryFolderBase f in content.Folders) | 527 | foreach (InventoryFolderBase f in content.Folders) |
409 | ids[i++] = f.ID; | 528 | { |
410 | inv.SendRemoveInventoryFolders(ids); | 529 | if (f.Type == (short)AssetType.TrashFolder || f.Type == (short)AssetType.Landmark || |
411 | ids = new UUID[content.Items.Count]; | 530 | f.Type == (short)AssetType.FavoriteFolder || f.Type == (short)AssetType.CurrentOutfitFolder) |
412 | i = 0; | 531 | { |
532 | // Don't remove these because the viewer refuses to exist without them | ||
533 | // and immediately sends a request to create them again, which makes things | ||
534 | // very confusing in the viewer. | ||
535 | // Just change their names | ||
536 | f.Name = "Home " + f.Name + " (Unavailable)"; | ||
537 | keep.Add(f); | ||
538 | } | ||
539 | else | ||
540 | { | ||
541 | m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID); | ||
542 | fids.Add(f.ID); | ||
543 | } | ||
544 | } | ||
545 | |||
413 | foreach (InventoryItemBase it in content.Items) | 546 | foreach (InventoryItemBase it in content.Items) |
414 | ids[i++] = it.ID; | 547 | iids.Add(it.ID); |
415 | inv.SendRemoveInventoryItems(ids); | 548 | |
549 | // next, add the subfolders and items of the keep folders | ||
550 | foreach (InventoryFolderBase f in keep) | ||
551 | { | ||
552 | InventoryCollection c = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, f.ID); | ||
553 | foreach (InventoryFolderBase sf in c.Folders) | ||
554 | { | ||
555 | m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID); | ||
556 | fids.Add(sf.ID); | ||
557 | } | ||
558 | foreach (InventoryItemBase it in c.Items) | ||
559 | iids.Add(it.ID); | ||
560 | } | ||
561 | |||
562 | inv.SendRemoveInventoryFolders(fids.ToArray()); | ||
563 | inv.SendRemoveInventoryItems(iids.ToArray()); | ||
564 | |||
565 | // Increase the version number | ||
566 | root.Version += 1; | ||
567 | m_Scenes[0].InventoryService.UpdateFolder(root); | ||
568 | //foreach (InventoryFolderBase f in keep) | ||
569 | //{ | ||
570 | // f.Version += 1; | ||
571 | // m_Scenes[0].InventoryService.UpdateFolder(f); | ||
572 | //} | ||
573 | |||
574 | // Send the new names and versions | ||
575 | inv.SendBulkUpdateInventory(keep.ToArray(), new InventoryItemBase[0]); | ||
576 | |||
416 | } | 577 | } |
417 | } | 578 | } |
418 | } | 579 | } |
419 | } | 580 | } |
420 | 581 | ||
582 | private void RemoveSuitcaseFolderContents(IClientAPI client) | ||
583 | { | ||
584 | return; | ||
585 | |||
586 | //// TODO tell the viewer to remove the suitcase folder's content | ||
587 | //if (client is IClientCore) | ||
588 | //{ | ||
589 | // IClientCore core = (IClientCore)client; | ||
590 | // IClientInventory inv; | ||
591 | |||
592 | // if (core.TryGet<IClientInventory>(out inv)) | ||
593 | // { | ||
594 | // InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | ||
595 | // if (root != null) | ||
596 | // { | ||
597 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing suitcase inventory for user {0}", client.Name); | ||
598 | // InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
599 | // List<UUID> fids = new List<UUID>(); | ||
600 | // List<UUID> iids = new List<UUID>(); | ||
601 | |||
602 | // if (content.Folders.Count == 0) | ||
603 | // m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: no subfolders???"); | ||
604 | // foreach (InventoryFolderBase f in content.Folders) | ||
605 | // { | ||
606 | // m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID); | ||
607 | // fids.Add(f.ID); | ||
608 | // } | ||
609 | |||
610 | // foreach (InventoryItemBase it in content.Items) | ||
611 | // iids.Add(it.ID); | ||
612 | |||
613 | // inv.SendRemoveInventoryFolders(fids.ToArray()); | ||
614 | // inv.SendRemoveInventoryItems(iids.ToArray()); | ||
615 | |||
616 | // // Increase the version number | ||
617 | // root.Version += 1; | ||
618 | // m_Scenes[0].InventoryService.UpdateFolder(root); | ||
619 | // } | ||
620 | // } | ||
621 | //} | ||
622 | } | ||
623 | |||
421 | private void RestoreRootFolderContents(IClientAPI client) | 624 | private void RestoreRootFolderContents(IClientAPI client) |
422 | { | 625 | { |
626 | // This works! | ||
627 | //InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | ||
628 | //client.SendBulkUpdateInventory(root); | ||
629 | |||
630 | // SORTA KINDA some items are missing... | ||
631 | //InventoryCollection userInventory = m_Scenes[0].InventoryService.GetUserInventory(client.AgentId); | ||
632 | //InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | ||
633 | //client.SendBulkUpdateInventory(root); | ||
634 | |||
635 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root folder"); | ||
423 | if (client is IClientCore) | 636 | if (client is IClientCore) |
424 | { | 637 | { |
425 | IClientCore core = (IClientCore)client; | 638 | IClientCore core = (IClientCore)client; |
@@ -428,19 +641,80 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
428 | if (core.TryGet<IClientInventory>(out inv)) | 641 | if (core.TryGet<IClientInventory>(out inv)) |
429 | { | 642 | { |
430 | InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | 643 | InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); |
431 | client.SendBulkUpdateInventory(root); | 644 | InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); |
432 | //if (root != null) | ||
433 | //{ | ||
434 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId); | ||
435 | // InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
436 | // m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID); | ||
437 | // foreach (InventoryItemBase i in content.Items) | ||
438 | // m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder); | ||
439 | 645 | ||
440 | // inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); | 646 | inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); |
441 | //} | ||
442 | } | 647 | } |
443 | } | 648 | } |
649 | |||
650 | // ATTEMPT # 3 -- STILL DOESN'T WORK! | ||
651 | //if (client is IClientCore) | ||
652 | //{ | ||
653 | // IClientCore core = (IClientCore)client; | ||
654 | // IClientInventory inv; | ||
655 | |||
656 | // if (core.TryGet<IClientInventory>(out inv)) | ||
657 | // { | ||
658 | // InventoryCollection userInventory = m_Scenes[0].InventoryService.GetUserInventory(client.AgentId); | ||
659 | // if (userInventory != null) | ||
660 | // { | ||
661 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId); | ||
662 | // foreach (InventoryFolderBase f in userInventory.Folders) | ||
663 | // m_log.DebugFormat("[AAA]: FOLDER {0} {1} {2} {3} {4}", f.Name, f.Type, f.Version, f.ID, f.ParentID); | ||
664 | // foreach (InventoryItemBase f in userInventory.Items) | ||
665 | // m_log.DebugFormat("[AAA]: ITEM {0} {1} {2}", f.Name, f.ID, f.Folder); | ||
666 | // inv.SendBulkUpdateInventory(userInventory.Folders.ToArray(), userInventory.Items.ToArray()); | ||
667 | // } | ||
668 | // else | ||
669 | // m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve inventory for user {0}", client.AgentId); | ||
670 | // } | ||
671 | //} | ||
672 | |||
673 | |||
674 | // ATTEMPT #2 -- BETTER THAN 1, BUT STILL DOES NOT WORK WELL | ||
675 | //if (client is IClientCore) | ||
676 | //{ | ||
677 | // IClientCore core = (IClientCore)client; | ||
678 | // IClientInventory inv; | ||
679 | |||
680 | // if (core.TryGet<IClientInventory>(out inv)) | ||
681 | // { | ||
682 | // List<InventoryFolderBase> skel = m_Scenes[0].InventoryService.GetInventorySkeleton(client.AgentId); | ||
683 | // if (skel != null) | ||
684 | // { | ||
685 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId); | ||
686 | // foreach (InventoryFolderBase f in skel) | ||
687 | // m_log.DebugFormat("[AAA]: {0} {1} {2} {3} {4}", f.Name, f.Type, f.Version, f.ID, f.ParentID); | ||
688 | // inv.SendBulkUpdateInventory(skel.ToArray(), new InventoryItemBase[0]); | ||
689 | // } | ||
690 | // else | ||
691 | // m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve skeleton for user {0}", client.AgentId); | ||
692 | |||
693 | // ATTEMPT #1 -- DOES NOT WORK | ||
694 | //InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); | ||
695 | //if (root != null) | ||
696 | //{ | ||
697 | //InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); | ||
698 | //InventoryFolderBase[] folders = new InventoryFolderBase[content.Folders.Count + 1]; | ||
699 | //m_log.DebugFormat("[AAA]: Folder name {0}, id {1}, version {2}, parent {3}", root.Name, root.ID, root.Version, root.ParentID); | ||
700 | //folders[0] = root; | ||
701 | //for (int count = 1; count < content.Folders.Count + 1; count++) | ||
702 | //{ | ||
703 | // folders[count] = content.Folders[count - 1]; | ||
704 | // m_log.DebugFormat("[AAA]: Name={0}, Id={1}, Version={2}, type={3}, folderID={4}", | ||
705 | // folders[count].Name, folders[count].ID, folders[count].Version, folders[count].Type, folders[count].ParentID); | ||
706 | //} | ||
707 | //foreach (InventoryItemBase i in content.Items) | ||
708 | // m_log.DebugFormat("[AAA]: Name={0}, folderID={1}", i.Name, i.Folder); | ||
709 | //inv.SendBulkUpdateInventory(/*content.Folders.ToArray()*/ folders, content.Items.ToArray()); | ||
710 | //} | ||
711 | //} | ||
712 | //} | ||
713 | } | ||
714 | |||
715 | private void RestoreSuitcaseFolderContents(IClientAPI client) | ||
716 | { | ||
717 | |||
444 | } | 718 | } |
445 | 719 | ||
446 | private GridRegion MakeRegion(AgentCircuitData aCircuit) | 720 | private GridRegion MakeRegion(AgentCircuitData aCircuit) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 4be3804..cf6d2f7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -297,14 +297,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
297 | return m_LocalGridInventoryService.CreateUserInventory(userID); | 297 | return m_LocalGridInventoryService.CreateUserInventory(userID); |
298 | } | 298 | } |
299 | 299 | ||
300 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | 300 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userID) |
301 | { | 301 | { |
302 | return m_LocalGridInventoryService.GetInventorySkeleton(userId); | 302 | string invURL = GetInventoryServiceURL(userID); |
303 | |||
304 | if (invURL == null) // not there, forward to local inventory connector to resolve | ||
305 | return m_LocalGridInventoryService.GetInventorySkeleton(userID); | ||
306 | |||
307 | IInventoryService connector = GetConnector(invURL); | ||
308 | |||
309 | return connector.GetInventorySkeleton(userID); | ||
303 | } | 310 | } |
304 | 311 | ||
305 | public InventoryCollection GetUserInventory(UUID userID) | 312 | public InventoryCollection GetUserInventory(UUID userID) |
306 | { | 313 | { |
307 | return null; | 314 | string invURL = GetInventoryServiceURL(userID); |
315 | m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetUserInventory for {0} {1}", userID, invURL); | ||
316 | |||
317 | if (invURL == null) // not there, forward to local inventory connector to resolve | ||
318 | return m_LocalGridInventoryService.GetUserInventory(userID); | ||
319 | |||
320 | InventoryCollection c = m_Cache.GetUserInventory(userID); | ||
321 | if (c != null) | ||
322 | return c; | ||
323 | |||
324 | IInventoryService connector = GetConnector(invURL); | ||
325 | c = connector.GetUserInventory(userID); | ||
326 | |||
327 | m_Cache.Cache(userID, c); | ||
328 | return c; | ||
308 | } | 329 | } |
309 | 330 | ||
310 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | 331 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) |
@@ -362,8 +383,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
362 | if (invURL == null) // not there, forward to local inventory connector to resolve | 383 | if (invURL == null) // not there, forward to local inventory connector to resolve |
363 | return m_LocalGridInventoryService.GetFolderContent(userID, folderID); | 384 | return m_LocalGridInventoryService.GetFolderContent(userID, folderID); |
364 | 385 | ||
365 | IInventoryService connector = GetConnector(invURL); | 386 | InventoryCollection c = m_Cache.GetFolderContent(userID, folderID); |
387 | if (c != null) | ||
388 | { | ||
389 | m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent found content in cache " + folderID); | ||
390 | return c; | ||
391 | } | ||
366 | 392 | ||
393 | IInventoryService connector = GetConnector(invURL); | ||
367 | return connector.GetFolderContent(userID, folderID); | 394 | return connector.GetFolderContent(userID, folderID); |
368 | 395 | ||
369 | } | 396 | } |
@@ -377,8 +404,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
377 | if (invURL == null) // not there, forward to local inventory connector to resolve | 404 | if (invURL == null) // not there, forward to local inventory connector to resolve |
378 | return m_LocalGridInventoryService.GetFolderItems(userID, folderID); | 405 | return m_LocalGridInventoryService.GetFolderItems(userID, folderID); |
379 | 406 | ||
380 | IInventoryService connector = GetConnector(invURL); | 407 | List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID); |
408 | if (items != null) | ||
409 | { | ||
410 | m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems found items in cache " + folderID); | ||
411 | return items; | ||
412 | } | ||
381 | 413 | ||
414 | IInventoryService connector = GetConnector(invURL); | ||
382 | return connector.GetFolderItems(userID, folderID); | 415 | return connector.GetFolderItems(userID, folderID); |
383 | 416 | ||
384 | } | 417 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 0fe778d..1e434b9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |||
@@ -12,6 +12,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
12 | 12 | ||
13 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); | 13 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); |
14 | private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); | 14 | private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); |
15 | private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>(); | ||
15 | 16 | ||
16 | public void Cache(UUID userID, InventoryFolderBase root) | 17 | public void Cache(UUID userID, InventoryFolderBase root) |
17 | { | 18 | { |
@@ -55,5 +56,55 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
55 | 56 | ||
56 | return null; | 57 | return null; |
57 | } | 58 | } |
59 | |||
60 | public void Cache(UUID userID, InventoryCollection inv) | ||
61 | { | ||
62 | lock (m_Inventories) | ||
63 | m_Inventories.AddOrUpdate(userID, inv, 120); | ||
64 | } | ||
65 | |||
66 | public InventoryCollection GetUserInventory(UUID userID) | ||
67 | { | ||
68 | InventoryCollection inv = null; | ||
69 | if (m_Inventories.TryGetValue(userID, out inv)) | ||
70 | return inv; | ||
71 | return null; | ||
72 | } | ||
73 | |||
74 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) | ||
75 | { | ||
76 | InventoryCollection inv = null; | ||
77 | InventoryCollection c; | ||
78 | if (m_Inventories.TryGetValue(userID, out inv)) | ||
79 | { | ||
80 | c = new InventoryCollection(); | ||
81 | c.UserID = userID; | ||
82 | |||
83 | c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f) | ||
84 | { | ||
85 | return f.ParentID == folderID; | ||
86 | }); | ||
87 | c.Items = inv.Items.FindAll(delegate(InventoryItemBase i) | ||
88 | { | ||
89 | return i.Folder == folderID; | ||
90 | }); | ||
91 | return c; | ||
92 | } | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | ||
97 | { | ||
98 | InventoryCollection inv = null; | ||
99 | if (m_Inventories.TryGetValue(userID, out inv)) | ||
100 | { | ||
101 | List<InventoryItemBase> items = inv.Items.FindAll(delegate(InventoryItemBase i) | ||
102 | { | ||
103 | return i.Folder == folderID; | ||
104 | }); | ||
105 | return items; | ||
106 | } | ||
107 | return null; | ||
108 | } | ||
58 | } | 109 | } |
59 | } | 110 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 77573c3..990dffb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
172 | 172 | ||
173 | public InventoryCollection GetUserInventory(UUID userID) | 173 | public InventoryCollection GetUserInventory(UUID userID) |
174 | { | 174 | { |
175 | return null; | 175 | return m_RemoteConnector.GetUserInventory(userID); |
176 | } | 176 | } |
177 | 177 | ||
178 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | 178 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) |
@@ -193,16 +193,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
193 | { | 193 | { |
194 | InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); | 194 | InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); |
195 | 195 | ||
196 | if (UserManager != null) | 196 | if (invCol != null && UserManager != null) |
197 | { | 197 | { |
198 | // Protect ourselves against the caller subsequently modifying the items list | 198 | // Protect ourselves against the caller subsequently modifying the items list |
199 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); | 199 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); |
200 | 200 | ||
201 | Util.FireAndForget(delegate | 201 | if (items != null && items.Count > 0) |
202 | { | 202 | Util.FireAndForget(delegate |
203 | foreach (InventoryItemBase item in items) | 203 | { |
204 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); | 204 | foreach (InventoryItemBase item in items) |
205 | }); | 205 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); |
206 | }); | ||
206 | } | 207 | } |
207 | 208 | ||
208 | return invCol; | 209 | return invCol; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5abd74f..10b25ed 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -36,6 +36,7 @@ using OpenMetaverse.Packets; | |||
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework; | 38 | using OpenSim.Region.Framework; |
39 | using OpenSim.Framework.Client; | ||
39 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using OpenSim.Region.Framework.Scenes.Serialization; |
41 | 42 | ||
@@ -117,31 +118,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | /// <param name="item"></param> | 118 | /// <param name="item"></param> |
118 | public bool AddInventoryItem(InventoryItemBase item) | 119 | public bool AddInventoryItem(InventoryItemBase item) |
119 | { | 120 | { |
120 | if (UUID.Zero == item.Folder) | 121 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) |
121 | { | 122 | { |
122 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 123 | int userlevel = 0; |
123 | if (f != null) | 124 | if (Permissions.IsGod(item.Owner)) |
124 | { | 125 | { |
125 | // m_log.DebugFormat( | 126 | userlevel = 1; |
126 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | 127 | } |
127 | // f.Name, (AssetType)f.Type, item.Name); | 128 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); |
129 | |||
130 | return true; | ||
131 | } | ||
132 | |||
133 | // OK so either the viewer didn't send a folderID or AddItem failed | ||
134 | UUID originalFolder = item.Folder; | ||
135 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | ||
136 | if (f != null) | ||
137 | { | ||
138 | m_log.DebugFormat( | ||
139 | "[AGENT INVENTORY]: Found folder {0} type {1} for item {2}", | ||
140 | f.Name, (AssetType)f.Type, item.Name); | ||
128 | 141 | ||
142 | item.Folder = f.ID; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | f = InventoryService.GetRootFolder(item.Owner); | ||
147 | if (f != null) | ||
148 | { | ||
129 | item.Folder = f.ID; | 149 | item.Folder = f.ID; |
130 | } | 150 | } |
131 | else | 151 | else |
132 | { | 152 | { |
133 | f = InventoryService.GetRootFolder(item.Owner); | 153 | m_log.WarnFormat( |
134 | if (f != null) | 154 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", |
135 | { | 155 | item.Owner, item.Name); |
136 | item.Folder = f.ID; | 156 | return false; |
137 | } | ||
138 | else | ||
139 | { | ||
140 | m_log.WarnFormat( | ||
141 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
142 | item.Owner, item.Name); | ||
143 | return false; | ||
144 | } | ||
145 | } | 157 | } |
146 | } | 158 | } |
147 | 159 | ||
@@ -153,7 +165,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
153 | userlevel = 1; | 165 | userlevel = 1; |
154 | } | 166 | } |
155 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); | 167 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); |
156 | 168 | ||
169 | if (originalFolder != UUID.Zero) | ||
170 | { | ||
171 | // Tell the viewer that the item didn't go there | ||
172 | ChangePlacement(item, f); | ||
173 | } | ||
174 | |||
157 | return true; | 175 | return true; |
158 | } | 176 | } |
159 | else | 177 | else |
@@ -165,7 +183,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | return false; | 183 | return false; |
166 | } | 184 | } |
167 | } | 185 | } |
168 | 186 | ||
187 | private void ChangePlacement(InventoryItemBase item, InventoryFolderBase f) | ||
188 | { | ||
189 | ScenePresence sp = GetScenePresence(item.Owner); | ||
190 | if (sp != null) | ||
191 | { | ||
192 | if (sp.ControllingClient is IClientCore) | ||
193 | { | ||
194 | IClientCore core = (IClientCore)sp.ControllingClient; | ||
195 | IClientInventory inv; | ||
196 | |||
197 | if (core.TryGet<IClientInventory>(out inv)) | ||
198 | { | ||
199 | InventoryFolderBase parent = new InventoryFolderBase(f.ParentID, f.Owner); | ||
200 | parent = InventoryService.GetFolder(parent); | ||
201 | inv.SendRemoveInventoryItems(new UUID[] { item.ID }); | ||
202 | inv.SendBulkUpdateInventory(new InventoryFolderBase[0], new InventoryItemBase[] { item }); | ||
203 | string message = "The item was placed in folder " + f.Name; | ||
204 | if (parent != null) | ||
205 | message += " under " + parent.Name; | ||
206 | sp.ControllingClient.SendAgentAlertMessage(message, false); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
169 | /// <summary> | 212 | /// <summary> |
170 | /// Add the given inventory item to a user's inventory. | 213 | /// Add the given inventory item to a user's inventory. |
171 | /// </summary> | 214 | /// </summary> |