From fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 16:41:01 +0000 Subject: * Cleaning code still. --- OpenSim/Grid/UserServer/Main.cs | 145 +++++++++++---------- OpenSim/Grid/UserServer/MessageServersConnector.cs | 70 +++++----- OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs | 2 +- OpenSim/Grid/UserServer/UserLoginService.cs | 118 +++++++++-------- OpenSim/Grid/UserServer/UserManager.cs | 132 +++++++++---------- 5 files changed, 238 insertions(+), 229 deletions(-) (limited to 'OpenSim/Grid/UserServer') diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 0534e3b..25e1585 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -48,12 +48,61 @@ namespace OpenSim.Grid.UserServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private UserConfig Cfg; - - public UserManager m_userManager; + private LLUUID m_lastCreatedUser = LLUUID.Random(); + public UserLoginService m_loginService; - public MessageServersConnector m_messagesService; + public MessageServersConnector m_messagesService; + public UserManager m_userManager; - private LLUUID m_lastCreatedUser = LLUUID.Random(); + private OpenUser_Main() + { + m_console = new ConsoleBase("OpenUser", this); + MainConsole.Instance = m_console; + } + + #region conscmd_callback Members + + public override void RunCmd(string cmd, string[] cmdparams) + { + base.RunCmd(cmd, cmdparams); + + switch (cmd) + { + case "help": + m_console.Notice("create user - create a new user"); + m_console.Notice("stats - statistical information for this server"); + m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); + break; + + case "create": + do_create(cmdparams[0]); + break; + + case "shutdown": + m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; + m_console.Close(); + Environment.Exit(0); + break; + + case "stats": + m_console.Notice(StatsManager.UserStats.Report()); + break; + + case "test-inventory": + // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); + // requester.ReturnResponseVal = TestResponse; + // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + SynchronousRestObjectPoster.BeginPostObject>("POST", + m_userManager. + _config. + InventoryUrl + + "RootFolders/", + m_lastCreatedUser); + break; + } + } + + #endregion [STAThread] public static void Main(string[] args) @@ -68,12 +117,6 @@ namespace OpenSim.Grid.UserServer userserver.Work(); } - private OpenUser_Main() - { - m_console = new ConsoleBase("OpenUser", this); - MainConsole.Instance = m_console; - } - private void Work() { m_console.Notice("Enter help for a list of commands\n"); @@ -87,16 +130,16 @@ namespace OpenSim.Grid.UserServer public void Startup() { Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); - + StatsManager.StartCollectingUserStats(); m_log.Info("[REGION]: Establishing data connection"); - m_userManager = new UserManager(); + m_userManager = new UserManager(); m_userManager._config = Cfg; - m_userManager.AddPlugin(Cfg.DatabaseProvider); + m_userManager.AddPlugin(Cfg.DatabaseProvider); m_loginService = new UserLoginService( - m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); + m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); m_messagesService = new MessageServersConnector(); @@ -104,7 +147,7 @@ namespace OpenSim.Grid.UserServer m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; m_log.Info("[REGION]: Starting HTTP process"); - + m_httpServer = new BaseHttpServer(Cfg.HttpPort); AddHttpHandlers(); m_httpServer.Start(); @@ -117,7 +160,7 @@ namespace OpenSim.Grid.UserServer m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); - + m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); @@ -128,7 +171,7 @@ namespace OpenSim.Grid.UserServer m_httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID); - + // Message Server ---> User Server m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); @@ -163,17 +206,17 @@ namespace OpenSim.Grid.UserServer { m_log.ErrorFormat( "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname); - + break; } - + tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); LLUUID userID = new LLUUID(); try { userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); - } + } catch (Exception ex) { m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString()); @@ -181,72 +224,31 @@ namespace OpenSim.Grid.UserServer try { - bool created + bool created = SynchronousRestObjectPoster.BeginPostObject( "POST", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); - + if (!created) { throw new Exception( String.Format( "The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", + + " Please contact your inventory service provider for more information.", userID)); } - } catch (WebException e) { m_log.ErrorFormat( - "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}", + "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); } catch (Exception e) { m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e); } - - m_lastCreatedUser = userID; - break; - } - } - public override void RunCmd(string cmd, string[] cmdparams) - { - base.RunCmd(cmd, cmdparams); - - switch (cmd) - { - case "help": - m_console.Notice("create user - create a new user"); - m_console.Notice("stats - statistical information for this server"); - m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); - break; - - case "create": - do_create(cmdparams[0]); - break; - - case "shutdown": - m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; - m_console.Close(); - Environment.Exit(0); - break; - - case "stats": - m_console.Notice(StatsManager.UserStats.Report()); - break; - - case "test-inventory": - // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); - // requester.ReturnResponseVal = TestResponse; - // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); - SynchronousRestObjectPoster.BeginPostObject>("POST", - m_userManager. - _config. - InventoryUrl + - "RootFolders/", - m_lastCreatedUser); + m_lastCreatedUser = userID; break; } } @@ -262,12 +264,11 @@ namespace OpenSim.Grid.UserServer } public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, - ulong regionhandle, float positionX, float positionY, - float positionZ, string firstname, string lastname) + ulong regionhandle, float positionX, float positionY, + float positionZ, string firstname, string lastname) { - - m_messagesService.TellMessageServersAboutUser( agentID, sessionID, RegionID, regionhandle, positionX, - positionY, positionZ, firstname, lastname); + m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX, + positionY, positionZ, firstname, lastname); } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs index 28f5c4c..70068e0 100644 --- a/OpenSim/Grid/UserServer/MessageServersConnector.cs +++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs @@ -41,12 +41,12 @@ namespace OpenSim.Grid.UserServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public Dictionary MessageServers; - + public MessageServersConnector() { MessageServers = new Dictionary(); } - + public void RegisterMessageServer(string URI, MessageServerInfo serverData) { lock (MessageServers) @@ -55,7 +55,7 @@ namespace OpenSim.Grid.UserServer MessageServers.Add(URI, serverData); } } - + public void DeRegisterMessageServer(string URI) { lock (MessageServers) @@ -64,7 +64,7 @@ namespace OpenSim.Grid.UserServer MessageServers.Remove(URI); } } - + public void AddResponsibleRegion(string URI, ulong regionhandle) { if (!MessageServers.ContainsKey(URI)) @@ -76,8 +76,9 @@ namespace OpenSim.Grid.UserServer MessageServerInfo msginfo = MessageServers["URI"]; msginfo.responsibleForRegions.Add(regionhandle); MessageServers["URI"] = msginfo; - } + } } + public void RemoveResponsibleRegion(string URI, ulong regionhandle) { if (!MessageServers.ContainsKey(URI)) @@ -92,20 +93,20 @@ namespace OpenSim.Grid.UserServer msginfo.responsibleForRegions.Remove(regionhandle); MessageServers["URI"] = msginfo; } - } - + } } + public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); if (requestData.Contains("uri")) { - string URI = (string)requestData["uri"]; - string sendkey=(string)requestData["sendkey"]; - string recvkey=(string)requestData["recvkey"]; + string URI = (string) requestData["uri"]; + string sendkey = (string) requestData["sendkey"]; + string recvkey = (string) requestData["recvkey"]; MessageServerInfo m = new MessageServerInfo(); m.URI = URI; m.sendkey = sendkey; @@ -116,15 +117,16 @@ namespace OpenSim.Grid.UserServer } return response; } + public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); if (requestData.Contains("uri")) { - string URI = (string)requestData["uri"]; + string URI = (string) requestData["uri"]; DeRegisterMessageServer(URI); responseData["responsestring"] = "TRUE"; @@ -132,23 +134,24 @@ namespace OpenSim.Grid.UserServer } return response; } + public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); if (requestData.Contains("fromuri")) { - string sURI = (string)requestData["fromuri"]; - string sagentID = (string)requestData["agentid"]; - string ssessionID = (string)requestData["sessionid"]; - string scurrentRegionID = (string)requestData["regionid"]; - string sregionhandle = (string)requestData["regionhandle"]; - string scurrentpos = (string)requestData["currentpos"]; + string sURI = (string) requestData["fromuri"]; + string sagentID = (string) requestData["agentid"]; + string ssessionID = (string) requestData["sessionid"]; + string scurrentRegionID = (string) requestData["regionid"]; + string sregionhandle = (string) requestData["regionhandle"]; + string scurrentpos = (string) requestData["currentpos"]; //LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); // TODO: Okay now raise event so the user server can pass this data to the Usermanager - + responseData["responsestring"] = "TRUE"; response.Value = responseData; } @@ -156,7 +159,7 @@ namespace OpenSim.Grid.UserServer } public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, - ulong regionhandle, float positionX, float positionY, + ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname) { // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D ) @@ -173,8 +176,8 @@ namespace OpenSim.Grid.UserServer foreach (MessageServerInfo serv in MessageServers.Values) { NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, - regionhandle, positionX, positionY, positionZ, - firstname, lastname); + regionhandle, positionX, positionY, positionZ, + firstname, lastname); } } } @@ -191,10 +194,10 @@ namespace OpenSim.Grid.UserServer // { // m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); // } - foreach (MessageServerInfo serv in MessageServers.Values) - { - NotifyMessageServerAboutUserLogoff(serv,agentID); - } + foreach (MessageServerInfo serv in MessageServers.Values) + { + NotifyMessageServerAboutUserLogoff(serv, agentID); + } } } @@ -218,10 +221,10 @@ namespace OpenSim.Grid.UserServer m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); } - private void NotifyMessageServerAboutUser(MessageServerInfo serv, - LLUUID agentID, LLUUID sessionID, LLUUID RegionID, - ulong regionhandle, float positionX, float positionY, float positionZ, - string firstname, string lastname) + private void NotifyMessageServerAboutUser(MessageServerInfo serv, + LLUUID agentID, LLUUID sessionID, LLUUID RegionID, + ulong regionhandle, float positionX, float positionY, float positionZ, + string firstname, string lastname) { Hashtable reqparams = new Hashtable(); reqparams["sendkey"] = serv.sendkey; @@ -250,7 +253,6 @@ namespace OpenSim.Grid.UserServer { m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user"); } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs index 680b357..eb60f11 100644 --- a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs @@ -60,4 +60,4 @@ using System.Runtime.InteropServices; // [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index b123b8c..b19b74d 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -41,26 +41,26 @@ using OpenSim.Framework.Servers; namespace OpenSim.Grid.UserServer { public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, - ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname); + ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname); public class UserLoginService : LoginService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public event UserLoggedInAtLocation OnUserLoggedInAtLocation; + private UserLoggedInAtLocation handlerUserLoggedInAtLocation; - private UserLoggedInAtLocation handlerUserLoggedInAtLocation = null; - public UserConfig m_config; public UserLoginService( - UserManagerBase userManager, LibraryRootFolder libraryRootFolder, + UserManagerBase userManager, LibraryRootFolder libraryRootFolder, UserConfig config, string welcomeMess) : base(userManager, libraryRootFolder, welcomeMess) { m_config = config; } + public event UserLoggedInAtLocation OnUserLoggedInAtLocation; + /// /// Customises the login response and fills in missing values. /// @@ -95,7 +95,8 @@ namespace OpenSim.Grid.UserServer else { string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest); - m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]); + m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]); if (startLocationRequestParsed[0] == "last") { // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z' @@ -108,9 +109,9 @@ namespace OpenSim.Grid.UserServer { m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]); SimInfo = - RegionProfileData.RequestSimProfileData( - startLocationRequestParsed[0], m_config.GridServerURL, - m_config.GridSendKey, m_config.GridRecvKey); + RegionProfileData.RequestSimProfileData( + startLocationRequestParsed[0], m_config.GridServerURL, + m_config.GridSendKey, m_config.GridRecvKey); if (SimInfo == null) { @@ -119,7 +120,9 @@ namespace OpenSim.Grid.UserServer RegionProfileData.RequestSimProfileData( theUser.HomeRegion, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); - } else { + } + else + { start_x = Convert.ToInt32(startLocationRequestParsed[1]); start_y = Convert.ToInt32(startLocationRequestParsed[2]); start_z = Convert.ToInt32(startLocationRequestParsed[3]); @@ -130,30 +133,30 @@ namespace OpenSim.Grid.UserServer // Customise the response //CFK: This is redundant and the next message should always appear. //CFK: m_log.Info("[LOGIN]: Home Location"); - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + - (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " + - "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" + - theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " + - "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" + - theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}"; + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" + + (SimInfo.regionLocY * Constants.RegionSize) + "], " + + "'position':[r" + theUser.HomeLocation.X + ",r" + + theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " + + "'look_at':[r" + theUser.HomeLocation.X + ",r" + + theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}"; // Destination //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into //CFK: the next one for X & Y and comment this one. //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + //CFK: "; Region Y: " + SimInfo.regionLocY); - response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString(); - response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]); + response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString(); + response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]); response.RegionX = SimInfo.regionLocX; response.RegionY = SimInfo.regionLocY; //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI string capsPath = Util.GetRandomCapsPath(); response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; - + m_log.DebugFormat( - "[LOGIN]: Sending new CAPS seed url {0} to client {1}", - response.SeedCapability, response.AgentID); + "[LOGIN]: Sending new CAPS seed url {0} to client {1}", + response.SeedCapability, response.AgentID); // Notify the target of an incoming user //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into @@ -163,7 +166,8 @@ namespace OpenSim.Grid.UserServer theUser.CurrentAgent.Region = SimInfo.UUID; theUser.CurrentAgent.Handle = SimInfo.regionHandle; - if (start_x >= 0 && start_y >= 0 && start_z >= 0) { + if (start_x >= 0 && start_y >= 0 && start_z >= 0) + { LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z); theUser.CurrentAgent.Position = tmp_v; } @@ -186,42 +190,43 @@ namespace OpenSim.Grid.UserServer // Update agent with target sim m_log.InfoFormat( - "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection", - SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI); + "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection", + SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI); - XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); - + if (GridResp.IsFault) { m_log.ErrorFormat( - "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}", + "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}", SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); } handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; if (handlerUserLoggedInAtLocation != null) { //m_log.Info("[LOGIN]: Letting other objects know about login"); - handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, - theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X,theUser.CurrentAgent.Position.Y,theUser.CurrentAgent.Position.Z, - theUser.FirstName,theUser.SurName); + handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, + theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, + theUser.CurrentAgent.Position.Z, + theUser.FirstName, theUser.SurName); } } catch (Exception) - //catch (System.AccessViolationException) + //catch (System.AccessViolationException) { tryDefault = true; } - + if (tryDefault) { // Send him to default region instead // Load information from the gridserver - ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize); + ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong) m_config.DefaultY * Constants.RegionSize); m_log.Warn( - "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString()); + "[LOGIN]: Home region not available: sending to default " + defaultHandle); try { @@ -231,19 +236,19 @@ namespace OpenSim.Grid.UserServer // Customise the response m_log.Info("[LOGIN]: Home Location"); - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + - (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " + - "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" + - theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " + - "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" + - theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}"; + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" + + (SimInfo.regionLocY * Constants.RegionSize) + "], " + + "'position':[r" + theUser.HomeLocation.X + ",r" + + theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " + + "'look_at':[r" + theUser.HomeLocation.X + ",r" + + theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}"; // Destination m_log.Info("[LOGIN]: " + "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); - response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString(); - response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]); + response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString(); + response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]); response.RegionX = SimInfo.regionLocX; response.RegionY = SimInfo.regionLocY; @@ -283,15 +288,16 @@ namespace OpenSim.Grid.UserServer { m_log.Info("[LOGIN]: Letting other objects know about login"); handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, - theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, theUser.CurrentAgent.Position.Z, - theUser.FirstName, theUser.SurName); + theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, + theUser.CurrentAgent.Position.Z, + theUser.FirstName, theUser.SurName); } } catch (Exception e) { m_log.Warn("[LOGIN]: Default region also not available"); - m_log.Warn("[LOGIN]: " + e.ToString()); + m_log.Warn("[LOGIN]: " + e); } } } @@ -300,8 +306,8 @@ namespace OpenSim.Grid.UserServer protected override InventoryData GetInventorySkeleton(LLUUID userID) { m_log.DebugFormat( - "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}", - m_config.InventoryUrl, userID); + "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}", + m_config.InventoryUrl, userID); List folders = SynchronousRestObjectPoster.BeginPostObject>( @@ -316,23 +322,23 @@ namespace OpenSim.Grid.UserServer // tools are creating the user profile directly in the database without creating the inventory. At // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already // exist. - bool created = + bool created = SynchronousRestObjectPoster.BeginPostObject( "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID); - + if (!created) { throw new Exception( String.Format( "The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", + + " Please contact your inventory service provider for more information.", userID)); } else { m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); } - + folders = SynchronousRestObjectPoster.BeginPostObject>( "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); } @@ -342,11 +348,11 @@ namespace OpenSim.Grid.UserServer LLUUID rootID = LLUUID.Zero; ArrayList AgentInventoryArray = new ArrayList(); Hashtable TempHash; - + foreach (InventoryFolderBase InvFolder in folders) { // m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); - + if (InvFolder.ParentID == LLUUID.Zero) { rootID = InvFolder.ID; @@ -359,16 +365,16 @@ namespace OpenSim.Grid.UserServer TempHash["folder_id"] = InvFolder.ID.ToString(); AgentInventoryArray.Add(TempHash); } - + return new InventoryData(AgentInventoryArray, rootID); } else { throw new Exception( String.Format( - "A root inventory folder for user {0} could not be retrieved from the inventory service", + "A root inventory folder for user {0} could not be retrieved from the inventory service", userID)); } } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 5d0e1d6..0122ad0 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -41,11 +41,11 @@ namespace OpenSim.Grid.UserServer public delegate void logOffUser(LLUUID AgentID); public class UserManager : UserManagerBase - { + { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private logOffUser handlerLogOffUser; public event logOffUser OnLogOffUser; - private logOffUser handlerLogOffUser = null; /// /// Deletes an active agent session @@ -81,17 +81,17 @@ namespace OpenSim.Grid.UserServer XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); // Query Result Information - responseData["queryid"] = (string) queryID.ToString(); - responseData["avcount"] = (string) returnUsers.Count.ToString(); + responseData["queryid"] = queryID.ToString(); + responseData["avcount"] = returnUsers.Count.ToString(); for (int i = 0; i < returnUsers.Count; i++) { - responseData["avatarid" + i.ToString()] = returnUsers[i].AvatarID.ToString(); - responseData["firstname" + i.ToString()] = returnUsers[i].firstName; - responseData["lastname" + i.ToString()] = returnUsers[i].lastName; + responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); + responseData["firstname" + i] = returnUsers[i].firstName; + responseData["lastname" + i] = returnUsers[i].lastName; } response.Value = responseData; - + return response; } @@ -101,14 +101,14 @@ namespace OpenSim.Grid.UserServer Hashtable responseData = new Hashtable(); // Query Result Information - responseData["avcount"] = (string)returnUsers.Count.ToString(); + responseData["avcount"] = returnUsers.Count.ToString(); for (int i = 0; i < returnUsers.Count; i++) { - responseData["ownerID" + i.ToString()] = returnUsers[i].FriendListOwner.UUID.ToString(); - responseData["friendID" + i.ToString()] = returnUsers[i].Friend.UUID.ToString(); - responseData["ownerPerms" + i.ToString()] = returnUsers[i].FriendListOwnerPerms.ToString(); - responseData["friendPerms" + i.ToString()] = returnUsers[i].FriendPerms.ToString(); + responseData["ownerID" + i] = returnUsers[i].FriendListOwner.UUID.ToString(); + responseData["friendID" + i] = returnUsers[i].Friend.UUID.ToString(); + responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString(); + responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString(); } response.Value = responseData; @@ -156,6 +156,21 @@ namespace OpenSim.Grid.UserServer return response; } + public override UserProfileData SetupMasterUser(string firstName, string lastName) + { + throw new Exception("The method or operation is not implemented."); + } + + public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) + { + throw new Exception("The method or operation is not implemented."); + } + + public override UserProfileData SetupMasterUser(LLUUID uuid) + { + throw new Exception("The method or operation is not implemented."); + } + #region XMLRPC User Methods public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) @@ -178,15 +193,16 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); string returnString = "FALSE"; // Query Result Information - + if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) { // UserManagerBase.AddNewuserFriend - AddNewUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); + AddNewUserFriend(new LLUUID((string) requestData["ownerID"]), new LLUUID((string) requestData["friendID"]), + (uint) Convert.ToInt32((string) requestData["friendPerms"])); returnString = "TRUE"; } responseData["returnString"] = returnString; @@ -197,15 +213,15 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); string returnString = "FALSE"; // Query Result Information - + if (requestData.Contains("ownerID") && requestData.Contains("friendID")) { // UserManagerBase.AddNewuserFriend - RemoveUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"])); + RemoveUserFriend(new LLUUID((string) requestData["ownerID"]), new LLUUID((string) requestData["friendID"])); returnString = "TRUE"; } responseData["returnString"] = returnString; @@ -216,13 +232,14 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); string returnString = "FALSE"; - + if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) { - UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); + UpdateUserFriendPerms(new LLUUID((string) requestData["ownerID"]), new LLUUID((string) requestData["friendID"]), + (uint) Convert.ToInt32((string) requestData["friendPerms"])); // UserManagerBase. returnString = "TRUE"; } @@ -234,16 +251,16 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); List returndata = new List(); if (requestData.Contains("ownerID")) { - returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"])); + returndata = GetUserFriendList(new LLUUID((string) requestData["ownerID"])); } - + return FriendListItemListtoXmlRPCResponse(returndata); } @@ -321,7 +338,7 @@ namespace OpenSim.Grid.UserServer { m_log.Debug("[UserManager]: Got request to update user profile"); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); UserProfileData userProfile; @@ -330,7 +347,7 @@ namespace OpenSim.Grid.UserServer return CreateUnknownUserErrorResponse(); } - LLUUID UserUUID = new LLUUID((string)requestData["avatar_uuid"]); + LLUUID UserUUID = new LLUUID((string) requestData["avatar_uuid"]); userProfile = GetUserProfile(UserUUID); if (null == userProfile) { @@ -342,33 +359,33 @@ namespace OpenSim.Grid.UserServer } if (requestData.Contains("FLImageID")) { - userProfile.FirstLifeImage = new LLUUID((string)requestData["FLImageID"]); + userProfile.FirstLifeImage = new LLUUID((string) requestData["FLImageID"]); } if (requestData.Contains("ImageID")) { - userProfile.Image = new LLUUID((string)requestData["ImageID"]); + userProfile.Image = new LLUUID((string) requestData["ImageID"]); } // dont' know how yet if (requestData.Contains("MaturePublish")) - { + { } if (requestData.Contains("AboutText")) { - userProfile.AboutText = (string)requestData["AboutText"]; + userProfile.AboutText = (string) requestData["AboutText"]; } if (requestData.Contains("FLAboutText")) { - userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"]; + userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"]; } // not in DB yet. if (requestData.Contains("ProfileURL")) - { + { } if (requestData.Contains("home_region")) { try { - userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]); + userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]); } catch (ArgumentException) { @@ -382,25 +399,23 @@ namespace OpenSim.Grid.UserServer { m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); } - } if (requestData.Contains("home_pos_x")) { try { - userProfile.HomeLocationX = (float)Convert.ToDecimal((string)requestData["home_pos_x"]); + userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home postion x"); } - } if (requestData.Contains("home_pos_y")) { try { - userProfile.HomeLocationY = (float)Convert.ToDecimal((string)requestData["home_pos_y"]); + userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]); } catch (InvalidCastException) { @@ -411,7 +426,7 @@ namespace OpenSim.Grid.UserServer { try { - userProfile.HomeLocationZ = (float)Convert.ToDecimal((string)requestData["home_pos_z"]); + userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]); } catch (InvalidCastException) { @@ -422,7 +437,7 @@ namespace OpenSim.Grid.UserServer { try { - userProfile.HomeLookAtX = (float)Convert.ToDecimal((string)requestData["home_look_x"]); + userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]); } catch (InvalidCastException) { @@ -433,7 +448,7 @@ namespace OpenSim.Grid.UserServer { try { - userProfile.HomeLookAtY = (float)Convert.ToDecimal((string)requestData["home_look_y"]); + userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]); } catch (InvalidCastException) { @@ -442,9 +457,9 @@ namespace OpenSim.Grid.UserServer } if (requestData.Contains("home_look_z")) { - try + try { - userProfile.HomeLookAtZ = (float)Convert.ToDecimal((string)requestData["home_look_z"]); + userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]); } catch (InvalidCastException) { @@ -461,18 +476,18 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; if (requestData.Contains("avatar_uuid")) { try { - LLUUID userUUID = new LLUUID((string)requestData["avatar_uuid"]); - LLUUID RegionID = new LLUUID((string)requestData["region_uuid"]); - ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); - float posx = (float)Convert.ToDecimal((string)requestData["region_pos_x"]); - float posy = (float)Convert.ToDecimal((string)requestData["region_pos_y"]); - float posz = (float)Convert.ToDecimal((string)requestData["region_pos_z"]); + LLUUID userUUID = new LLUUID((string) requestData["avatar_uuid"]); + LLUUID RegionID = new LLUUID((string) requestData["region_uuid"]); + ulong regionhandle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); + float posx = (float) Convert.ToDecimal((string) requestData["region_pos_x"]); + float posy = (float) Convert.ToDecimal((string) requestData["region_pos_y"]); + float posz = (float) Convert.ToDecimal((string) requestData["region_pos_z"]); handlerLogOffUser = OnLogOffUser; if (handlerLogOffUser != null) @@ -495,20 +510,5 @@ namespace OpenSim.Grid.UserServer } #endregion - - public override UserProfileData SetupMasterUser(string firstName, string lastName) - { - throw new Exception("The method or operation is not implemented."); - } - - public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) - { - throw new Exception("The method or operation is not implemented."); - } - - public override UserProfileData SetupMasterUser(LLUUID uuid) - { - throw new Exception("The method or operation is not implemented."); - } } -} +} \ No newline at end of file -- cgit v1.1