From 5818958a9a6c5a10743928973172d255632af6de Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 24 Sep 2007 02:41:13 +0000 Subject: [PATCH] *** CHANGED CONFIG BEHAVIOUR *** * Changed really strange LocalSettings behaviour with enforcing hard-coded plugin names if none supplied * UserServices and InventoryPlugin will only load if supplied with filename --- .../InventoryServiceBase.cs | 32 +++++++-------- .../Framework/UserManager/UserManagerBase.cs | 41 +++++++++---------- OpenSim/Region/Application/OpenSimMain.cs | 4 +- .../Local/CommunicationsLocal.cs | 26 +++++------- 4 files changed, 47 insertions(+), 56 deletions(-) diff --git a/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs index dc66bd43ac..d76fac51c3 100644 --- a/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs +++ b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs @@ -23,28 +23,28 @@ namespace OpenSim.Framework.InventoryServiceBase /// The filename to the user server plugin DLL public void AddPlugin(string FileName) { - MainLog.Instance.Verbose("Inventory", "Inventorystorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - foreach (Type pluginType in pluginAssembly.GetTypes()) + if (!String.IsNullOrEmpty(FileName)) { - if (!pluginType.IsAbstract) + MainLog.Instance.Verbose("Inventory", "Inventorystorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) { - Type typeInterface = pluginType.GetInterface("IInventoryData", true); - - if (typeInterface != null) + if (!pluginType.IsAbstract) { - IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(); - this.m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); - } + Type typeInterface = pluginType.GetInterface("IInventoryData", true); - typeInterface = null; + if (typeInterface != null) + { + IInventoryData plug = + (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this.m_plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); + } + } } } - - pluginAssembly = null; } /// diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index e11204b14c..4a2870bf0f 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.Collections; using System.Collections.Generic; @@ -32,15 +33,11 @@ using System.Reflection; using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; +using OpenSim.Framework.Configuration; using OpenSim.Framework.Console; using OpenSim.Framework.Data; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; - namespace OpenSim.Framework.UserManagement { public abstract class UserManagerBase @@ -54,32 +51,32 @@ namespace OpenSim.Framework.UserManagement /// The filename to the user server plugin DLL public void AddPlugin(string FileName) { - MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); - foreach (Type pluginType in pluginAssembly.GetTypes()) + if (!String.IsNullOrEmpty(FileName)) { - if (!pluginType.IsAbstract) + MainLog.Instance.Verbose("Userstorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + MainLog.Instance.Verbose("Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + foreach (Type pluginType in pluginAssembly.GetTypes()) { - Type typeInterface = pluginType.GetInterface("IUserData", true); - - if (typeInterface != null) + if (!pluginType.IsAbstract) { - IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(); - AddPlugin(plug); - } + Type typeInterface = pluginType.GetInterface("IUserData", true); - typeInterface = null; + if (typeInterface != null) + { + IUserData plug = + (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + AddPlugin(plug); + } + } } } - - pluginAssembly = null; } - private void AddPlugin(IUserData plug) + public void AddPlugin(IUserData plug) { + plug.Initialise(); this._plugins.Add(plug.getName(), plug); MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 161e73f5fd..c28025bc14 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -79,8 +79,8 @@ namespace OpenSim private bool standaloneAuthenticate = false; private string standaloneWelcomeMessage = null; - private string standaloneInventoryPlugin = ""; - private string standaloneUserPlugin = ""; + private string standaloneInventoryPlugin = "OpenSim.Framework.Data.SQLite.dll"; + private string standaloneUserPlugin = "OpenSim.Framework.Data.DB4o.dll"; private string m_assetStorage = "db4o"; diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 1f543103dc..3031b8af19 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -44,13 +44,13 @@ namespace OpenSim.Region.Communications.Local public LocalUserServices UserServices; public LocalLoginService LoginServices; public LocalInventoryService InvenServices; - + protected LocalSettings m_settings; - protected CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache ) + protected CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) : base(serversInfo, httpServer, assetCache) { - + } public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings) @@ -94,7 +94,7 @@ namespace OpenSim.Region.Communications.Local if (cmmdParams.Length < 2) { - + firstName = MainLog.Instance.CmdPrompt("First name", "Default"); lastName = MainLog.Instance.CmdPrompt("Last name", "User"); password = MainLog.Instance.PasswdPrompt("Password"); @@ -126,7 +126,7 @@ namespace OpenSim.Region.Communications.Local { return LLUUID.Zero; } - else + else { this.InvenServices.CreateNewUserInventory(userProf.UUID); Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); @@ -136,23 +136,17 @@ namespace OpenSim.Region.Communications.Local public class LocalSettings { - public string WelcomeMessage = ""; + public string WelcomeMessage; public bool AccountAuthentication = false; - public string InventoryPlugin = "OpenSim.Framework.Data.SQLite.dll"; - public string UserDatabasePlugin = "OpenSim.Framework.Data.DB4o.dll"; + public string InventoryPlugin; + public string UserDatabasePlugin; public LocalSettings(string welcomeMessage, bool accountsAuthenticate, string inventoryPlugin, string userPlugin) { WelcomeMessage = welcomeMessage; AccountAuthentication = accountsAuthenticate; - if (inventoryPlugin != "") - { - InventoryPlugin = inventoryPlugin; - } - if (userPlugin != "") - { - UserDatabasePlugin = userPlugin; - } + InventoryPlugin = inventoryPlugin; + UserDatabasePlugin = userPlugin; } }