aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-09-29 14:41:16 +0000
committerJustin Clarke Casey2008-09-29 14:41:16 +0000
commit7ec065198aea732ffc241ab70a72acfb534aeccc (patch)
treea7ccd45d10c995870ef0807f586d39a7cb8fc1a8
parentfixes future mantis from SachaMagne. (diff)
downloadopensim-SC_OLD-7ec065198aea732ffc241ab70a72acfb534aeccc.zip
opensim-SC_OLD-7ec065198aea732ffc241ab70a72acfb534aeccc.tar.gz
opensim-SC_OLD-7ec065198aea732ffc241ab70a72acfb534aeccc.tar.bz2
opensim-SC_OLD-7ec065198aea732ffc241ab70a72acfb534aeccc.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=2294
* This is an initial basic experimental code for inventory import and export from the region server * Probably not yet ready for general use * Thanks Kayne!
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs15
-rw-r--r--OpenSim/Region/Application/OpenSim.cs4
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs89
3 files changed, 33 insertions, 75 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 61343a0..f78cdee 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -316,6 +316,21 @@ namespace OpenSim.Framework.Communications.Cache
316 return folderList; 316 return folderList;
317 } 317 }
318 318
319 public List<InventoryFolderImpl> RequestListOfFolderImpls()
320 {
321 List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>();
322
323 lock (SubFolders)
324 {
325 foreach (InventoryFolderImpl folder in SubFolders.Values)
326 {
327 folderList.Add(folder);
328 }
329 }
330
331 return folderList;
332 }
333
319 public int TotalCount 334 public int TotalCount
320 { 335 {
321 get 336 get
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 1a5c098..0b3d5df 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -282,6 +282,10 @@ namespace OpenSim
282 SaveInv(cmdparams); 282 SaveInv(cmdparams);
283 break; 283 break;
284 284
285 case "load-inv":
286 LoadInv(cmdparams);
287 break;
288
285 case "plugin": 289 case "plugin":
286 m_sceneManager.SendCommandToPluginModules(cmdparams); 290 m_sceneManager.SendCommandToPluginModules(cmdparams);
287 break; 291 break;
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 0502d80..8f6a3ff 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -49,6 +49,8 @@ using OpenSim.Region.Environment.Interfaces;
49using OpenSim.Region.Environment.Scenes; 49using OpenSim.Region.Environment.Scenes;
50using OpenSim.Region.Physics.Manager; 50using OpenSim.Region.Physics.Manager;
51 51
52using OpenSim.Region.Environment.Modules.Avatar.Inventory;
53
52namespace OpenSim 54namespace OpenSim
53{ 55{
54 /// <summary> 56 /// <summary>
@@ -707,90 +709,27 @@ namespace OpenSim
707 protected void SaveInv(string[] cmdparams) 709 protected void SaveInv(string[] cmdparams)
708 { 710 {
709 m_log.Error("[CONSOLE]: This command has not yet been implemented!"); 711 m_log.Error("[CONSOLE]: This command has not yet been implemented!");
710
711 if (cmdparams.Length < 3) 712 if (cmdparams.Length < 3)
712 { 713 {
713 m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); 714 m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
714 return; 715 return;
715 } 716 }
717 new InventoryArchiveWriteRequest(m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(cmdparams);
718 }
716 719
717 string firstName = cmdparams[0]; 720 /// <summary>
718 string lastName = cmdparams[1]; 721 /// Load inventory from a tar.gz file.
719 string invPath = cmdparams[2]; 722 /// </summary>
720 //string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); 723 /// <param name="cmdparams"></param>
721 724 protected void LoadInv(string[] cmdparams)
722 UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); 725 {
723 if (null == userProfile) 726 m_log.Error("[CONSOLE]: This command has not yet been implemented!");
724 { 727 if (cmdparams.Length < 3)
725 m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName);
726 return;
727 }
728
729 CachedUserInfo userInfo = m_commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
730 if (null == userInfo)
731 {
732 m_log.ErrorFormat("[CONSOLE]: Failed to find user info for {0} {1} {2}", firstName, lastName, userProfile.ID);
733 return;
734 }
735
736 InventoryFolderImpl inventoryFolder = null;
737 InventoryItemBase inventoryItem = null;
738
739 if (userInfo.HasReceivedInventory)
740 {
741 // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
742 // itself (possibly at a small loss in efficiency).
743 string[] components
744 = invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries);
745 invPath = String.Empty;
746 foreach (string c in components)
747 {
748 invPath += c + InventoryFolderImpl.PATH_DELIMITER;
749 }
750
751 invPath = invPath.Remove(invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
752
753 // Annoyingly Split actually returns the original string if the input string consists only of delimiters
754 // Therefore if we still start with a / after the split, then we need the root folder
755 if (invPath.StartsWith(InventoryFolderImpl.PATH_DELIMITER))
756 {
757 inventoryFolder = userInfo.RootFolder;
758 }
759 else
760 {
761 inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath);
762 }
763
764 // The path may point to an item instead
765 if (inventoryFolder == null)
766 {
767 inventoryItem = userInfo.RootFolder.FindItemByPath(invPath);
768 }
769 }
770 else
771 { 728 {
772 m_log.ErrorFormat("[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}", firstName, lastName, userProfile.ID); 729 m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
773 return; 730 return;
774 } 731 }
775 732 new InventoryArchiveReadRequest(m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(cmdparams);
776 if (null == inventoryFolder)
777 {
778 if (null == inventoryItem)
779 {
780 m_log.ErrorFormat("[CONSOLE]: Could not find inventory entry at path {0}", invPath);
781 return;
782 }
783 else
784 {
785 m_log.InfoFormat("[CONSOLE]: Found item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID,
786 invPath);
787 }
788 }
789 else
790 {
791 m_log.InfoFormat("[CONSOLE]: Found folder {0} {1} at {2}", inventoryFolder.Name, inventoryFolder.ID,
792 invPath);
793 }
794 } 733 }
795 734
796 /// <summary> 735 /// <summary>