From 4455140f3040d6d2a14057e963619aa461b51c50 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 10 Feb 2012 23:52:06 +0000 Subject: Change parser to leave embedded quotes alone if the pattern is recognized as an OptionSet long option --- OpenSim/Framework/Console/CommandConsole.cs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index a0d3541..0d6288b 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using log4net; using OpenSim.Framework; @@ -531,6 +532,11 @@ namespace OpenSim.Framework.Console public class Parser { + // If an unquoted portion ends with an element matching this regex + // and the next element contains a space, then we have stripped + // embedded quotes that should not have been stripped + private static Regex optionRegex = new Regex("^--[a-zA-Z0-9-]+=$"); + public static string[] Parse(string text) { List result = new List(); @@ -544,10 +550,38 @@ namespace OpenSim.Framework.Console if (index % 2 == 0) { string[] words = unquoted[index].Split(new char[] {' '}); + + bool option = false; foreach (string w in words) { if (w != String.Empty) + { + if (optionRegex.Match(w) == Match.Empty) + option = false; + else + option = true; result.Add(w); + } + } + // The last item matched the regex, put the quotes back + if (option) + { + // If the line ended with it, don't do anything + if (index < (unquoted.Length - 1)) + { + // Get and remove the option name + string optionText = result[result.Count - 1]; + result.RemoveAt(result.Count - 1); + + // Add the quoted value back + optionText += "\"" + unquoted[index + 1] + "\""; + + // Push the result into our return array + result.Add(optionText); + + // Skip the already used value + index++; + } } } else -- cgit v1.1 From 02cb0bf80a0b67eb0316ac74e1ea9741bfce1385 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 17:40:02 +0100 Subject: added a timeout paramenter to PollServiceEventArgs, so each type can define it's timeout --- OpenSim/Framework/Console/RemoteConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index eabb62d..e04ca1e 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -233,7 +233,7 @@ namespace OpenSim.Framework.Console string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( - uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID)); + uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, -- cgit v1.1 From 195b69d1ea90a123ce1a61536dffa33276c1e76a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:54:47 +0200 Subject: Allow the use of the region debug console found in recent viewers. This console will be available to estate owners and managers. If the user using the console had god privs, they can use "set console on" and "set console off" to switch on the actual region console. This allows console access from within the viewer. The region debug console can coexist with any other main console. --- OpenSim/Framework/Console/CommandConsole.cs | 9 +++++++++ OpenSim/Framework/Console/LocalConsole.cs | 4 +++- OpenSim/Framework/Console/MockConsole.cs | 4 +++- OpenSim/Framework/Console/RemoteConsole.cs | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 87bdacd..bd23d1c 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -678,6 +678,8 @@ namespace OpenSim.Framework.Console { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event OnOutputDelegate OnOutput; + public ICommands Commands { get; private set; } public CommandConsole(string defaultPrompt) : base(defaultPrompt) @@ -697,6 +699,13 @@ namespace OpenSim.Framework.Console Output(s); } + protected void FireOnOutput(string text) + { + OnOutputDelegate onOutput = OnOutput; + if (onOutput != null) + onOutput(text); + } + /// /// Display a command prompt on the console and wait for user input /// diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index f65813b..d41481f 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -319,6 +319,8 @@ namespace OpenSim.Framework.Console public override void Output(string text, string level) { + FireOnOutput(text); + lock (m_commandLine) { if (m_cursorYPosition == -1) @@ -509,4 +511,4 @@ namespace OpenSim.Framework.Console } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 4d8751f..b489f93 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -40,6 +40,8 @@ namespace OpenSim.Framework.Console /// public class MockConsole : ICommandConsole { + public event OnOutputDelegate OnOutput; + private MockCommands m_commands = new MockCommands(); public ICommands Commands { get { return m_commands; } } @@ -76,4 +78,4 @@ namespace OpenSim.Framework.Console public string[] Resolve(string[] cmd) { return null; } public XmlElement GetXml(XmlDocument doc) { return null; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index e04ca1e..50eb173 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -100,6 +100,7 @@ namespace OpenSim.Framework.Console m_LineNumber++; m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text); } + FireOnOutput(text.Trim()); System.Console.WriteLine(text.Trim()); } -- cgit v1.1 From be9cef8682cddf9589976f543e98e886d16098a1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 16:20:26 +0100 Subject: missing file --- OpenSim/Framework/Console/RemoteConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 50eb173..3e3c2b3 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -425,7 +425,7 @@ namespace OpenSim.Framework.Console return false; } - private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request) + private Hashtable GetEvents(UUID RequestID, UUID sessionID) { ConsoleConnection c = null; -- cgit v1.1 From 2e7b72d3dad42288237f85d02a9769ce31109309 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 02:04:24 +0000 Subject: Revert help to display a full command list. Leave the help categories in as "help categories" in case it turns out useful in the future. May not work. --- OpenSim/Framework/Console/CommandConsole.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index de30414..f160404 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Console = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; public const string ItemHelpText -= @"For more information, type 'help all' to get a list of all commands, += @"For more information, type 'help' to get a list of all commands, or type help ' where is one of the following:"; /// @@ -113,15 +113,16 @@ namespace OpenSim.Framework.Console // General help if (helpParts.Count == 0) { + help.Add(GeneralHelpText); + help.AddRange(CollectAllCommandsHelp()); + } + else if (helpParts.Count == 1 && helpParts[0] == "categories") + { help.Add(""); // Will become a newline. help.Add(GeneralHelpText); help.Add(ItemHelpText); help.AddRange(CollectModulesHelp(tree)); } - else if (helpParts.Count == 1 && helpParts[0] == "all") - { - help.AddRange(CollectAllCommandsHelp()); - } else { help.AddRange(CollectHelp(helpParts)); -- cgit v1.1 From c96729b55dbb9d0025700c84b03aae35b9f42780 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 02:06:05 +0000 Subject: Add a newline before the constant help text --- OpenSim/Framework/Console/CommandConsole.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index f160404..106b406 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -113,6 +113,7 @@ namespace OpenSim.Framework.Console // General help if (helpParts.Count == 0) { + help.Add(""); // Will become a newline. help.Add(GeneralHelpText); help.AddRange(CollectAllCommandsHelp()); } -- cgit v1.1 From 658109700125f74b72dc1d1990e5713f06ee538e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Nov 2012 03:20:15 +0100 Subject: Fix new command console code to match the output of the original while keeping the new features --- OpenSim/Framework/Console/CommandConsole.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 106b406..d703d78 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -144,8 +144,11 @@ namespace OpenSim.Framework.Console { foreach (List commands in m_modulesCommands.Values) { - var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); - help.AddRange(ourHelpText); + foreach (CommandInfo c in commands) + { + if (c.long_help != String.Empty) + help.Add(string.Format("{0} - {1}", c.help_text, c.long_help)); + } } } -- cgit v1.1 From addab1244ecc586b0a6fc8560b94c871567b78da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Jan 2013 21:38:00 +0000 Subject: Add "show animations" console command for debug purposes. This shows the current animation sequence and default anims for avatars. --- OpenSim/Framework/Console/ConsoleDisplayTable.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleDisplayTable.cs b/OpenSim/Framework/Console/ConsoleDisplayTable.cs index c620dfe..c6f2272 100644 --- a/OpenSim/Framework/Console/ConsoleDisplayTable.cs +++ b/OpenSim/Framework/Console/ConsoleDisplayTable.cs @@ -139,16 +139,16 @@ namespace OpenSim.Framework.Console public struct ConsoleDisplayTableRow { - public List Cells { get; private set; } + public List Cells { get; private set; } - public ConsoleDisplayTableRow(List cells) : this() + public ConsoleDisplayTableRow(List cells) : this() { Cells = cells; } - public ConsoleDisplayTableRow(params string[] cells) : this() + public ConsoleDisplayTableRow(params object[] cells) : this() { - Cells = new List(cells); + Cells = new List(cells); } } } \ No newline at end of file -- cgit v1.1 From 6b55f5183787fb719c7bd4547e5894096a7aed51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Jan 2013 22:11:13 +0000 Subject: minor: Allow objects to be added directly to a row on a ConsoleDisplayTable rather than having to ToString() them first --- OpenSim/Framework/Console/ConsoleDisplayTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleDisplayTable.cs b/OpenSim/Framework/Console/ConsoleDisplayTable.cs index c6f2272..0d22206 100644 --- a/OpenSim/Framework/Console/ConsoleDisplayTable.cs +++ b/OpenSim/Framework/Console/ConsoleDisplayTable.cs @@ -84,7 +84,7 @@ namespace OpenSim.Framework.Console Columns.Add(new ConsoleDisplayTableColumn(name, width)); } - public void AddRow(params string[] cells) + public void AddRow(params object[] cells) { Rows.Add(new ConsoleDisplayTableRow(cells)); } -- cgit v1.1 From 8f31649faddfc2f7a28131f592b1e79ae75b863f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Jan 2013 22:37:50 +0000 Subject: Fix indenting on ConsoleDisplayTable, align indenting on "show animations" console command --- OpenSim/Framework/Console/ConsoleDisplayTable.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleDisplayTable.cs b/OpenSim/Framework/Console/ConsoleDisplayTable.cs index 0d22206..711a337 100644 --- a/OpenSim/Framework/Console/ConsoleDisplayTable.cs +++ b/OpenSim/Framework/Console/ConsoleDisplayTable.cs @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Console public List Rows { get; private set; } /// - /// Number of spaces to indent the table. + /// Number of spaces to indent the whole table. /// public int Indent { get; set; } @@ -113,7 +113,8 @@ namespace OpenSim.Framework.Console for (int i = 0; i < Columns.Count; i++) { - formatSb.Append(' ', TableSpacing); + if (i != 0) + formatSb.Append(' ', TableSpacing); // Can only do left formatting for now formatSb.AppendFormat("{{{0},-{1}}}", i, Columns[i].Width); -- cgit v1.1 From c28a2f05caae50590e64e61d8b7358ee92a7fca3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jan 2013 00:54:28 +0000 Subject: minor: make spacing consistent in console help output --- OpenSim/Framework/Console/CommandConsole.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index de30414..f9c9307 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -110,10 +110,11 @@ namespace OpenSim.Framework.Console // Remove initial help keyword helpParts.RemoveAt(0); + help.Add(""); // Will become a newline. + // General help if (helpParts.Count == 0) { - help.Add(""); // Will become a newline. help.Add(GeneralHelpText); help.Add(ItemHelpText); help.AddRange(CollectModulesHelp(tree)); @@ -127,6 +128,8 @@ namespace OpenSim.Framework.Console help.AddRange(CollectHelp(helpParts)); } + help.Add(""); // Will become a newline. + return help; } @@ -200,8 +203,8 @@ namespace OpenSim.Framework.Console help.Add(commandInfo.descriptive_help); - if (descriptiveHelp != string.Empty) - help.Add(string.Empty); +// if (descriptiveHelp != string.Empty) +// help.Add(string.Empty); } else { -- cgit v1.1 From 290dc274ec0860e96f0c19479c8da512779cdab3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jan 2013 01:04:43 +0000 Subject: minor: Remove unnecessary commented out code from last commit c28a2f05 and fix up code comment --- OpenSim/Framework/Console/CommandConsole.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index f9c9307..b9f402a 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -197,14 +197,11 @@ namespace OpenSim.Framework.Console string descriptiveHelp = commandInfo.descriptive_help; - // If we do have some descriptive help then insert a spacing line before and after for readability. + // If we do have some descriptive help then insert a spacing line before for readability. if (descriptiveHelp != string.Empty) help.Add(string.Empty); help.Add(commandInfo.descriptive_help); - -// if (descriptiveHelp != string.Empty) -// help.Add(string.Empty); } else { -- cgit v1.1 From 1f1da230976451d30d920c237d53c699ba96b9d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Feb 2013 00:23:17 +0000 Subject: Bump version and assembly version numbers from 0.7.5 to 0.7.6 This is mostly Bluewall's work but I am also bumping the general version number OpenSimulator 0.7.5 remains in the release candidate stage. I'm doing this because master is significantly adding things that will not be in 0.7.5 This update should not cause issues with existing external binary DLLs because our DLLs do not have strong names and so the exact version match requirement is not in force. --- OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 37c7304..c618454 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.7.5.*")] +[assembly : AssemblyVersion("0.7.6.*")] -- cgit v1.1 From a671c06ee59e17a6ae7be9740e8e045ae9ac224c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 20 Feb 2013 22:09:33 +0000 Subject: Correct mistake in parsing 'show object pos' and similar pos commands where the 'to' text would be treat as the end vector rather than discarded. Before this, the commands still work but the help text is wrong - one has to leave out the 'to' in stating the vectors --- OpenSim/Framework/Console/ConsoleUtil.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index dff956a..97a86a8 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -49,14 +49,14 @@ namespace OpenSim.Framework.Console = @"Each component of the coord is comma separated. There must be no spaces between the commas. If you don't care about the z component you can simply omit it. If you don't care about the x or y components then you can leave them blank (though a comma is still required) - If you want to specify the maxmimum value of a component then you can use ~ instead of a number + If you want to specify the maximum value of a component then you can use ~ instead of a number If you want to specify the minimum value of a component then you can use -~ instead of a number e.g. - delete object pos 20,20,20 to 40,40,40 + show object pos 20,20,20 to 40,40,40 delete object pos 20,20 to 40,40 - delete object pos ,20,20 to ,40,40 + show object pos ,20,20 to ,40,40 delete object pos ,,30 to ,,~ - delete object pos ,,-~ to ,,30"; + show object pos ,,-~ to ,,30"; public const string MinRawConsoleVectorValue = "-~"; public const string MaxRawConsoleVectorValue = "~"; -- cgit v1.1 From ff0332730d54cf23c53795a9e6bac0262b6c86c3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 9 May 2013 23:11:37 +0100 Subject: Implement delete key for local console --- OpenSim/Framework/Console/LocalConsole.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index d41481f..a967db6 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -426,6 +426,21 @@ namespace OpenSim.Framework.Console System.Console.Write("{0}", prompt); break; + case ConsoleKey.Delete: + if (m_cursorXPosition == m_commandLine.Length) + break; + + m_commandLine.Remove(m_cursorXPosition, 1); + + SetCursorLeft(0); + m_cursorYPosition = SetCursorTop(m_cursorYPosition); + + if (m_echo) + System.Console.Write("{0}{1} ", prompt, m_commandLine); + else + System.Console.Write("{0}", prompt); + + break; case ConsoleKey.End: m_cursorXPosition = m_commandLine.Length; break; -- cgit v1.1 From 7c0bfca7a03584dd65c5659f177b434ee94ddc9d Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 7 Jun 2013 23:43:45 +0100 Subject: Adding Avination's PollService to round out the HTTP inventory changes --- OpenSim/Framework/Console/RemoteConsole.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 27edd4b..3e3c2b3 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( - uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID)); + uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, @@ -425,7 +425,7 @@ namespace OpenSim.Framework.Console return false; } - private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request) + private Hashtable GetEvents(UUID RequestID, UUID sessionID) { ConsoleConnection c = null; -- cgit v1.1 From 1b7b664c8696531fec26378d1386362d8a3da55e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 15 Jul 2013 23:22:39 +0100 Subject: Add request received/handling stats for caps which are served by http poll handlers. This adds explicit cap poll handler supporting to the Caps classes rather than relying on callers to do the complicated coding. Other refactoring was required to get logic into the right places to support this. --- OpenSim/Framework/Console/RemoteConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 3e3c2b3..8ad7b0d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( - uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout + uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, -- cgit v1.1 From 9bcf07279513294d58c3076e7d8a6eb5ee64c759 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Aug 2013 23:44:48 +0100 Subject: Make it possible to switch whether we serialize osd requests per endpoint or not, either via config (SerializeOSDRequests in [Network]) or via the "debug comms set" console command. For debug purposes to assess what impact this has on network response in a heavy test environment. --- OpenSim/Framework/Console/ConsoleUtil.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 97a86a8..c0ff454 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -156,7 +156,27 @@ namespace OpenSim.Framework.Console } /// - /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 + /// Convert a console integer to an int, automatically complaining if a console is given. + /// + /// Can be null if no console is available. + /// /param> + /// + /// + public static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b) + { + if (!bool.TryParse(rawConsoleString, out b)) + { + if (console != null) + console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); + + return false; + } + + return true; + } + + /// + /// Convert a console integer to an int, automatically complaining if a console is given. /// /// Can be null if no console is available. /// /param> -- cgit v1.1 From 2fa42f24fd0e80adc16320a404e3e85ca6d1baa1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Aug 2013 21:00:31 +0100 Subject: Make it possible to disconnected a specified number of bots via the pCampbot console command "disconnect []" Bots disconnected are ascending from last in numeric order. Temporarily no way to reconnect bots. --- OpenSim/Framework/Console/ConsoleUtil.cs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index c0ff454..794bfaf 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -179,8 +179,8 @@ namespace OpenSim.Framework.Console /// Convert a console integer to an int, automatically complaining if a console is given. /// /// Can be null if no console is available. - /// /param> - /// + /// /param> + /// /// public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) { @@ -194,6 +194,31 @@ namespace OpenSim.Framework.Console return true; } + + /// + /// Convert a console integer to a natural int, automatically complaining if a console is given. + /// + /// Can be null if no console is available. + /// /param> + /// + /// + public static bool TryParseConsoleNaturalInt(ICommandConsole console, string rawConsoleInt, out int i) + { + if (TryParseConsoleInt(console, rawConsoleInt, out i)) + { + if (i < 0) + { + if (console != null) + console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); + + return false; + } + + return true; + } + + return false; + } /// /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 -- cgit v1.1 From 42bdf446585007029faf4cd21abd289487f0f797 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Oct 2013 23:33:47 +0100 Subject: Bump OPenSimulator version and assembly versions up to 0.8.0 Dev --- OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index c618454..ba59025 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.7.6.*")] +[assembly : AssemblyVersion("0.8.0.*")] -- cgit v1.1 From 4e6f7435d0ab2b1d8ce5c723a0be33b88d05e571 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 5 Mar 2014 01:23:16 +0000 Subject: Add UUID and ready status (whether region has finished starting up) to "show regions" console output. --- OpenSim/Framework/Console/ConsoleDisplayUtil.cs | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 OpenSim/Framework/Console/ConsoleDisplayUtil.cs (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleDisplayUtil.cs b/OpenSim/Framework/Console/ConsoleDisplayUtil.cs new file mode 100644 index 0000000..b65fd75 --- /dev/null +++ b/OpenSim/Framework/Console/ConsoleDisplayUtil.cs @@ -0,0 +1,43 @@ +/* + * 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; + +namespace OpenSim.Framework.Console +{ + /// + /// This will be a set of typical column sizes to allow greater consistency between console commands. + /// + public static class ConsoleDisplayUtil + { + public const int CoordTupleSize = 11; + public const int EstateNameSize = 20; + public const int PortSize = 5; + public const int RegionNameSize = 20; + public const int UuidSize = 36; + } +} \ No newline at end of file -- cgit v1.1 From aa2fb1ec250bab4dde750b29ca2fec4d69add506 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 6 Mar 2014 00:40:24 +0000 Subject: minor: Increase size of parcel name field in "land show" console command output. Construct table using CDT rather than string formats --- OpenSim/Framework/Console/ConsoleDisplayUtil.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleDisplayUtil.cs b/OpenSim/Framework/Console/ConsoleDisplayUtil.cs index b65fd75..6417663 100644 --- a/OpenSim/Framework/Console/ConsoleDisplayUtil.cs +++ b/OpenSim/Framework/Console/ConsoleDisplayUtil.cs @@ -35,9 +35,14 @@ namespace OpenSim.Framework.Console public static class ConsoleDisplayUtil { public const int CoordTupleSize = 11; - public const int EstateNameSize = 20; public const int PortSize = 5; + + public const int EstateNameSize = 20; + public const int ParcelNameSize = 40; public const int RegionNameSize = 20; + public const int UserNameSize = 35; + public const int UuidSize = 36; + public const int VectorSize = 15; } } \ No newline at end of file -- cgit v1.1 From 998d7009a65def0a4debc9369d35b63611db5b55 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Apr 2014 20:04:12 +0300 Subject: Eliminated many warnings --- OpenSim/Framework/Console/MockConsole.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 8ba58e4..18a48bd 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -40,7 +40,9 @@ namespace OpenSim.Framework.Console /// public class MockConsole : ICommandConsole { +#pragma warning disable 0067 public event OnOutputDelegate OnOutput; +#pragma warning restore 0067 private MockCommands m_commands = new MockCommands(); -- cgit v1.1 From 253110293a785b6dda94147cbfc3343fb8ca0434 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 30 Apr 2014 18:04:47 +0100 Subject: Add "terrain show" console command which outputs terrain height for a given region co-ordinate. For debug purposes. --- OpenSim/Framework/Console/ConsoleUtil.cs | 78 ++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 794bfaf..b7a3494 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -252,24 +252,80 @@ namespace OpenSim.Framework.Console /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue /// Other than that, component values must be numeric. /// - /// + /// + /// Behaviour if component is blank. If null then conversion fails on a blank component. + /// /// /// public static bool TryParseConsoleVector( string rawConsoleVector, Func blankComponentFunc, out Vector3 vector) { - List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); - - if (components.Count < 1 || components.Count > 3) + return Vector3.TryParse(CookVector(rawConsoleVector, 3, blankComponentFunc), out vector); + } + + /// + /// Convert a vector input from the console to an OpenMetaverse.Vector2 + /// + /// + /// A string in the form , where there is no space between values. + /// Any component can be missing (e.g. ,40). blankComponentFunc is invoked to replace the blank with a suitable value + /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40) + /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue + /// Other than that, component values must be numeric. + /// + /// + /// Behaviour if component is blank. If null then conversion fails on a blank component. + /// + /// + /// + public static bool TryParseConsole2DVector( + string rawConsoleVector, Func blankComponentFunc, out Vector2 vector) + { + // We don't use Vector2.TryParse() for now because for some reason it expects an input with 3 components + // rather than 2. + string cookedVector = CookVector(rawConsoleVector, 2, blankComponentFunc); + + if (cookedVector == null) { - vector = Vector3.Zero; return false; } + else + { + string[] cookedComponents = cookedVector.Split(VectorSeparatorChars); + + vector = new Vector2(float.Parse(cookedComponents[0]), float.Parse(cookedComponents[1])); + + return true; + } + + //return Vector2.TryParse(CookVector(rawConsoleVector, 2, blankComponentFunc), out vector); + } + + /// + /// Convert a raw console vector into a vector that can be be parsed by the relevant OpenMetaverse.TryParse() + /// + /// + /// + /// + /// null if conversion was not possible + private static string CookVector( + string rawConsoleVector, int dimensions, Func blankComponentFunc) + { + List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); - for (int i = components.Count; i < 3; i++) - components.Add(""); + if (components.Count < 1 || components.Count > dimensions) + return null; - List semiDigestedComponents + if (components.Count < dimensions) + { + if (blankComponentFunc == null) + return null; + else + for (int i = components.Count; i < dimensions; i++) + components.Add(""); + } + + List cookedComponents = components.ConvertAll( c => { @@ -283,11 +339,7 @@ namespace OpenSim.Framework.Console return c; }); - string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); - - // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); - - return Vector3.TryParse(semiDigestedConsoleVector, out vector); + return string.Join(VectorSeparator, cookedComponents.ToArray()); } } } \ No newline at end of file -- cgit v1.1 From 44f533d95ab99c73116a60ebe79021dd12862155 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 30 Apr 2014 15:45:00 -0400 Subject: Assign value to 'vector' to fix building under xbuild and Monodevelop --- OpenSim/Framework/Console/ConsoleUtil.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index b7a3494..3711cb1 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -284,6 +284,7 @@ namespace OpenSim.Framework.Console // We don't use Vector2.TryParse() for now because for some reason it expects an input with 3 components // rather than 2. string cookedVector = CookVector(rawConsoleVector, 2, blankComponentFunc); + vector = new Vector2(0.0f); if (cookedVector == null) { -- cgit v1.1 From f0411dc128b232431b936f28711b6ee0197a2f51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 30 Apr 2014 21:50:18 +0100 Subject: minor: Use Vector2.Zero constant and only set in condition branch where it was missing in TryParseConsole2DVector(). xbuild still compiles. --- OpenSim/Framework/Console/ConsoleUtil.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 3711cb1..744f652 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -284,10 +284,11 @@ namespace OpenSim.Framework.Console // We don't use Vector2.TryParse() for now because for some reason it expects an input with 3 components // rather than 2. string cookedVector = CookVector(rawConsoleVector, 2, blankComponentFunc); - vector = new Vector2(0.0f); if (cookedVector == null) { + vector = Vector2.Zero; + return false; } else -- cgit v1.1 From fbcb76383d5083a7a1b4c4ba75d37b247859a87d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 20:57:50 +0100 Subject: Allow console output to be multiline by making colourization regex RegexOptions.SingleLine --- OpenSim/Framework/Console/LocalConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index a967db6..b17b8e0 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -283,7 +283,7 @@ namespace OpenSim.Framework.Console { string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - Regex RE = new Regex(regex, RegexOptions.Multiline); + Regex RE = new Regex(regex, RegexOptions.Singleline); MatchCollection matches = RE.Matches(text); if (matches.Count == 1) -- cgit v1.1 From f55e15363665ac885b51fa549c9c1566e9ea0cc6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 21:09:48 +0100 Subject: Compile the regex that extract categories for colourization just once rather than on every single log. Compiling every time is unnecessary since Regex is thread-safe. --- OpenSim/Framework/Console/LocalConsole.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index b17b8e0..260a86f 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -46,6 +46,11 @@ namespace OpenSim.Framework.Console // private readonly object m_syncRoot = new object(); private const string LOGLEVEL_NONE = "(none)"; + // Used to extract categories for colourization. + private Regex m_categoryRegex + = new Regex( + @"^(?.*?)\[(?[^\]]+)\]:?(?.*)", RegexOptions.Singleline | RegexOptions.Compiled); + private int m_cursorYPosition = -1; private int m_cursorXPosition = 0; private StringBuilder m_commandLine = new StringBuilder(); @@ -280,11 +285,8 @@ namespace OpenSim.Framework.Console string outText = text; if (level != LOGLEVEL_NONE) - { - string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - - Regex RE = new Regex(regex, RegexOptions.Singleline); - MatchCollection matches = RE.Matches(text); + { + MatchCollection matches = m_categoryRegex.Matches(text); if (matches.Count == 1) { -- cgit v1.1 From 5450b1b0247bb3907f60f2b3f9b0582903de4f83 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jun 2014 18:37:15 +0100 Subject: Change assembly versions to 0.8.1 --- OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index ba59025..4e50e44 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.8.0.*")] +[assembly : AssemblyVersion("0.8.1.*")] -- cgit v1.1 From 9be935ac6d74fd3b8c0c95058a575e400dd916a4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 Jul 2014 22:27:39 +0100 Subject: Add ICommands.HasCommand() method so that we can detect whether a command has already been registered without needing to also run it --- OpenSim/Framework/Console/CommandConsole.cs | 46 +++++++++++++++++++---------- OpenSim/Framework/Console/MockConsole.cs | 1 + 2 files changed, 32 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index b9f402a..0f68afe 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -424,9 +424,9 @@ namespace OpenSim.Framework.Console return new string[] { new List(current.Keys)[0] }; } - public string[] Resolve(string[] cmd) + private CommandInfo ResolveCommand(string[] cmd, out string[] result) { - string[] result = cmd; + result = cmd; int index = -1; Dictionary current = tree; @@ -458,7 +458,7 @@ namespace OpenSim.Framework.Console } else if (found.Count > 0) { - return new string[0]; + return null; } else { @@ -467,21 +467,37 @@ namespace OpenSim.Framework.Console } if (current.ContainsKey(String.Empty)) + return (CommandInfo)current[String.Empty]; + + return null; + } + + public bool HasCommand(string command) + { + string[] result; + return ResolveCommand(Parser.Parse(command), out result) != null; + } + + public string[] Resolve(string[] cmd) + { + string[] result; + CommandInfo ci = ResolveCommand(cmd, out result); + + if (ci == null) + return new string[0]; + + if (ci.fn.Count == 0) + return new string[0]; + + foreach (CommandDelegate fn in ci.fn) { - CommandInfo ci = (CommandInfo)current[String.Empty]; - if (ci.fn.Count == 0) + if (fn != null) + fn(ci.module, result); + else return new string[0]; - foreach (CommandDelegate fn in ci.fn) - { - if (fn != null) - fn(ci.module, result); - else - return new string[0]; - } - return result; } - - return new string[0]; + + return result; } public XmlElement GetXml(XmlDocument doc) diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 18a48bd..1a142df 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -82,6 +82,7 @@ namespace OpenSim.Framework.Console public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) {} public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {} public string[] FindNextOption(string[] cmd, bool term) { return null; } + public bool HasCommand(string cmd) { return false; } public string[] Resolve(string[] cmd) { return null; } public XmlElement GetXml(XmlDocument doc) { return null; } } -- cgit v1.1 From f6f7585ec583788b11960cf5a1ac36409e6583aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Jul 2014 00:13:29 +0100 Subject: Add a "debug scene set child-repri " command that allows child reprioritization distance to be changed on the fly. This governs when child agent position changes are sent to neighbouring regions. Corresponding config parameter is ChildReprioritizationDistance in [InterestManagement] in OpenSim.ini For test purposes. --- OpenSim/Framework/Console/ConsoleUtil.cs | 44 ++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 744f652..44f6dc1 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -156,7 +156,7 @@ namespace OpenSim.Framework.Console } /// - /// Convert a console integer to an int, automatically complaining if a console is given. + /// Convert a console input to a bool, automatically complaining if a console is given. /// /// Can be null if no console is available. /// /param> @@ -176,7 +176,7 @@ namespace OpenSim.Framework.Console } /// - /// Convert a console integer to an int, automatically complaining if a console is given. + /// Convert a console input to an int, automatically complaining if a console is given. /// /// Can be null if no console is available. /// /param> @@ -196,6 +196,46 @@ namespace OpenSim.Framework.Console } /// + /// Convert a console input to a float, automatically complaining if a console is given. + /// + /// Can be null if no console is available. + /// /param> + /// + /// + public static bool TryParseConsoleFloat(ICommandConsole console, string rawConsoleInput, out float i) + { + if (!float.TryParse(rawConsoleInput, out i)) + { + if (console != null) + console.OutputFormat("ERROR: {0} is not a valid float", rawConsoleInput); + + return false; + } + + return true; + } + + /// + /// Convert a console input to a double, automatically complaining if a console is given. + /// + /// Can be null if no console is available. + /// /param> + /// + /// + public static bool TryParseConsoleDouble(ICommandConsole console, string rawConsoleInput, out double i) + { + if (!double.TryParse(rawConsoleInput, out i)) + { + if (console != null) + console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); + + return false; + } + + return true; + } + + /// /// Convert a console integer to a natural int, automatically complaining if a console is given. /// /// Can be null if no console is available. -- cgit v1.1 From bde60cc92e0966177a1aeb03dce3183a92b7a38c Mon Sep 17 00:00:00 2001 From: Jak Daniels Date: Mon, 22 Sep 2014 16:54:12 +0100 Subject: Add persistent command history in console Signed-off-by: BlueWall --- OpenSim/Framework/Console/LocalConsole.cs | 58 +++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 260a86f..28293c0 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -32,6 +32,8 @@ using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading; +using System.IO; +using Nini.Config; using log4net; namespace OpenSim.Framework.Console @@ -41,7 +43,9 @@ namespace OpenSim.Framework.Console /// public class LocalConsole : CommandConsole { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private string m_historyPath; + private bool m_historyEnable; // private readonly object m_syncRoot = new object(); private const string LOGLEVEL_NONE = "(none)"; @@ -79,8 +83,54 @@ namespace OpenSim.Framework.Console return Colors[(Math.Abs(input.ToUpper().GetHashCode()) % Colors.Length)]; } - public LocalConsole(string defaultPrompt) : base(defaultPrompt) + public LocalConsole(string defaultPrompt, IConfig startupConfig = null) : base(defaultPrompt) { + + if (startupConfig == null) return; + + m_historyEnable = startupConfig.GetBoolean("ConsoleHistoryFileEnabled", false); + if (!m_historyEnable) + { + m_log.Info("[LOCAL CONSOLE]: Persistent command line history from file is Disabled"); + return; + } + + string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt"); + int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); + m_historyPath = Path.GetFullPath(Path.Combine(Util.configDir(), m_historyFile)); + m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath); + + if (File.Exists(m_historyPath)) + { + using (StreamReader history_file = new StreamReader(m_historyPath)) + { + string line; + while ((line = history_file.ReadLine()) != null) + { + m_history.Add(line); + } + } + + if (m_history.Count > m_historySize) + { + while (m_history.Count > m_historySize) + m_history.RemoveAt(0); + + using (StreamWriter history_file = new StreamWriter(m_historyPath)) + { + foreach (string line in m_history) + { + history_file.WriteLine(line); + } + } + } + m_log.InfoFormat("[LOCAL CONSOLE]: Read {0} lines of command line history from file {1}", m_history.Count, m_historyPath); + } + else + { + m_log.InfoFormat("[LOCAL CONSOLE]: Creating new empty command line history file {0}", m_historyPath); + File.Create(m_historyPath).Dispose(); + } } private void AddToHistory(string text) @@ -89,6 +139,10 @@ namespace OpenSim.Framework.Console m_history.RemoveAt(0); m_history.Add(text); + if (m_historyEnable) + { + File.AppendAllText(m_historyPath, text + Environment.NewLine); + } } /// -- cgit v1.1 From 129cc49eb4d2f43cdda3804447f84bd3df397ff1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Mar 2015 22:42:14 +0000 Subject: Allow a console command to give blank arguments ("") without the parser failing, e.g. login text "" Relates to http://opensimulator.org/mantis/view.php?id=7489 --- OpenSim/Framework/Console/CommandConsole.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 0f68afe..23a2cc8 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -433,6 +433,10 @@ namespace OpenSim.Framework.Console foreach (string s in cmd) { + // If a user puts an empty string on the console then this cannot be part of the command. + if (s == "") + break; + index++; List found = new List(); @@ -443,9 +447,8 @@ namespace OpenSim.Framework.Console { found.Clear(); found.Add(opt); - break; } - if (opt.StartsWith(s)) + else if (opt.StartsWith(s)) { found.Add(opt); } -- cgit v1.1 From 8b13e4e7315fd2736eff7963ef2d786f5913a450 Mon Sep 17 00:00:00 2001 From: dahlia Date: Sat, 14 Mar 2015 14:24:55 -0700 Subject: Revert "Allow a console command to give blank arguments ("") without the parser failing, e.g. login text """ This reverts commit 129cc49eb4d2f43cdda3804447f84bd3df397ff1. It was causing the "alert" console command to fail. --- OpenSim/Framework/Console/CommandConsole.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 23a2cc8..0f68afe 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -433,10 +433,6 @@ namespace OpenSim.Framework.Console foreach (string s in cmd) { - // If a user puts an empty string on the console then this cannot be part of the command. - if (s == "") - break; - index++; List found = new List(); @@ -447,8 +443,9 @@ namespace OpenSim.Framework.Console { found.Clear(); found.Add(opt); + break; } - else if (opt.StartsWith(s)) + if (opt.StartsWith(s)) { found.Add(opt); } -- cgit v1.1 From da32512ea449c2de2d4a6069f899fbd4a8bb03fa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 29 Apr 2015 18:47:17 -0700 Subject: Updated all occurrences of AssemblyVersion("0.8.1.*") to AssemblyVersion("0.8.2.*") --- OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 4e50e44..67af471 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.8.1.*")] +[assembly : AssemblyVersion("0.8.2.*")] -- cgit v1.1 From cdaed113872f0615a0d2864cc54064a4432054c6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 3 Sep 2015 18:39:08 +0100 Subject: at last we can login and see objects ( friends is dead and disable in scenepresence) --- OpenSim/Framework/Console/CommandConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 851fbed..d908b68 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Console = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; public const string ItemHelpText -= @"For more information, type 'help' to get a list of all commands, += @"For more information, type 'help ' to get a list of all commands, or type help ' where is one of the following:"; /// -- cgit v1.1 From 759789bc45539e2e526deea5a705efc167f135d9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 24 Sep 2015 02:07:30 +0100 Subject: change console main help to match master --- OpenSim/Framework/Console/CommandConsole.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index d908b68..6b7cdf8 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -83,8 +83,8 @@ namespace OpenSim.Framework.Console = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; public const string ItemHelpText -= @"For more information, type 'help ' to get a list of all commands, - or type help ' where is one of the following:"; + = @"For more information, type 'help all' to get a list of all commands, + or type help ' where is one of the following:"; /// /// Commands organized by keyword in a tree @@ -116,15 +116,13 @@ namespace OpenSim.Framework.Console if (helpParts.Count == 0) { help.Add(GeneralHelpText); - help.AddRange(CollectAllCommandsHelp()); - } - else if (helpParts.Count == 1 && helpParts[0] == "categories") - { - help.Add(""); // Will become a newline. - help.Add(GeneralHelpText); help.Add(ItemHelpText); help.AddRange(CollectModulesHelp(tree)); } + else if (helpParts.Count == 1 && helpParts[0] == "all") + { + help.AddRange(CollectAllCommandsHelp()); + } else { help.AddRange(CollectHelp(helpParts)); @@ -147,11 +145,8 @@ namespace OpenSim.Framework.Console { foreach (List commands in m_modulesCommands.Values) { - foreach (CommandInfo c in commands) - { - if (c.long_help != String.Empty) - help.Add(string.Format("{0} - {1}", c.help_text, c.long_help)); - } + var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); + help.AddRange(ourHelpText); } } -- cgit v1.1 From ab12a142798a1358b82d927f3d6046e30fcc57c2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2016 11:14:02 -0800 Subject: Pushed AssemblyVersion up to VersionInfo, so that we don't need to do global replace anymore. --- OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 67af471..c53d92b 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.8.2.*")] +[assembly : AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] -- cgit v1.1 From 28f7d429fc5cc6a8e52766d06d6a261825d792c2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 19 Nov 2016 02:27:31 +0000 Subject: REST console v2. This is an incompatible protocol change. It degrades gracefully. --- OpenSim/Framework/Console/RemoteConsole.cs | 321 ++++++++++++++++++++++++----- 1 file changed, 265 insertions(+), 56 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 8ad7b0d..9049b4b 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -34,6 +34,7 @@ using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading; +using System.Timers; using OpenMetaverse; using Nini.Config; using OpenSim.Framework.Servers.HttpServer; @@ -41,90 +42,232 @@ using log4net; namespace OpenSim.Framework.Console { - public class ConsoleConnection - { - public int last; - public long lastLineSeen; - public bool newConnection = true; - } - // A console that uses REST interfaces // public class RemoteConsole : CommandConsole { - private IHttpServer m_Server = null; - private IConfigSource m_Config = null; - - private List m_Scrollback = new List(); - private ManualResetEvent m_DataEvent = new ManualResetEvent(false); - private List m_InputData = new List(); - private long m_LineNumber = 0; - private Dictionary m_Connections = + // Connection specific data, indexed by a session ID + // we create when a client connects. + protected class ConsoleConnection + { + // Last activity from the client + public int last; + + // Last line of scrollback posted to this client + public long lastLineSeen; + + // True if this is a new connection, e.g. has never + // displayed a prompt to the user. + public bool newConnection = true; + } + + // A line in the scrollback buffer. + protected class ScrollbackEntry + { + // The line number of this entry + public long lineNumber; + + // The text to send to the client + public string text; + + // The level this should be logged as. Omitted for + // prompts and input echo. + public string level; + + // True if the text above is a prompt, e.g. the + // client should turn on the cursor / accept input + public bool isPrompt; + + // True if the requested input is a command. A + // client may offer help or validate input if + // this is set. If false, input should be sent + // as typed. + public bool isCommand; + + // True if this text represents a line of text that + // was input in response to a prompt. A client should + // turn off the cursor and refrain from sending commands + // until a new prompt is received. + public bool isInput; + } + + // Data that is relevant to all connections + + // The scrollback buffer + protected List m_Scrollback = new List(); + + // Monotonously incrementing line number. This may eventually + // wrap. No provision is made for that case because 64 bits + // is a long, long time. + protected long m_lineNumber = 0; + + // These two variables allow us to send the correct + // information about the prompt status to the client, + // irrespective of what may have run off the top of the + // scrollback buffer; + protected bool m_expectingInput = false; + protected bool m_expectingCommand = true; + protected string m_lastPromptUsed; + + // This is the list of things received from clients. + // Note: Race conditions can happen. If a client sends + // something while nothing is expected, it will be + // intepreted as input to the next prompt. For + // commands this is largely correct. For other prompts, + // YMMV. + // TODO: Find a better way to fix this + protected List m_InputData = new List(); + + // Event to allow ReadLine to wait synchronously even though + // everthing else is asynchronous here. + protected ManualResetEvent m_DataEvent = new ManualResetEvent(false); + + // The list of sessions we maintain. Unlike other console types, + // multiple users on the same console are explicitly allowed. + protected Dictionary m_Connections = new Dictionary(); - private string m_UserName = String.Empty; - private string m_Password = String.Empty; - private string m_AllowedOrigin = String.Empty; + + // Timer to control expiration of sessions that have been + // disconnected. + protected System.Timers.Timer m_expireTimer = new System.Timers.Timer(5000); + + // The less interesting stuff that makes the actual server + // work. + protected IHttpServer m_Server = null; + protected IConfigSource m_Config = null; + + protected string m_UserName = String.Empty; + protected string m_Password = String.Empty; + protected string m_AllowedOrigin = String.Empty; + public RemoteConsole(string defaultPrompt) : base(defaultPrompt) { + // There is something wrong with this architecture. + // A prompt is sent on every single input, so why have this? + // TODO: Investigate and fix. + m_lastPromptUsed = defaultPrompt; + + // Start expiration of sesssions. + m_expireTimer.Elapsed += DoExpire; + m_expireTimer.Start(); } public void ReadConfig(IConfigSource config) { m_Config = config; + // We're pulling this from the 'Network' section for legacy + // compatibility. However, this is so essentially insecure + // that TLS and client certs should be used instead of + // a username / password. IConfig netConfig = m_Config.Configs["Network"]; + if (netConfig == null) return; + // Get the username and password. m_UserName = netConfig.GetString("ConsoleUser", String.Empty); m_Password = netConfig.GetString("ConsolePass", String.Empty); + + // Woefully underdocumented, this is what makes javascript + // console clients work. Set to "*" for anywhere or (better) + // to specific addresses. m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty); } public void SetServer(IHttpServer server) { + // This is called by the framework to give us the server + // instance (means: port) to work with. m_Server = server; + // Add our handlers m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession); m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession); m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); } public override void Output(string text, string level) + { + Output(text, level, false, false, false); + } + + protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) { + // Increment the line number. It was 0 and they start at 1 + // so we need to pre-increment. + m_lineNumber++; + + // Create and populate the new entry. + ScrollbackEntry newEntry = new ScrollbackEntry(); + + newEntry.lineNumber = m_lineNumber; + newEntry.text = text; + newEntry.level = level; + newEntry.isPrompt = isPrompt; + newEntry.isCommand = isCommand; + newEntry.isInput = isInput; + + // Add a line to the scrollback. In some cases, that may not + // actually be a line of text. lock (m_Scrollback) { + // Prune the scrollback to the length se send as connect + // burst to give the user some context. while (m_Scrollback.Count >= 1000) m_Scrollback.RemoveAt(0); - m_LineNumber++; - m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text); + + m_Scrollback.Add(newEntry); } + + // Let the rest of the system know we have output something. FireOnOutput(text.Trim()); + + // Also display it for debugging. System.Console.WriteLine(text.Trim()); } public override void Output(string text) { - Output(text, "normal"); + // Output plain (non-logging style) text. + Output(text, String.Empty, false, false, false); } public override string ReadLine(string p, bool isCommand, bool e) { - if (isCommand) - Output("+++"+p); - else - Output("-++"+p); - + // Output the prompt an prepare to wait. This + // is called on a dedicated console thread and + // needs to be synchronous. Old architecture but + // not worth upgrading. + if (isCommand) + { + m_expectingInput = true; + m_expectingCommand = true; + Output(p, String.Empty, true, true, false); + m_lastPromptUsed = p; + } + else + { + m_expectingInput = true; + Output(p, String.Empty, true, false, false); + } + + + // Here is where we wait for the user to input something. m_DataEvent.WaitOne(); string cmdinput; + // Check for empty input. Read input if not empty. lock (m_InputData) { if (m_InputData.Count == 0) { m_DataEvent.Reset(); + m_expectingInput = false; + m_expectingCommand = false; + return ""; } @@ -135,8 +278,19 @@ namespace OpenSim.Framework.Console } + m_expectingInput = false; + m_expectingCommand = false; + + // Echo to all the other users what we have done. This + // will also go to ourselves. + Output (cmdinput, String.Empty, false, false, true); + + // If this is a command, we need to resolve and execute it. if (isCommand) { + // This call will actually execute the command and create + // any output associated with it. The core just gets an + // empty string so it will call again immediately. string[] cmd = Commands.Resolve(Parser.Parse(cmdinput)); if (cmd.Length != 0) @@ -151,18 +305,23 @@ namespace OpenSim.Framework.Console return String.Empty; } } + + // Return the raw input string if not a command. return cmdinput; } - private Hashtable CheckOrigin(Hashtable result) + // Very simplistic static access control header. + protected Hashtable CheckOrigin(Hashtable result) { if (!string.IsNullOrEmpty(m_AllowedOrigin)) result["access_control_allow_origin"] = m_AllowedOrigin; + return result; } + /* TODO: Figure out how PollServiceHTTPHandler can access the request headers * in order to use m_AllowedOrigin as a regular expression - private Hashtable CheckOrigin(Hashtable headers, Hashtable result) + protected Hashtable CheckOrigin(Hashtable headers, Hashtable result) { if (!string.IsNullOrEmpty(m_AllowedOrigin)) { @@ -177,18 +336,23 @@ namespace OpenSim.Framework.Console } */ - private void DoExpire() + protected void DoExpire(Object sender, ElapsedEventArgs e) { + // Iterate the list of console connections and find those we + // haven't heard from for longer then the longpoll interval. + // Remove them. List expired = new List(); lock (m_Connections) { + // Mark the expired ones foreach (KeyValuePair kvp in m_Connections) { if (System.Environment.TickCount - kvp.Value.last > 500000) expired.Add(kvp.Key); } + // Delete them foreach (UUID id in expired) { m_Connections.Remove(id); @@ -197,10 +361,10 @@ namespace OpenSim.Framework.Console } } - private Hashtable HandleHttpStartSession(Hashtable request) + // Start a new session. + protected Hashtable HandleHttpStartSession(Hashtable request) { - DoExpire(); - + // The login is in the form of a http form post Hashtable post = DecodePostString(request["body"].ToString()); Hashtable reply = new Hashtable(); @@ -208,6 +372,7 @@ namespace OpenSim.Framework.Console reply["int_response_code"] = 401; reply["content_type"] = "text/plain"; + // Check user name and password if (m_UserName == String.Empty) return reply; @@ -220,22 +385,28 @@ namespace OpenSim.Framework.Console return reply; } + // Set up the new console connection record ConsoleConnection c = new ConsoleConnection(); c.last = System.Environment.TickCount; c.lastLineSeen = 0; + // Assign session ID UUID sessionID = UUID.Random(); + // Add connection to list. lock (m_Connections) { m_Connections[sessionID] = c; } + // This call is a CAP. The URL is the authentication. string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout + // Our reply is an XML document. + // TODO: Change this to Linq.Xml XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); @@ -252,12 +423,13 @@ namespace OpenSim.Framework.Console rootElement.AppendChild(id); XmlElement prompt = xmldoc.CreateElement("", "Prompt", ""); - prompt.AppendChild(xmldoc.CreateTextNode(DefaultPrompt)); + prompt.AppendChild(xmldoc.CreateTextNode(m_lastPromptUsed)); rootElement.AppendChild(prompt); rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc)); + // Set up the response and check origin reply["str_response_string"] = xmldoc.InnerXml; reply["int_response_code"] = 200; reply["content_type"] = "text/xml"; @@ -266,10 +438,9 @@ namespace OpenSim.Framework.Console return reply; } - private Hashtable HandleHttpCloseSession(Hashtable request) + // Client closes session. Clean up. + protected Hashtable HandleHttpCloseSession(Hashtable request) { - DoExpire(); - Hashtable post = DecodePostString(request["body"].ToString()); Hashtable reply = new Hashtable(); @@ -316,10 +487,9 @@ namespace OpenSim.Framework.Console return reply; } - private Hashtable HandleHttpSessionCommand(Hashtable request) + // Command received from the client. + protected Hashtable HandleHttpSessionCommand(Hashtable request) { - DoExpire(); - Hashtable post = DecodePostString(request["body"].ToString()); Hashtable reply = new Hashtable(); @@ -327,6 +497,7 @@ namespace OpenSim.Framework.Console reply["int_response_code"] = 404; reply["content_type"] = "text/plain"; + // Check the ID if (post["ID"] == null) return reply; @@ -334,21 +505,25 @@ namespace OpenSim.Framework.Console if (!UUID.TryParse(post["ID"].ToString(), out id)) return reply; + // Find the connection for that ID. lock (m_Connections) { if (!m_Connections.ContainsKey(id)) return reply; } + // Empty post. Just error out. if (post["COMMAND"] == null) return reply; + // Place the input data in the buffer. lock (m_InputData) { m_DataEvent.Set(); m_InputData.Add(post["COMMAND"].ToString()); } + // Create the XML reply document. XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); @@ -372,7 +547,8 @@ namespace OpenSim.Framework.Console return reply; } - private Hashtable DecodePostString(string data) + // Decode a HTTP form post to a Hashtable + protected Hashtable DecodePostString(string data) { Hashtable result = new Hashtable(); @@ -396,6 +572,7 @@ namespace OpenSim.Framework.Console return result; } + // Close the CAP receiver for the responses for a given client. public void CloseConnection(UUID id) { try @@ -409,7 +586,9 @@ namespace OpenSim.Framework.Console } } - private bool HasEvents(UUID RequestID, UUID sessionID) + // Check if there is anything to send. Return true if this client has + // lines pending. + protected bool HasEvents(UUID RequestID, UUID sessionID) { ConsoleConnection c = null; @@ -420,13 +599,15 @@ namespace OpenSim.Framework.Console c = m_Connections[sessionID]; } c.last = System.Environment.TickCount; - if (c.lastLineSeen < m_LineNumber) + if (c.lastLineSeen < m_lineNumber) return true; return false; } - private Hashtable GetEvents(UUID RequestID, UUID sessionID) + // Send all pending output to the client. + protected Hashtable GetEvents(UUID RequestID, UUID sessionID) { + // Find the connection that goes with this client. ConsoleConnection c = null; lock (m_Connections) @@ -435,12 +616,15 @@ namespace OpenSim.Framework.Console return NoEvents(RequestID, UUID.Zero); c = m_Connections[sessionID]; } + + // If we have nothing to send, send the no events response. c.last = System.Environment.TickCount; - if (c.lastLineSeen >= m_LineNumber) + if (c.lastLineSeen >= m_lineNumber) return NoEvents(RequestID, UUID.Zero); Hashtable result = new Hashtable(); + // Create the response document. XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); @@ -449,30 +633,53 @@ namespace OpenSim.Framework.Console XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession", ""); - if (c.newConnection) - { - c.newConnection = false; - Output("+++" + DefaultPrompt); - } + //if (c.newConnection) + //{ + // c.newConnection = false; + // Output("+++" + DefaultPrompt); + //} lock (m_Scrollback) { - long startLine = m_LineNumber - m_Scrollback.Count; + long startLine = m_lineNumber - m_Scrollback.Count; long sendStart = startLine; if (sendStart < c.lastLineSeen) sendStart = c.lastLineSeen; - for (long i = sendStart ; i < m_LineNumber ; i++) + for (long i = sendStart ; i < m_lineNumber ; i++) { + ScrollbackEntry e = m_Scrollback[(int)(i - startLine)]; + XmlElement res = xmldoc.CreateElement("", "Line", ""); - long line = i + 1; - res.SetAttribute("Number", line.ToString()); - res.AppendChild(xmldoc.CreateTextNode(m_Scrollback[(int)(i - startLine)])); + res.SetAttribute("Number", e.lineNumber.ToString()); + res.SetAttribute("Level", e.level); + // Don't include these for the scrollback, we'll send the + // real state later. + if (!c.newConnection) + { + res.SetAttribute("Prompt", e.isPrompt ? "true" : "false"); + res.SetAttribute("Command", e.isCommand ? "true" : "false"); + res.SetAttribute("Input", e.isInput ? "true" : "false"); + } + else if (i == m_lineNumber - 1) // Last line for a new connection + { + res.SetAttribute("Prompt", m_expectingInput ? "true" : "false"); + res.SetAttribute("Command", m_expectingCommand ? "true" : "false"); + res.SetAttribute("Input", (!m_expectingInput) ? "true" : "false"); + } + else + { + res.SetAttribute("Input", e.isInput ? "true" : "false"); + } + + res.AppendChild(xmldoc.CreateTextNode(e.text)); rootElement.AppendChild(res); } } - c.lastLineSeen = m_LineNumber; + + c.lastLineSeen = m_lineNumber; + c.newConnection = false; xmldoc.AppendChild(rootElement); @@ -486,7 +693,9 @@ namespace OpenSim.Framework.Console return result; } - private Hashtable NoEvents(UUID RequestID, UUID id) + // This is really just a no-op. It generates what is sent + // to the client if the poll times out without any events. + protected Hashtable NoEvents(UUID RequestID, UUID id) { Hashtable result = new Hashtable(); -- cgit v1.1 From 08dee3fa34f72912cab3c5facdc79083e85b39ef Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 Nov 2016 15:46:47 +0000 Subject: fix pool parameters for httptests --- OpenSim/Framework/Console/RemoteConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 9049b4b..b9c7537 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -403,7 +403,7 @@ namespace OpenSim.Framework.Console string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( - uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout + uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, null, sessionID,25000)); // 25 secs timeout // Our reply is an XML document. // TODO: Change this to Linq.Xml -- cgit v1.1 From b16abc8166c29585cb76cc55c3bdd76e5833cb4f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 5 Jan 2017 19:07:37 +0000 Subject: Massive tab and trailing space cleanup --- OpenSim/Framework/Console/CommandConsole.cs | 40 +-- OpenSim/Framework/Console/ConsoleBase.cs | 8 +- OpenSim/Framework/Console/ConsoleUtil.cs | 22 +- OpenSim/Framework/Console/LocalConsole.cs | 22 +- OpenSim/Framework/Console/MockConsole.cs | 4 +- OpenSim/Framework/Console/RemoteConsole.cs | 400 ++++++++++++++-------------- 6 files changed, 248 insertions(+), 248 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 6b7cdf8..52360b4 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -52,27 +52,27 @@ namespace OpenSim.Framework.Console /// The module from which this command comes /// public string module; - + /// /// Whether the module is shared /// public bool shared; - + /// /// Very short BNF description /// public string help_text; - + /// /// Longer one line help text /// public string long_help; - + /// /// Full descriptive help for this command /// public string descriptive_help; - + /// /// The method to invoke for this command /// @@ -106,7 +106,7 @@ namespace OpenSim.Framework.Console { List help = new List(); List helpParts = new List(cmd); - + // Remove initial help keyword helpParts.RemoveAt(0); @@ -154,7 +154,7 @@ namespace OpenSim.Framework.Console return help; } - + /// /// See if we can find the requested command in order to display longer help /// @@ -171,23 +171,23 @@ namespace OpenSim.Framework.Console help.Insert(0, ItemHelpText); return help; } - + Dictionary dict = tree; while (helpParts.Count > 0) { string helpPart = helpParts[0]; - + if (!dict.ContainsKey(helpPart)) break; - + //m_log.Debug("Found {0}", helpParts[0]); - + if (dict[helpPart] is Dictionary) - dict = (Dictionary)dict[helpPart]; - + dict = (Dictionary)dict[helpPart]; + helpParts.RemoveAt(0); } - + // There was a command for the given help string if (dict.ContainsKey(String.Empty)) { @@ -200,14 +200,14 @@ namespace OpenSim.Framework.Console // If we do have some descriptive help then insert a spacing line before for readability. if (descriptiveHelp != string.Empty) help.Add(string.Empty); - + help.Add(commandInfo.descriptive_help); } else { help.Add(string.Format("No help is available for {0}", originalHelpRequest)); } - + return help; } @@ -268,7 +268,7 @@ namespace OpenSim.Framework.Console // } // return result; // } - + /// /// Add a command to those which can be invoked from the console. /// @@ -299,7 +299,7 @@ namespace OpenSim.Framework.Console string[] parts = Parser.Parse(command); Dictionary current = tree; - + foreach (string part in parts) { if (current.ContainsKey(part)) @@ -326,7 +326,7 @@ namespace OpenSim.Framework.Console return; } - + info = new CommandInfo(); info.module = module; info.shared = shared; @@ -471,7 +471,7 @@ namespace OpenSim.Framework.Console return null; } - + public bool HasCommand(string command) { string[] result; diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 2d8e723..64cddea 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -67,7 +67,7 @@ namespace OpenSim.Framework.Console { System.Console.WriteLine(text); } - + public virtual void OutputFormat(string format, params object[] components) { Output(string.Format(format, components)); @@ -86,7 +86,7 @@ namespace OpenSim.Framework.Console return ret; } - + public string CmdPrompt(string p, List excludedCharacters) { bool itisdone = false; @@ -95,7 +95,7 @@ namespace OpenSim.Framework.Console { itisdone = true; ret = CmdPrompt(p); - + foreach (char c in excludedCharacters) { if (ret.Contains(c.ToString())) @@ -117,7 +117,7 @@ namespace OpenSim.Framework.Console { itisdone = true; ret = CmdPrompt(p, def); - + if (ret == String.Empty) { ret = def; diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 44f6dc1..bfa05a2 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Console // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public const int LocalIdNotFound = 0; - + /// /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section /// rather than in each help summary. @@ -57,10 +57,10 @@ namespace OpenSim.Framework.Console show object pos ,20,20 to ,40,40 delete object pos ,,30 to ,,~ show object pos ,,-~ to ,,30"; - + public const string MinRawConsoleVectorValue = "-~"; public const string MaxRawConsoleVectorValue = "~"; - + public const string VectorSeparator = ","; public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); @@ -81,7 +81,7 @@ namespace OpenSim.Framework.Console return true; } - + /// /// Try to parse a console UUID from the console. /// @@ -101,7 +101,7 @@ namespace OpenSim.Framework.Console return false; } - + return true; } @@ -259,7 +259,7 @@ namespace OpenSim.Framework.Console return false; } - + /// /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 /// @@ -270,7 +270,7 @@ namespace OpenSim.Framework.Console { return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); } - + /// /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 /// @@ -281,7 +281,7 @@ namespace OpenSim.Framework.Console { return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); } - + /// /// Convert a vector input from the console to an OpenMetaverse.Vector3 /// @@ -354,10 +354,10 @@ namespace OpenSim.Framework.Console string rawConsoleVector, int dimensions, Func blankComponentFunc) { List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); - + if (components.Count < 1 || components.Count > dimensions) return null; - + if (components.Count < dimensions) { if (blankComponentFunc == null) @@ -380,7 +380,7 @@ namespace OpenSim.Framework.Console else return c; }); - + return string.Join(VectorSeparator, cookedComponents.ToArray()); } } diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 28293c0..73f0323 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Console private const string LOGLEVEL_NONE = "(none)"; // Used to extract categories for colourization. - private Regex m_categoryRegex + private Regex m_categoryRegex = new Regex( @"^(?.*?)\[(?[^\]]+)\]:?(?.*)", RegexOptions.Singleline | RegexOptions.Compiled); @@ -167,15 +167,15 @@ namespace OpenSim.Framework.Console { System.Console.CursorLeft = 0; } - else + else { int bufferWidth = System.Console.BufferWidth; - + // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) if (bufferWidth > 0 && left >= bufferWidth) System.Console.CursorLeft = bufferWidth - 1; } - + if (top < 0) { top = 0; @@ -183,7 +183,7 @@ namespace OpenSim.Framework.Console else { int bufferHeight = System.Console.BufferHeight; - + // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) if (bufferHeight > 0 && top >= bufferHeight) top = bufferHeight - 1; @@ -216,14 +216,14 @@ namespace OpenSim.Framework.Console { System.Console.CursorTop = 0; } - else + else { int bufferHeight = System.Console.BufferHeight; // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) if (bufferHeight > 0 && top >= bufferHeight) System.Console.CursorTop = bufferHeight - 1; } - + if (left < 0) { left = 0; @@ -339,7 +339,7 @@ namespace OpenSim.Framework.Console string outText = text; if (level != LOGLEVEL_NONE) - { + { MatchCollection matches = m_categoryRegex.Matches(text); if (matches.Count == 1) @@ -364,7 +364,7 @@ namespace OpenSim.Framework.Console WriteColorText(ConsoleColor.Yellow, outText); else System.Console.Write(outText); - + System.Console.WriteLine(); } @@ -551,7 +551,7 @@ namespace OpenSim.Framework.Console } string commandLine = m_commandLine.ToString(); - + if (isCommand) { string[] cmd = Commands.Resolve(Parser.Parse(commandLine)); @@ -573,7 +573,7 @@ namespace OpenSim.Framework.Console // If we're not echoing to screen (e.g. a password) then we probably don't want it in history if (m_echo && commandLine != "") AddToHistory(commandLine); - + return commandLine; default: break; diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 1a142df..e1ff720 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -35,7 +35,7 @@ namespace OpenSim.Framework.Console { /// /// This is a Fake console that's used when setting up the Scene in Unit Tests - /// Don't use this except for Unit Testing or you're in for a world of hurt when the + /// Don't use this except for Unit Testing or you're in for a world of hurt when the /// sim gets to ReadLine /// public class MockConsole : ICommandConsole @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Console public string ReadLine(string p, bool isCommand, bool e) { return ""; } - public object ConsoleScene { + public object ConsoleScene { get { return null; } set {} } diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 9049b4b..f59c902 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -46,93 +46,93 @@ namespace OpenSim.Framework.Console // public class RemoteConsole : CommandConsole { - // Connection specific data, indexed by a session ID - // we create when a client connects. - protected class ConsoleConnection - { - // Last activity from the client - public int last; - - // Last line of scrollback posted to this client - public long lastLineSeen; - - // True if this is a new connection, e.g. has never - // displayed a prompt to the user. - public bool newConnection = true; - } - - // A line in the scrollback buffer. - protected class ScrollbackEntry - { - // The line number of this entry - public long lineNumber; - - // The text to send to the client - public string text; - - // The level this should be logged as. Omitted for - // prompts and input echo. - public string level; - - // True if the text above is a prompt, e.g. the - // client should turn on the cursor / accept input - public bool isPrompt; - - // True if the requested input is a command. A - // client may offer help or validate input if - // this is set. If false, input should be sent - // as typed. - public bool isCommand; - - // True if this text represents a line of text that - // was input in response to a prompt. A client should - // turn off the cursor and refrain from sending commands - // until a new prompt is received. - public bool isInput; - } - - // Data that is relevant to all connections - - // The scrollback buffer + // Connection specific data, indexed by a session ID + // we create when a client connects. + protected class ConsoleConnection + { + // Last activity from the client + public int last; + + // Last line of scrollback posted to this client + public long lastLineSeen; + + // True if this is a new connection, e.g. has never + // displayed a prompt to the user. + public bool newConnection = true; + } + + // A line in the scrollback buffer. + protected class ScrollbackEntry + { + // The line number of this entry + public long lineNumber; + + // The text to send to the client + public string text; + + // The level this should be logged as. Omitted for + // prompts and input echo. + public string level; + + // True if the text above is a prompt, e.g. the + // client should turn on the cursor / accept input + public bool isPrompt; + + // True if the requested input is a command. A + // client may offer help or validate input if + // this is set. If false, input should be sent + // as typed. + public bool isCommand; + + // True if this text represents a line of text that + // was input in response to a prompt. A client should + // turn off the cursor and refrain from sending commands + // until a new prompt is received. + public bool isInput; + } + + // Data that is relevant to all connections + + // The scrollback buffer protected List m_Scrollback = new List(); - // Monotonously incrementing line number. This may eventually - // wrap. No provision is made for that case because 64 bits - // is a long, long time. + // Monotonously incrementing line number. This may eventually + // wrap. No provision is made for that case because 64 bits + // is a long, long time. protected long m_lineNumber = 0; - // These two variables allow us to send the correct - // information about the prompt status to the client, - // irrespective of what may have run off the top of the - // scrollback buffer; - protected bool m_expectingInput = false; - protected bool m_expectingCommand = true; - protected string m_lastPromptUsed; - - // This is the list of things received from clients. - // Note: Race conditions can happen. If a client sends - // something while nothing is expected, it will be - // intepreted as input to the next prompt. For - // commands this is largely correct. For other prompts, - // YMMV. - // TODO: Find a better way to fix this + // These two variables allow us to send the correct + // information about the prompt status to the client, + // irrespective of what may have run off the top of the + // scrollback buffer; + protected bool m_expectingInput = false; + protected bool m_expectingCommand = true; + protected string m_lastPromptUsed; + + // This is the list of things received from clients. + // Note: Race conditions can happen. If a client sends + // something while nothing is expected, it will be + // intepreted as input to the next prompt. For + // commands this is largely correct. For other prompts, + // YMMV. + // TODO: Find a better way to fix this protected List m_InputData = new List(); - // Event to allow ReadLine to wait synchronously even though - // everthing else is asynchronous here. + // Event to allow ReadLine to wait synchronously even though + // everthing else is asynchronous here. protected ManualResetEvent m_DataEvent = new ManualResetEvent(false); - // The list of sessions we maintain. Unlike other console types, - // multiple users on the same console are explicitly allowed. + // The list of sessions we maintain. Unlike other console types, + // multiple users on the same console are explicitly allowed. protected Dictionary m_Connections = new Dictionary(); - // Timer to control expiration of sessions that have been - // disconnected. - protected System.Timers.Timer m_expireTimer = new System.Timers.Timer(5000); + // Timer to control expiration of sessions that have been + // disconnected. + protected System.Timers.Timer m_expireTimer = new System.Timers.Timer(5000); - // The less interesting stuff that makes the actual server - // work. + // The less interesting stuff that makes the actual server + // work. protected IHttpServer m_Server = null; protected IConfigSource m_Config = null; @@ -143,130 +143,130 @@ namespace OpenSim.Framework.Console public RemoteConsole(string defaultPrompt) : base(defaultPrompt) { - // There is something wrong with this architecture. - // A prompt is sent on every single input, so why have this? - // TODO: Investigate and fix. - m_lastPromptUsed = defaultPrompt; - - // Start expiration of sesssions. - m_expireTimer.Elapsed += DoExpire; - m_expireTimer.Start(); + // There is something wrong with this architecture. + // A prompt is sent on every single input, so why have this? + // TODO: Investigate and fix. + m_lastPromptUsed = defaultPrompt; + + // Start expiration of sesssions. + m_expireTimer.Elapsed += DoExpire; + m_expireTimer.Start(); } public void ReadConfig(IConfigSource config) { m_Config = config; - // We're pulling this from the 'Network' section for legacy - // compatibility. However, this is so essentially insecure - // that TLS and client certs should be used instead of - // a username / password. + // We're pulling this from the 'Network' section for legacy + // compatibility. However, this is so essentially insecure + // that TLS and client certs should be used instead of + // a username / password. IConfig netConfig = m_Config.Configs["Network"]; if (netConfig == null) return; - // Get the username and password. + // Get the username and password. m_UserName = netConfig.GetString("ConsoleUser", String.Empty); m_Password = netConfig.GetString("ConsolePass", String.Empty); - // Woefully underdocumented, this is what makes javascript - // console clients work. Set to "*" for anywhere or (better) - // to specific addresses. + // Woefully underdocumented, this is what makes javascript + // console clients work. Set to "*" for anywhere or (better) + // to specific addresses. m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty); } public void SetServer(IHttpServer server) { - // This is called by the framework to give us the server - // instance (means: port) to work with. + // This is called by the framework to give us the server + // instance (means: port) to work with. m_Server = server; - // Add our handlers + // Add our handlers m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession); m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession); m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); } public override void Output(string text, string level) - { - Output(text, level, false, false, false); - } + { + Output(text, level, false, false, false); + } protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) { - // Increment the line number. It was 0 and they start at 1 - // so we need to pre-increment. - m_lineNumber++; - - // Create and populate the new entry. - ScrollbackEntry newEntry = new ScrollbackEntry(); - - newEntry.lineNumber = m_lineNumber; - newEntry.text = text; - newEntry.level = level; - newEntry.isPrompt = isPrompt; - newEntry.isCommand = isCommand; - newEntry.isInput = isInput; - - // Add a line to the scrollback. In some cases, that may not - // actually be a line of text. + // Increment the line number. It was 0 and they start at 1 + // so we need to pre-increment. + m_lineNumber++; + + // Create and populate the new entry. + ScrollbackEntry newEntry = new ScrollbackEntry(); + + newEntry.lineNumber = m_lineNumber; + newEntry.text = text; + newEntry.level = level; + newEntry.isPrompt = isPrompt; + newEntry.isCommand = isCommand; + newEntry.isInput = isInput; + + // Add a line to the scrollback. In some cases, that may not + // actually be a line of text. lock (m_Scrollback) { - // Prune the scrollback to the length se send as connect - // burst to give the user some context. + // Prune the scrollback to the length se send as connect + // burst to give the user some context. while (m_Scrollback.Count >= 1000) m_Scrollback.RemoveAt(0); m_Scrollback.Add(newEntry); } - // Let the rest of the system know we have output something. + // Let the rest of the system know we have output something. FireOnOutput(text.Trim()); - // Also display it for debugging. + // Also display it for debugging. System.Console.WriteLine(text.Trim()); } public override void Output(string text) { - // Output plain (non-logging style) text. + // Output plain (non-logging style) text. Output(text, String.Empty, false, false, false); } public override string ReadLine(string p, bool isCommand, bool e) { - // Output the prompt an prepare to wait. This - // is called on a dedicated console thread and - // needs to be synchronous. Old architecture but - // not worth upgrading. - if (isCommand) - { - m_expectingInput = true; - m_expectingCommand = true; + // Output the prompt an prepare to wait. This + // is called on a dedicated console thread and + // needs to be synchronous. Old architecture but + // not worth upgrading. + if (isCommand) + { + m_expectingInput = true; + m_expectingCommand = true; Output(p, String.Empty, true, true, false); - m_lastPromptUsed = p; - } - else - { - m_expectingInput = true; + m_lastPromptUsed = p; + } + else + { + m_expectingInput = true; Output(p, String.Empty, true, false, false); - } + } - // Here is where we wait for the user to input something. + // Here is where we wait for the user to input something. m_DataEvent.WaitOne(); string cmdinput; - // Check for empty input. Read input if not empty. + // Check for empty input. Read input if not empty. lock (m_InputData) { if (m_InputData.Count == 0) { m_DataEvent.Reset(); - m_expectingInput = false; - m_expectingCommand = false; + m_expectingInput = false; + m_expectingCommand = false; return ""; } @@ -278,19 +278,19 @@ namespace OpenSim.Framework.Console } - m_expectingInput = false; - m_expectingCommand = false; + m_expectingInput = false; + m_expectingCommand = false; - // Echo to all the other users what we have done. This - // will also go to ourselves. - Output (cmdinput, String.Empty, false, false, true); + // Echo to all the other users what we have done. This + // will also go to ourselves. + Output (cmdinput, String.Empty, false, false, true); - // If this is a command, we need to resolve and execute it. + // If this is a command, we need to resolve and execute it. if (isCommand) { - // This call will actually execute the command and create - // any output associated with it. The core just gets an - // empty string so it will call again immediately. + // This call will actually execute the command and create + // any output associated with it. The core just gets an + // empty string so it will call again immediately. string[] cmd = Commands.Resolve(Parser.Parse(cmdinput)); if (cmd.Length != 0) @@ -306,11 +306,11 @@ namespace OpenSim.Framework.Console } } - // Return the raw input string if not a command. + // Return the raw input string if not a command. return cmdinput; } - // Very simplistic static access control header. + // Very simplistic static access control header. protected Hashtable CheckOrigin(Hashtable result) { if (!string.IsNullOrEmpty(m_AllowedOrigin)) @@ -338,21 +338,21 @@ namespace OpenSim.Framework.Console protected void DoExpire(Object sender, ElapsedEventArgs e) { - // Iterate the list of console connections and find those we - // haven't heard from for longer then the longpoll interval. - // Remove them. + // Iterate the list of console connections and find those we + // haven't heard from for longer then the longpoll interval. + // Remove them. List expired = new List(); lock (m_Connections) { - // Mark the expired ones + // Mark the expired ones foreach (KeyValuePair kvp in m_Connections) { if (System.Environment.TickCount - kvp.Value.last > 500000) expired.Add(kvp.Key); } - // Delete them + // Delete them foreach (UUID id in expired) { m_Connections.Remove(id); @@ -361,10 +361,10 @@ namespace OpenSim.Framework.Console } } - // Start a new session. + // Start a new session. protected Hashtable HandleHttpStartSession(Hashtable request) { - // The login is in the form of a http form post + // The login is in the form of a http form post Hashtable post = DecodePostString(request["body"].ToString()); Hashtable reply = new Hashtable(); @@ -372,7 +372,7 @@ namespace OpenSim.Framework.Console reply["int_response_code"] = 401; reply["content_type"] = "text/plain"; - // Check user name and password + // Check user name and password if (m_UserName == String.Empty) return reply; @@ -385,28 +385,28 @@ namespace OpenSim.Framework.Console return reply; } - // Set up the new console connection record + // Set up the new console connection record ConsoleConnection c = new ConsoleConnection(); c.last = System.Environment.TickCount; c.lastLineSeen = 0; - // Assign session ID + // Assign session ID UUID sessionID = UUID.Random(); - // Add connection to list. + // Add connection to list. lock (m_Connections) { m_Connections[sessionID] = c; } - // This call is a CAP. The URL is the authentication. + // This call is a CAP. The URL is the authentication. string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout - // Our reply is an XML document. - // TODO: Change this to Linq.Xml + // Our reply is an XML document. + // TODO: Change this to Linq.Xml XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); @@ -429,7 +429,7 @@ namespace OpenSim.Framework.Console rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc)); - // Set up the response and check origin + // Set up the response and check origin reply["str_response_string"] = xmldoc.InnerXml; reply["int_response_code"] = 200; reply["content_type"] = "text/xml"; @@ -438,7 +438,7 @@ namespace OpenSim.Framework.Console return reply; } - // Client closes session. Clean up. + // Client closes session. Clean up. protected Hashtable HandleHttpCloseSession(Hashtable request) { Hashtable post = DecodePostString(request["body"].ToString()); @@ -487,7 +487,7 @@ namespace OpenSim.Framework.Console return reply; } - // Command received from the client. + // Command received from the client. protected Hashtable HandleHttpSessionCommand(Hashtable request) { Hashtable post = DecodePostString(request["body"].ToString()); @@ -497,7 +497,7 @@ namespace OpenSim.Framework.Console reply["int_response_code"] = 404; reply["content_type"] = "text/plain"; - // Check the ID + // Check the ID if (post["ID"] == null) return reply; @@ -505,25 +505,25 @@ namespace OpenSim.Framework.Console if (!UUID.TryParse(post["ID"].ToString(), out id)) return reply; - // Find the connection for that ID. + // Find the connection for that ID. lock (m_Connections) { if (!m_Connections.ContainsKey(id)) return reply; } - // Empty post. Just error out. + // Empty post. Just error out. if (post["COMMAND"] == null) return reply; - // Place the input data in the buffer. + // Place the input data in the buffer. lock (m_InputData) { m_DataEvent.Set(); m_InputData.Add(post["COMMAND"].ToString()); } - // Create the XML reply document. + // Create the XML reply document. XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); @@ -547,7 +547,7 @@ namespace OpenSim.Framework.Console return reply; } - // Decode a HTTP form post to a Hashtable + // Decode a HTTP form post to a Hashtable protected Hashtable DecodePostString(string data) { Hashtable result = new Hashtable(); @@ -565,14 +565,14 @@ namespace OpenSim.Framework.Console if (elems.Length > 1) value = System.Web.HttpUtility.UrlDecode(elems[1]); - + result[name] = value; } return result; } - // Close the CAP receiver for the responses for a given client. + // Close the CAP receiver for the responses for a given client. public void CloseConnection(UUID id) { try @@ -586,8 +586,8 @@ namespace OpenSim.Framework.Console } } - // Check if there is anything to send. Return true if this client has - // lines pending. + // Check if there is anything to send. Return true if this client has + // lines pending. protected bool HasEvents(UUID RequestID, UUID sessionID) { ConsoleConnection c = null; @@ -604,10 +604,10 @@ namespace OpenSim.Framework.Console return false; } - // Send all pending output to the client. + // Send all pending output to the client. protected Hashtable GetEvents(UUID RequestID, UUID sessionID) { - // Find the connection that goes with this client. + // Find the connection that goes with this client. ConsoleConnection c = null; lock (m_Connections) @@ -617,14 +617,14 @@ namespace OpenSim.Framework.Console c = m_Connections[sessionID]; } - // If we have nothing to send, send the no events response. + // If we have nothing to send, send the no events response. c.last = System.Environment.TickCount; if (c.lastLineSeen >= m_lineNumber) return NoEvents(RequestID, UUID.Zero); Hashtable result = new Hashtable(); - // Create the response document. + // Create the response document. XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); @@ -648,29 +648,29 @@ namespace OpenSim.Framework.Console for (long i = sendStart ; i < m_lineNumber ; i++) { - ScrollbackEntry e = m_Scrollback[(int)(i - startLine)]; + ScrollbackEntry e = m_Scrollback[(int)(i - startLine)]; XmlElement res = xmldoc.CreateElement("", "Line", ""); res.SetAttribute("Number", e.lineNumber.ToString()); res.SetAttribute("Level", e.level); - // Don't include these for the scrollback, we'll send the - // real state later. - if (!c.newConnection) - { - res.SetAttribute("Prompt", e.isPrompt ? "true" : "false"); - res.SetAttribute("Command", e.isCommand ? "true" : "false"); - res.SetAttribute("Input", e.isInput ? "true" : "false"); - } - else if (i == m_lineNumber - 1) // Last line for a new connection - { - res.SetAttribute("Prompt", m_expectingInput ? "true" : "false"); - res.SetAttribute("Command", m_expectingCommand ? "true" : "false"); - res.SetAttribute("Input", (!m_expectingInput) ? "true" : "false"); - } - else - { - res.SetAttribute("Input", e.isInput ? "true" : "false"); - } + // Don't include these for the scrollback, we'll send the + // real state later. + if (!c.newConnection) + { + res.SetAttribute("Prompt", e.isPrompt ? "true" : "false"); + res.SetAttribute("Command", e.isCommand ? "true" : "false"); + res.SetAttribute("Input", e.isInput ? "true" : "false"); + } + else if (i == m_lineNumber - 1) // Last line for a new connection + { + res.SetAttribute("Prompt", m_expectingInput ? "true" : "false"); + res.SetAttribute("Command", m_expectingCommand ? "true" : "false"); + res.SetAttribute("Input", (!m_expectingInput) ? "true" : "false"); + } + else + { + res.SetAttribute("Input", e.isInput ? "true" : "false"); + } res.AppendChild(xmldoc.CreateTextNode(e.text)); @@ -679,7 +679,7 @@ namespace OpenSim.Framework.Console } c.lastLineSeen = m_lineNumber; - c.newConnection = false; + c.newConnection = false; xmldoc.AppendChild(rootElement); @@ -693,8 +693,8 @@ namespace OpenSim.Framework.Console return result; } - // This is really just a no-op. It generates what is sent - // to the client if the poll times out without any events. + // This is really just a no-op. It generates what is sent + // to the client if the poll times out without any events. protected Hashtable NoEvents(UUID RequestID, UUID id) { Hashtable result = new Hashtable(); -- cgit v1.1 From 4381f16e186cd63210b7bcc5e4d34ea708fa0ba9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 30 Jan 2018 08:15:42 +0000 Subject: keepalive is default --- OpenSim/Framework/Console/RemoteConsole.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index ddd9578..24f01b0 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -687,7 +687,6 @@ namespace OpenSim.Framework.Console result["int_response_code"] = 200; result["content_type"] = "application/xml"; result["keepalive"] = false; - result["reusecontext"] = false; result = CheckOrigin(result); return result; -- cgit v1.1 From 8ed4bee521d9736abd753ed1e72c7e0461e49846 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2018 00:46:47 +0100 Subject: mantis 8333: kept idea but my own code. With ini setting ConsoleHistoryTimeStamp set to true, the console history file will have timestamps. Im lazy date is in en-us culture for now. (robust also) --- OpenSim/Framework/Console/LocalConsole.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 73f0323..ba32f50 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -46,6 +46,7 @@ namespace OpenSim.Framework.Console private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_historyPath; private bool m_historyEnable; + private bool m_historytimestamps; // private readonly object m_syncRoot = new object(); private const string LOGLEVEL_NONE = "(none)"; @@ -98,15 +99,30 @@ namespace OpenSim.Framework.Console string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt"); int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); m_historyPath = Path.GetFullPath(Path.Combine(Util.configDir(), m_historyFile)); - m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath); + m_historytimestamps = startupConfig.GetBoolean("ConsoleHistoryTimeStamp", false); + m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1} {2} timestamps", + m_historySize, m_historyPath, m_historytimestamps?"with":"without"); if (File.Exists(m_historyPath)) { + List originallines = new List(); using (StreamReader history_file = new StreamReader(m_historyPath)) { string line; while ((line = history_file.ReadLine()) != null) { + originallines.Add(line); + if(line.StartsWith("[")) + { + int indx = line.IndexOf("]:> "); + if(indx > 0) + { + if(indx + 4 >= line.Length) + line = String.Empty; + else + line = line.Substring(indx + 4); + } + } m_history.Add(line); } } @@ -114,11 +130,14 @@ namespace OpenSim.Framework.Console if (m_history.Count > m_historySize) { while (m_history.Count > m_historySize) + { m_history.RemoveAt(0); + originallines.RemoveAt(0); + } using (StreamWriter history_file = new StreamWriter(m_historyPath)) { - foreach (string line in m_history) + foreach (string line in originallines) { history_file.WriteLine(line); } @@ -141,6 +160,8 @@ namespace OpenSim.Framework.Console m_history.Add(text); if (m_historyEnable) { + if (m_historytimestamps) + text = String.Format("[{0} {1}]:> {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), text); File.AppendAllText(m_historyPath, text + Environment.NewLine); } } -- cgit v1.1 From 81fb1b008fb8d7206cfdc43c1cc27bbcd94d74aa Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2018 21:51:43 +0100 Subject: http reusecontext is obsolete --- OpenSim/Framework/Console/RemoteConsole.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 24f01b0..b90b75f 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -712,7 +712,6 @@ namespace OpenSim.Framework.Console result["int_response_code"] = 200; result["content_type"] = "text/xml"; result["keepalive"] = false; - result["reusecontext"] = false; result = CheckOrigin(result); return result; -- cgit v1.1 From 0fd17c08ae642fac17b24dfad06c61cfe5739483 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 20 Aug 2019 23:28:59 +0100 Subject: Massive console refactor. Greatly simplify interface. --- OpenSim/Framework/Console/ConsoleBase.cs | 86 +++++++----------------------- OpenSim/Framework/Console/ConsoleUtil.cs | 20 +++---- OpenSim/Framework/Console/LocalConsole.cs | 15 ++---- OpenSim/Framework/Console/MockConsole.cs | 14 ++--- OpenSim/Framework/Console/RemoteConsole.cs | 16 +++--- 5 files changed, 48 insertions(+), 103 deletions(-) mode change 100644 => 100755 OpenSim/Framework/Console/ConsoleUtil.cs mode change 100644 => 100755 OpenSim/Framework/Console/LocalConsole.cs mode change 100644 => 100755 OpenSim/Framework/Console/MockConsole.cs mode change 100644 => 100755 OpenSim/Framework/Console/RemoteConsole.cs (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 64cddea..56bda05 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -35,13 +35,13 @@ using log4net; namespace OpenSim.Framework.Console { - public class ConsoleBase + public class ConsoleBase : IConsole { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected string prompt = "# "; - public object ConsoleScene { get; set; } + public IScene ConsoleScene { get; set; } public string DefaultPrompt { get; set; } @@ -58,78 +58,39 @@ namespace OpenSim.Framework.Console { } - public virtual void Output(string text, string level) + public virtual void Output(string format, string level = null, params object[] components) { - Output(text); + System.Console.WriteLine(format, components); } - public virtual void Output(string text) - { - System.Console.WriteLine(text); - } - - public virtual void OutputFormat(string format, params object[] components) - { - Output(string.Format(format, components)); - } - - public string CmdPrompt(string p) - { - return ReadLine(String.Format("{0}: ", p), false, true); - } - - public string CmdPrompt(string p, string def) - { - string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); - if (ret == String.Empty) - ret = def; - - return ret; - } - - public string CmdPrompt(string p, List excludedCharacters) + public virtual string Prompt(string p, string def = null, List excludedCharacters = null, bool echo = true) { bool itisdone = false; string ret = String.Empty; while (!itisdone) { itisdone = true; - ret = CmdPrompt(p); - foreach (char c in excludedCharacters) - { - if (ret.Contains(c.ToString())) - { - System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); - itisdone = false; - } - } - } - - return ret; - } - - public string CmdPrompt(string p, string def, List excludedCharacters) - { - bool itisdone = false; - string ret = String.Empty; - while (!itisdone) - { - itisdone = true; - ret = CmdPrompt(p, def); + if (def != null) + ret = ReadLine(String.Format("{0}: ", p), false, echo); + else + ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, echo); - if (ret == String.Empty) + if (ret == String.Empty && def != null) { ret = def; } else { - foreach (char c in excludedCharacters) + if (excludedCharacters != null) { - if (ret.Contains(c.ToString())) + foreach (char c in excludedCharacters) { - System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); - itisdone = false; + if (ret.Contains(c.ToString())) + { + System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); + itisdone = false; + } } } } @@ -139,14 +100,14 @@ namespace OpenSim.Framework.Console } // Displays a command prompt and returns a default value, user may only enter 1 of 2 options - public string CmdPrompt(string prompt, string defaultresponse, List options) + public virtual string Prompt(string prompt, string defaultresponse, List options) { bool itisdone = false; string optstr = String.Empty; foreach (string s in options) optstr += " " + s; - string temp = CmdPrompt(prompt, defaultresponse); + string temp = Prompt(prompt, defaultresponse); while (itisdone == false) { if (options.Contains(temp)) @@ -156,19 +117,12 @@ namespace OpenSim.Framework.Console else { System.Console.WriteLine("Valid options are" + optstr); - temp = CmdPrompt(prompt, defaultresponse); + temp = Prompt(prompt, defaultresponse); } } return temp; } - // Displays a prompt and waits for the user to enter a string, then returns that string - // (Done with no echo and suitable for passwords) - public string PasswdPrompt(string p) - { - return ReadLine(String.Format("{0}: ", p), false, false); - } - public virtual string ReadLine(string p, bool isCommand, bool e) { System.Console.Write("{0}", p); diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs old mode 100644 new mode 100755 index bfa05a2..5342a29 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Console { if (File.Exists(path)) { - console.OutputFormat("File {0} already exists. Please move or remove it.", path); + console.Output("File {0} already exists. Please move or remove it.", null, path); return false; } @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console if (!UUID.TryParse(rawUuid, out uuid)) { if (console != null) - console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); + console.Output("ERROR: {0} is not a valid uuid", null, rawUuid); return false; } @@ -110,7 +110,7 @@ namespace OpenSim.Framework.Console if (!uint.TryParse(rawLocalId, out localId)) { if (console != null) - console.OutputFormat("ERROR: {0} is not a valid local id", localId); + console.Output("ERROR: {0} is not a valid local id", null, localId); return false; } @@ -118,7 +118,7 @@ namespace OpenSim.Framework.Console if (localId == 0) { if (console != null) - console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); + console.Output("ERROR: {0} is not a valid local id - it must be greater than 0", null, localId); return false; } @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Console } if (console != null) - console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); + console.Output("ERROR: {0} is not a valid UUID or local id", null, rawId); return false; } @@ -167,7 +167,7 @@ namespace OpenSim.Framework.Console if (!bool.TryParse(rawConsoleString, out b)) { if (console != null) - console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); + console.Output("ERROR: {0} is not a true or false value", null, rawConsoleString); return false; } @@ -187,7 +187,7 @@ namespace OpenSim.Framework.Console if (!int.TryParse(rawConsoleInt, out i)) { if (console != null) - console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); + console.Output("ERROR: {0} is not a valid integer", null, rawConsoleInt); return false; } @@ -207,7 +207,7 @@ namespace OpenSim.Framework.Console if (!float.TryParse(rawConsoleInput, out i)) { if (console != null) - console.OutputFormat("ERROR: {0} is not a valid float", rawConsoleInput); + console.Output("ERROR: {0} is not a valid float", null, rawConsoleInput); return false; } @@ -227,7 +227,7 @@ namespace OpenSim.Framework.Console if (!double.TryParse(rawConsoleInput, out i)) { if (console != null) - console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); + console.Output("ERROR: {0} is not a valid double", null, rawConsoleInput); return false; } @@ -249,7 +249,7 @@ namespace OpenSim.Framework.Console if (i < 0) { if (console != null) - console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); + console.Output("ERROR: {0} is not a positive integer", null, rawConsoleInt); return false; } diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs old mode 100644 new mode 100755 index ba32f50..55c5c7e --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -359,7 +359,7 @@ namespace OpenSim.Framework.Console { string outText = text; - if (level != LOGLEVEL_NONE) + if (level != null) { MatchCollection matches = m_categoryRegex.Matches(text); @@ -389,20 +389,15 @@ namespace OpenSim.Framework.Console System.Console.WriteLine(); } - public override void Output(string text) + public override void Output(string format, string level = null, params object[] components) { - Output(text, LOGLEVEL_NONE); - } - - public override void Output(string text, string level) - { - FireOnOutput(text); + FireOnOutput(format); lock (m_commandLine) { if (m_cursorYPosition == -1) { - WriteLocalText(text, level); + WriteLocalText(format, level); return; } @@ -418,7 +413,7 @@ namespace OpenSim.Framework.Console m_cursorYPosition = SetCursorTop(m_cursorYPosition); SetCursorLeft(0); - WriteLocalText(text, level); + WriteLocalText(format, level); m_cursorYPosition = System.Console.CursorTop; diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs old mode 100644 new mode 100755 index e1ff720..d68b066 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -56,21 +56,17 @@ namespace OpenSim.Framework.Console public string ReadLine(string p, bool isCommand, bool e) { return ""; } - public object ConsoleScene { + public IScene ConsoleScene { get { return null; } set {} } - public void Output(string text, string level) {} - public void Output(string text) {} - public void OutputFormat(string format, params object[] components) {} + public void Output(string format, string level, params object[] components) {} - public string CmdPrompt(string p) { return ""; } - public string CmdPrompt(string p, string def) { return ""; } - public string CmdPrompt(string p, List excludedCharacters) { return ""; } - public string CmdPrompt(string p, string def, List excludedCharacters) { return ""; } + public string Prompt(string p) { return ""; } + public string Prompt(string p, string def, List excludedCharacters, bool echo) { return ""; } - public string CmdPrompt(string prompt, string defaultresponse, List options) { return ""; } + public string Prompt(string prompt, string defaultresponse, List options) { return ""; } public string PasswdPrompt(string p) { return ""; } } diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs old mode 100644 new mode 100755 index b90b75f..16b4636 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -188,13 +188,19 @@ namespace OpenSim.Framework.Console m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); } - public override void Output(string text, string level) + public override void Output(string format, string level = null, params object[] components) { - Output(text, level, false, false, false); + if (components.Length == 0) + Output(format, level, false, false, false); + else + Output(String.Format(format, components), level, false, false, false); } protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) { + if (level == null) + level = String.Empty; + // Increment the line number. It was 0 and they start at 1 // so we need to pre-increment. m_lineNumber++; @@ -228,12 +234,6 @@ namespace OpenSim.Framework.Console System.Console.WriteLine(text.Trim()); } - public override void Output(string text) - { - // Output plain (non-logging style) text. - Output(text, String.Empty, false, false, false); - } - public override string ReadLine(string p, bool isCommand, bool e) { // Output the prompt an prepare to wait. This -- cgit v1.1 From 7e136c67fd89f6c559420093acdee867967773bb Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 21 Aug 2019 21:15:58 +0100 Subject: Call SetServer on consoles reflectively to avoid having type checks in places where it tends to be forgotten to update them. --- OpenSim/Framework/Console/RemoteConsole.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 16b4636..11006a9 100755 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -46,6 +46,8 @@ namespace OpenSim.Framework.Console // public class RemoteConsole : CommandConsole { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // Connection specific data, indexed by a session ID // we create when a client connects. protected class ConsoleConnection -- cgit v1.1 From 110644c23a8f6c2dedc4392c833101d369c58f3e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 21 Aug 2019 21:23:54 +0100 Subject: Make ReadConfig a general features of consoles, rather than type dependent --- OpenSim/Framework/Console/CommandConsole.cs | 5 +++++ OpenSim/Framework/Console/MockConsole.cs | 3 +++ OpenSim/Framework/Console/RemoteConsole.cs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 OpenSim/Framework/Console/CommandConsole.cs (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs old mode 100644 new mode 100755 index 52360b4..d2b6618 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -36,6 +36,7 @@ using System.Text.RegularExpressions; using System.Threading; using log4net; using OpenSim.Framework; +using Nini.Config; namespace OpenSim.Framework.Console { @@ -789,5 +790,9 @@ namespace OpenSim.Framework.Console } return cmdinput; } + + public virtual void ReadConfig(IConfigSource configSource) + { + } } } diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index d68b066..6adc678 100755 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -30,6 +30,7 @@ using System.Threading; using System.Collections.Generic; using System.Text; using System.Xml; +using Nini.Config; namespace OpenSim.Framework.Console { @@ -69,6 +70,8 @@ namespace OpenSim.Framework.Console public string Prompt(string prompt, string defaultresponse, List options) { return ""; } public string PasswdPrompt(string p) { return ""; } + + public void ReadConfig(IConfigSource configSource) { } } public class MockCommands : ICommands diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 11006a9..8dc7333 100755 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -155,7 +155,7 @@ namespace OpenSim.Framework.Console m_expireTimer.Start(); } - public void ReadConfig(IConfigSource config) + public override void ReadConfig(IConfigSource config) { m_Config = config; -- cgit v1.1 From 584df2ab38c35b31e1a279f1992f7032d256ceb5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 25 Aug 2019 23:05:57 +0100 Subject: Fix console outputting raw format strings --- OpenSim/Framework/Console/LocalConsole.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 55c5c7e..f2d2fa3 100755 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -391,13 +391,15 @@ namespace OpenSim.Framework.Console public override void Output(string format, string level = null, params object[] components) { - FireOnOutput(format); + string text = String.Format(format, components); + + FireOnOutput(text); lock (m_commandLine) { if (m_cursorYPosition == -1) { - WriteLocalText(format, level); + WriteLocalText(text, level); return; } @@ -413,7 +415,7 @@ namespace OpenSim.Framework.Console m_cursorYPosition = SetCursorTop(m_cursorYPosition); SetCursorLeft(0); - WriteLocalText(format, level); + WriteLocalText(text, level); m_cursorYPosition = System.Console.CursorTop; -- cgit v1.1 From b046ccebf27b653fb5b02256ffd5e55e5a685482 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 21 Sep 2019 16:35:38 +0100 Subject: make Console Output(..) compatible with rest of code, again --- OpenSim/Framework/Console/ConsoleBase.cs | 7 ++++++- OpenSim/Framework/Console/LocalConsole.cs | 3 +-- OpenSim/Framework/Console/MockConsole.cs | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 56bda05..b011719 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -58,7 +58,12 @@ namespace OpenSim.Framework.Console { } - public virtual void Output(string format, string level = null, params object[] components) + public void Output(string format, params object[] components) + { + Output(format, null, components); + } + + public virtual void Output(string format, string level, params object[] components) { System.Console.WriteLine(format, components); } diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index f2d2fa3..d19e244 100755 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -389,7 +389,7 @@ namespace OpenSim.Framework.Console System.Console.WriteLine(); } - public override void Output(string format, string level = null, params object[] components) + public override void Output(string format, string level, params object[] components) { string text = String.Format(format, components); @@ -400,7 +400,6 @@ namespace OpenSim.Framework.Console if (m_cursorYPosition == -1) { WriteLocalText(text, level); - return; } diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 6adc678..e5db271 100755 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -62,7 +62,8 @@ namespace OpenSim.Framework.Console set {} } - public void Output(string format, string level, params object[] components) {} + public void Output(string format, params object[] components) { } + public void Output(string format, string level, params object[] components) { } public string Prompt(string p) { return ""; } public string Prompt(string p, string def, List excludedCharacters, bool echo) { return ""; } -- cgit v1.1 From 43b56eaf08457ffce3aa5f73321bb18dda9ae1db Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 21 Sep 2019 16:59:41 +0100 Subject: make Console Promt(..) compatible with rest of code, again --- OpenSim/Framework/Console/ConsoleBase.cs | 17 ++++++++++++++++- OpenSim/Framework/Console/MockConsole.cs | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index b011719..343958b 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -68,7 +68,22 @@ namespace OpenSim.Framework.Console System.Console.WriteLine(format, components); } - public virtual string Prompt(string p, string def = null, List excludedCharacters = null, bool echo = true) + public string Prompt(string p) + { + return Prompt(p, null, null, true); + } + + public string Prompt(string p, string def) + { + return Prompt(p, def, null, true); + } + + public string Prompt(string p, List excludedCharacters) + { + return Prompt(p, null, excludedCharacters, true); + } + + public virtual string Prompt(string p, string def, List excludedCharacters, bool echo = true) { bool itisdone = false; string ret = String.Empty; diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index e5db271..291b7e9 100755 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -66,6 +66,8 @@ namespace OpenSim.Framework.Console public void Output(string format, string level, params object[] components) { } public string Prompt(string p) { return ""; } + public string Prompt(string p, string def) { return ""; } + public string Prompt(string p, List excludedCharacters) { return ""; } public string Prompt(string p, string def, List excludedCharacters, bool echo) { return ""; } public string Prompt(string prompt, string defaultresponse, List options) { return ""; } -- cgit v1.1 From 7939974d921064d4316b5143e3eb45d3e99abf33 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Oct 2019 11:55:27 +0100 Subject: try to fix console AGAIN --- OpenSim/Framework/Console/ConsoleBase.cs | 59 ++++++++++++++++++++++++++-- OpenSim/Framework/Console/LocalConsole.cs | 27 ++++++++++++- OpenSim/Framework/Console/MockConsole.cs | 2 +- OpenSim/Framework/Console/OpenSimAppender.cs | 4 +- OpenSim/Framework/Console/RemoteConsole.cs | 30 ++++++++++++-- 5 files changed, 110 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 343958b..f9dfb63 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -35,6 +35,32 @@ using log4net; namespace OpenSim.Framework.Console { + public class ConsoleLevel + { + public string m_string; + + ConsoleLevel(string v) + { + m_string = v; + } + + static public implicit operator ConsoleLevel(string s) + { + return new ConsoleLevel(s); + } + + public static string ToString(ConsoleLevel s) + { + return s.m_string; + } + + public override string ToString() + { + return m_string; + } + } + + public class ConsoleBase : IConsole { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -58,14 +84,39 @@ namespace OpenSim.Framework.Console { } - public void Output(string format, params object[] components) + public void Output(string format) { - Output(format, null, components); + System.Console.WriteLine(format); } - public virtual void Output(string format, string level, params object[] components) + public virtual void Output(string format, params object[] components) { - System.Console.WriteLine(format, components); + string level = null; + if (components != null && components.Length > 0) + { + if (components[0] == null || components[0] is ConsoleLevel) + { + if (components[0] is ConsoleLevel) + level = ((ConsoleLevel)components[0]).ToString(); + + if (components.Length > 1) + { + object[] tmp = new object[components.Length - 1]; + Array.Copy(components, 1, tmp, 0, components.Length - 1); + components = tmp; + } + else + components = null; + } + + } + string text; + if (components == null || components.Length == 0) + text = format; + else + text = String.Format(format, components); + + System.Console.WriteLine(text); } public string Prompt(string p) diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index d19e244..e1492b8 100755 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -389,9 +389,32 @@ namespace OpenSim.Framework.Console System.Console.WriteLine(); } - public override void Output(string format, string level, params object[] components) + public override void Output(string format, params object[] components) { - string text = String.Format(format, components); + string level = null; + if(components != null && components.Length > 0) + { + if(components[0] == null || components[0] is ConsoleLevel) + { + if(components[0] is ConsoleLevel) + level = ((ConsoleLevel)components[0]).ToString(); + + if (components.Length > 1) + { + object[] tmp = new object[components.Length - 1]; + Array.Copy(components, 1, tmp, 0, components.Length - 1); + components = tmp; + } + else + components = null; + } + + } + string text; + if (components == null || components.Length == 0) + text = format; + else + text = String.Format(format, components); FireOnOutput(text); diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 291b7e9..d314047 100755 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -62,8 +62,8 @@ namespace OpenSim.Framework.Console set {} } + public void Output(string format) { } public void Output(string format, params object[] components) { } - public void Output(string format, string level, params object[] components) { } public string Prompt(string p) { return ""; } public string Prompt(string p, string def) { return ""; } diff --git a/OpenSim/Framework/Console/OpenSimAppender.cs b/OpenSim/Framework/Console/OpenSimAppender.cs index 72a251e..39a550b 100644 --- a/OpenSim/Framework/Console/OpenSimAppender.cs +++ b/OpenSim/Framework/Console/OpenSimAppender.cs @@ -55,12 +55,14 @@ namespace OpenSim.Framework.Console { if (m_console != null) { - string level = "normal"; + ConsoleLevel level; if (le.Level == Level.Error) level = "error"; else if (le.Level == Level.Warn) level = "warn"; + else + level = "normal"; m_console.Output(loggingMessage, level); } diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 8dc7333..889df36 100755 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -190,12 +190,34 @@ namespace OpenSim.Framework.Console m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); } - public override void Output(string format, string level = null, params object[] components) + public override void Output(string format, params object[] components) { - if (components.Length == 0) - Output(format, level, false, false, false); + string level = null; + if (components != null && components.Length > 0) + { + if (components[0] == null || components[0] is ConsoleLevel) + { + if (components[0] is ConsoleLevel) + level = ((ConsoleLevel)components[0]).ToString(); + + if (components.Length > 1) + { + object[] tmp = new object[components.Length - 1]; + Array.Copy(components, 1, tmp, 0, components.Length - 1); + components = tmp; + } + else + components = null; + } + } + + string text; + if (components == null || components.Length == 0) + text = format; else - Output(String.Format(format, components), level, false, false, false); + text = String.Format(format, components); + + Output(text, level, false, false, false); } protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) -- cgit v1.1 From b98ad6c53c484aa2744c5040c9f29c475c3d4f72 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 22 Oct 2019 12:23:19 +0100 Subject: remove some useless NULL arguments --- OpenSim/Framework/Console/ConsoleUtil.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 5342a29..2f73a8d 100755 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Console { if (File.Exists(path)) { - console.Output("File {0} already exists. Please move or remove it.", null, path); + console.Output("File {0} already exists. Please move or remove it.", path); return false; } @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console if (!UUID.TryParse(rawUuid, out uuid)) { if (console != null) - console.Output("ERROR: {0} is not a valid uuid", null, rawUuid); + console.Output("ERROR: {0} is not a valid uuid", rawUuid); return false; } @@ -110,7 +110,7 @@ namespace OpenSim.Framework.Console if (!uint.TryParse(rawLocalId, out localId)) { if (console != null) - console.Output("ERROR: {0} is not a valid local id", null, localId); + console.Output("ERROR: {0} is not a valid local id", localId); return false; } @@ -118,7 +118,7 @@ namespace OpenSim.Framework.Console if (localId == 0) { if (console != null) - console.Output("ERROR: {0} is not a valid local id - it must be greater than 0", null, localId); + console.Output("ERROR: {0} is not a valid local id - it must be greater than 0", localId); return false; } @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Console } if (console != null) - console.Output("ERROR: {0} is not a valid UUID or local id", null, rawId); + console.Output("ERROR: {0} is not a valid UUID or local id", rawId); return false; } @@ -167,7 +167,7 @@ namespace OpenSim.Framework.Console if (!bool.TryParse(rawConsoleString, out b)) { if (console != null) - console.Output("ERROR: {0} is not a true or false value", null, rawConsoleString); + console.Output("ERROR: {0} is not a true or false value", rawConsoleString); return false; } @@ -187,7 +187,7 @@ namespace OpenSim.Framework.Console if (!int.TryParse(rawConsoleInt, out i)) { if (console != null) - console.Output("ERROR: {0} is not a valid integer", null, rawConsoleInt); + console.Output("ERROR: {0} is not a valid integer", rawConsoleInt); return false; } @@ -207,7 +207,7 @@ namespace OpenSim.Framework.Console if (!float.TryParse(rawConsoleInput, out i)) { if (console != null) - console.Output("ERROR: {0} is not a valid float", null, rawConsoleInput); + console.Output("ERROR: {0} is not a valid float", rawConsoleInput); return false; } @@ -227,7 +227,7 @@ namespace OpenSim.Framework.Console if (!double.TryParse(rawConsoleInput, out i)) { if (console != null) - console.Output("ERROR: {0} is not a valid double", null, rawConsoleInput); + console.Output("ERROR: {0} is not a valid double", rawConsoleInput); return false; } @@ -249,7 +249,7 @@ namespace OpenSim.Framework.Console if (i < 0) { if (console != null) - console.Output("ERROR: {0} is not a positive integer", null, rawConsoleInt); + console.Output("ERROR: {0} is not a positive integer", rawConsoleInt); return false; } -- cgit v1.1 From be6080c3c822707d152ccecc2e6fbe83ca1d5ba5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 24 Oct 2019 17:07:59 +0100 Subject: partial revert console Prompt code to fix it --- OpenSim/Framework/Console/ConsoleBase.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index f9dfb63..75dbe11 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -121,17 +121,38 @@ namespace OpenSim.Framework.Console public string Prompt(string p) { - return Prompt(p, null, null, true); + return ReadLine(String.Format("{0}: ", p), false, true); } public string Prompt(string p, string def) { - return Prompt(p, def, null, true); + string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); + if (ret == String.Empty) + ret = def; + + return ret; } public string Prompt(string p, List excludedCharacters) { - return Prompt(p, null, excludedCharacters, true); + bool itisdone = false; + string ret = String.Empty; + while (!itisdone) + { + itisdone = true; + ret = Prompt(p); + + foreach (char c in excludedCharacters) + { + if (ret.Contains(c.ToString())) + { + System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); + itisdone = false; + } + } + } + + return ret; } public virtual string Prompt(string p, string def, List excludedCharacters, bool echo = true) @@ -142,6 +163,8 @@ namespace OpenSim.Framework.Console { itisdone = true; + ret = Prompt(p, def); + if (def != null) ret = ReadLine(String.Format("{0}: ", p), false, echo); else -- cgit v1.1 From bf2e0f77376b179edda608e9fd7b0e9738c83bb6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 24 Oct 2019 17:30:24 +0100 Subject: oops, dont ask things twice --- OpenSim/Framework/Console/ConsoleBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 75dbe11..8748b25 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -163,9 +163,7 @@ namespace OpenSim.Framework.Console { itisdone = true; - ret = Prompt(p, def); - - if (def != null) + if (def == null) ret = ReadLine(String.Format("{0}: ", p), false, echo); else ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, echo); -- cgit v1.1 From dcfd54b7608093d509cd045a152a4cde7317f66f Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 8 Sep 2020 21:17:45 +1000 Subject: Move various paths out of the bin directory. --- OpenSim/Framework/Console/LocalConsole.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index e1492b8..f84d21c 100755 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -96,9 +96,9 @@ namespace OpenSim.Framework.Console return; } - string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt"); + string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", Path.Combine(Util.logsDir(), "OpenSimConsoleHistory.txt")); int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); - m_historyPath = Path.GetFullPath(Path.Combine(Util.configDir(), m_historyFile)); + m_historyPath = Path.GetFullPath(m_historyFile); m_historytimestamps = startupConfig.GetBoolean("ConsoleHistoryTimeStamp", false); m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1} {2} timestamps", m_historySize, m_historyPath, m_historytimestamps?"with":"without"); -- cgit v1.1 From 237659ba30a2d6a072aae989252a1e6be0423c3c Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 9 Sep 2020 00:52:35 +1000 Subject: Remove useless executable bit that Windows adds. --- OpenSim/Framework/Console/CommandConsole.cs | 0 OpenSim/Framework/Console/ConsoleBase.cs | 0 OpenSim/Framework/Console/ConsolePluginCommand.cs | 0 OpenSim/Framework/Console/ConsoleUtil.cs | 0 OpenSim/Framework/Console/LocalConsole.cs | 0 OpenSim/Framework/Console/MockConsole.cs | 0 OpenSim/Framework/Console/RemoteConsole.cs | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 OpenSim/Framework/Console/CommandConsole.cs mode change 100755 => 100644 OpenSim/Framework/Console/ConsoleBase.cs mode change 100755 => 100644 OpenSim/Framework/Console/ConsolePluginCommand.cs mode change 100755 => 100644 OpenSim/Framework/Console/ConsoleUtil.cs mode change 100755 => 100644 OpenSim/Framework/Console/LocalConsole.cs mode change 100755 => 100644 OpenSim/Framework/Console/MockConsole.cs mode change 100755 => 100644 OpenSim/Framework/Console/RemoteConsole.cs (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs old mode 100755 new mode 100644 diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs old mode 100755 new mode 100644 diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs old mode 100755 new mode 100644 diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs old mode 100755 new mode 100644 diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs old mode 100755 new mode 100644 diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs old mode 100755 new mode 100644 diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs old mode 100755 new mode 100644 -- cgit v1.1 From 05852eaad72e24fee0ff2badf595037c7fd6e13f Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 9 Sep 2020 22:10:21 +1000 Subject: Use F1 instead of ? as the in command help key. "?" was a silly choice, what if you wanted to use it in a command? Alas this doesn't seem to work, but at least you can type "?" now. --- OpenSim/Framework/Console/LocalConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index f84d21c..39351e1 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -494,7 +494,7 @@ namespace OpenSim.Framework.Console if (m_cursorXPosition >= 318) continue; - if (enteredChar == '?' && isCommand) + if (key.Key == ConsoleKey.F1 && isCommand) { if (ContextHelp()) continue; -- cgit v1.1