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
---
.../Communications/CommunicationsManager.cs | 47 +-------------
OpenSim/Region/Application/OpenSim.cs | 71 ++++++++++++++++++++--
OpenSim/Region/Application/OpenSimBase.cs | 2 -
3 files changed, 68 insertions(+), 52 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 3659d86..2bfe045 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -31,7 +31,6 @@ using System.Reflection;
using libsecondlife;
using log4net;
using OpenSim.Framework.Communications.Cache;
-using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
namespace OpenSim.Framework.Communications
@@ -231,50 +230,6 @@ namespace OpenSim.Framework.Communications
#endregion
- 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 = MainConsole.Instance.CmdPrompt("First name", "Default");
- else firstName = cmmdParams[1];
-
- if ( cmmdParams.Length < 3 )
- lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
- else lastName = cmmdParams[2];
-
- if ( cmmdParams.Length < 4 )
- password = MainConsole.Instance.PasswdPrompt("Password");
- else password = cmmdParams[3];
-
- if ( cmmdParams.Length < 5 )
- regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
- else regX = Convert.ToUInt32(cmmdParams[4]);
-
- if ( cmmdParams.Length < 6 )
- regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
- else regY = Convert.ToUInt32(cmmdParams[5]);
-
-
- if (null == m_userService.GetUserProfile(firstName, lastName))
- {
- AddUser(firstName, lastName, password, regX, regY);
- }
- else
- {
- m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
- }
- break;
- }
- }
-
///
/// Persistently adds a user to OpenSim.
///
@@ -283,7 +238,7 @@ namespace OpenSim.Framework.Communications
///
///
///
- /// The UUID of the added user. Returns null if the add was unsuccessful
+ /// The UUID of the added user. Returns LLUUID.Zero if the add was unsuccessful
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
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