diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Console/CommandConsole.cs | 40 | ||||
-rwxr-xr-x | OpenSim/Framework/Console/ConsoleBase.cs | 8 | ||||
-rw-r--r-- | OpenSim/Framework/Console/ConsoleUtil.cs | 22 | ||||
-rw-r--r-- | OpenSim/Framework/Console/LocalConsole.cs | 22 | ||||
-rw-r--r-- | OpenSim/Framework/Console/MockConsole.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Console/RemoteConsole.cs | 400 |
6 files changed, 248 insertions, 248 deletions
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 | |||
52 | /// The module from which this command comes | 52 | /// The module from which this command comes |
53 | /// </value> | 53 | /// </value> |
54 | public string module; | 54 | public string module; |
55 | 55 | ||
56 | /// <value> | 56 | /// <value> |
57 | /// Whether the module is shared | 57 | /// Whether the module is shared |
58 | /// </value> | 58 | /// </value> |
59 | public bool shared; | 59 | public bool shared; |
60 | 60 | ||
61 | /// <value> | 61 | /// <value> |
62 | /// Very short BNF description | 62 | /// Very short BNF description |
63 | /// </value> | 63 | /// </value> |
64 | public string help_text; | 64 | public string help_text; |
65 | 65 | ||
66 | /// <value> | 66 | /// <value> |
67 | /// Longer one line help text | 67 | /// Longer one line help text |
68 | /// </value> | 68 | /// </value> |
69 | public string long_help; | 69 | public string long_help; |
70 | 70 | ||
71 | /// <value> | 71 | /// <value> |
72 | /// Full descriptive help for this command | 72 | /// Full descriptive help for this command |
73 | /// </value> | 73 | /// </value> |
74 | public string descriptive_help; | 74 | public string descriptive_help; |
75 | 75 | ||
76 | /// <value> | 76 | /// <value> |
77 | /// The method to invoke for this command | 77 | /// The method to invoke for this command |
78 | /// </value> | 78 | /// </value> |
@@ -106,7 +106,7 @@ namespace OpenSim.Framework.Console | |||
106 | { | 106 | { |
107 | List<string> help = new List<string>(); | 107 | List<string> help = new List<string>(); |
108 | List<string> helpParts = new List<string>(cmd); | 108 | List<string> helpParts = new List<string>(cmd); |
109 | 109 | ||
110 | // Remove initial help keyword | 110 | // Remove initial help keyword |
111 | helpParts.RemoveAt(0); | 111 | helpParts.RemoveAt(0); |
112 | 112 | ||
@@ -154,7 +154,7 @@ namespace OpenSim.Framework.Console | |||
154 | 154 | ||
155 | return help; | 155 | return help; |
156 | } | 156 | } |
157 | 157 | ||
158 | /// <summary> | 158 | /// <summary> |
159 | /// See if we can find the requested command in order to display longer help | 159 | /// See if we can find the requested command in order to display longer help |
160 | /// </summary> | 160 | /// </summary> |
@@ -171,23 +171,23 @@ namespace OpenSim.Framework.Console | |||
171 | help.Insert(0, ItemHelpText); | 171 | help.Insert(0, ItemHelpText); |
172 | return help; | 172 | return help; |
173 | } | 173 | } |
174 | 174 | ||
175 | Dictionary<string, object> dict = tree; | 175 | Dictionary<string, object> dict = tree; |
176 | while (helpParts.Count > 0) | 176 | while (helpParts.Count > 0) |
177 | { | 177 | { |
178 | string helpPart = helpParts[0]; | 178 | string helpPart = helpParts[0]; |
179 | 179 | ||
180 | if (!dict.ContainsKey(helpPart)) | 180 | if (!dict.ContainsKey(helpPart)) |
181 | break; | 181 | break; |
182 | 182 | ||
183 | //m_log.Debug("Found {0}", helpParts[0]); | 183 | //m_log.Debug("Found {0}", helpParts[0]); |
184 | 184 | ||
185 | if (dict[helpPart] is Dictionary<string, Object>) | 185 | if (dict[helpPart] is Dictionary<string, Object>) |
186 | dict = (Dictionary<string, object>)dict[helpPart]; | 186 | dict = (Dictionary<string, object>)dict[helpPart]; |
187 | 187 | ||
188 | helpParts.RemoveAt(0); | 188 | helpParts.RemoveAt(0); |
189 | } | 189 | } |
190 | 190 | ||
191 | // There was a command for the given help string | 191 | // There was a command for the given help string |
192 | if (dict.ContainsKey(String.Empty)) | 192 | if (dict.ContainsKey(String.Empty)) |
193 | { | 193 | { |
@@ -200,14 +200,14 @@ namespace OpenSim.Framework.Console | |||
200 | // If we do have some descriptive help then insert a spacing line before for readability. | 200 | // If we do have some descriptive help then insert a spacing line before for readability. |
201 | if (descriptiveHelp != string.Empty) | 201 | if (descriptiveHelp != string.Empty) |
202 | help.Add(string.Empty); | 202 | help.Add(string.Empty); |
203 | 203 | ||
204 | help.Add(commandInfo.descriptive_help); | 204 | help.Add(commandInfo.descriptive_help); |
205 | } | 205 | } |
206 | else | 206 | else |
207 | { | 207 | { |
208 | help.Add(string.Format("No help is available for {0}", originalHelpRequest)); | 208 | help.Add(string.Format("No help is available for {0}", originalHelpRequest)); |
209 | } | 209 | } |
210 | 210 | ||
211 | return help; | 211 | return help; |
212 | } | 212 | } |
213 | 213 | ||
@@ -268,7 +268,7 @@ namespace OpenSim.Framework.Console | |||
268 | // } | 268 | // } |
269 | // return result; | 269 | // return result; |
270 | // } | 270 | // } |
271 | 271 | ||
272 | /// <summary> | 272 | /// <summary> |
273 | /// Add a command to those which can be invoked from the console. | 273 | /// Add a command to those which can be invoked from the console. |
274 | /// </summary> | 274 | /// </summary> |
@@ -299,7 +299,7 @@ namespace OpenSim.Framework.Console | |||
299 | string[] parts = Parser.Parse(command); | 299 | string[] parts = Parser.Parse(command); |
300 | 300 | ||
301 | Dictionary<string, Object> current = tree; | 301 | Dictionary<string, Object> current = tree; |
302 | 302 | ||
303 | foreach (string part in parts) | 303 | foreach (string part in parts) |
304 | { | 304 | { |
305 | if (current.ContainsKey(part)) | 305 | if (current.ContainsKey(part)) |
@@ -326,7 +326,7 @@ namespace OpenSim.Framework.Console | |||
326 | 326 | ||
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | info = new CommandInfo(); | 330 | info = new CommandInfo(); |
331 | info.module = module; | 331 | info.module = module; |
332 | info.shared = shared; | 332 | info.shared = shared; |
@@ -471,7 +471,7 @@ namespace OpenSim.Framework.Console | |||
471 | 471 | ||
472 | return null; | 472 | return null; |
473 | } | 473 | } |
474 | 474 | ||
475 | public bool HasCommand(string command) | 475 | public bool HasCommand(string command) |
476 | { | 476 | { |
477 | string[] result; | 477 | 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 | |||
67 | { | 67 | { |
68 | System.Console.WriteLine(text); | 68 | System.Console.WriteLine(text); |
69 | } | 69 | } |
70 | 70 | ||
71 | public virtual void OutputFormat(string format, params object[] components) | 71 | public virtual void OutputFormat(string format, params object[] components) |
72 | { | 72 | { |
73 | Output(string.Format(format, components)); | 73 | Output(string.Format(format, components)); |
@@ -86,7 +86,7 @@ namespace OpenSim.Framework.Console | |||
86 | 86 | ||
87 | return ret; | 87 | return ret; |
88 | } | 88 | } |
89 | 89 | ||
90 | public string CmdPrompt(string p, List<char> excludedCharacters) | 90 | public string CmdPrompt(string p, List<char> excludedCharacters) |
91 | { | 91 | { |
92 | bool itisdone = false; | 92 | bool itisdone = false; |
@@ -95,7 +95,7 @@ namespace OpenSim.Framework.Console | |||
95 | { | 95 | { |
96 | itisdone = true; | 96 | itisdone = true; |
97 | ret = CmdPrompt(p); | 97 | ret = CmdPrompt(p); |
98 | 98 | ||
99 | foreach (char c in excludedCharacters) | 99 | foreach (char c in excludedCharacters) |
100 | { | 100 | { |
101 | if (ret.Contains(c.ToString())) | 101 | if (ret.Contains(c.ToString())) |
@@ -117,7 +117,7 @@ namespace OpenSim.Framework.Console | |||
117 | { | 117 | { |
118 | itisdone = true; | 118 | itisdone = true; |
119 | ret = CmdPrompt(p, def); | 119 | ret = CmdPrompt(p, def); |
120 | 120 | ||
121 | if (ret == String.Empty) | 121 | if (ret == String.Empty) |
122 | { | 122 | { |
123 | ret = def; | 123 | 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 | |||
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | public const int LocalIdNotFound = 0; | 42 | public const int LocalIdNotFound = 0; |
43 | 43 | ||
44 | /// <summary> | 44 | /// <summary> |
45 | /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section | 45 | /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section |
46 | /// rather than in each help summary. | 46 | /// rather than in each help summary. |
@@ -57,10 +57,10 @@ namespace OpenSim.Framework.Console | |||
57 | show object pos ,20,20 to ,40,40 | 57 | show object pos ,20,20 to ,40,40 |
58 | delete object pos ,,30 to ,,~ | 58 | delete object pos ,,30 to ,,~ |
59 | show object pos ,,-~ to ,,30"; | 59 | show object pos ,,-~ to ,,30"; |
60 | 60 | ||
61 | public const string MinRawConsoleVectorValue = "-~"; | 61 | public const string MinRawConsoleVectorValue = "-~"; |
62 | public const string MaxRawConsoleVectorValue = "~"; | 62 | public const string MaxRawConsoleVectorValue = "~"; |
63 | 63 | ||
64 | public const string VectorSeparator = ","; | 64 | public const string VectorSeparator = ","; |
65 | public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); | 65 | public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); |
66 | 66 | ||
@@ -81,7 +81,7 @@ namespace OpenSim.Framework.Console | |||
81 | 81 | ||
82 | return true; | 82 | return true; |
83 | } | 83 | } |
84 | 84 | ||
85 | /// <summary> | 85 | /// <summary> |
86 | /// Try to parse a console UUID from the console. | 86 | /// Try to parse a console UUID from the console. |
87 | /// </summary> | 87 | /// </summary> |
@@ -101,7 +101,7 @@ namespace OpenSim.Framework.Console | |||
101 | 101 | ||
102 | return false; | 102 | return false; |
103 | } | 103 | } |
104 | 104 | ||
105 | return true; | 105 | return true; |
106 | } | 106 | } |
107 | 107 | ||
@@ -259,7 +259,7 @@ namespace OpenSim.Framework.Console | |||
259 | 259 | ||
260 | return false; | 260 | return false; |
261 | } | 261 | } |
262 | 262 | ||
263 | /// <summary> | 263 | /// <summary> |
264 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | 264 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 |
265 | /// </summary> | 265 | /// </summary> |
@@ -270,7 +270,7 @@ namespace OpenSim.Framework.Console | |||
270 | { | 270 | { |
271 | return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); | 271 | return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); |
272 | } | 272 | } |
273 | 273 | ||
274 | /// <summary> | 274 | /// <summary> |
275 | /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 | 275 | /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 |
276 | /// </summary> | 276 | /// </summary> |
@@ -281,7 +281,7 @@ namespace OpenSim.Framework.Console | |||
281 | { | 281 | { |
282 | return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); | 282 | return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); |
283 | } | 283 | } |
284 | 284 | ||
285 | /// <summary> | 285 | /// <summary> |
286 | /// Convert a vector input from the console to an OpenMetaverse.Vector3 | 286 | /// Convert a vector input from the console to an OpenMetaverse.Vector3 |
287 | /// </summary> | 287 | /// </summary> |
@@ -354,10 +354,10 @@ namespace OpenSim.Framework.Console | |||
354 | string rawConsoleVector, int dimensions, Func<string, string> blankComponentFunc) | 354 | string rawConsoleVector, int dimensions, Func<string, string> blankComponentFunc) |
355 | { | 355 | { |
356 | List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); | 356 | List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); |
357 | 357 | ||
358 | if (components.Count < 1 || components.Count > dimensions) | 358 | if (components.Count < 1 || components.Count > dimensions) |
359 | return null; | 359 | return null; |
360 | 360 | ||
361 | if (components.Count < dimensions) | 361 | if (components.Count < dimensions) |
362 | { | 362 | { |
363 | if (blankComponentFunc == null) | 363 | if (blankComponentFunc == null) |
@@ -380,7 +380,7 @@ namespace OpenSim.Framework.Console | |||
380 | else | 380 | else |
381 | return c; | 381 | return c; |
382 | }); | 382 | }); |
383 | 383 | ||
384 | return string.Join(VectorSeparator, cookedComponents.ToArray()); | 384 | return string.Join(VectorSeparator, cookedComponents.ToArray()); |
385 | } | 385 | } |
386 | } | 386 | } |
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 | |||
51 | private const string LOGLEVEL_NONE = "(none)"; | 51 | private const string LOGLEVEL_NONE = "(none)"; |
52 | 52 | ||
53 | // Used to extract categories for colourization. | 53 | // Used to extract categories for colourization. |
54 | private Regex m_categoryRegex | 54 | private Regex m_categoryRegex |
55 | = new Regex( | 55 | = new Regex( |
56 | @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled); | 56 | @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled); |
57 | 57 | ||
@@ -167,15 +167,15 @@ namespace OpenSim.Framework.Console | |||
167 | { | 167 | { |
168 | System.Console.CursorLeft = 0; | 168 | System.Console.CursorLeft = 0; |
169 | } | 169 | } |
170 | else | 170 | else |
171 | { | 171 | { |
172 | int bufferWidth = System.Console.BufferWidth; | 172 | int bufferWidth = System.Console.BufferWidth; |
173 | 173 | ||
174 | // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) | 174 | // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) |
175 | if (bufferWidth > 0 && left >= bufferWidth) | 175 | if (bufferWidth > 0 && left >= bufferWidth) |
176 | System.Console.CursorLeft = bufferWidth - 1; | 176 | System.Console.CursorLeft = bufferWidth - 1; |
177 | } | 177 | } |
178 | 178 | ||
179 | if (top < 0) | 179 | if (top < 0) |
180 | { | 180 | { |
181 | top = 0; | 181 | top = 0; |
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Console | |||
183 | else | 183 | else |
184 | { | 184 | { |
185 | int bufferHeight = System.Console.BufferHeight; | 185 | int bufferHeight = System.Console.BufferHeight; |
186 | 186 | ||
187 | // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) | 187 | // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) |
188 | if (bufferHeight > 0 && top >= bufferHeight) | 188 | if (bufferHeight > 0 && top >= bufferHeight) |
189 | top = bufferHeight - 1; | 189 | top = bufferHeight - 1; |
@@ -216,14 +216,14 @@ namespace OpenSim.Framework.Console | |||
216 | { | 216 | { |
217 | System.Console.CursorTop = 0; | 217 | System.Console.CursorTop = 0; |
218 | } | 218 | } |
219 | else | 219 | else |
220 | { | 220 | { |
221 | int bufferHeight = System.Console.BufferHeight; | 221 | int bufferHeight = System.Console.BufferHeight; |
222 | // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) | 222 | // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) |
223 | if (bufferHeight > 0 && top >= bufferHeight) | 223 | if (bufferHeight > 0 && top >= bufferHeight) |
224 | System.Console.CursorTop = bufferHeight - 1; | 224 | System.Console.CursorTop = bufferHeight - 1; |
225 | } | 225 | } |
226 | 226 | ||
227 | if (left < 0) | 227 | if (left < 0) |
228 | { | 228 | { |
229 | left = 0; | 229 | left = 0; |
@@ -339,7 +339,7 @@ namespace OpenSim.Framework.Console | |||
339 | string outText = text; | 339 | string outText = text; |
340 | 340 | ||
341 | if (level != LOGLEVEL_NONE) | 341 | if (level != LOGLEVEL_NONE) |
342 | { | 342 | { |
343 | MatchCollection matches = m_categoryRegex.Matches(text); | 343 | MatchCollection matches = m_categoryRegex.Matches(text); |
344 | 344 | ||
345 | if (matches.Count == 1) | 345 | if (matches.Count == 1) |
@@ -364,7 +364,7 @@ namespace OpenSim.Framework.Console | |||
364 | WriteColorText(ConsoleColor.Yellow, outText); | 364 | WriteColorText(ConsoleColor.Yellow, outText); |
365 | else | 365 | else |
366 | System.Console.Write(outText); | 366 | System.Console.Write(outText); |
367 | 367 | ||
368 | System.Console.WriteLine(); | 368 | System.Console.WriteLine(); |
369 | } | 369 | } |
370 | 370 | ||
@@ -551,7 +551,7 @@ namespace OpenSim.Framework.Console | |||
551 | } | 551 | } |
552 | 552 | ||
553 | string commandLine = m_commandLine.ToString(); | 553 | string commandLine = m_commandLine.ToString(); |
554 | 554 | ||
555 | if (isCommand) | 555 | if (isCommand) |
556 | { | 556 | { |
557 | string[] cmd = Commands.Resolve(Parser.Parse(commandLine)); | 557 | string[] cmd = Commands.Resolve(Parser.Parse(commandLine)); |
@@ -573,7 +573,7 @@ namespace OpenSim.Framework.Console | |||
573 | // If we're not echoing to screen (e.g. a password) then we probably don't want it in history | 573 | // If we're not echoing to screen (e.g. a password) then we probably don't want it in history |
574 | if (m_echo && commandLine != "") | 574 | if (m_echo && commandLine != "") |
575 | AddToHistory(commandLine); | 575 | AddToHistory(commandLine); |
576 | 576 | ||
577 | return commandLine; | 577 | return commandLine; |
578 | default: | 578 | default: |
579 | break; | 579 | 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 | |||
35 | { | 35 | { |
36 | /// <summary> | 36 | /// <summary> |
37 | /// This is a Fake console that's used when setting up the Scene in Unit Tests | 37 | /// This is a Fake console that's used when setting up the Scene in Unit Tests |
38 | /// Don't use this except for Unit Testing or you're in for a world of hurt when the | 38 | /// Don't use this except for Unit Testing or you're in for a world of hurt when the |
39 | /// sim gets to ReadLine | 39 | /// sim gets to ReadLine |
40 | /// </summary> | 40 | /// </summary> |
41 | public class MockConsole : ICommandConsole | 41 | public class MockConsole : ICommandConsole |
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Console | |||
56 | 56 | ||
57 | public string ReadLine(string p, bool isCommand, bool e) { return ""; } | 57 | public string ReadLine(string p, bool isCommand, bool e) { return ""; } |
58 | 58 | ||
59 | public object ConsoleScene { | 59 | public object ConsoleScene { |
60 | get { return null; } | 60 | get { return null; } |
61 | set {} | 61 | set {} |
62 | } | 62 | } |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index b9c7537..ddd9578 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -46,93 +46,93 @@ namespace OpenSim.Framework.Console | |||
46 | // | 46 | // |
47 | public class RemoteConsole : CommandConsole | 47 | public class RemoteConsole : CommandConsole |
48 | { | 48 | { |
49 | // Connection specific data, indexed by a session ID | 49 | // Connection specific data, indexed by a session ID |
50 | // we create when a client connects. | 50 | // we create when a client connects. |
51 | protected class ConsoleConnection | 51 | protected class ConsoleConnection |
52 | { | 52 | { |
53 | // Last activity from the client | 53 | // Last activity from the client |
54 | public int last; | 54 | public int last; |
55 | 55 | ||
56 | // Last line of scrollback posted to this client | 56 | // Last line of scrollback posted to this client |
57 | public long lastLineSeen; | 57 | public long lastLineSeen; |
58 | 58 | ||
59 | // True if this is a new connection, e.g. has never | 59 | // True if this is a new connection, e.g. has never |
60 | // displayed a prompt to the user. | 60 | // displayed a prompt to the user. |
61 | public bool newConnection = true; | 61 | public bool newConnection = true; |
62 | } | 62 | } |
63 | 63 | ||
64 | // A line in the scrollback buffer. | 64 | // A line in the scrollback buffer. |
65 | protected class ScrollbackEntry | 65 | protected class ScrollbackEntry |
66 | { | 66 | { |
67 | // The line number of this entry | 67 | // The line number of this entry |
68 | public long lineNumber; | 68 | public long lineNumber; |
69 | 69 | ||
70 | // The text to send to the client | 70 | // The text to send to the client |
71 | public string text; | 71 | public string text; |
72 | 72 | ||
73 | // The level this should be logged as. Omitted for | 73 | // The level this should be logged as. Omitted for |
74 | // prompts and input echo. | 74 | // prompts and input echo. |
75 | public string level; | 75 | public string level; |
76 | 76 | ||
77 | // True if the text above is a prompt, e.g. the | 77 | // True if the text above is a prompt, e.g. the |
78 | // client should turn on the cursor / accept input | 78 | // client should turn on the cursor / accept input |
79 | public bool isPrompt; | 79 | public bool isPrompt; |
80 | 80 | ||
81 | // True if the requested input is a command. A | 81 | // True if the requested input is a command. A |
82 | // client may offer help or validate input if | 82 | // client may offer help or validate input if |
83 | // this is set. If false, input should be sent | 83 | // this is set. If false, input should be sent |
84 | // as typed. | 84 | // as typed. |
85 | public bool isCommand; | 85 | public bool isCommand; |
86 | 86 | ||
87 | // True if this text represents a line of text that | 87 | // True if this text represents a line of text that |
88 | // was input in response to a prompt. A client should | 88 | // was input in response to a prompt. A client should |
89 | // turn off the cursor and refrain from sending commands | 89 | // turn off the cursor and refrain from sending commands |
90 | // until a new prompt is received. | 90 | // until a new prompt is received. |
91 | public bool isInput; | 91 | public bool isInput; |
92 | } | 92 | } |
93 | 93 | ||
94 | // Data that is relevant to all connections | 94 | // Data that is relevant to all connections |
95 | 95 | ||
96 | // The scrollback buffer | 96 | // The scrollback buffer |
97 | protected List<ScrollbackEntry> m_Scrollback = new List<ScrollbackEntry>(); | 97 | protected List<ScrollbackEntry> m_Scrollback = new List<ScrollbackEntry>(); |
98 | 98 | ||
99 | // Monotonously incrementing line number. This may eventually | 99 | // Monotonously incrementing line number. This may eventually |
100 | // wrap. No provision is made for that case because 64 bits | 100 | // wrap. No provision is made for that case because 64 bits |
101 | // is a long, long time. | 101 | // is a long, long time. |
102 | protected long m_lineNumber = 0; | 102 | protected long m_lineNumber = 0; |
103 | 103 | ||
104 | // These two variables allow us to send the correct | 104 | // These two variables allow us to send the correct |
105 | // information about the prompt status to the client, | 105 | // information about the prompt status to the client, |
106 | // irrespective of what may have run off the top of the | 106 | // irrespective of what may have run off the top of the |
107 | // scrollback buffer; | 107 | // scrollback buffer; |
108 | protected bool m_expectingInput = false; | 108 | protected bool m_expectingInput = false; |
109 | protected bool m_expectingCommand = true; | 109 | protected bool m_expectingCommand = true; |
110 | protected string m_lastPromptUsed; | 110 | protected string m_lastPromptUsed; |
111 | 111 | ||
112 | // This is the list of things received from clients. | 112 | // This is the list of things received from clients. |
113 | // Note: Race conditions can happen. If a client sends | 113 | // Note: Race conditions can happen. If a client sends |
114 | // something while nothing is expected, it will be | 114 | // something while nothing is expected, it will be |
115 | // intepreted as input to the next prompt. For | 115 | // intepreted as input to the next prompt. For |
116 | // commands this is largely correct. For other prompts, | 116 | // commands this is largely correct. For other prompts, |
117 | // YMMV. | 117 | // YMMV. |
118 | // TODO: Find a better way to fix this | 118 | // TODO: Find a better way to fix this |
119 | protected List<string> m_InputData = new List<string>(); | 119 | protected List<string> m_InputData = new List<string>(); |
120 | 120 | ||
121 | // Event to allow ReadLine to wait synchronously even though | 121 | // Event to allow ReadLine to wait synchronously even though |
122 | // everthing else is asynchronous here. | 122 | // everthing else is asynchronous here. |
123 | protected ManualResetEvent m_DataEvent = new ManualResetEvent(false); | 123 | protected ManualResetEvent m_DataEvent = new ManualResetEvent(false); |
124 | 124 | ||
125 | // The list of sessions we maintain. Unlike other console types, | 125 | // The list of sessions we maintain. Unlike other console types, |
126 | // multiple users on the same console are explicitly allowed. | 126 | // multiple users on the same console are explicitly allowed. |
127 | protected Dictionary<UUID, ConsoleConnection> m_Connections = | 127 | protected Dictionary<UUID, ConsoleConnection> m_Connections = |
128 | new Dictionary<UUID, ConsoleConnection>(); | 128 | new Dictionary<UUID, ConsoleConnection>(); |
129 | 129 | ||
130 | // Timer to control expiration of sessions that have been | 130 | // Timer to control expiration of sessions that have been |
131 | // disconnected. | 131 | // disconnected. |
132 | protected System.Timers.Timer m_expireTimer = new System.Timers.Timer(5000); | 132 | protected System.Timers.Timer m_expireTimer = new System.Timers.Timer(5000); |
133 | 133 | ||
134 | // The less interesting stuff that makes the actual server | 134 | // The less interesting stuff that makes the actual server |
135 | // work. | 135 | // work. |
136 | protected IHttpServer m_Server = null; | 136 | protected IHttpServer m_Server = null; |
137 | protected IConfigSource m_Config = null; | 137 | protected IConfigSource m_Config = null; |
138 | 138 | ||
@@ -143,130 +143,130 @@ namespace OpenSim.Framework.Console | |||
143 | 143 | ||
144 | public RemoteConsole(string defaultPrompt) : base(defaultPrompt) | 144 | public RemoteConsole(string defaultPrompt) : base(defaultPrompt) |
145 | { | 145 | { |
146 | // There is something wrong with this architecture. | 146 | // There is something wrong with this architecture. |
147 | // A prompt is sent on every single input, so why have this? | 147 | // A prompt is sent on every single input, so why have this? |
148 | // TODO: Investigate and fix. | 148 | // TODO: Investigate and fix. |
149 | m_lastPromptUsed = defaultPrompt; | 149 | m_lastPromptUsed = defaultPrompt; |
150 | 150 | ||
151 | // Start expiration of sesssions. | 151 | // Start expiration of sesssions. |
152 | m_expireTimer.Elapsed += DoExpire; | 152 | m_expireTimer.Elapsed += DoExpire; |
153 | m_expireTimer.Start(); | 153 | m_expireTimer.Start(); |
154 | } | 154 | } |
155 | 155 | ||
156 | public void ReadConfig(IConfigSource config) | 156 | public void ReadConfig(IConfigSource config) |
157 | { | 157 | { |
158 | m_Config = config; | 158 | m_Config = config; |
159 | 159 | ||
160 | // We're pulling this from the 'Network' section for legacy | 160 | // We're pulling this from the 'Network' section for legacy |
161 | // compatibility. However, this is so essentially insecure | 161 | // compatibility. However, this is so essentially insecure |
162 | // that TLS and client certs should be used instead of | 162 | // that TLS and client certs should be used instead of |
163 | // a username / password. | 163 | // a username / password. |
164 | IConfig netConfig = m_Config.Configs["Network"]; | 164 | IConfig netConfig = m_Config.Configs["Network"]; |
165 | 165 | ||
166 | if (netConfig == null) | 166 | if (netConfig == null) |
167 | return; | 167 | return; |
168 | 168 | ||
169 | // Get the username and password. | 169 | // Get the username and password. |
170 | m_UserName = netConfig.GetString("ConsoleUser", String.Empty); | 170 | m_UserName = netConfig.GetString("ConsoleUser", String.Empty); |
171 | m_Password = netConfig.GetString("ConsolePass", String.Empty); | 171 | m_Password = netConfig.GetString("ConsolePass", String.Empty); |
172 | 172 | ||
173 | // Woefully underdocumented, this is what makes javascript | 173 | // Woefully underdocumented, this is what makes javascript |
174 | // console clients work. Set to "*" for anywhere or (better) | 174 | // console clients work. Set to "*" for anywhere or (better) |
175 | // to specific addresses. | 175 | // to specific addresses. |
176 | m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty); | 176 | m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty); |
177 | } | 177 | } |
178 | 178 | ||
179 | public void SetServer(IHttpServer server) | 179 | public void SetServer(IHttpServer server) |
180 | { | 180 | { |
181 | // This is called by the framework to give us the server | 181 | // This is called by the framework to give us the server |
182 | // instance (means: port) to work with. | 182 | // instance (means: port) to work with. |
183 | m_Server = server; | 183 | m_Server = server; |
184 | 184 | ||
185 | // Add our handlers | 185 | // Add our handlers |
186 | m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession); | 186 | m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession); |
187 | m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession); | 187 | m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession); |
188 | m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); | 188 | m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); |
189 | } | 189 | } |
190 | 190 | ||
191 | public override void Output(string text, string level) | 191 | public override void Output(string text, string level) |
192 | { | 192 | { |
193 | Output(text, level, false, false, false); | 193 | Output(text, level, false, false, false); |
194 | } | 194 | } |
195 | 195 | ||
196 | protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) | 196 | protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) |
197 | { | 197 | { |
198 | // Increment the line number. It was 0 and they start at 1 | 198 | // Increment the line number. It was 0 and they start at 1 |
199 | // so we need to pre-increment. | 199 | // so we need to pre-increment. |
200 | m_lineNumber++; | 200 | m_lineNumber++; |
201 | 201 | ||
202 | // Create and populate the new entry. | 202 | // Create and populate the new entry. |
203 | ScrollbackEntry newEntry = new ScrollbackEntry(); | 203 | ScrollbackEntry newEntry = new ScrollbackEntry(); |
204 | 204 | ||
205 | newEntry.lineNumber = m_lineNumber; | 205 | newEntry.lineNumber = m_lineNumber; |
206 | newEntry.text = text; | 206 | newEntry.text = text; |
207 | newEntry.level = level; | 207 | newEntry.level = level; |
208 | newEntry.isPrompt = isPrompt; | 208 | newEntry.isPrompt = isPrompt; |
209 | newEntry.isCommand = isCommand; | 209 | newEntry.isCommand = isCommand; |
210 | newEntry.isInput = isInput; | 210 | newEntry.isInput = isInput; |
211 | 211 | ||
212 | // Add a line to the scrollback. In some cases, that may not | 212 | // Add a line to the scrollback. In some cases, that may not |
213 | // actually be a line of text. | 213 | // actually be a line of text. |
214 | lock (m_Scrollback) | 214 | lock (m_Scrollback) |
215 | { | 215 | { |
216 | // Prune the scrollback to the length se send as connect | 216 | // Prune the scrollback to the length se send as connect |
217 | // burst to give the user some context. | 217 | // burst to give the user some context. |
218 | while (m_Scrollback.Count >= 1000) | 218 | while (m_Scrollback.Count >= 1000) |
219 | m_Scrollback.RemoveAt(0); | 219 | m_Scrollback.RemoveAt(0); |
220 | 220 | ||
221 | m_Scrollback.Add(newEntry); | 221 | m_Scrollback.Add(newEntry); |
222 | } | 222 | } |
223 | 223 | ||
224 | // Let the rest of the system know we have output something. | 224 | // Let the rest of the system know we have output something. |
225 | FireOnOutput(text.Trim()); | 225 | FireOnOutput(text.Trim()); |
226 | 226 | ||
227 | // Also display it for debugging. | 227 | // Also display it for debugging. |
228 | System.Console.WriteLine(text.Trim()); | 228 | System.Console.WriteLine(text.Trim()); |
229 | } | 229 | } |
230 | 230 | ||
231 | public override void Output(string text) | 231 | public override void Output(string text) |
232 | { | 232 | { |
233 | // Output plain (non-logging style) text. | 233 | // Output plain (non-logging style) text. |
234 | Output(text, String.Empty, false, false, false); | 234 | Output(text, String.Empty, false, false, false); |
235 | } | 235 | } |
236 | 236 | ||
237 | public override string ReadLine(string p, bool isCommand, bool e) | 237 | public override string ReadLine(string p, bool isCommand, bool e) |
238 | { | 238 | { |
239 | // Output the prompt an prepare to wait. This | 239 | // Output the prompt an prepare to wait. This |
240 | // is called on a dedicated console thread and | 240 | // is called on a dedicated console thread and |
241 | // needs to be synchronous. Old architecture but | 241 | // needs to be synchronous. Old architecture but |
242 | // not worth upgrading. | 242 | // not worth upgrading. |
243 | if (isCommand) | 243 | if (isCommand) |
244 | { | 244 | { |
245 | m_expectingInput = true; | 245 | m_expectingInput = true; |
246 | m_expectingCommand = true; | 246 | m_expectingCommand = true; |
247 | Output(p, String.Empty, true, true, false); | 247 | Output(p, String.Empty, true, true, false); |
248 | m_lastPromptUsed = p; | 248 | m_lastPromptUsed = p; |
249 | } | 249 | } |
250 | else | 250 | else |
251 | { | 251 | { |
252 | m_expectingInput = true; | 252 | m_expectingInput = true; |
253 | Output(p, String.Empty, true, false, false); | 253 | Output(p, String.Empty, true, false, false); |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | // Here is where we wait for the user to input something. | 257 | // Here is where we wait for the user to input something. |
258 | m_DataEvent.WaitOne(); | 258 | m_DataEvent.WaitOne(); |
259 | 259 | ||
260 | string cmdinput; | 260 | string cmdinput; |
261 | 261 | ||
262 | // Check for empty input. Read input if not empty. | 262 | // Check for empty input. Read input if not empty. |
263 | lock (m_InputData) | 263 | lock (m_InputData) |
264 | { | 264 | { |
265 | if (m_InputData.Count == 0) | 265 | if (m_InputData.Count == 0) |
266 | { | 266 | { |
267 | m_DataEvent.Reset(); | 267 | m_DataEvent.Reset(); |
268 | m_expectingInput = false; | 268 | m_expectingInput = false; |
269 | m_expectingCommand = false; | 269 | m_expectingCommand = false; |
270 | 270 | ||
271 | return ""; | 271 | return ""; |
272 | } | 272 | } |
@@ -278,19 +278,19 @@ namespace OpenSim.Framework.Console | |||
278 | 278 | ||
279 | } | 279 | } |
280 | 280 | ||
281 | m_expectingInput = false; | 281 | m_expectingInput = false; |
282 | m_expectingCommand = false; | 282 | m_expectingCommand = false; |
283 | 283 | ||
284 | // Echo to all the other users what we have done. This | 284 | // Echo to all the other users what we have done. This |
285 | // will also go to ourselves. | 285 | // will also go to ourselves. |
286 | Output (cmdinput, String.Empty, false, false, true); | 286 | Output (cmdinput, String.Empty, false, false, true); |
287 | 287 | ||
288 | // If this is a command, we need to resolve and execute it. | 288 | // If this is a command, we need to resolve and execute it. |
289 | if (isCommand) | 289 | if (isCommand) |
290 | { | 290 | { |
291 | // This call will actually execute the command and create | 291 | // This call will actually execute the command and create |
292 | // any output associated with it. The core just gets an | 292 | // any output associated with it. The core just gets an |
293 | // empty string so it will call again immediately. | 293 | // empty string so it will call again immediately. |
294 | string[] cmd = Commands.Resolve(Parser.Parse(cmdinput)); | 294 | string[] cmd = Commands.Resolve(Parser.Parse(cmdinput)); |
295 | 295 | ||
296 | if (cmd.Length != 0) | 296 | if (cmd.Length != 0) |
@@ -306,11 +306,11 @@ namespace OpenSim.Framework.Console | |||
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | // Return the raw input string if not a command. | 309 | // Return the raw input string if not a command. |
310 | return cmdinput; | 310 | return cmdinput; |
311 | } | 311 | } |
312 | 312 | ||
313 | // Very simplistic static access control header. | 313 | // Very simplistic static access control header. |
314 | protected Hashtable CheckOrigin(Hashtable result) | 314 | protected Hashtable CheckOrigin(Hashtable result) |
315 | { | 315 | { |
316 | if (!string.IsNullOrEmpty(m_AllowedOrigin)) | 316 | if (!string.IsNullOrEmpty(m_AllowedOrigin)) |
@@ -338,21 +338,21 @@ namespace OpenSim.Framework.Console | |||
338 | 338 | ||
339 | protected void DoExpire(Object sender, ElapsedEventArgs e) | 339 | protected void DoExpire(Object sender, ElapsedEventArgs e) |
340 | { | 340 | { |
341 | // Iterate the list of console connections and find those we | 341 | // Iterate the list of console connections and find those we |
342 | // haven't heard from for longer then the longpoll interval. | 342 | // haven't heard from for longer then the longpoll interval. |
343 | // Remove them. | 343 | // Remove them. |
344 | List<UUID> expired = new List<UUID>(); | 344 | List<UUID> expired = new List<UUID>(); |
345 | 345 | ||
346 | lock (m_Connections) | 346 | lock (m_Connections) |
347 | { | 347 | { |
348 | // Mark the expired ones | 348 | // Mark the expired ones |
349 | foreach (KeyValuePair<UUID, ConsoleConnection> kvp in m_Connections) | 349 | foreach (KeyValuePair<UUID, ConsoleConnection> kvp in m_Connections) |
350 | { | 350 | { |
351 | if (System.Environment.TickCount - kvp.Value.last > 500000) | 351 | if (System.Environment.TickCount - kvp.Value.last > 500000) |
352 | expired.Add(kvp.Key); | 352 | expired.Add(kvp.Key); |
353 | } | 353 | } |
354 | 354 | ||
355 | // Delete them | 355 | // Delete them |
356 | foreach (UUID id in expired) | 356 | foreach (UUID id in expired) |
357 | { | 357 | { |
358 | m_Connections.Remove(id); | 358 | m_Connections.Remove(id); |
@@ -361,10 +361,10 @@ namespace OpenSim.Framework.Console | |||
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | // Start a new session. | 364 | // Start a new session. |
365 | protected Hashtable HandleHttpStartSession(Hashtable request) | 365 | protected Hashtable HandleHttpStartSession(Hashtable request) |
366 | { | 366 | { |
367 | // The login is in the form of a http form post | 367 | // The login is in the form of a http form post |
368 | Hashtable post = DecodePostString(request["body"].ToString()); | 368 | Hashtable post = DecodePostString(request["body"].ToString()); |
369 | Hashtable reply = new Hashtable(); | 369 | Hashtable reply = new Hashtable(); |
370 | 370 | ||
@@ -372,7 +372,7 @@ namespace OpenSim.Framework.Console | |||
372 | reply["int_response_code"] = 401; | 372 | reply["int_response_code"] = 401; |
373 | reply["content_type"] = "text/plain"; | 373 | reply["content_type"] = "text/plain"; |
374 | 374 | ||
375 | // Check user name and password | 375 | // Check user name and password |
376 | if (m_UserName == String.Empty) | 376 | if (m_UserName == String.Empty) |
377 | return reply; | 377 | return reply; |
378 | 378 | ||
@@ -385,28 +385,28 @@ namespace OpenSim.Framework.Console | |||
385 | return reply; | 385 | return reply; |
386 | } | 386 | } |
387 | 387 | ||
388 | // Set up the new console connection record | 388 | // Set up the new console connection record |
389 | ConsoleConnection c = new ConsoleConnection(); | 389 | ConsoleConnection c = new ConsoleConnection(); |
390 | c.last = System.Environment.TickCount; | 390 | c.last = System.Environment.TickCount; |
391 | c.lastLineSeen = 0; | 391 | c.lastLineSeen = 0; |
392 | 392 | ||
393 | // Assign session ID | 393 | // Assign session ID |
394 | UUID sessionID = UUID.Random(); | 394 | UUID sessionID = UUID.Random(); |
395 | 395 | ||
396 | // Add connection to list. | 396 | // Add connection to list. |
397 | lock (m_Connections) | 397 | lock (m_Connections) |
398 | { | 398 | { |
399 | m_Connections[sessionID] = c; | 399 | m_Connections[sessionID] = c; |
400 | } | 400 | } |
401 | 401 | ||
402 | // This call is a CAP. The URL is the authentication. | 402 | // This call is a CAP. The URL is the authentication. |
403 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 403 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
404 | 404 | ||
405 | m_Server.AddPollServiceHTTPHandler( | 405 | m_Server.AddPollServiceHTTPHandler( |
406 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, null, sessionID,25000)); // 25 secs timeout | 406 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, null, sessionID,25000)); // 25 secs timeout |
407 | 407 | ||
408 | // Our reply is an XML document. | 408 | // Our reply is an XML document. |
409 | // TODO: Change this to Linq.Xml | 409 | // TODO: Change this to Linq.Xml |
410 | XmlDocument xmldoc = new XmlDocument(); | 410 | XmlDocument xmldoc = new XmlDocument(); |
411 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 411 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
412 | "", ""); | 412 | "", ""); |
@@ -429,7 +429,7 @@ namespace OpenSim.Framework.Console | |||
429 | 429 | ||
430 | rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc)); | 430 | rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc)); |
431 | 431 | ||
432 | // Set up the response and check origin | 432 | // Set up the response and check origin |
433 | reply["str_response_string"] = xmldoc.InnerXml; | 433 | reply["str_response_string"] = xmldoc.InnerXml; |
434 | reply["int_response_code"] = 200; | 434 | reply["int_response_code"] = 200; |
435 | reply["content_type"] = "text/xml"; | 435 | reply["content_type"] = "text/xml"; |
@@ -438,7 +438,7 @@ namespace OpenSim.Framework.Console | |||
438 | return reply; | 438 | return reply; |
439 | } | 439 | } |
440 | 440 | ||
441 | // Client closes session. Clean up. | 441 | // Client closes session. Clean up. |
442 | protected Hashtable HandleHttpCloseSession(Hashtable request) | 442 | protected Hashtable HandleHttpCloseSession(Hashtable request) |
443 | { | 443 | { |
444 | Hashtable post = DecodePostString(request["body"].ToString()); | 444 | Hashtable post = DecodePostString(request["body"].ToString()); |
@@ -487,7 +487,7 @@ namespace OpenSim.Framework.Console | |||
487 | return reply; | 487 | return reply; |
488 | } | 488 | } |
489 | 489 | ||
490 | // Command received from the client. | 490 | // Command received from the client. |
491 | protected Hashtable HandleHttpSessionCommand(Hashtable request) | 491 | protected Hashtable HandleHttpSessionCommand(Hashtable request) |
492 | { | 492 | { |
493 | Hashtable post = DecodePostString(request["body"].ToString()); | 493 | Hashtable post = DecodePostString(request["body"].ToString()); |
@@ -497,7 +497,7 @@ namespace OpenSim.Framework.Console | |||
497 | reply["int_response_code"] = 404; | 497 | reply["int_response_code"] = 404; |
498 | reply["content_type"] = "text/plain"; | 498 | reply["content_type"] = "text/plain"; |
499 | 499 | ||
500 | // Check the ID | 500 | // Check the ID |
501 | if (post["ID"] == null) | 501 | if (post["ID"] == null) |
502 | return reply; | 502 | return reply; |
503 | 503 | ||
@@ -505,25 +505,25 @@ namespace OpenSim.Framework.Console | |||
505 | if (!UUID.TryParse(post["ID"].ToString(), out id)) | 505 | if (!UUID.TryParse(post["ID"].ToString(), out id)) |
506 | return reply; | 506 | return reply; |
507 | 507 | ||
508 | // Find the connection for that ID. | 508 | // Find the connection for that ID. |
509 | lock (m_Connections) | 509 | lock (m_Connections) |
510 | { | 510 | { |
511 | if (!m_Connections.ContainsKey(id)) | 511 | if (!m_Connections.ContainsKey(id)) |
512 | return reply; | 512 | return reply; |
513 | } | 513 | } |
514 | 514 | ||
515 | // Empty post. Just error out. | 515 | // Empty post. Just error out. |
516 | if (post["COMMAND"] == null) | 516 | if (post["COMMAND"] == null) |
517 | return reply; | 517 | return reply; |
518 | 518 | ||
519 | // Place the input data in the buffer. | 519 | // Place the input data in the buffer. |
520 | lock (m_InputData) | 520 | lock (m_InputData) |
521 | { | 521 | { |
522 | m_DataEvent.Set(); | 522 | m_DataEvent.Set(); |
523 | m_InputData.Add(post["COMMAND"].ToString()); | 523 | m_InputData.Add(post["COMMAND"].ToString()); |
524 | } | 524 | } |
525 | 525 | ||
526 | // Create the XML reply document. | 526 | // Create the XML reply document. |
527 | XmlDocument xmldoc = new XmlDocument(); | 527 | XmlDocument xmldoc = new XmlDocument(); |
528 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 528 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
529 | "", ""); | 529 | "", ""); |
@@ -547,7 +547,7 @@ namespace OpenSim.Framework.Console | |||
547 | return reply; | 547 | return reply; |
548 | } | 548 | } |
549 | 549 | ||
550 | // Decode a HTTP form post to a Hashtable | 550 | // Decode a HTTP form post to a Hashtable |
551 | protected Hashtable DecodePostString(string data) | 551 | protected Hashtable DecodePostString(string data) |
552 | { | 552 | { |
553 | Hashtable result = new Hashtable(); | 553 | Hashtable result = new Hashtable(); |
@@ -565,14 +565,14 @@ namespace OpenSim.Framework.Console | |||
565 | 565 | ||
566 | if (elems.Length > 1) | 566 | if (elems.Length > 1) |
567 | value = System.Web.HttpUtility.UrlDecode(elems[1]); | 567 | value = System.Web.HttpUtility.UrlDecode(elems[1]); |
568 | 568 | ||
569 | result[name] = value; | 569 | result[name] = value; |
570 | } | 570 | } |
571 | 571 | ||
572 | return result; | 572 | return result; |
573 | } | 573 | } |
574 | 574 | ||
575 | // Close the CAP receiver for the responses for a given client. | 575 | // Close the CAP receiver for the responses for a given client. |
576 | public void CloseConnection(UUID id) | 576 | public void CloseConnection(UUID id) |
577 | { | 577 | { |
578 | try | 578 | try |
@@ -586,8 +586,8 @@ namespace OpenSim.Framework.Console | |||
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | // Check if there is anything to send. Return true if this client has | 589 | // Check if there is anything to send. Return true if this client has |
590 | // lines pending. | 590 | // lines pending. |
591 | protected bool HasEvents(UUID RequestID, UUID sessionID) | 591 | protected bool HasEvents(UUID RequestID, UUID sessionID) |
592 | { | 592 | { |
593 | ConsoleConnection c = null; | 593 | ConsoleConnection c = null; |
@@ -604,10 +604,10 @@ namespace OpenSim.Framework.Console | |||
604 | return false; | 604 | return false; |
605 | } | 605 | } |
606 | 606 | ||
607 | // Send all pending output to the client. | 607 | // Send all pending output to the client. |
608 | protected Hashtable GetEvents(UUID RequestID, UUID sessionID) | 608 | protected Hashtable GetEvents(UUID RequestID, UUID sessionID) |
609 | { | 609 | { |
610 | // Find the connection that goes with this client. | 610 | // Find the connection that goes with this client. |
611 | ConsoleConnection c = null; | 611 | ConsoleConnection c = null; |
612 | 612 | ||
613 | lock (m_Connections) | 613 | lock (m_Connections) |
@@ -617,14 +617,14 @@ namespace OpenSim.Framework.Console | |||
617 | c = m_Connections[sessionID]; | 617 | c = m_Connections[sessionID]; |
618 | } | 618 | } |
619 | 619 | ||
620 | // If we have nothing to send, send the no events response. | 620 | // If we have nothing to send, send the no events response. |
621 | c.last = System.Environment.TickCount; | 621 | c.last = System.Environment.TickCount; |
622 | if (c.lastLineSeen >= m_lineNumber) | 622 | if (c.lastLineSeen >= m_lineNumber) |
623 | return NoEvents(RequestID, UUID.Zero); | 623 | return NoEvents(RequestID, UUID.Zero); |
624 | 624 | ||
625 | Hashtable result = new Hashtable(); | 625 | Hashtable result = new Hashtable(); |
626 | 626 | ||
627 | // Create the response document. | 627 | // Create the response document. |
628 | XmlDocument xmldoc = new XmlDocument(); | 628 | XmlDocument xmldoc = new XmlDocument(); |
629 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 629 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
630 | "", ""); | 630 | "", ""); |
@@ -648,29 +648,29 @@ namespace OpenSim.Framework.Console | |||
648 | 648 | ||
649 | for (long i = sendStart ; i < m_lineNumber ; i++) | 649 | for (long i = sendStart ; i < m_lineNumber ; i++) |
650 | { | 650 | { |
651 | ScrollbackEntry e = m_Scrollback[(int)(i - startLine)]; | 651 | ScrollbackEntry e = m_Scrollback[(int)(i - startLine)]; |
652 | 652 | ||
653 | XmlElement res = xmldoc.CreateElement("", "Line", ""); | 653 | XmlElement res = xmldoc.CreateElement("", "Line", ""); |
654 | res.SetAttribute("Number", e.lineNumber.ToString()); | 654 | res.SetAttribute("Number", e.lineNumber.ToString()); |
655 | res.SetAttribute("Level", e.level); | 655 | res.SetAttribute("Level", e.level); |
656 | // Don't include these for the scrollback, we'll send the | 656 | // Don't include these for the scrollback, we'll send the |
657 | // real state later. | 657 | // real state later. |
658 | if (!c.newConnection) | 658 | if (!c.newConnection) |
659 | { | 659 | { |
660 | res.SetAttribute("Prompt", e.isPrompt ? "true" : "false"); | 660 | res.SetAttribute("Prompt", e.isPrompt ? "true" : "false"); |
661 | res.SetAttribute("Command", e.isCommand ? "true" : "false"); | 661 | res.SetAttribute("Command", e.isCommand ? "true" : "false"); |
662 | res.SetAttribute("Input", e.isInput ? "true" : "false"); | 662 | res.SetAttribute("Input", e.isInput ? "true" : "false"); |
663 | } | 663 | } |
664 | else if (i == m_lineNumber - 1) // Last line for a new connection | 664 | else if (i == m_lineNumber - 1) // Last line for a new connection |
665 | { | 665 | { |
666 | res.SetAttribute("Prompt", m_expectingInput ? "true" : "false"); | 666 | res.SetAttribute("Prompt", m_expectingInput ? "true" : "false"); |
667 | res.SetAttribute("Command", m_expectingCommand ? "true" : "false"); | 667 | res.SetAttribute("Command", m_expectingCommand ? "true" : "false"); |
668 | res.SetAttribute("Input", (!m_expectingInput) ? "true" : "false"); | 668 | res.SetAttribute("Input", (!m_expectingInput) ? "true" : "false"); |
669 | } | 669 | } |
670 | else | 670 | else |
671 | { | 671 | { |
672 | res.SetAttribute("Input", e.isInput ? "true" : "false"); | 672 | res.SetAttribute("Input", e.isInput ? "true" : "false"); |
673 | } | 673 | } |
674 | 674 | ||
675 | res.AppendChild(xmldoc.CreateTextNode(e.text)); | 675 | res.AppendChild(xmldoc.CreateTextNode(e.text)); |
676 | 676 | ||
@@ -679,7 +679,7 @@ namespace OpenSim.Framework.Console | |||
679 | } | 679 | } |
680 | 680 | ||
681 | c.lastLineSeen = m_lineNumber; | 681 | c.lastLineSeen = m_lineNumber; |
682 | c.newConnection = false; | 682 | c.newConnection = false; |
683 | 683 | ||
684 | xmldoc.AppendChild(rootElement); | 684 | xmldoc.AppendChild(rootElement); |
685 | 685 | ||
@@ -693,8 +693,8 @@ namespace OpenSim.Framework.Console | |||
693 | return result; | 693 | return result; |
694 | } | 694 | } |
695 | 695 | ||
696 | // This is really just a no-op. It generates what is sent | 696 | // This is really just a no-op. It generates what is sent |
697 | // to the client if the poll times out without any events. | 697 | // to the client if the poll times out without any events. |
698 | protected Hashtable NoEvents(UUID RequestID, UUID id) | 698 | protected Hashtable NoEvents(UUID RequestID, UUID id) |
699 | { | 699 | { |
700 | Hashtable result = new Hashtable(); | 700 | Hashtable result = new Hashtable(); |