aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs316
1 files changed, 295 insertions, 21 deletions
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)