From 9b1eefbcdeb21e42e0feb5336c0a084def2b4aa8 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 3 Oct 2007 06:20:00 +0000 Subject: Some continuation of lbsa71's refactoring of the CommunicationsManager. --- .../Communications/CommunicationsManager.cs | 55 +++++++++++++++++++ OpenSim/Region/Application/OpenSimMain.cs | 9 ++- .../Communications/Local/CommunicationsLocal.cs | 64 ++-------------------- OpenSim/Region/Examples/SimpleApp/Program.cs | 4 +- 4 files changed, 68 insertions(+), 64 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 6ea3c29..cd5d901 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Caches; @@ -32,6 +33,8 @@ using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; +using OpenSim.Framework.Console; +using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications { @@ -93,6 +96,58 @@ namespace OpenSim.Framework.Communications m_transactionsManager = new AssetTransactionManager(this); } + public void doCreate(string[] cmmdParams) + { + switch (cmmdParams[0]) + { + case "user": + string firstName; + string lastName; + string password; + uint regX = 1000; + uint regY = 1000; + + if (cmmdParams.Length < 2) + { + + firstName = MainLog.Instance.CmdPrompt("First name", "Default"); + lastName = MainLog.Instance.CmdPrompt("Last name", "User"); + password = MainLog.Instance.PasswdPrompt("Password"); + regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000")); + regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000")); + } + else + { + firstName = cmmdParams[1]; + lastName = cmmdParams[2]; + password = cmmdParams[3]; + regX = Convert.ToUInt32(cmmdParams[4]); + regY = Convert.ToUInt32(cmmdParams[5]); + + } + + AddUser(firstName, lastName, password, regX, regY); + break; + } + } + + public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) + { + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + ""); + + m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY); + UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); + if (userProf == null) + { + return LLUUID.Zero; + } + else + { + this.m_inventoryService.CreateNewUserInventory(userProf.UUID); + System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); + return userProf.UUID; + } + } #region Packet Handlers diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index e0ea212..04b8dce 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -108,6 +108,7 @@ namespace OpenSim } ReadConfigSettings(startupSource); + } protected void ReadConfigSettings(IConfigSource configSource) @@ -145,6 +146,7 @@ namespace OpenSim /// public override void StartUp() { + if (!Directory.Exists(Util.logDir())) { Directory.CreateDirectory(Util.logDir()); @@ -157,14 +159,17 @@ namespace OpenSim if (m_sandbox) { - CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings(standaloneWelcomeMessage, standaloneAuthenticate, standaloneInventoryPlugin); + CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings(standaloneWelcomeMessage, standaloneAuthenticate); LocalInventoryService inventoryService = new LocalInventoryService(); + inventoryService.AddPlugin(standaloneInventoryPlugin); + LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService ); userService.AddPlugin( standaloneUserPlugin ); - CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService); + CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService, inventoryService); m_commsManager = localComms; + if (standaloneAuthenticate) { this.CreateAccount = localComms.doCreate; diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 76814cf..f51f564 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -38,14 +38,11 @@ using OpenSim.Framework.Utilities; namespace OpenSim.Region.Communications.Local { public class CommunicationsLocal : CommunicationsManager - { - public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings, LocalUserServices userService) + { + public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings, LocalUserServices userService, LocalInventoryService inventoryService) : base(serversInfo, httpServer, assetCache) { - LocalInventoryService inventoryService = new LocalInventoryService(); - inventoryService.AddPlugin(settings.InventoryPlugin); m_inventoryService = inventoryService; - m_userService = userService; LocalBackEndServices backendService = new LocalBackEndServices(); @@ -58,70 +55,17 @@ namespace OpenSim.Region.Communications.Local httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); } - public void doCreate(string[] cmmdParams) - { - switch (cmmdParams[0]) - { - case "user": - string firstName; - string lastName; - string password; - uint regX = 1000; - uint regY = 1000; - - if (cmmdParams.Length < 2) - { - - firstName = MainLog.Instance.CmdPrompt("First name", "Default"); - lastName = MainLog.Instance.CmdPrompt("Last name", "User"); - password = MainLog.Instance.PasswdPrompt("Password"); - regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000")); - regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000")); - } - else - { - firstName = cmmdParams[1]; - lastName = cmmdParams[2]; - password = cmmdParams[3]; - regX = Convert.ToUInt32(cmmdParams[4]); - regY = Convert.ToUInt32(cmmdParams[5]); - - } - - AddUser(firstName, lastName, password, regX, regY); - break; - } - } - - public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) - { - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + ""); - - m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY); - UserProfileData userProf = this.UserService.GetUserProfile(firstName, lastName); - if (userProf == null) - { - return LLUUID.Zero; - } - else - { - this.m_inventoryService.CreateNewUserInventory(userProf.UUID); - Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); - return userProf.UUID; - } - } + public class LocalSettings { public string WelcomeMessage; public bool AccountAuthentication = false; - public string InventoryPlugin; - public LocalSettings(string welcomeMessage, bool accountsAuthenticate, string inventoryPlugin) + public LocalSettings(string welcomeMessage, bool accountsAuthenticate) { WelcomeMessage = welcomeMessage; AccountAuthentication = accountsAuthenticate; - InventoryPlugin = inventoryPlugin; } } diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index eafa500..5f39413 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -41,12 +41,12 @@ namespace SimpleApp { base.StartUp(); - CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings("", false, ""); + CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings("", false); LocalInventoryService inventoryService = new LocalInventoryService(); LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService); - m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService ); + m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService, inventoryService ); m_log.Notice(m_log.LineInfo); -- cgit v1.1