From 3376b82501000692d6dac24b051af738cdaf2737 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 24 May 2007 12:16:50 +0000 Subject: Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server. --- OpenGridServices.UserServer/Main.cs | 197 ------- OpenGridServices.UserServer/OGS-UserServer.csproj | 63 --- .../OpenGridServices.UserServer.csproj | 132 ----- .../OpenGridServices.UserServer.exe.build | 50 -- .../Properties/AssemblyInfo.cs | 33 -- OpenGridServices.UserServer/UserManager.cs | 566 --------------------- 6 files changed, 1041 deletions(-) delete mode 100644 OpenGridServices.UserServer/Main.cs delete mode 100644 OpenGridServices.UserServer/OGS-UserServer.csproj delete mode 100644 OpenGridServices.UserServer/OpenGridServices.UserServer.csproj delete mode 100644 OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build delete mode 100644 OpenGridServices.UserServer/Properties/AssemblyInfo.cs delete mode 100644 OpenGridServices.UserServer/UserManager.cs (limited to 'OpenGridServices.UserServer') diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs deleted file mode 100644 index 0eb314b..0000000 --- a/OpenGridServices.UserServer/Main.cs +++ /dev/null @@ -1,197 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.IO; -using System.Text; -using libsecondlife; -using OpenSim.Framework.User; -using OpenSim.Framework.Sims; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Console; -using OpenSim.Servers; - -namespace OpenGridServices.UserServer -{ - /// - /// - public class OpenUser_Main : BaseServer, conscmd_callback - { - private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; - private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll"; - private UserConfig Cfg; - - public UserManager m_userManager; // Replaces below. - - //private UserProfileManager m_userProfileManager; // Depreciated - - public Dictionary UserSessions = new Dictionary(); - - ConsoleBase m_console; - - [STAThread] - public static void Main(string[] args) - { - Console.WriteLine("Starting...\n"); - - OpenUser_Main userserver = new OpenUser_Main(); - - userserver.Startup(); - userserver.Work(); - } - - private OpenUser_Main() - { - m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this , false); - MainConsole.Instance = m_console; - } - - private void Work() - { - m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"\nEnter help for a list of commands\n"); - - while (true) - { - m_console.MainConsolePrompt(); - } - } - - public void Startup() - { - MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration"); - Cfg = this.LoadConfigDll(this.ConfigDll); - Cfg.InitConfig(); - - MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Establishing data connection"); - m_userManager = new UserManager(); - m_userManager._config = Cfg; - m_userManager.AddPlugin(StorageDll); - - MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP process"); - BaseHttpServer httpServer = new BaseHttpServer(8002); - - httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod); - httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod); - - httpServer.Start(); - } - - - public void do_create(string what) - { - switch (what) - { - case "user": - m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Commandline user creation is currently disabled."); - break; - /* - string tempfirstname; - string templastname; - string tempMD5Passwd; - - tempfirstname = m_console.CmdPrompt("First name"); - templastname = m_console.CmdPrompt("Last name"); - tempMD5Passwd = m_console.PasswdPrompt("Password"); - - System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); - byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd); - bs = x.ComputeHash(bs); - System.Text.StringBuilder s = new System.Text.StringBuilder(); - foreach (byte b in bs) - { - s.Append(b.ToString("x2").ToLower()); - } - tempMD5Passwd = s.ToString(); - - UserProfile newuser = m_userProfileManager.CreateNewProfile(tempfirstname, templastname, tempMD5Passwd); - newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f); - newuser.homepos = new LLVector3(128f, 128f, 150f); - m_userProfileManager.SaveUserProfiles(); - break; - */ - } - } - - public void RunCmd(string cmd, string[] cmdparams) - { - switch (cmd) - { - case "help": - m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"create user - create a new user"); - m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - shutdown the grid (USE CAUTION!)"); - break; - - case "create": - do_create(cmdparams[0]); - break; - - case "shutdown": - m_console.Close(); - Environment.Exit(0); - break; - } - } - - private UserConfig LoadConfigDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - UserConfig config = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IUserConfig", true); - - if (typeInterface != null) - { - IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - config = plug.GetConfigObject(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return config; - } - - public void Show(string ShowWhat) - { - } - } -} diff --git a/OpenGridServices.UserServer/OGS-UserServer.csproj b/OpenGridServices.UserServer/OGS-UserServer.csproj deleted file mode 100644 index f4fa8b6..0000000 --- a/OpenGridServices.UserServer/OGS-UserServer.csproj +++ /dev/null @@ -1,63 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {D45B6E48-5668-478D-B9CB-6D46E665FACF} - Exe - Properties - OGS_UserServer - OGS-UserServer - OpenGridServices.OpenUser_Main - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\..\common\bin\libsecondlife.dll - - - - - - - - OGS-Console.cs - - - VersionInfo.cs - - - - - - - - - {2E46A825-3168-492F-93BC-637126B5B72B} - OpenSim.Framework - - - {7667E6E2-F227-41A2-B1B2-315613E1BAFC} - ServerConsole - - - - \ No newline at end of file diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj deleted file mode 100644 index 9f4da40..0000000 --- a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj +++ /dev/null @@ -1,132 +0,0 @@ - - - Local - 8.0.50727 - 2.0 - {66591469-0000-0000-0000-000000000000} - Debug - AnyCPU - - - - OpenGridServices.UserServer - JScript - Grid - IE50 - false - Exe - - OpenGridServices.UserServer - - - - - - False - 285212672 - False - - - TRACE;DEBUG - - True - 4096 - False - ..\bin\ - False - False - False - 4 - - - - False - 285212672 - False - - - TRACE - - False - 4096 - True - ..\bin\ - False - False - False - 4 - - - - - System.dll - False - - - System.Data.dll - False - - - System.Xml.dll - False - - - ..\bin\libsecondlife.dll - False - - - ..\bin\Db4objects.Db4o.dll - False - - - - - OpenSim.Framework - {8ACA2445-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Framework.Console - {A7CD0630-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenGrid.Framework.Data - {62CDF671-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Servers - {8BB20F0A-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - XMLRPC - {8E81D43C-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - Code - - - Code - - - - - - - - - - diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build b/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build deleted file mode 100644 index 548c3cc..0000000 --- a/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenGridServices.UserServer/Properties/AssemblyInfo.cs b/OpenGridServices.UserServer/Properties/AssemblyInfo.cs deleted file mode 100644 index 5d5ce8d..0000000 --- a/OpenGridServices.UserServer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OGS-UserServer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OGS-UserServer")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e266513a-090b-4d38-80f6-8599eef68c8c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices.UserServer/UserManager.cs deleted file mode 100644 index a312445..0000000 --- a/OpenGridServices.UserServer/UserManager.cs +++ /dev/null @@ -1,566 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using OpenGrid.Framework.Data; -using libsecondlife; -using System.Reflection; - -using System.Xml; -using Nwc.XmlRpc; -using OpenSim.Framework.Sims; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; - -using System.Security.Cryptography; - -namespace OpenGridServices.UserServer -{ - public class UserManager - { - public OpenSim.Framework.Interfaces.UserConfig _config; - Dictionary _plugins = new Dictionary(); - - /// - /// Adds a new user server plugin - user servers will be requested in the order they were loaded. - /// - /// The filename to the user server plugin DLL - public void AddPlugin(string FileName) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Userstorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IUserData", true); - - if (typeInterface != null) - { - IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(); - this._plugins.Add(plug.getName(), plug); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Userstorage: Added IUserData Interface"); - } - - typeInterface = null; - } - } - - pluginAssembly = null; - } - - /// - /// Loads a user profile from a database by UUID - /// - /// The target UUID - /// A user profile - public UserProfileData getUserProfile(LLUUID uuid) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - UserProfileData profile = plugin.Value.getUserByUUID(uuid); - profile.currentAgent = getUserAgent(profile.UUID); - return profile; - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - - - /// - /// Loads a user profile by name - /// - /// The target name - /// A user profile - public UserProfileData getUserProfile(string name) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - UserProfileData profile = plugin.Value.getUserByName(name); - profile.currentAgent = getUserAgent(profile.UUID); - return profile; - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Loads a user profile by name - /// - /// First name - /// Last name - /// A user profile - public UserProfileData getUserProfile(string fname, string lname) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - UserProfileData profile = plugin.Value.getUserByName(fname,lname); - try - { - profile.currentAgent = getUserAgent(profile.UUID); - } - catch (Exception e) - { - // Ignore - } - return profile; - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Loads a user agent by uuid (not called directly) - /// - /// The agents UUID - /// Agent profiles - public UserAgentData getUserAgent(LLUUID uuid) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - return plugin.Value.getAgentByUUID(uuid); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Loads a user agent by name (not called directly) - /// - /// The agents name - /// A user agent - public UserAgentData getUserAgent(string name) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - return plugin.Value.getAgentByName(name); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Loads a user agent by name (not called directly) - /// - /// The agents firstname - /// The agents lastname - /// A user agent - public UserAgentData getUserAgent(string fname, string lname) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - return plugin.Value.getAgentByName(fname,lname); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Creates a error response caused by invalid XML - /// - /// An XMLRPC response - private static XmlRpcResponse CreateErrorConnectingToGridResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable ErrorRespData = new Hashtable(); - ErrorRespData["reason"] = "key"; - ErrorRespData["message"] = "Error connecting to grid. Could not percieve credentials from login XML."; - ErrorRespData["login"] = "false"; - response.Value = ErrorRespData; - return response; - } - - /// - /// Creates an error response caused by bad login credentials - /// - /// An XMLRPC response - private static XmlRpcResponse CreateLoginErrorResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable ErrorRespData = new Hashtable(); - ErrorRespData["reason"] = "key"; - ErrorRespData["message"] = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; - ErrorRespData["login"] = "false"; - response.Value = ErrorRespData; - return response; - } - - /// - /// Creates an error response caused by being logged in already - /// - /// An XMLRPC Response - private static XmlRpcResponse CreateAlreadyLoggedInResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable PresenceErrorRespData = new Hashtable(); - PresenceErrorRespData["reason"] = "presence"; - PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner"; - PresenceErrorRespData["login"] = "false"; - response.Value = PresenceErrorRespData; - return response; - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser) - { - // Load information from the gridserver - SimProfile SimInfo = new SimProfile(); - SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); - - // Customise the response - // Home Location - response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).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() + "]}"; - - // Destination - response["sim_ip"] = SimInfo.sim_ip; - response["sim_port"] = (Int32)SimInfo.sim_port; - response["region_y"] = (Int32)SimInfo.RegionLocY * 256; - response["region_x"] = (Int32)SimInfo.RegionLocX * 256; - - // Notify the target of an incoming user - Console.WriteLine("Notifying " + SimInfo.regionname + " (" + SimInfo.caps_url + ")"); - - // Prepare notification - Hashtable SimParams = new Hashtable(); - SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); - SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); - SimParams["firstname"] = theUser.username; - SimParams["lastname"] = theUser.surname; - SimParams["agent_id"] = theUser.UUID.ToString(); - SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response["circuit_code"]); - SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); - SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); - SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(SimParams); - - // Update agent with target sim - theUser.currentAgent.currentRegion = SimInfo.UUID; - theUser.currentAgent.currentHandle = SimInfo.regionhandle; - - // Send - XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); - XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); - } - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public bool AuthenticateUser(ref UserProfileData profile, string password) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine( - OpenSim.Framework.Console.LogPriority.LOW, - "Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - - /// - /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB - /// - /// The users profile - /// The users loginrequest - public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request) - { - Hashtable requestData = (Hashtable)request.Params[0]; - - UserAgentData agent = new UserAgentData(); - - // User connection - agent.agentIP = ""; - agent.agentOnline = true; - agent.agentPort = 0; - - // Generate sessions - RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); - byte[] randDataS = new byte[16]; - byte[] randDataSS = new byte[16]; - rand.GetBytes(randDataS); - rand.GetBytes(randDataSS); - - agent.secureSessionID = new LLUUID(randDataSS, 0); - agent.sessionID = new LLUUID(randDataS, 0); - - // Profile UUID - agent.UUID = profile.UUID; - - // Current position (from Home) - agent.currentHandle = profile.homeRegion; - agent.currentPos = profile.homeLocation; - - // If user specified additional start, use that - if (requestData.ContainsKey("start")) - { - string startLoc = (string)requestData["start"]; - if (!(startLoc == "last" || startLoc == "home")) - { - // Ignore it! Heh. - } - } - - // What time did the user login? - agent.loginTime = Util.UnixTimeSinceEpoch(); - agent.logoutTime = 0; - - // Current location - agent.regionID = new LLUUID(); // Fill in later - agent.currentRegion = new LLUUID(); // Fill in later - - profile.currentAgent = agent; - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - // Saves the agent to database - return true; - } - - /// - /// Main user login function - /// - /// The XMLRPC request - /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin = false; - string firstname = ""; - string lastname = ""; - string passwd = ""; - - UserProfileData TheUser; - - if (GoodXML) - { - firstname = (string)requestData["first"]; - lastname = (string)requestData["last"]; - passwd = (string)requestData["passwd"]; - - TheUser = getUserProfile(firstname, lastname); - if (TheUser == null) - return CreateLoginErrorResponse(); - - GoodLogin = AuthenticateUser(ref TheUser, passwd); - } - else - { - return CreateErrorConnectingToGridResponse(); - } - - if (!GoodLogin) - { - return CreateLoginErrorResponse(); - } - else - { - // If we already have a session... - if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline) - { - // Reject the login - return CreateAlreadyLoggedInResponse(); - } - // Otherwise... - // Create a new agent session - CreateAgent(ref TheUser, request); - - try - { - Hashtable responseData = new Hashtable(); - - LLUUID AgentID = TheUser.UUID; - - // Global Texture Section - Hashtable GlobalT = new Hashtable(); - GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; - GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - ArrayList GlobalTextures = new ArrayList(); - GlobalTextures.Add(GlobalT); - - // Login Flags Section - Hashtable LoginFlagsHash = new Hashtable(); - LoginFlagsHash["daylight_savings"] = "N"; - LoginFlagsHash["stipend_since_login"] = "N"; - LoginFlagsHash["gendered"] = "Y"; - LoginFlagsHash["ever_logged_in"] = "N"; // Should allow male/female av selection - ArrayList LoginFlags = new ArrayList(); - LoginFlags.Add(LoginFlagsHash); - - // UI Customisation Section - Hashtable uiconfig = new Hashtable(); - uiconfig["allow_first_life"] = "Y"; - ArrayList ui_config = new ArrayList(); - ui_config.Add(uiconfig); - - // Classified Categories Section - Hashtable ClassifiedCategoriesHash = new Hashtable(); - ClassifiedCategoriesHash["category_name"] = "Generic"; - ClassifiedCategoriesHash["category_id"] = (Int32)1; - ArrayList ClassifiedCategories = new ArrayList(); - ClassifiedCategories.Add(ClassifiedCategoriesHash); - - // Inventory Library Section - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - - AgentInventory Library = new AgentInventory(); - Library.CreateRootFolder(AgentID, true); - - foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - ArrayList InitialOutfit = new ArrayList(); - InitialOutfit.Add(InitialOutfitHash); - - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - - // Generics - responseData["last_name"] = TheUser.surname; - responseData["ui-config"] = ui_config; - responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); - responseData["login-flags"] = LoginFlags; - responseData["global-textures"] = GlobalTextures; - responseData["classified_categories"] = ClassifiedCategories; - responseData["event_categories"] = new ArrayList(); - responseData["inventory-skeleton"] = AgentInventoryArray; - responseData["inventory-skel-lib"] = new ArrayList(); - responseData["inventory-root"] = InventoryRoot; - responseData["event_notifications"] = new ArrayList(); - responseData["gestures"] = new ArrayList(); - responseData["inventory-lib-owner"] = new ArrayList(); - responseData["initial-outfit"] = InitialOutfit; - responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["start_location"] = "last"; - responseData["home"] = "!!null temporary value {home}!!"; // Overwritten - responseData["message"] = _config.DefaultStartupMsg; - responseData["first_name"] = TheUser.username; - responseData["circuit_code"] = (Int32)circode; - responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port; - responseData["secure_session_id"] = TheUser.currentAgent.secureSessionID.ToStringHyphenated(); - responseData["look_at"] = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - responseData["agent_id"] = AgentID.ToStringHyphenated(); - responseData["region_y"] = (Int32)0; // Overwritten - responseData["region_x"] = (Int32)0; // Overwritten - responseData["seed_capability"] = ""; - responseData["agent_access"] = "M"; - responseData["session_id"] = TheUser.currentAgent.sessionID.ToStringHyphenated(); - responseData["login"] = "true"; - - this.CustomiseResponse(ref responseData, ref TheUser); - - CommitAgent(ref TheUser); - - response.Value = responseData; - // TheUser.SendDataToSim(SimInfo); - return response; - - } - catch (Exception E) - { - Console.WriteLine(E.ToString()); - } - //} - } - return response; - - } - - /// - /// Deletes an active agent session - /// - /// The request - /// The path (eg /bork/narf/test) - /// Parameters sent - /// Success "OK" else error - public string RestDeleteUserSessionMethod(string request, string path, string param) - { - // TODO! Important! - - return "OK"; - } - - } -} -- cgit v1.1