diff --git a/OpenSim/Framework/AssetConfig.cs b/OpenSim/Framework/AssetConfig.cs index 9ae98d773a..cc0217f0a5 100644 --- a/OpenSim/Framework/AssetConfig.cs +++ b/OpenSim/Framework/AssetConfig.cs @@ -40,6 +40,7 @@ namespace OpenSim.Framework public string DatabaseConnect = String.Empty; public string DatabaseProvider = String.Empty; public uint HttpPort = DefaultHttpPort; + public string AssetSetsLocation = string.Empty; public AssetConfig(string description, string filename) { @@ -58,6 +59,10 @@ namespace OpenSim.Framework configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false); + + configMember.addConfigurationOption("assetset_location", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Location of 'AssetSets.xml'", + string.Format(".{0}assets{0}AssetSets.xml", System.IO.Path.DirectorySeparatorChar), false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -70,6 +75,9 @@ namespace OpenSim.Framework case "database_connect": DatabaseConnect = (string) configuration_result; break; + case "assetset_location": + AssetSetsLocation = (string) configuration_result; + break; case "http_port": HttpPort = (uint) configuration_result; break; @@ -78,4 +86,4 @@ namespace OpenSim.Framework return true; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index 6fe9fb4863..9d0f697882 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs @@ -86,12 +86,6 @@ namespace OpenSim.Framework.AssetLoader.Filesystem } } - public void ForEachDefaultXmlAsset(Action action) - { - string assetSetFilename = Path.Combine(Util.assetsDir(), "AssetSets.xml"); - - ForEachDefaultXmlAsset(assetSetFilename, action); - } public void ForEachDefaultXmlAsset(string assetSetFilename, Action action) { @@ -99,16 +93,18 @@ namespace OpenSim.Framework.AssetLoader.Filesystem if (File.Exists(assetSetFilename)) { string assetSetPath = "ERROR"; - + string assetRootPath = ""; try { XmlConfigSource source = new XmlConfigSource(assetSetFilename); + assetRootPath = Path.GetFullPath(source.SavePath); + assetRootPath = Path.GetDirectoryName(assetRootPath); for (int i = 0; i < source.Configs.Count; i++) { assetSetPath = source.Configs[i].GetString("file", String.Empty); - LoadXmlAssetSet(Path.Combine(Util.assetsDir(), assetSetPath), assets); + LoadXmlAssetSet(Path.Combine(assetRootPath, assetSetPath), assets); } } catch (XmlException e) @@ -118,7 +114,7 @@ namespace OpenSim.Framework.AssetLoader.Filesystem } else { - m_log.Error("[ASSETS]: Asset set control file assets/AssetSets.xml does not exist! No assets loaded."); + m_log.ErrorFormat("[ASSETS]: Asset set control file {0} does not exist! No assets loaded.", assetSetFilename); } assets.ForEach(action); diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index a289fb79a5..137bde917c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -106,11 +106,11 @@ namespace OpenSim.Framework.Communications.Cache } } - public virtual void LoadDefaultAssets() + public virtual void LoadDefaultAssets(string pAssetSetsXml) { m_log.Info("[ASSET SERVER]: Setting up asset database"); - assetLoader.ForEachDefaultXmlAsset(StoreAsset); + assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); } public AssetServerBase() diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index cf3490b4fe..0b05adf554 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -52,11 +52,9 @@ namespace OpenSim.Framework.Communications.Cache /// protected Dictionary libraryFolders = new Dictionary(); - - public LibraryRootFolder() + + public LibraryRootFolder(string pLibrariesLocation) { - m_log.Info("[LIBRARY INVENTORY]: Loading library inventory"); - Owner = libOwner; ID = new UUID("00000112-000f-0000-0000-000100bba000"); Name = "OpenSim Library"; @@ -66,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache libraryFolders.Add(ID, this); - LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); + LoadLibraries(pLibrariesLocation); } public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, @@ -96,9 +94,7 @@ namespace OpenSim.Framework.Communications.Cache /// protected void LoadLibraries(string librariesControlPath) { - m_log.InfoFormat( - "[LIBRARY INVENTORY]: Loading libraries control file {0}", librariesControlPath); - + m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath); LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); } @@ -106,17 +102,18 @@ namespace OpenSim.Framework.Communications.Cache /// Read a library set from config /// /// - protected void ReadLibraryFromConfig(IConfig config) + protected void ReadLibraryFromConfig(IConfig config, string path) { + string basePath = Path.GetDirectoryName(path); string foldersPath = Path.Combine( - Util.inventoryDir(), config.GetString("foldersFile", String.Empty)); + basePath, config.GetString("foldersFile", String.Empty)); LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); string itemsPath = Path.Combine( - Util.inventoryDir(), config.GetString("itemsFile", String.Empty)); + basePath, config.GetString("itemsFile", String.Empty)); LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); } @@ -125,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache /// Read a library inventory folder from a loaded configuration /// /// - private void ReadFolderFromConfig(IConfig config) + private void ReadFolderFromConfig(IConfig config, string path) { InventoryFolderImpl folderInfo = new InventoryFolderImpl(); @@ -158,7 +155,7 @@ namespace OpenSim.Framework.Communications.Cache /// Read a library inventory item metadata from a loaded configuration /// /// - private void ReadItemFromConfig(IConfig config) + private void ReadItemFromConfig(IConfig config, string path) { InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; @@ -195,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache } } - private delegate void ConfigAction(IConfig config); + private delegate void ConfigAction(IConfig config, string path); /// /// Load the given configuration at a path and perform an action on each Config contained within it @@ -213,7 +210,7 @@ namespace OpenSim.Framework.Communications.Cache for (int i = 0; i < source.Configs.Count; i++) { - action(source.Configs[i]); + action(source.Configs[i], path); } } catch (XmlException e) diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs index 02b8465f1e..3d66311168 100644 --- a/OpenSim/Framework/ConfigSettings.cs +++ b/OpenSim/Framework/ConfigSettings.cs @@ -179,5 +179,30 @@ namespace OpenSim.Framework get { return m_dumpAssetsToFile; } set { m_dumpAssetsToFile = value; } } + + protected string m_librariesXMLFile; + public string LibrariesXMLFile + { + get + { + return m_librariesXMLFile; + } + set + { + m_librariesXMLFile = value; + } + } + protected string m_assetSetsXMLFile; + public string AssetSetsXMLFile + { + get + { + return m_assetSetsXMLFile; + } + set + { + m_assetSetsXMLFile = value; + } + } } } diff --git a/OpenSim/Framework/IAssetLoader.cs b/OpenSim/Framework/IAssetLoader.cs index 6aa71d35fb..3ecc051cbc 100644 --- a/OpenSim/Framework/IAssetLoader.cs +++ b/OpenSim/Framework/IAssetLoader.cs @@ -31,7 +31,6 @@ namespace OpenSim.Framework { public interface IAssetLoader { - void ForEachDefaultXmlAsset(Action action); void ForEachDefaultXmlAsset(string assetSetFilename, Action action); } } \ No newline at end of file diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index 87ba271465..cc048b73ea 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -47,6 +47,7 @@ namespace OpenSim.Framework public uint HttpPort = DefaultHttpPort; public bool HttpSSL = DefaultHttpSSL; public uint DefaultUserLevel = 0; + public string LibraryXmlfile = ""; private Uri m_inventoryUrl; @@ -109,6 +110,11 @@ namespace OpenSim.Framework "Default Inventory Server URI", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/", false); + configMember.addConfigurationOption("library_location", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Path to library control file", + string.Format(".{0}inventory{0}Libraries.xml", System.IO.Path.DirectorySeparatorChar), false); + configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Data.MySQL.dll", false); configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING, @@ -173,7 +179,10 @@ namespace OpenSim.Framework case "default_loginLevel": DefaultUserLevel = (uint)configuration_result; - break; + break; + case "library_location": + LibraryXmlfile = (string)configuration_result; + break; } return true; diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 6d1028bbc4..72300b5dfc 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -87,8 +87,8 @@ namespace OpenSim.Grid.AssetServer m_log.Info("[ASSET]: Setting up asset DB"); setupDB(config); - m_log.Info("[ASSET]: Loading default asset set.."); - LoadDefaultAssets(); + m_log.Info("[ASSET]: Loading default asset set from '" + config.AssetSetsLocation + "'"); + LoadDefaultAssets(config.AssetSetsLocation); m_log.Info("[ASSET]: Starting HTTP process"); m_httpServer = new BaseHttpServer(config.HttpPort); @@ -142,9 +142,9 @@ namespace OpenSim.Grid.AssetServer } } - public void LoadDefaultAssets() + public void LoadDefaultAssets(string pAssetSetsLocation) { - assetLoader.ForEachDefaultXmlAsset(StoreAsset); + assetLoader.ForEachDefaultXmlAsset(pAssetSetsLocation, StoreAsset); } protected void StoreAsset(AssetBase asset) diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index f688e4c2eb..324675712f 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -137,7 +137,7 @@ namespace OpenSim.Grid.UserServer protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) { m_loginService = new UserLoginService( - m_userManager, inventoryService, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); + m_userManager, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg); } protected virtual void AddHttpHandlers() diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index bfaf5af7dc..12cb0ea070 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -43,8 +43,7 @@ namespace OpenSim protected NetworkServersInfo m_networkServersInfo; public ConfigurationLoader() - { - + { } public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource, out ConfigSettings configSettings, out NetworkServersInfo networkInfo) @@ -149,7 +148,9 @@ namespace OpenSim config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); config.Set("user_source", ""); config.Set("asset_plugin", "OpenSim.Data.SQLite.dll"); - config.Set("asset_source", ""); + config.Set("asset_source", ""); + config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar)); + config.Set("AssetSetsXMLFile", string.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar)); config.Set("dump_assets_to_file", false); } @@ -186,7 +187,6 @@ namespace OpenSim m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode", false); m_configSettings.PhysicsEngine = startupConfig.GetString("physics"); m_configSettings.MeshEngineName = startupConfig.GetString("meshing"); - m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim", true); m_configSettings.See_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true); @@ -218,7 +218,10 @@ namespace OpenSim m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin"); m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source"); - m_configSettings.DumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); + m_configSettings.LibrariesXMLFile = standaloneConfig.GetString("LibrariesXMLFile"); + m_configSettings.AssetSetsXMLFile = standaloneConfig.GetString("AssetSetsXMLFile"); + + m_configSettings.DumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); } m_networkServersInfo.loadFromConfiguration(m_config.Source); diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 832043d441..9031a8ba81 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -178,7 +178,7 @@ namespace OpenSim m_stats = StatsManager.StartCollectingSimExtraStats(); - LibraryRootFolder libraryRootFolder = new LibraryRootFolder(); + LibraryRootFolder libraryRootFolder = new LibraryRootFolder(m_configSettings.LibrariesXMLFile); // StandAlone mode? is determined by !startupConfig.GetBoolean("gridmode", false) if (m_configSettings.Standalone) @@ -291,7 +291,7 @@ namespace OpenSim else { SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource); - sqlAssetServer.LoadDefaultAssets(); + sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); assetServer = sqlAssetServer; } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index bd48f8c82a..cc117ad0ae 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -178,7 +178,7 @@ ;WorldMapModule = "WorldMap" ;MapImageModule = "MapImageModule" - + [StandAlone] accounts_authenticate = true @@ -225,6 +225,14 @@ ; User Source MySQL example ;user_source = "Data Source=localhost;Database=opensim;User ID=opensim;Password=****;" + ; Specifies the location and filename of the default inventory library control file. The path can be relative or absolute + ; Default is ./inventory/Libraries.xml + ;LibrariesXMLFile="./inventory/Libraries.xml" + + ; Specifies the location and filename of the inventory library assets control file. The path can be relative or absolute + ; Setting is optional. Default is ./assets/AssetSets.xml + ;AssetSetsXMLFile="./assets/AssetSets.xml" + dump_assets_to_file = false