From e595959d97f35bf866801fff8b9ceb1ed35b3825 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 29 Jul 2008 17:39:15 +0000 Subject: * refactor: move create user console command parsing down to OpenSim.cs from CommunicationsManager --- OpenSim/Region/Application/OpenSim.cs | 71 +++++++++++++++++++++++++++++-- OpenSim/Region/Application/OpenSimBase.cs | 2 - 2 files changed, 67 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 66c7c48..71a941e 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -208,7 +208,6 @@ namespace OpenSim } } - /// /// Runs commands issued by the server console from the operator /// @@ -348,9 +347,7 @@ namespace OpenSim break; case "create": - if (m_sandbox) - CreateAccount(cmdparams); - + Create(cmdparams); break; case "create-region": @@ -524,6 +521,23 @@ namespace OpenSim break; } } + + /// + /// Execute switch for some of the create commands + /// + /// + protected void Create(string[] args) + { + if (args.Length == 0) + return; + + switch (args[0]) + { + case "user": + CreateUser(args); + break; + } + } /// /// Turn on some debugging values for OpenSim. @@ -653,6 +667,48 @@ namespace OpenSim } } + /// + /// Create a new user + /// + /// + protected void CreateUser(string[] cmdparams) + { + string firstName; + string lastName; + string password; + uint regX = 1000; + uint regY = 1000; + + if (cmdparams.Length < 2) + firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); + else firstName = cmdparams[1]; + + if ( cmdparams.Length < 3 ) + lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); + else lastName = cmdparams[2]; + + if ( cmdparams.Length < 4 ) + password = MainConsole.Instance.PasswdPrompt("Password"); + else password = cmdparams[3]; + + if ( cmdparams.Length < 5 ) + regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); + else regX = Convert.ToUInt32(cmdparams[4]); + + if ( cmdparams.Length < 6 ) + regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); + else regY = Convert.ToUInt32(cmdparams[5]); + + if (null == m_commsManager.UserService.GetUserProfile(firstName, lastName)) + { + m_commsManager.AddUser(firstName, lastName, password, regX, regY); + } + else + { + m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName); + } + } + protected void SaveXml(string[] cmdparams) { m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); @@ -773,6 +829,13 @@ namespace OpenSim protected void SaveInv(string[] cmdparams) { m_log.Error("[CONSOLE]: This has not been implemented yet!"); + +// CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(); +// if (userInfo == null) +// { +// m_log.Error("[AGENT INVENTORY]: Failed to find user " + oldAgentID.ToString()); +// return; +// } } private static string CombineParams(string[] commandParams, int pos) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index a9351d3..8de7c58 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -393,8 +393,6 @@ namespace OpenSim m_gridInfoService = new GridInfoService(); m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod); m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod)); - - CreateAccount = localComms.doCreate; } else { -- cgit v1.1