From b47e405420b316a2f68b3e6f4c5ed35dc713260e Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 12 Aug 2009 22:54:57 -0400 Subject: * minor: Comments --- OpenSim/Region/Application/Application.cs | 33 +++++++- OpenSim/Region/Application/ConfigurationLoader.cs | 45 ++++++++++- OpenSim/Region/Application/IApplicationPlugin.cs | 12 +++ OpenSim/Region/Application/OpenSim.cs | 95 ++++++++++++++++++++++- 4 files changed, 181 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index ad157c6..df80290 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -36,25 +36,47 @@ using OpenSim.Framework.Console; namespace OpenSim { + /// + /// Starting class for the OpenSimulator Region + /// public class Application { + /// + /// Text Console Logger + /// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Path to the main ini Configuration file + /// public static string iniFilePath = ""; + /// + /// Save Crashes in the bin/crashes folder. Configurable with m_crashDir + /// public static bool m_saveCrashDumps = false; + + /// + /// Directory to save crash reports to. Relative to bin/ + /// public static string m_crashDir = "crashes"; + /// + /// Instance of the OpenSim class. This could be OpenSim or OpenSimBackground depending on the configuration + /// protected static OpenSimBase m_sim = null; //could move our main function into OpenSimMain and kill this class public static void Main(string[] args) { - // First line + // First line, hook the appdomain to the crash reporter AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + // Add the arguments supplied when running the application to the configuration ArgvConfigSource configSource = new ArgvConfigSource(args); + + // Configure Log4Net configSource.AddSwitch("Startup", "logconfig"); string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty); if (logConfigFile != String.Empty) @@ -69,6 +91,8 @@ namespace OpenSim m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config"); } + // Check if the system is compatible with OpenSimulator. + // Ensures that the minimum system requirements are met m_log.Info("Performing compatibility checks... "); string supported = String.Empty; if (Util.IsEnvironmentSupported(ref supported)) @@ -80,6 +104,7 @@ namespace OpenSim m_log.Warn("Environment is unsupported (" + supported + ")\n"); } + // Configure nIni aliases and localles Culture.SetCurrentCulture(); @@ -99,8 +124,13 @@ namespace OpenSim configSource.AddConfig("StandAlone"); configSource.AddConfig("Network"); + // Check if we're running in the background or not bool background = configSource.Configs["Startup"].GetBoolean("background", false); + + // Check if we're saving crashes m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false); + + // load Crash directory config m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); if (background) @@ -118,6 +148,7 @@ namespace OpenSim { try { + // Block thread here for input MainConsole.Instance.Prompt(); } catch (Exception e) diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index 3a65242..c3e7b86 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -37,12 +37,32 @@ using OpenSim.Framework; namespace OpenSim { + /// + /// Loads the Configuration files into nIni + /// public class ConfigurationLoader { + /// + /// Various Config settings the region needs to start + /// Physics Engine, Mesh Engine, GridMode, PhysicsPrim allowed, Neighbor, + /// StorageDLL, Storage Connection String, Estate connection String, Client Stack + /// Standalone settings. + /// protected ConfigSettings m_configSettings; + + /// + /// A source of Configuration data + /// protected OpenSimConfigSource m_config; + + /// + /// Grid Service Information. This refers to classes and addresses of the grid service + /// protected NetworkServersInfo m_networkServersInfo; + /// + /// Console logger + /// private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); @@ -51,6 +71,13 @@ namespace OpenSim { } + /// + /// Loads the region configuration + /// + /// Parameters passed into the process when started + /// + /// + /// A configuration that gets passed to modules public OpenSimConfigSource LoadConfigSettings( IConfigSource argvSource, out ConfigSettings configSettings, out NetworkServersInfo networkInfo) @@ -169,15 +196,22 @@ namespace OpenSim return m_config; } + /// + /// Adds the included files as ini configuration files + /// + /// List of URL strings or filename strings private void AddIncludes(List sources) { + //loop over config sources foreach (IConfig config in m_config.Source.Configs) { + // Look for Include-* in the key name string[] keys = config.GetKeys(); foreach (string k in keys) { if (k.StartsWith("Include-")) { + // read the config file to be included. string file = config.GetString(k); if (IsUri(file)) { @@ -199,7 +233,11 @@ namespace OpenSim } } } - + /// + /// Check if we can convert the string to a URI + /// + /// String uri to the remote resource + /// true if we can convert the string to a Uri object bool IsUri(string file) { Uri configUri; @@ -253,7 +291,7 @@ namespace OpenSim /// /// Setup a default config values in case they aren't present in the ini file /// - /// + /// A Configuration source containing the default configuration private static IConfigSource DefaultConfig() { IConfigSource defaultConfig = new IniConfigSource(); @@ -322,6 +360,9 @@ namespace OpenSim return defaultConfig; } + /// + /// Read initial region settings from the ConfigSource + /// protected virtual void ReadConfigSettings() { IConfig startupConfig = m_config.Source.Configs["Startup"]; diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 1e1dae0..6e6d48c 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -29,12 +29,24 @@ using OpenSim.Framework; namespace OpenSim { + /// + /// OpenSimulator Application Plugin framework interface + /// public interface IApplicationPlugin : IPlugin { + /// + /// Initialize the Plugin + /// + /// The Application instance void Initialise(OpenSimBase openSim); + + /// + /// Called when the application loading is completed + /// void PostInitialise(); } + public class ApplicationPluginInitialiser : PluginInitialiserBase { private OpenSimBase server; diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index aeb6f57..390cfcd 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -146,6 +146,9 @@ namespace OpenSim ChangeSelectedRegion("region", new string[] {"change", "region", "root"}); } + /// + /// Register standard set of region console commands + /// private void RegisterConsoleCommands() { m_console.Commands.AddCommand("region", false, "clear assets", @@ -332,6 +335,11 @@ namespace OpenSim base.ShutdownSpecific(); } + /// + /// Timer to run a specific text file as console commands. Configured in in the main ini file + /// + /// + /// private void RunAutoTimerScript(object sender, EventArgs e) { if (m_timedScript != "disabled") @@ -342,6 +350,11 @@ namespace OpenSim #region Console Commands + /// + /// Kicks users off the region + /// + /// + /// name of avatar to kick private void KickUserCommand(string module, string[] cmdparams) { if (cmdparams.Length < 4) @@ -401,6 +414,10 @@ namespace OpenSim } } + /// + /// Opens a file and uses it as input to the console command parser. + /// + /// name of file to use as input to the console private static void PrintFileToConsole(string fileName) { if (File.Exists(fileName)) @@ -419,12 +436,22 @@ namespace OpenSim m_log.Info("Not implemented."); } + /// + /// Force resending of all updates to all clients in active region(s) + /// + /// + /// private void HandleForceUpdate(string module, string[] args) { m_log.Info("Updating all clients"); m_sceneManager.ForceCurrentSceneClientUpdate(); } + /// + /// Edits the scale of a primative with the name specified + /// + /// + /// 0,1, name, x, y, z private void HandleEditScale(string module, string[] args) { if (args.Length == 6) @@ -437,6 +464,11 @@ namespace OpenSim } } + /// + /// Creates a new region based on the parameters specified. This will ask the user questions on the console + /// + /// + /// 0,1,region name, region XML file private void HandleCreateRegion(string module, string[] cmd) { if (cmd.Length < 4) @@ -473,16 +505,32 @@ namespace OpenSim } } + /// + /// Enable logins + /// + /// + /// private void HandleLoginEnable(string module, string[] cmd) { ProcessLogin(true); } + + /// + /// Disable logins + /// + /// + /// private void HandleLoginDisable(string module, string[] cmd) { ProcessLogin(false); } + /// + /// Log login status to the console + /// + /// + /// private void HandleLoginStatus(string module, string[] cmd) { if (m_commsManager.GridService.RegionLoginsEnabled == false) @@ -492,6 +540,12 @@ namespace OpenSim m_log.Info("[ Login ] Login are enabled"); } + + /// + /// Change and load configuration file data. + /// + /// + /// private void HandleConfig(string module, string[] cmd) { List args = new List(cmd); @@ -557,6 +611,12 @@ namespace OpenSim } } + + /// + /// Load, Unload, and list Region modules in use + /// + /// + /// private void HandleModules(string module, string[] cmd) { List args = new List(cmd); @@ -797,6 +857,11 @@ namespace OpenSim } // see BaseOpenSimServer + /// + /// Many commands list objects for debugging. Some of the types are listed here + /// + /// + /// public override void HandleShow(string mod, string[] cmd) { base.HandleShow(mod, cmd); @@ -902,6 +967,10 @@ namespace OpenSim } } + /// + /// print UDP Queue data for each client + /// + /// private string GetQueuesReport() { string report = String.Empty; @@ -1010,6 +1079,11 @@ namespace OpenSim m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword); } + /// + /// Use XML2 format to serialize data to a file + /// + /// + /// protected void SavePrimsXml2(string module, string[] cmdparams) { if (cmdparams.Length > 5) @@ -1022,6 +1096,11 @@ namespace OpenSim } } + /// + /// Use XML format to serialize data to a file + /// + /// + /// protected void SaveXml(string module, string[] cmdparams) { m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); @@ -1036,6 +1115,11 @@ namespace OpenSim } } + /// + /// Loads data and region objects from XML format. + /// + /// + /// protected void LoadXml(string module, string[] cmdparams) { m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); @@ -1079,7 +1163,11 @@ namespace OpenSim } } } - + /// + /// Serialize region data to XML2Format + /// + /// + /// protected void SaveXml2(string module, string[] cmdparams) { if (cmdparams.Length > 2) @@ -1092,6 +1180,11 @@ namespace OpenSim } } + /// + /// Load region data from Xml2Format + /// + /// + /// protected void LoadXml2(string module, string[] cmdparams) { if (cmdparams.Length > 2) -- cgit v1.1