diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs index 52bc3d6ae5..b0726e66a3 100644 --- a/OpenSim/Framework/GridConfig.cs +++ b/OpenSim/Framework/GridConfig.cs @@ -26,6 +26,7 @@ */ using System; +using Nini.Config; namespace OpenSim.Framework { @@ -49,6 +50,11 @@ namespace OpenSim.Framework public string UserRecvKey = String.Empty; public string UserSendKey = String.Empty; + public GridConfig() + { + + } + public GridConfig(string description, string filename) { configMember = @@ -56,6 +62,11 @@ namespace OpenSim.Framework configMember.performConfigurationRetrieve(); } + public void LoadConfigurationFromNini(IConfigSource configSource) + { + + } + public void loadConfigurationOptions() { configMember.addConfigurationOption("default_asset_server", diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index 901b57af15..04d5d05b66 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -27,6 +27,7 @@ using System; using System.IO; +using Nini.Config; namespace OpenSim.Framework { @@ -91,6 +92,11 @@ namespace OpenSim.Framework configMember.performConfigurationRetrieve(); } + public void LoadConfigurationFromNini(IConfigSource configSource) + { + + } + public void loadConfigurationOptions() { configMember.addConfigurationOption("default_startup_message", diff --git a/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs b/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs index fd7f4c16f1..3caa63b018 100644 --- a/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs +++ b/OpenSim/Grid/GridServer.Modules/GridServerPlugin.cs @@ -33,7 +33,7 @@ namespace OpenSim.Grid.GridServer.Modules public void Initialise(GridServerBase gridServer) { m_core = gridServer; - m_config = gridServer.Config; + m_config = gridServer.GConfig; m_version = gridServer.Version; m_console = MainConsole.Instance; @@ -67,7 +67,7 @@ namespace OpenSim.Grid.GridServer.Modules { // m_log.Info("[DATA]: Connecting to Storage Server"); m_gridDBService = new GridDBService(); - m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); + //m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); //Register the database access service so modules can fetch it // RegisterInterface(m_gridDBService); diff --git a/OpenSim/Grid/GridServer/GridConfigurationLoader.cs b/OpenSim/Grid/GridServer/GridConfigurationLoader.cs new file mode 100644 index 0000000000..8c2b806088 --- /dev/null +++ b/OpenSim/Grid/GridServer/GridConfigurationLoader.cs @@ -0,0 +1,250 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * 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 OpenSimulator Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.IO; +using System.Reflection; +using System.Threading; +using System.Xml; +using log4net; +using Nini.Config; +using OpenSim.Framework; + +namespace OpenSim.Grid.GridServer +{ + public class GridConfigurationLoader + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected OpenSimConfigSource m_config; + + public GridConfigurationLoader() + { + } + + public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource) + { + bool iniFileExists = false; + + IConfig startupConfig = configSource.Configs["Startup"]; + + string masterFileName = startupConfig.GetString("inimaster", ""); + string masterfilePath = Path.Combine(Util.configDir(), masterFileName); + + string iniDirName = startupConfig.GetString("inidirectory", "GridConfig"); + string iniDirPath = Path.Combine(Util.configDir(), iniDirName); + + string iniFileName = startupConfig.GetString("inifile", "OpenSim.Grid.ini"); + string iniFilePath = Path.Combine(Util.configDir(), iniFileName); + + string xmlPath = Path.Combine(Util.configDir(), "OpenSim.Grid.xml"); + + m_config = new OpenSimConfigSource(); + m_config.Source = new IniConfigSource(); + m_config.Source.Merge(DefaultConfig()); + + m_log.Info("[CONFIG] Reading configuration settings"); + + Uri configUri; + + //check for master .INI file (name passed in command line, no default), or XML over http + if (masterFileName.Length > 0) // If a master file name is given ... + { + m_log.InfoFormat("[CONFIG] Reading config master file {0}", masterfilePath); + + bool isMasterUri = Uri.TryCreate(masterFileName, UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp; + + if (!ReadConfig(masterFileName, masterfilePath, m_config, isMasterUri)) + { + m_log.FatalFormat("[CONFIG] Could not open master config file {0}", masterfilePath); + } + } + + if (Directory.Exists(iniDirName)) + { + m_log.InfoFormat("Searching folder: {0} , for config ini files", iniDirName); + string[] fileEntries = Directory.GetFiles(iniDirName); + foreach (string filePath in fileEntries) + { + // m_log.InfoFormat("reading ini file < {0} > from config dir", filePath); + ReadConfig(Path.GetFileName(filePath), filePath, m_config, false); + } + } + + // Check for .INI file (either default or name passed on command + // line) or XML config source over http + bool isIniUri = Uri.TryCreate(iniFileName, UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp; + iniFileExists = ReadConfig(iniFileName, iniFilePath, m_config, isIniUri); + + if (!iniFileExists) + { + // check for a xml config file + if (File.Exists(xmlPath)) + { + iniFilePath = xmlPath; + + m_log.InfoFormat("Reading XML configuration from {0}", Path.GetFullPath(xmlPath)); + iniFileExists = true; + + m_config.Source = new XmlConfigSource(); + m_config.Source.Merge(new XmlConfigSource(iniFilePath)); + } + } + + m_config.Source.Merge(configSource); + + if (!iniFileExists) + { + m_log.FatalFormat("[CONFIG] Could not load any configuration"); + if (!isIniUri) + m_log.FatalFormat("[CONFIG] Tried to load {0}, ", Path.GetFullPath(iniFilePath)); + else + m_log.FatalFormat("[CONFIG] Tried to load from URI {0}, ", iniFileName); + m_log.FatalFormat("[CONFIG] and XML source {0}", Path.GetFullPath(xmlPath)); + + m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.Grid.ini.example file to OpenSim.Grid.ini?"); + Environment.Exit(1); + } + + ReadConfigSettings(); + + return m_config; + } + + /// + /// Provide same ini loader functionality for standard ini and master ini - file system or XML over http + /// + /// The name of the ini to load + /// Full path to the ini + /// The current configuration source + /// Boolean representing whether the ini source is a URI path over http or a file on the system + /// + private bool ReadConfig(string iniName, string iniPath, OpenSimConfigSource m_config, bool isUri) + { + bool success = false; + + if (!isUri && File.Exists(iniPath)) + { + m_log.InfoFormat("[CONFIG] Reading configuration file {0}", Path.GetFullPath(iniPath)); + + // From reading Nini's code, it seems that later merged keys replace earlier ones. + m_config.Source.Merge(new IniConfigSource(iniPath)); + success = true; + } + else + { + if (isUri) + { + m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...", iniName); + + // The ini file path is a http URI + // Try to read it + try + { + XmlReader r = XmlReader.Create(iniName); + XmlConfigSource cs = new XmlConfigSource(r); + m_config.Source.Merge(cs); + + success = true; + m_log.InfoFormat("[CONFIG] Loaded config from {0}", iniName); + } + catch (Exception e) + { + m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniName); + Environment.Exit(1); + } + } + } + return success; + } + + /// + /// Setup a default config values in case they aren't present in the ini file + /// + /// + public static IConfigSource DefaultConfig() + { + IConfigSource defaultConfig = new IniConfigSource(); + + { + IConfig config = defaultConfig.Configs["Startup"]; + + if (null == config) + config = defaultConfig.AddConfig("Startup"); + + config.Set("LoadPlugins", "GridServerPlugin;UserServerPlugin"); + config.Set("HttpPort", "8051"); + } + + { + IConfig config = defaultConfig.Configs["GridServices"]; + + if (null == config) + config = defaultConfig.AddConfig("GridServices"); + + config.Set("enable", false); + + } + + return defaultConfig; + } + + protected virtual void ReadConfigSettings() + { + IConfig startupConfig = m_config.Source.Configs["Startup"]; + if (startupConfig != null) + { + + } + + IConfig standaloneConfig = m_config.Source.Configs["StandAlone"]; + if (standaloneConfig != null) + { + + } + } + } + + public class OpenSimConfigSource + { + public IConfigSource Source; + + public void Save(string path) + { + if (Source is IniConfigSource) + { + IniConfigSource iniCon = (IniConfigSource)Source; + iniCon.Save(path); + } + else if (Source is XmlConfigSource) + { + XmlConfigSource xmlCon = (XmlConfigSource)Source; + xmlCon.Save(path); + } + } + } +} diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index a1170f8bc8..77c0255f92 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -31,6 +31,7 @@ using System.IO; using System.Reflection; using System.Timers; using log4net; +using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -44,11 +45,25 @@ namespace OpenSim.Grid.GridServer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected GridConfig m_config; + protected GridConfig m_gconfig; + protected UserConfig m_uconfig; - public GridConfig Config + protected GridConfigurationLoader m_configLoader; + protected OpenSimConfigSource m_configSource; + + public OpenSimConfigSource ConfigSource { - get { return m_config; } + get { return m_configSource; } + } + + public GridConfig GConfig + { + get { return m_gconfig; } + } + + public UserConfig UConfig + { + get { return m_uconfig; } } public string Version @@ -68,18 +83,31 @@ namespace OpenSim.Grid.GridServer } } - public GridServerBase() + public GridServerBase(IConfigSource configSource) { m_console = new ConsoleBase("Grid"); MainConsole.Instance = m_console; + + m_configLoader = new GridConfigurationLoader(); + m_configSource = m_configLoader.LoadConfigSettings(configSource); } protected override void StartupSpecific() { - m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); + uint httpPort = 8051; + + m_gconfig = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); + + m_uconfig = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); + + IConfig startupConfig = m_configSource.Source.Configs["Startup"]; + if (startupConfig != null) + { + Convert.ToUInt32(startupConfig.GetString("HttpPort", "8051")); + } m_log.Info("[GRID]: Starting HTTP process"); - m_httpServer = new BaseHttpServer(m_config.HttpPort); + m_httpServer = new BaseHttpServer(httpPort); LoadPlugins(); diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Grid/GridServer/Program.cs index 3b3bb42248..a3d44e90c1 100644 --- a/OpenSim/Grid/GridServer/Program.cs +++ b/OpenSim/Grid/GridServer/Program.cs @@ -26,6 +26,7 @@ */ using log4net.Config; +using Nini.Config; namespace OpenSim.Grid.GridServer { @@ -35,7 +36,18 @@ namespace OpenSim.Grid.GridServer { XmlConfigurator.Configure(); - GridServerBase app = new GridServerBase(); + ArgvConfigSource configSource = new ArgvConfigSource(args); + + configSource.Alias.AddAlias("On", true); + configSource.Alias.AddAlias("Off", false); + configSource.Alias.AddAlias("True", true); + configSource.Alias.AddAlias("False", false); + + configSource.AddSwitch("Startup", "inifile"); + configSource.AddSwitch("Startup", "inimaster"); + configSource.AddSwitch("Startup", "inidirectory"); + + GridServerBase app = new GridServerBase(configSource); // if (args.Length > 0 && args[0] == "-setuponly") // { diff --git a/OpenSim/Grid/UserServer.Modules/Resources/UserServer.Modules.addin.xml b/OpenSim/Grid/UserServer.Modules/Resources/UserServer.Modules.addin.xml new file mode 100644 index 0000000000..b1e671629b --- /dev/null +++ b/OpenSim/Grid/UserServer.Modules/Resources/UserServer.Modules.addin.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/OpenSim/Grid/UserServer/UserServerCommandModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerCommandModule.cs similarity index 97% rename from OpenSim/Grid/UserServer/UserServerCommandModule.cs rename to OpenSim/Grid/UserServer.Modules/UserServerCommandModule.cs index f73b3deb32..256f792a89 100644 --- a/OpenSim/Grid/UserServer/UserServerCommandModule.cs +++ b/OpenSim/Grid/UserServer.Modules/UserServerCommandModule.cs @@ -1,374 +1,373 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Generic; -using System.IO; -using System.Reflection; -using log4net; -using log4net.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Statistics; -using OpenSim.Grid.Communications.OGS1; -using OpenSim.Grid.Framework; -using OpenSim.Grid.UserServer.Modules; - -namespace OpenSim.Grid.UserServer -{ - public class UserServerCommandModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected ConsoleBase m_console; - protected UserConfig m_cfg; - - protected UserDataBaseService m_userDataBaseService; - protected UserLoginService m_loginService; - - protected UUID m_lastCreatedUser = UUID.Random(); - - protected IGridServiceCore m_core; - - public UserServerCommandModule() - { - } - - public void Initialise(IGridServiceCore core) - { - m_core = core; - } - - public void PostInitialise() - { - UserConfig cfg; - if (m_core.TryGet(out cfg)) - { - m_cfg = cfg; - } - - UserDataBaseService userDBservice; - if (m_core.TryGet(out userDBservice)) - { - m_userDataBaseService = userDBservice; - } - - UserLoginService loginService; - if (m_core.TryGet(out loginService)) - { - m_loginService = loginService; - } - - ConsoleBase console; - if ((m_core.TryGet(out console)) && (m_cfg != null) - && (m_userDataBaseService != null) && (m_loginService != null)) - { - RegisterConsoleCommands(console); - } - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - - } - - private void RegisterConsoleCommands(ConsoleBase console) - { - m_console = console; - m_console.Commands.AddCommand("userserver", false, "create user", - "create user [ [ [ [email]]]]", - "Create a new user account", RunCommand); - - m_console.Commands.AddCommand("userserver", false, "reset user password", - "reset user password [ [ []]]", - "Reset a user's password", RunCommand); - - m_console.Commands.AddCommand("userserver", false, "login level", - "login level ", - "Set the minimum user level to log in", HandleLoginCommand); - - m_console.Commands.AddCommand("userserver", false, "login reset", - "login reset", - "Reset the login level to allow all users", - HandleLoginCommand); - - m_console.Commands.AddCommand("userserver", false, "login text", - "login text ", - "Set the text users will see on login", HandleLoginCommand); - - m_console.Commands.AddCommand("userserver", false, "test-inventory", - "test-inventory", - "Perform a test inventory transaction", RunCommand); - - m_console.Commands.AddCommand("userserver", false, "logoff-user", - "logoff-user ", - "Log off a named user", RunCommand); - } - - #region Console Command Handlers - public void do_create(string[] args) - { - switch (args[0]) - { - case "user": - CreateUser(args); - break; - } - } - - /// - /// Execute switch for some of the reset commands - /// - /// - protected void Reset(string[] args) - { - if (args.Length == 0) - return; - - switch (args[0]) - { - case "user": - - switch (args[1]) - { - case "password": - ResetUserPassword(args); - break; - } - - break; - } - } - - /// - /// Create a new user - /// - /// string array with parameters: firstname, lastname, password, locationX, locationY, email - protected void CreateUser(string[] cmdparams) - { - string firstName; - string lastName; - string password; - string email; - 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 (cmdparams.Length < 7) - email = MainConsole.Instance.CmdPrompt("Email", ""); - else email = cmdparams[6]; - - if (null == m_userDataBaseService.GetUserProfile(firstName, lastName)) - { - m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY); - } - else - { - m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName); - } - } - - /// - /// Reset a user password. - /// - /// - private void ResetUserPassword(string[] cmdparams) - { - string firstName; - string lastName; - string newPassword; - - if (cmdparams.Length < 3) - firstName = MainConsole.Instance.CmdPrompt("First name"); - else firstName = cmdparams[2]; - - if (cmdparams.Length < 4) - lastName = MainConsole.Instance.CmdPrompt("Last name"); - else lastName = cmdparams[3]; - - if (cmdparams.Length < 5) - newPassword = MainConsole.Instance.PasswdPrompt("New password"); - else newPassword = cmdparams[4]; - - m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword); - } - - /* - private void HandleTestCommand(string module, string[] cmd) - { - m_log.Info("test command received"); - } - */ - - private void HandleLoginCommand(string module, string[] cmd) - { - string subcommand = cmd[1]; - - switch (subcommand) - { - case "level": - // Set the minimal level to allow login - // Useful to allow grid update without worrying about users. - // or fixing critical issues - // - if (cmd.Length > 2) - { - int level = Convert.ToInt32(cmd[2]); - m_loginService.setloginlevel(level); - } - break; - case "reset": - m_loginService.setloginlevel(0); - break; - case "text": - if (cmd.Length > 2) - { - m_loginService.setwelcometext(cmd[2]); - } - break; - } - } - - public void RunCommand(string module, string[] cmd) - { - List args = new List(cmd); - string command = cmd[0]; - - args.RemoveAt(0); - - string[] cmdparams = args.ToArray(); - - switch (command) - { - case "create": - do_create(cmdparams); - break; - - case "reset": - Reset(cmdparams); - break; - - - case "test-inventory": - // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); - // requester.ReturnResponseVal = TestResponse; - // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); - SynchronousRestObjectPoster.BeginPostObject>( - "POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser); - break; - - case "logoff-user": - if (cmdparams.Length >= 3) - { - string firstname = cmdparams[0]; - string lastname = cmdparams[1]; - string message = ""; - - for (int i = 2; i < cmdparams.Length; i++) - message += " " + cmdparams[i]; - - UserProfileData theUser = null; - try - { - theUser = m_loginService.GetTheUser(firstname, lastname); - } - catch (Exception) - { - m_log.Error("[LOGOFF]: Error getting user data from the database."); - } - - if (theUser != null) - { - if (theUser.CurrentAgent != null) - { - if (theUser.CurrentAgent.AgentOnline) - { - m_log.Info("[LOGOFF]: Logging off requested user!"); - m_loginService.LogOffUser(theUser, message); - - theUser.CurrentAgent.AgentOnline = false; - - m_loginService.CommitAgent(ref theUser); - } - else - { - m_log.Info( - "[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway."); - m_loginService.LogOffUser(theUser, message); - - theUser.CurrentAgent.AgentOnline = false; - - m_loginService.CommitAgent(ref theUser); - } - } - else - { - m_log.Error( - "[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify"); - } - } - else - { - m_log.Info("[LOGOFF]: User doesn't exist in the database"); - } - } - else - { - m_log.Error( - "[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message"); - } - - break; - } - } - } - #endregion -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Generic; +using System.IO; +using System.Reflection; +using log4net; +using log4net.Config; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Statistics; +using OpenSim.Grid.Communications.OGS1; +using OpenSim.Grid.Framework; + +namespace OpenSim.Grid.UserServer.Modules +{ + public class UserServerCommandModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected ConsoleBase m_console; + protected UserConfig m_cfg; + + protected UserDataBaseService m_userDataBaseService; + protected UserLoginService m_loginService; + + protected UUID m_lastCreatedUser = UUID.Random(); + + protected IGridServiceCore m_core; + + public UserServerCommandModule() + { + } + + public void Initialise(IGridServiceCore core) + { + m_core = core; + } + + public void PostInitialise() + { + UserConfig cfg; + if (m_core.TryGet(out cfg)) + { + m_cfg = cfg; + } + + UserDataBaseService userDBservice; + if (m_core.TryGet(out userDBservice)) + { + m_userDataBaseService = userDBservice; + } + + UserLoginService loginService; + if (m_core.TryGet(out loginService)) + { + m_loginService = loginService; + } + + ConsoleBase console; + if ((m_core.TryGet(out console)) && (m_cfg != null) + && (m_userDataBaseService != null) && (m_loginService != null)) + { + RegisterConsoleCommands(console); + } + } + + public void RegisterHandlers(BaseHttpServer httpServer) + { + + } + + private void RegisterConsoleCommands(ConsoleBase console) + { + m_console = console; + m_console.Commands.AddCommand("userserver", false, "create user", + "create user [ [ [ [email]]]]", + "Create a new user account", RunCommand); + + m_console.Commands.AddCommand("userserver", false, "reset user password", + "reset user password [ [ []]]", + "Reset a user's password", RunCommand); + + m_console.Commands.AddCommand("userserver", false, "login level", + "login level ", + "Set the minimum user level to log in", HandleLoginCommand); + + m_console.Commands.AddCommand("userserver", false, "login reset", + "login reset", + "Reset the login level to allow all users", + HandleLoginCommand); + + m_console.Commands.AddCommand("userserver", false, "login text", + "login text ", + "Set the text users will see on login", HandleLoginCommand); + + m_console.Commands.AddCommand("userserver", false, "test-inventory", + "test-inventory", + "Perform a test inventory transaction", RunCommand); + + m_console.Commands.AddCommand("userserver", false, "logoff-user", + "logoff-user ", + "Log off a named user", RunCommand); + } + + #region Console Command Handlers + public void do_create(string[] args) + { + switch (args[0]) + { + case "user": + CreateUser(args); + break; + } + } + + /// + /// Execute switch for some of the reset commands + /// + /// + protected void Reset(string[] args) + { + if (args.Length == 0) + return; + + switch (args[0]) + { + case "user": + + switch (args[1]) + { + case "password": + ResetUserPassword(args); + break; + } + + break; + } + } + + /// + /// Create a new user + /// + /// string array with parameters: firstname, lastname, password, locationX, locationY, email + protected void CreateUser(string[] cmdparams) + { + string firstName; + string lastName; + string password; + string email; + 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 (cmdparams.Length < 7) + email = MainConsole.Instance.CmdPrompt("Email", ""); + else email = cmdparams[6]; + + if (null == m_userDataBaseService.GetUserProfile(firstName, lastName)) + { + m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY); + } + else + { + m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName); + } + } + + /// + /// Reset a user password. + /// + /// + private void ResetUserPassword(string[] cmdparams) + { + string firstName; + string lastName; + string newPassword; + + if (cmdparams.Length < 3) + firstName = MainConsole.Instance.CmdPrompt("First name"); + else firstName = cmdparams[2]; + + if (cmdparams.Length < 4) + lastName = MainConsole.Instance.CmdPrompt("Last name"); + else lastName = cmdparams[3]; + + if (cmdparams.Length < 5) + newPassword = MainConsole.Instance.PasswdPrompt("New password"); + else newPassword = cmdparams[4]; + + m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword); + } + + /* + private void HandleTestCommand(string module, string[] cmd) + { + m_log.Info("test command received"); + } + */ + + private void HandleLoginCommand(string module, string[] cmd) + { + string subcommand = cmd[1]; + + switch (subcommand) + { + case "level": + // Set the minimal level to allow login + // Useful to allow grid update without worrying about users. + // or fixing critical issues + // + if (cmd.Length > 2) + { + int level = Convert.ToInt32(cmd[2]); + m_loginService.setloginlevel(level); + } + break; + case "reset": + m_loginService.setloginlevel(0); + break; + case "text": + if (cmd.Length > 2) + { + m_loginService.setwelcometext(cmd[2]); + } + break; + } + } + + public void RunCommand(string module, string[] cmd) + { + List args = new List(cmd); + string command = cmd[0]; + + args.RemoveAt(0); + + string[] cmdparams = args.ToArray(); + + switch (command) + { + case "create": + do_create(cmdparams); + break; + + case "reset": + Reset(cmdparams); + break; + + + case "test-inventory": + // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); + // requester.ReturnResponseVal = TestResponse; + // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + SynchronousRestObjectPoster.BeginPostObject>( + "POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser); + break; + + case "logoff-user": + if (cmdparams.Length >= 3) + { + string firstname = cmdparams[0]; + string lastname = cmdparams[1]; + string message = ""; + + for (int i = 2; i < cmdparams.Length; i++) + message += " " + cmdparams[i]; + + UserProfileData theUser = null; + try + { + theUser = m_loginService.GetTheUser(firstname, lastname); + } + catch (Exception) + { + m_log.Error("[LOGOFF]: Error getting user data from the database."); + } + + if (theUser != null) + { + if (theUser.CurrentAgent != null) + { + if (theUser.CurrentAgent.AgentOnline) + { + m_log.Info("[LOGOFF]: Logging off requested user!"); + m_loginService.LogOffUser(theUser, message); + + theUser.CurrentAgent.AgentOnline = false; + + m_loginService.CommitAgent(ref theUser); + } + else + { + m_log.Info( + "[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway."); + m_loginService.LogOffUser(theUser, message); + + theUser.CurrentAgent.AgentOnline = false; + + m_loginService.CommitAgent(ref theUser); + } + } + else + { + m_log.Error( + "[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify"); + } + } + else + { + m_log.Info("[LOGOFF]: User doesn't exist in the database"); + } + } + else + { + m_log.Error( + "[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message"); + } + + break; + } + } + } + #endregion +} diff --git a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerEventDispatchModule.cs similarity index 97% rename from OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs rename to OpenSim/Grid/UserServer.Modules/UserServerEventDispatchModule.cs index 9ff9cfc868..50bd00e1a2 100644 --- a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs +++ b/OpenSim/Grid/UserServer.Modules/UserServerEventDispatchModule.cs @@ -1,141 +1,140 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Generic; -using System.IO; -using System.Reflection; -using log4net; -using log4net.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Statistics; -using OpenSim.Grid.Communications.OGS1; -using OpenSim.Grid.Framework; -using OpenSim.Grid.UserServer.Modules; - -namespace OpenSim.Grid.UserServer -{ - //Do we actually need these event dispatchers? - //shouldn't the other modules just directly register event handlers to each other? - public class UserServerEventDispatchModule - { - protected UserManager m_userManager; - protected MessageServersConnector m_messagesService; - protected UserLoginService m_loginService; - - public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService) - { - m_userManager = userManager; - m_messagesService = messagesService; - m_loginService = loginService; - } - - public void Initialise(IGridServiceCore core) - { - } - - public void PostInitialise() - { - m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; - m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; - - m_messagesService.OnAgentLocation += HandleAgentLocation; - m_messagesService.OnAgentLeaving += HandleAgentLeaving; - m_messagesService.OnRegionStartup += HandleRegionStartup; - m_messagesService.OnRegionShutdown += HandleRegionShutdown; - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - - } - - public void Close() - { - m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; - } - - #region Event Handlers - public void NotifyMessageServersUserLoggOff(UUID agentID) - { - m_messagesService.TellMessageServersAboutUserLogoff(agentID); - } - - public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID, - ulong regionhandle, float positionX, float positionY, - float positionZ, string firstname, string lastname) - { - m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX, - positionY, positionZ, firstname, lastname); - } - - public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) - { - m_userManager.HandleAgentLocation(agentID, regionID, regionHandle); - } - - public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) - { - m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle); - } - - public void HandleRegionStartup(UUID regionID) - { - // This might seem strange, that we send this back to the - // server it came from. But there is method to the madness. - // There can be multiple user servers on the same database, - // and each can have multiple messaging servers. So, we send - // it to all known user servers, who send it to all known - // message servers. That way, we should be able to finally - // update presence to all regions and thereby all friends - // - m_userManager.HandleRegionStartup(regionID); - m_messagesService.TellMessageServersAboutRegionShutdown(regionID); - } - - public void HandleRegionShutdown(UUID regionID) - { - // This might seem strange, that we send this back to the - // server it came from. But there is method to the madness. - // There can be multiple user servers on the same database, - // and each can have multiple messaging servers. So, we send - // it to all known user servers, who send it to all known - // message servers. That way, we should be able to finally - // update presence to all regions and thereby all friends - // - m_userManager.HandleRegionShutdown(regionID); - m_messagesService.TellMessageServersAboutRegionShutdown(regionID); - } - #endregion - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Generic; +using System.IO; +using System.Reflection; +using log4net; +using log4net.Config; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Statistics; +using OpenSim.Grid.Communications.OGS1; +using OpenSim.Grid.Framework; + +namespace OpenSim.Grid.UserServer.Modules +{ + //Do we actually need these event dispatchers? + //shouldn't the other modules just directly register event handlers to each other? + public class UserServerEventDispatchModule + { + protected UserManager m_userManager; + protected MessageServersConnector m_messagesService; + protected UserLoginService m_loginService; + + public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService) + { + m_userManager = userManager; + m_messagesService = messagesService; + m_loginService = loginService; + } + + public void Initialise(IGridServiceCore core) + { + } + + public void PostInitialise() + { + m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; + m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; + + m_messagesService.OnAgentLocation += HandleAgentLocation; + m_messagesService.OnAgentLeaving += HandleAgentLeaving; + m_messagesService.OnRegionStartup += HandleRegionStartup; + m_messagesService.OnRegionShutdown += HandleRegionShutdown; + } + + public void RegisterHandlers(BaseHttpServer httpServer) + { + + } + + public void Close() + { + m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; + } + + #region Event Handlers + public void NotifyMessageServersUserLoggOff(UUID agentID) + { + m_messagesService.TellMessageServersAboutUserLogoff(agentID); + } + + public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID, + ulong regionhandle, float positionX, float positionY, + float positionZ, string firstname, string lastname) + { + m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX, + positionY, positionZ, firstname, lastname); + } + + public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) + { + m_userManager.HandleAgentLocation(agentID, regionID, regionHandle); + } + + public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) + { + m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle); + } + + public void HandleRegionStartup(UUID regionID) + { + // This might seem strange, that we send this back to the + // server it came from. But there is method to the madness. + // There can be multiple user servers on the same database, + // and each can have multiple messaging servers. So, we send + // it to all known user servers, who send it to all known + // message servers. That way, we should be able to finally + // update presence to all regions and thereby all friends + // + m_userManager.HandleRegionStartup(regionID); + m_messagesService.TellMessageServersAboutRegionShutdown(regionID); + } + + public void HandleRegionShutdown(UUID regionID) + { + // This might seem strange, that we send this back to the + // server it came from. But there is method to the madness. + // There can be multiple user servers on the same database, + // and each can have multiple messaging servers. So, we send + // it to all known user servers, who send it to all known + // message servers. That way, we should be able to finally + // update presence to all regions and thereby all friends + // + m_userManager.HandleRegionShutdown(regionID); + m_messagesService.TellMessageServersAboutRegionShutdown(regionID); + } + #endregion + } +} diff --git a/OpenSim/Grid/UserServer.Modules/UserServerPlugin.cs b/OpenSim/Grid/UserServer.Modules/UserServerPlugin.cs new file mode 100644 index 0000000000..e3d1f84b7a --- /dev/null +++ b/OpenSim/Grid/UserServer.Modules/UserServerPlugin.cs @@ -0,0 +1,231 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * 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 OpenSim Project 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 THE DEVELOPERS ``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 THE CONTRIBUTORS 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.Generic; +using System.IO; +using System.Reflection; +using log4net; +using log4net.Config; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Statistics; +using OpenSim.Grid.Communications.OGS1; +using OpenSim.Grid.Framework; +using OpenSim.Grid.GridServer; + +namespace OpenSim.Grid.UserServer.Modules +{ + public class UserServerPlugin : IGridPlugin + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected UserConfig m_cfg; + + protected UserDataBaseService m_userDataBaseService; + + public UserManager m_userManager; + + protected UserServerAvatarAppearanceModule m_avatarAppearanceModule; + protected UserServerFriendsModule m_friendsModule; + + public UserLoginService m_loginService; + public MessageServersConnector m_messagesService; + + protected GridInfoServiceModule m_gridInfoService; + + protected UserServerCommandModule m_consoleCommandModule; + protected UserServerEventDispatchModule m_eventDispatcher; + + protected BaseHttpServer m_httpServer; + + protected IGridServiceCore m_core; + + protected ConsoleBase m_console; + + + public UserServerPlugin() + { + } + + #region IGridPlugin Members + + public void Initialise(GridServerBase gridServer) + { + Initialise(gridServer.HttpServer, gridServer, gridServer.UConfig); + } + + #endregion + + public void Initialise(BaseHttpServer httpServer, IGridServiceCore core, UserConfig config) + { + m_httpServer = httpServer; + m_core = core; + m_cfg = config; + m_console = MainConsole.Instance; + + IInterServiceInventoryServices inventoryService = StartupCoreComponents(); + + //setup services/modules + StartupUserServerModules(); + + StartOtherComponents(inventoryService); + + //PostInitialise the modules + PostInitialiseModules(); + + RegisterHttpHandlers(); + } + + protected virtual IInterServiceInventoryServices StartupCoreComponents() + { + + m_core.RegisterInterface(m_console); + m_core.RegisterInterface(m_cfg); + + //Should be in modules? + IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(m_cfg.InventoryUrl); + // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy(); + + m_core.RegisterInterface(inventoryService); + // RegisterInterface(regionProfileService); + + return inventoryService; + } + + /// + /// Start up the user manager + /// + /// + protected virtual void StartupUserServerModules() + { + m_log.Info("[STARTUP]: Establishing data connection"); + //setup database access service, for now this has to be created before the other modules. + m_userDataBaseService = new UserDataBaseService(); + m_userDataBaseService.Initialise(m_core); + + //TODO: change these modules so they fetch the databaseService class in the PostInitialise method + m_userManager = new UserManager(m_userDataBaseService); + m_userManager.Initialise(m_core); + + m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService); + m_avatarAppearanceModule.Initialise(m_core); + + m_friendsModule = new UserServerFriendsModule(m_userDataBaseService); + m_friendsModule.Initialise(m_core); + + m_consoleCommandModule = new UserServerCommandModule(); + m_consoleCommandModule.Initialise(m_core); + + m_messagesService = new MessageServersConnector(); + m_messagesService.Initialise(m_core); + + m_gridInfoService = new GridInfoServiceModule(); + m_gridInfoService.Initialise(m_core); + } + + protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService) + { + StartupLoginService(inventoryService); + // + // Get the minimum defaultLevel to access to the grid + // + m_loginService.setloginlevel((int)m_cfg.DefaultUserLevel); + + m_core.RegisterInterface(m_loginService); //TODO: should be done in the login service + + m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService); + m_eventDispatcher.Initialise(m_core); + } + + /// + /// Start up the login service + /// + /// + protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) + { + m_loginService = new UserLoginService( + m_userDataBaseService, inventoryService, new LibraryRootFolder(m_cfg.LibraryXmlfile), m_cfg, m_cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); + } + + protected virtual void PostInitialiseModules() + { + m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here + m_userDataBaseService.PostInitialise(); + m_messagesService.PostInitialise(); + m_eventDispatcher.PostInitialise(); //it will register event handlers in here + m_gridInfoService.PostInitialise(); + m_userManager.PostInitialise(); + m_avatarAppearanceModule.PostInitialise(); + m_friendsModule.PostInitialise(); + } + + protected virtual void RegisterHttpHandlers() + { + m_loginService.RegisterHandlers(m_httpServer, m_cfg.EnableLLSDLogin, true); + + m_userManager.RegisterHandlers(m_httpServer); + m_friendsModule.RegisterHandlers(m_httpServer); + m_avatarAppearanceModule.RegisterHandlers(m_httpServer); + m_messagesService.RegisterHandlers(m_httpServer); + m_gridInfoService.RegisterHandlers(m_httpServer); + } + + #region IPlugin Members + + public string Version + { + get { return "0.0"; } + } + + public string Name + { + get { return "UserServerPlugin"; } + } + + public void Initialise() + { + + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + throw new NotImplementedException(); + } + + #endregion + } +} diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 5a1dfd1215..c527252a06 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -54,20 +54,7 @@ namespace OpenSim.Grid.UserServer protected UserConfig Cfg; - protected UserDataBaseService m_userDataBaseService; - - public UserManager m_userManager; - - protected UserServerAvatarAppearanceModule m_avatarAppearanceModule; - protected UserServerFriendsModule m_friendsModule; - - public UserLoginService m_loginService; - public MessageServersConnector m_messagesService; - - protected GridInfoServiceModule m_gridInfoService; - - protected UserServerCommandModule m_consoleCommandModule; - protected UserServerEventDispatchModule m_eventDispatcher; + protected UserServerPlugin m_serverPlugin; public static void Main(string[] args) { @@ -99,126 +86,23 @@ namespace OpenSim.Grid.UserServer protected override void StartupSpecific() { - IInterServiceInventoryServices inventoryService = StartupCoreComponents(); + Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); m_stats = StatsManager.StartCollectingUserStats(); - //setup services/modules - StartupUserServerModules(); + m_httpServer = new BaseHttpServer(Cfg.HttpPort); - StartOtherComponents(inventoryService); - - //PostInitialise the modules - PostInitialiseModules(); - - //register http handlers and start http server - m_log.Info("[STARTUP]: Starting HTTP process"); - RegisterHttpHandlers(); + m_serverPlugin = new UserServerPlugin(); + m_serverPlugin.Initialise(m_httpServer, this, Cfg); + m_httpServer.Start(); base.StartupSpecific(); } - protected virtual IInterServiceInventoryServices StartupCoreComponents() - { - Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); - - m_httpServer = new BaseHttpServer(Cfg.HttpPort); - - RegisterInterface(m_console); - RegisterInterface(Cfg); - - //Should be in modules? - IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); - // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy(); - - RegisterInterface(inventoryService); - // RegisterInterface(regionProfileService); - - return inventoryService; - } - - /// - /// Start up the user manager - /// - /// - protected virtual void StartupUserServerModules() - { - m_log.Info("[STARTUP]: Establishing data connection"); - //setup database access service, for now this has to be created before the other modules. - m_userDataBaseService = new UserDataBaseService(); - m_userDataBaseService.Initialise(this); - - //TODO: change these modules so they fetch the databaseService class in the PostInitialise method - m_userManager = new UserManager(m_userDataBaseService); - m_userManager.Initialise(this); - - m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService); - m_avatarAppearanceModule.Initialise(this); - - m_friendsModule = new UserServerFriendsModule(m_userDataBaseService); - m_friendsModule.Initialise(this); - - m_consoleCommandModule = new UserServerCommandModule(); - m_consoleCommandModule.Initialise(this); - - m_messagesService = new MessageServersConnector(); - m_messagesService.Initialise(this); - - m_gridInfoService = new GridInfoServiceModule(); - m_gridInfoService.Initialise(this); - } - - protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService) - { - StartupLoginService(inventoryService); - // - // Get the minimum defaultLevel to access to the grid - // - m_loginService.setloginlevel((int)Cfg.DefaultUserLevel); - - RegisterInterface(m_loginService); //TODO: should be done in the login service - - m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService); - m_eventDispatcher.Initialise(this); - } - - /// - /// Start up the login service - /// - /// - protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) - { - m_loginService = new UserLoginService( - m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); - } - - protected virtual void PostInitialiseModules() - { - m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here - m_userDataBaseService.PostInitialise(); - m_messagesService.PostInitialise(); - m_eventDispatcher.PostInitialise(); //it will register event handlers in here - m_gridInfoService.PostInitialise(); - m_userManager.PostInitialise(); - m_avatarAppearanceModule.PostInitialise(); - m_friendsModule.PostInitialise(); - } - - protected virtual void RegisterHttpHandlers() - { - m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); - - m_userManager.RegisterHandlers(m_httpServer); - m_friendsModule.RegisterHandlers(m_httpServer); - m_avatarAppearanceModule.RegisterHandlers(m_httpServer); - m_messagesService.RegisterHandlers(m_httpServer); - m_gridInfoService.RegisterHandlers(m_httpServer); - } - public override void ShutdownSpecific() { - m_eventDispatcher.Close(); + } #region IUGAIMCore @@ -262,9 +146,5 @@ namespace OpenSim.Grid.UserServer } #endregion - public void TestResponse(List resp) - { - m_console.Notice("response got"); - } } } diff --git a/bin/AprSharp.pdb b/bin/AprSharp.pdb deleted file mode 100644 index 67e0f07b6a..0000000000 Binary files a/bin/AprSharp.pdb and /dev/null differ diff --git a/bin/MXP.pdb b/bin/MXP.pdb deleted file mode 100644 index 89572ca3a5..0000000000 Binary files a/bin/MXP.pdb and /dev/null differ diff --git a/bin/Newtonsoft.Json.pdb b/bin/Newtonsoft.Json.pdb deleted file mode 100644 index a8b8b8f27d..0000000000 Binary files a/bin/Newtonsoft.Json.pdb and /dev/null differ diff --git a/bin/OpenSim.32BitLaunch.pdb b/bin/OpenSim.32BitLaunch.pdb deleted file mode 100644 index 5083dd5df5..0000000000 Binary files a/bin/OpenSim.32BitLaunch.pdb and /dev/null differ diff --git a/bin/OpenSim.Grid.ini b/bin/OpenSim.Grid.ini new file mode 100644 index 0000000000..257dc94489 --- /dev/null +++ b/bin/OpenSim.Grid.ini @@ -0,0 +1,2 @@ +[Startup] +HttpPort=8051 \ No newline at end of file diff --git a/bin/SubversionSharp.pdb b/bin/SubversionSharp.pdb deleted file mode 100644 index 19e54aea86..0000000000 Binary files a/bin/SubversionSharp.pdb and /dev/null differ diff --git a/bin/libapr.pdb b/bin/libapr.pdb deleted file mode 100644 index 2e5ae0c0da..0000000000 Binary files a/bin/libapr.pdb and /dev/null differ diff --git a/bin/libapriconv.pdb b/bin/libapriconv.pdb deleted file mode 100644 index 0e92adcc1d..0000000000 Binary files a/bin/libapriconv.pdb and /dev/null differ diff --git a/bin/libaprutil.pdb b/bin/libaprutil.pdb deleted file mode 100644 index de862efdbd..0000000000 Binary files a/bin/libaprutil.pdb and /dev/null differ diff --git a/bin/protobuf-net.pdb b/bin/protobuf-net.pdb deleted file mode 100644 index 9c85bdcab0..0000000000 Binary files a/bin/protobuf-net.pdb and /dev/null differ diff --git a/prebuild.xml b/prebuild.xml index 4425520a34..d8e9f59c61 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -955,6 +955,7 @@ + @@ -963,6 +964,7 @@ + @@ -992,6 +994,7 @@ +