From 7ec065198aea732ffc241ab70a72acfb534aeccc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 29 Sep 2008 14:41:16 +0000 Subject: [PATCH] * 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! --- .../Cache/InventoryFolderImpl.cs | 15 ++++ OpenSim/Region/Application/OpenSim.cs | 4 + OpenSim/Region/Application/OpenSimBase.cs | 89 +++---------------- 3 files changed, 33 insertions(+), 75 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 61343a024f..f78cdeea71 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -316,6 +316,21 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } + public List RequestListOfFolderImpls() + { + List folderList = new List(); + + lock (SubFolders) + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + folderList.Add(folder); + } + } + + return folderList; + } + public int TotalCount { get diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 1a5c09872e..0b3d5dffdb 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -282,6 +282,10 @@ namespace OpenSim SaveInv(cmdparams); break; + case "load-inv": + LoadInv(cmdparams); + break; + case "plugin": m_sceneManager.SendCommandToPluginModules(cmdparams); break; diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 0502d802ea..8f6a3ff2ba 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -49,6 +49,8 @@ using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Environment.Modules.Avatar.Inventory; + namespace OpenSim { /// @@ -707,90 +709,27 @@ namespace OpenSim protected void SaveInv(string[] cmdparams) { m_log.Error("[CONSOLE]: This command has not yet been implemented!"); - if (cmdparams.Length < 3) { m_log.Error("[CONSOLE]: usage is save-inv []"); return; } + new InventoryArchiveWriteRequest(m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(cmdparams); + } - string firstName = cmdparams[0]; - string lastName = cmdparams[1]; - string invPath = cmdparams[2]; - //string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); - - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); - if (null == userProfile) + /// + /// Load inventory from a tar.gz file. + /// + /// + protected void LoadInv(string[] cmdparams) + { + m_log.Error("[CONSOLE]: This command has not yet been implemented!"); + if (cmdparams.Length < 3) { - m_log.ErrorFormat("[CONSOLE]: Failed to find user {0} {1}", firstName, lastName); + m_log.Error("[CONSOLE]: usage is load-inv []"); return; } - - CachedUserInfo userInfo = m_commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); - if (null == userInfo) - { - m_log.ErrorFormat("[CONSOLE]: Failed to find user info for {0} {1} {2}", firstName, lastName, userProfile.ID); - return; - } - - InventoryFolderImpl inventoryFolder = null; - InventoryItemBase inventoryItem = null; - - if (userInfo.HasReceivedInventory) - { - // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl - // itself (possibly at a small loss in efficiency). - string[] components - = invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); - invPath = String.Empty; - foreach (string c in components) - { - invPath += c + InventoryFolderImpl.PATH_DELIMITER; - } - - invPath = invPath.Remove(invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); - - // Annoyingly Split actually returns the original string if the input string consists only of delimiters - // Therefore if we still start with a / after the split, then we need the root folder - if (invPath.StartsWith(InventoryFolderImpl.PATH_DELIMITER)) - { - inventoryFolder = userInfo.RootFolder; - } - else - { - inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath); - } - - // The path may point to an item instead - if (inventoryFolder == null) - { - inventoryItem = userInfo.RootFolder.FindItemByPath(invPath); - } - } - else - { - m_log.ErrorFormat("[CONSOLE]: Have not yet received inventory info for user {0} {1} {2}", firstName, lastName, userProfile.ID); - return; - } - - if (null == inventoryFolder) - { - if (null == inventoryItem) - { - m_log.ErrorFormat("[CONSOLE]: Could not find inventory entry at path {0}", invPath); - return; - } - else - { - m_log.InfoFormat("[CONSOLE]: Found item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID, - invPath); - } - } - else - { - m_log.InfoFormat("[CONSOLE]: Found folder {0} {1} at {2}", inventoryFolder.Name, inventoryFolder.ID, - invPath); - } + new InventoryArchiveReadRequest(m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(cmdparams); } ///