From 9bfbfa381abc92f3c5fc8e97405943128c85c5d4 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 10 Feb 2009 23:15:48 +0000 Subject: [PATCH] Add proper handling for shared vs. unshared modules to the command interface. Shared modules will now only get added once, so the command handler is called once per module, not once per scene. Removal of scenes has no adverse effects. Nonshared modules will be called for each scene. --- OpenSim/Framework/Console/ConsoleBase.cs | 45 +++++++--- OpenSim/Framework/IScene.cs | 2 +- .../Framework/Servers/BaseOpenSimServer.cs | 16 ++-- OpenSim/Grid/GridServer/GridServerBase.cs | 8 +- OpenSim/Grid/InventoryServer/Main.cs | 2 +- OpenSim/Grid/MessagingServer/Main.cs | 4 +- OpenSim/Grid/UserServer/Main.cs | 14 +-- OpenSim/Region/Application/HGOpenSimNode.cs | 4 +- OpenSim/Region/Application/OpenSim.cs | 88 +++++++++---------- OpenSim/Region/Application/OpenSimBase.cs | 7 +- .../World/Permissions/PermissionsModule.cs | 6 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 17 +++- OpenSim/Tools/pCampBot/BotManager.cs | 6 +- 13 files changed, 126 insertions(+), 93 deletions(-) diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 8e61587e97..721e91a5ef 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -48,6 +48,11 @@ namespace OpenSim.Framework.Console /// public string module; + /// + /// Whether the module is shared + /// + public bool shared; + /// /// Very short BNF description /// @@ -66,7 +71,7 @@ namespace OpenSim.Framework.Console /// /// The method to invoke for this command /// - public CommandDelegate fn; + public List fn; } /// @@ -172,10 +177,11 @@ namespace OpenSim.Framework.Console /// /// /// - public void AddCommand( - string module, string command, string help, string longhelp, CommandDelegate fn) + public void AddCommand(string module, bool shared, string command, + string help, string longhelp, CommandDelegate fn) { - AddCommand(module, command, help, longhelp, String.Empty, fn); + AddCommand(module, shared, command, help, longhelp, + String.Empty, fn); } /// @@ -187,8 +193,9 @@ namespace OpenSim.Framework.Console /// /// /// - public void AddCommand( - string module, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) + public void AddCommand(string module, bool shared, string command, + string help, string longhelp, string descriptivehelp, + CommandDelegate fn) { string[] parts = Parser.Parse(command); @@ -212,15 +219,25 @@ namespace OpenSim.Framework.Console } } + CommandInfo info; + if (current.ContainsKey(String.Empty)) + { + info = (CommandInfo)current[String.Empty]; + if (!info.shared && !info.fn.Contains(fn)) + info.fn.Add(fn); + return; + } - CommandInfo info = new CommandInfo(); + info = new CommandInfo(); info.module = module; + info.shared = shared; info.help_text = help; info.long_help = longhelp; info.descriptive_help = descriptivehelp; - info.fn = fn; + info.fn = new List(); + info.fn.Add(fn); current[String.Empty] = info; } @@ -275,7 +292,7 @@ namespace OpenSim.Framework.Console if (s == String.Empty) { CommandInfo ci = (CommandInfo)current[String.Empty]; - if (ci.fn != null) + if (ci.fn.Count != null) addcr = true; } else @@ -337,9 +354,10 @@ namespace OpenSim.Framework.Console if (current.ContainsKey(String.Empty)) { CommandInfo ci = (CommandInfo)current[String.Empty]; - if (ci.fn == null) + if (ci.fn.Count == null) return new string[0]; - ci.fn(ci.module, result); + foreach (CommandDelegate fn in ci.fn) + fn(ci.module, result); return result; } return new string[0]; @@ -409,9 +427,8 @@ namespace OpenSim.Framework.Console { DefaultPrompt = defaultPrompt; - Commands.AddCommand( - "console", "help", "help []", - "Get general command list or more detailed help on a specific command", Help); + Commands.AddCommand("console", false, "help", "help []", + "Get general command list or more detailed help on a specific command", Help); } public void SetGuiMode(bool mode) diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 493c626bd3..1c0a3b5cf3 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -90,6 +90,6 @@ namespace OpenSim.Framework T RequestModuleInterface(); T[] RequestModuleInterfaces(); - void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback); + void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); } } diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index ac5e183388..ff53e1a0a0 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -104,35 +104,35 @@ namespace OpenSim.Framework.Servers { SetConsoleLogLevel(new string[] { "ALL" }); - m_console.Commands.AddCommand("base", "quit", + m_console.Commands.AddCommand("base", false, "quit", "quit", "Quit the application", HandleQuit); - m_console.Commands.AddCommand("base", "shutdown", + m_console.Commands.AddCommand("base", false, "shutdown", "shutdown", "Quit the application", HandleQuit); - m_console.Commands.AddCommand("base", "set log level", + m_console.Commands.AddCommand("base", false, "set log level", "set log level ", "Set the console logging level", HandleLogLevel); - m_console.Commands.AddCommand("base", "show info", + m_console.Commands.AddCommand("base", false, "show info", "show info", "Show general information", HandleShow); - m_console.Commands.AddCommand("base", "show stats", + m_console.Commands.AddCommand("base", false, "show stats", "show stats", "Show statistics", HandleShow); - m_console.Commands.AddCommand("base", "show threads", + m_console.Commands.AddCommand("base", false, "show threads", "show threads", "Show thread status", HandleShow); - m_console.Commands.AddCommand("base", "show uptime", + m_console.Commands.AddCommand("base", false, "show uptime", "show uptime", "Show server uptime", HandleShow); - m_console.Commands.AddCommand("base", "show version", + m_console.Commands.AddCommand("base", false, "show version", "show version", "Show server version", HandleShow); } diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 3fb07b5993..9cc25e8291 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -114,15 +114,17 @@ namespace OpenSim.Grid.GridServer base.StartupSpecific(); - m_console.Commands.AddCommand("gridserver", "enable registration", + m_console.Commands.AddCommand("gridserver", false, + "enable registration", "enable registration", "Enable new regions to register", HandleRegistration); - m_console.Commands.AddCommand("gridserver", "disable registration", + m_console.Commands.AddCommand("gridserver", false, + "disable registration", "disable registration", "Disable registering new regions", HandleRegistration); - m_console.Commands.AddCommand("gridserver", "show status", + m_console.Commands.AddCommand("gridserver", false, "show status", "show status", "Show registration status", HandleShowStatus); } diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 4727f6e863..862ae58bbc 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -80,7 +80,7 @@ namespace OpenSim.Grid.InventoryServer base.StartupSpecific(); - m_console.Commands.AddCommand("inventoryserver", "add user", + m_console.Commands.AddCommand("inventoryserver", false, "add user", "add user", "Add a random user inventory", HandleAddUser); } diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 9b7e73163f..13f52ab108 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -127,11 +127,11 @@ namespace OpenSim.Grid.MessagingServer base.StartupSpecific(); - m_console.Commands.AddCommand("messageserver", "clear cache", + m_console.Commands.AddCommand("messageserver", false, "clear cache", "clear cache", "Clear presence cache", HandleClearCache); - m_console.Commands.AddCommand("messageserver", "register", + m_console.Commands.AddCommand("messageserver", false, "register", "register", "Re-register with user server(s)", HandleRegister); } diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 0b0bee1826..dd3f0b74ce 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -122,32 +122,32 @@ namespace OpenSim.Grid.UserServer base.StartupSpecific(); - m_console.Commands.AddCommand("userserver", "create user", + m_console.Commands.AddCommand("userserver", false, "create user", "create user [ [ [ [email]]]]", "Create a new user account", RunCommand); - m_console.Commands.AddCommand("userserver", "reset user password", + m_console.Commands.AddCommand("userserver", false, "reset user password", "reset user password [ [ []]]", "Reset a user's password", RunCommand); - m_console.Commands.AddCommand("userserver", "login level", + m_console.Commands.AddCommand("userserver", false, "login level", "login level ", "Set the minimum user level to log in", HandleLoginCommand); - m_console.Commands.AddCommand("userserver", "login reset", + m_console.Commands.AddCommand("userserver", false, "login reset", "login reset", "Reset the login level to allow all users", HandleLoginCommand); - m_console.Commands.AddCommand("userserver", "login text", + m_console.Commands.AddCommand("userserver", false, "login text", "login text ", "Set the text users will see on login", HandleLoginCommand); - m_console.Commands.AddCommand("userserver", "test-inventory", + m_console.Commands.AddCommand("userserver", false, "test-inventory", "test-inventory", "Perform a test inventory transaction", RunCommand); - m_console.Commands.AddCommand("userserver", "logoff-user", + m_console.Commands.AddCommand("userserver", false, "logoff-user", "logoff-user ", "Log off a named user", RunCommand); } diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs index 458c6afa78..6f6d6cbc09 100644 --- a/OpenSim/Region/Application/HGOpenSimNode.cs +++ b/OpenSim/Region/Application/HGOpenSimNode.cs @@ -78,8 +78,8 @@ namespace OpenSim base.StartupSpecific(); - MainConsole.Instance.Commands.AddCommand("hypergrid", "link-mapping", "link-mapping [ ] ", "Set local coordinate to map HG regions to", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", "link-region", "link-region :[:] ", "Link a hypergrid region", RunCommand); + MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [ ] ", "Set local coordinate to map HG regions to", RunCommand); + MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", "link-region :[:] ", "Link a hypergrid region", RunCommand); } protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 7b47eb4bd2..898e298da5 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -99,185 +99,185 @@ namespace OpenSim m_console.SetGuiMode(m_gui); MainConsole.Instance = m_console; - m_console.Commands.AddCommand("region", "clear assets", + m_console.Commands.AddCommand("region", false, "clear assets", "clear assets", "Clear the asset cache", HandleClearAssets); - m_console.Commands.AddCommand("region", "force update", + m_console.Commands.AddCommand("region", false, "force update", "force update", "Force the update of all objects on clients", HandleForceUpdate); - m_console.Commands.AddCommand("region", "debug packet", + m_console.Commands.AddCommand("region", false, "debug packet", "debug packet ", "Turn on packet debugging", Debug); - m_console.Commands.AddCommand("region", "debug scene", + m_console.Commands.AddCommand("region", false, "debug scene", "debug scene ", "Turn on scene debugging", Debug); - m_console.Commands.AddCommand("region", "change region", + m_console.Commands.AddCommand("region", false, "change region", "change region ", "Change current console region", ChangeSelectedRegion); - m_console.Commands.AddCommand("region", "save xml", + m_console.Commands.AddCommand("region", false, "save xml", "save xml", "Save a region's data in XML format", SaveXml); - m_console.Commands.AddCommand("region", "save xml2", + m_console.Commands.AddCommand("region", false, "save xml2", "save xml2", "Save a region's data in XML2 format", SaveXml2); - m_console.Commands.AddCommand("region", "load xml", + m_console.Commands.AddCommand("region", false, "load xml", "load xml [-newIDs [ ]]", "Load a region's data from XML format", LoadXml); - m_console.Commands.AddCommand("region", "load xml2", + m_console.Commands.AddCommand("region", false, "load xml2", "load xml2", "Load a region's data from XML2 format", LoadXml2); - m_console.Commands.AddCommand("region", "save prims xml2", + m_console.Commands.AddCommand("region", false, "save prims xml2", "save prims xml2 [ ]", "Save named prim to XML2", SavePrimsXml2); - m_console.Commands.AddCommand("region", "load oar", + m_console.Commands.AddCommand("region", false, "load oar", "load oar ", "Load a region's data from OAR archive", LoadOar); - m_console.Commands.AddCommand("region", "save oar", + m_console.Commands.AddCommand("region", false, "save oar", "save oar ", "Save a region's data to an OAR archive", "More information on forthcoming options here soon", SaveOar); /* - m_console.Commands.AddCommand("region", "save inventory", + m_console.Commands.AddCommand("region", false, "save inventory", "save inventory ", "Save user inventory data", SaveInv); - m_console.Commands.AddCommand("region", "load inventory", + m_console.Commands.AddCommand("region", false, "load inventory", "load inventory ", "Load user inventory data", LoadInv); */ - m_console.Commands.AddCommand("region", "edit scale", + m_console.Commands.AddCommand("region", false, "edit scale", "edit scale ", "Change the scale of a named prim", HandleEditScale); - m_console.Commands.AddCommand("region", "kick user", + m_console.Commands.AddCommand("region", false, "kick user", "kick user ", "Kick a user off the simulator", KickUserCommand); - m_console.Commands.AddCommand("region", "show assets", + m_console.Commands.AddCommand("region", false, "show assets", "show assets", "Show asset data", HandleShow); - m_console.Commands.AddCommand("region", "show users", + m_console.Commands.AddCommand("region", false, "show users", "show users [full]", "Show user data", HandleShow); - m_console.Commands.AddCommand("region", "show users full", + m_console.Commands.AddCommand("region", false, "show users full", "show users full", String.Empty, HandleShow); - m_console.Commands.AddCommand("region", "show modules", + m_console.Commands.AddCommand("region", false, "show modules", "show modules", "Show module data", HandleShow); - m_console.Commands.AddCommand("region", "show regions", + m_console.Commands.AddCommand("region", false, "show regions", "show regions", "Show region data", HandleShow); - m_console.Commands.AddCommand("region", "show queues", + m_console.Commands.AddCommand("region", false, "show queues", "show queues", "Show queue data", HandleShow); - m_console.Commands.AddCommand("region", "alert", + m_console.Commands.AddCommand("region", false, "alert", "alert ", "Send an alert to a user", RunCommand); - m_console.Commands.AddCommand("region", "alert general", + m_console.Commands.AddCommand("region", false, "alert general", "alert general ", "Send an alert everyone", RunCommand); - m_console.Commands.AddCommand("region", "backup", + m_console.Commands.AddCommand("region", false, "backup", "backup", "Persist objects to the database now", RunCommand); - m_console.Commands.AddCommand("region", "create region", + m_console.Commands.AddCommand("region", false, "create region", "create region", "Create a new region", HandleCreateRegion); - m_console.Commands.AddCommand("region", "login enable", + m_console.Commands.AddCommand("region", false, "login enable", "login enable", "Enable logins to the simulator", HandleLoginEnable); - m_console.Commands.AddCommand("region", "login disable", + m_console.Commands.AddCommand("region", false, "login disable", "login disable", "Disable logins to the simulator", HandleLoginDisable); - m_console.Commands.AddCommand("region", "login status", + m_console.Commands.AddCommand("region", false, "login status", "login status", "Display status of logins", HandleLoginStatus); - m_console.Commands.AddCommand("region", "restart", + m_console.Commands.AddCommand("region", false, "restart", "restart", "Restart all sims in this instance", RunCommand); - m_console.Commands.AddCommand("region", "config set", + m_console.Commands.AddCommand("region", false, "config set", "config set
", "Set a config option", HandleConfig); - m_console.Commands.AddCommand("region", "config get", + m_console.Commands.AddCommand("region", false, "config get", "config get
", "Read a config option", HandleConfig); - m_console.Commands.AddCommand("region", "config save", + m_console.Commands.AddCommand("region", false, "config save", "config save", "Save current configuration", HandleConfig); - m_console.Commands.AddCommand("region", "command-script", + m_console.Commands.AddCommand("region", false, "command-script", "command-script