diff options
23 files changed, 1471 insertions, 1035 deletions
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 30af23a..f990748 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -26,22 +26,250 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Text; |
30 | using System.Diagnostics; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | 30 | using System.Reflection; |
33 | using System.Text.RegularExpressions; | 31 | using System.Diagnostics; |
32 | using System.Collections.Generic; | ||
34 | using log4net; | 33 | using log4net; |
35 | 34 | ||
36 | namespace OpenSim.Framework.Console | 35 | namespace OpenSim.Framework.Console |
37 | { | 36 | { |
37 | public delegate void CommandDelegate(string module, string[] cmd); | ||
38 | |||
39 | public class Commands | ||
40 | { | ||
41 | private class CommandInfo | ||
42 | { | ||
43 | public string module; | ||
44 | public string help_text; | ||
45 | public string long_help; | ||
46 | public CommandDelegate fn; | ||
47 | } | ||
48 | |||
49 | private Dictionary<string, Object> tree = | ||
50 | new Dictionary<string, Object>(); | ||
51 | |||
52 | public List<string> GetHelp() | ||
53 | { | ||
54 | List<string> help = new List<string>(); | ||
55 | |||
56 | help.AddRange(CollectHelp(tree)); | ||
57 | |||
58 | help.Sort(); | ||
59 | |||
60 | return help; | ||
61 | } | ||
62 | |||
63 | private List<string> CollectHelp(Dictionary<string, Object> dict) | ||
64 | { | ||
65 | List<string> result = new List<string>(); | ||
66 | |||
67 | foreach (KeyValuePair<string, object> kvp in dict) | ||
68 | { | ||
69 | if (kvp.Value is Dictionary<string, Object>) | ||
70 | { | ||
71 | result.AddRange(CollectHelp((Dictionary<string, Object>)kvp.Value)); | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | if (((CommandInfo)kvp.Value).long_help != String.Empty) | ||
76 | result.Add(((CommandInfo)kvp.Value).help_text+" - "+ | ||
77 | ((CommandInfo)kvp.Value).long_help); | ||
78 | } | ||
79 | } | ||
80 | return result; | ||
81 | } | ||
82 | |||
83 | public void AddCommand(string module, string command, string help, string longhelp, CommandDelegate fn) | ||
84 | { | ||
85 | string[] parts = Parser.Parse(command); | ||
86 | |||
87 | Dictionary<string, Object> current = tree; | ||
88 | foreach (string s in parts) | ||
89 | { | ||
90 | if (current.ContainsKey(s)) | ||
91 | { | ||
92 | if (current[s] is Dictionary<string, Object>) | ||
93 | { | ||
94 | current = (Dictionary<string, Object>)current[s]; | ||
95 | } | ||
96 | else | ||
97 | return; | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | current[s] = new Dictionary<string, Object>(); | ||
102 | current = (Dictionary<string, Object>)current[s]; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | if (current.ContainsKey(String.Empty)) | ||
107 | return; | ||
108 | CommandInfo info = new CommandInfo(); | ||
109 | info.module = module; | ||
110 | info.help_text = help; | ||
111 | info.long_help = longhelp; | ||
112 | info.fn = fn; | ||
113 | current[String.Empty] = info; | ||
114 | } | ||
115 | |||
116 | public string[] FindNextOption(string[] cmd, bool term) | ||
117 | { | ||
118 | Dictionary<string, object> current = tree; | ||
119 | |||
120 | int remaining = cmd.Length; | ||
121 | |||
122 | foreach (string s in cmd) | ||
123 | { | ||
124 | remaining--; | ||
125 | |||
126 | List<string> found = new List<string>(); | ||
127 | |||
128 | foreach (string opt in current.Keys) | ||
129 | { | ||
130 | if (opt.StartsWith(s)) | ||
131 | { | ||
132 | found.Add(opt); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | if (found.Count == 1 && (remaining != 0 || term)) | ||
137 | { | ||
138 | current = (Dictionary<string, object>)current[found[0]]; | ||
139 | } | ||
140 | else if (found.Count > 0) | ||
141 | { | ||
142 | return found.ToArray(); | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | break; | ||
147 | // return new string[] {"<cr>"}; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | if (current.Count > 1) | ||
152 | { | ||
153 | List<string> choices = new List<string>(); | ||
154 | |||
155 | bool addcr = false; | ||
156 | foreach (string s in current.Keys) | ||
157 | { | ||
158 | if (s == String.Empty) | ||
159 | { | ||
160 | CommandInfo ci = (CommandInfo)current[String.Empty]; | ||
161 | if (ci.fn != null) | ||
162 | addcr = true; | ||
163 | } | ||
164 | else | ||
165 | choices.Add(s); | ||
166 | } | ||
167 | if (addcr) | ||
168 | choices.Add("<cr>"); | ||
169 | return choices.ToArray(); | ||
170 | } | ||
171 | |||
172 | if (current.ContainsKey(String.Empty)) | ||
173 | return new string[] { "Command help: "+((CommandInfo)current[String.Empty]).help_text}; | ||
174 | |||
175 | return new string[] { new List<string>(current.Keys)[0] }; | ||
176 | } | ||
177 | |||
178 | public string[] Resolve(string[] cmd) | ||
179 | { | ||
180 | string[] result = cmd; | ||
181 | int index = -1; | ||
182 | |||
183 | Dictionary<string, object> current = tree; | ||
184 | |||
185 | foreach (string s in cmd) | ||
186 | { | ||
187 | index++; | ||
188 | |||
189 | List<string> found = new List<string>(); | ||
190 | |||
191 | foreach (string opt in current.Keys) | ||
192 | { | ||
193 | if (opt.StartsWith(s)) | ||
194 | { | ||
195 | found.Add(opt); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | if (found.Count == 1) | ||
200 | { | ||
201 | result[index] = found[0]; | ||
202 | current = (Dictionary<string, object>)current[found[0]]; | ||
203 | } | ||
204 | else if (found.Count > 0) | ||
205 | { | ||
206 | return new string[0]; | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | break; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | if (current.ContainsKey(String.Empty)) | ||
215 | { | ||
216 | CommandInfo ci = (CommandInfo)current[String.Empty]; | ||
217 | if (ci.fn == null) | ||
218 | return new string[0]; | ||
219 | ci.fn(ci.module, result); | ||
220 | return result; | ||
221 | } | ||
222 | return new string[0]; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | public class Parser | ||
227 | { | ||
228 | public static string[] Parse(string text) | ||
229 | { | ||
230 | List<string> result = new List<string>(); | ||
231 | |||
232 | int index; | ||
233 | |||
234 | string[] unquoted = text.Split(new char[] {'"'}); | ||
235 | |||
236 | for (index = 0 ; index < unquoted.Length ; index++) | ||
237 | { | ||
238 | if (index % 2 == 0) | ||
239 | { | ||
240 | string[] words = unquoted[index].Split(new char[] {' '}); | ||
241 | foreach (string w in words) | ||
242 | { | ||
243 | if (w != String.Empty) | ||
244 | result.Add(w); | ||
245 | } | ||
246 | } | ||
247 | else | ||
248 | { | ||
249 | result.Add(unquoted[index]); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | return result.ToArray(); | ||
254 | } | ||
255 | } | ||
256 | |||
38 | public class ConsoleBase | 257 | public class ConsoleBase |
39 | { | 258 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 259 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 260 | ||
42 | private readonly object m_syncRoot = new object(); | 261 | private readonly object m_syncRoot = new object(); |
43 | 262 | ||
44 | public conscmd_callback m_cmdParser; | 263 | private int y = -1; |
264 | private int cp = 0; | ||
265 | private int h = 1; | ||
266 | private string prompt = "# "; | ||
267 | private StringBuilder cmdline = new StringBuilder(); | ||
268 | public Commands Commands = new Commands(); | ||
269 | private bool echo = true; | ||
270 | private List<string> history = new List<string>(); | ||
271 | |||
272 | public object ConsoleScene = null; | ||
45 | 273 | ||
46 | /// <summary> | 274 | /// <summary> |
47 | /// The default prompt text. | 275 | /// The default prompt text. |
@@ -53,15 +281,19 @@ namespace OpenSim.Framework.Console | |||
53 | } | 281 | } |
54 | protected string m_defaultPrompt; | 282 | protected string m_defaultPrompt; |
55 | 283 | ||
56 | /// <summary> | 284 | public ConsoleBase(string defaultPrompt) |
57 | /// Constructor. | ||
58 | /// </summary> | ||
59 | /// <param name="defaultPrompt"></param> | ||
60 | /// <param name="cmdparser"></param> | ||
61 | public ConsoleBase(string defaultPrompt, conscmd_callback cmdparser) | ||
62 | { | 285 | { |
63 | DefaultPrompt = defaultPrompt; | 286 | DefaultPrompt = defaultPrompt; |
64 | m_cmdParser = cmdparser; | 287 | |
288 | Commands.AddCommand("console", "help", "help", "Get command list", Help); | ||
289 | } | ||
290 | |||
291 | private void AddToHistory(string text) | ||
292 | { | ||
293 | while (history.Count >= 100) | ||
294 | history.RemoveAt(0); | ||
295 | |||
296 | history.Add(text); | ||
65 | } | 297 | } |
66 | 298 | ||
67 | /// <summary> | 299 | /// <summary> |
@@ -95,8 +327,7 @@ namespace OpenSim.Framework.Console | |||
95 | /// <param name="args">WriteLine-style message arguments</param> | 327 | /// <param name="args">WriteLine-style message arguments</param> |
96 | public void Warn(string sender, string format, params object[] args) | 328 | public void Warn(string sender, string format, params object[] args) |
97 | { | 329 | { |
98 | WritePrefixLine(DeriveColor(sender), sender); | 330 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Yellow, format, args); |
99 | WriteNewLine(ConsoleColor.Yellow, format, args); | ||
100 | } | 331 | } |
101 | 332 | ||
102 | /// <summary> | 333 | /// <summary> |
@@ -117,10 +348,8 @@ namespace OpenSim.Framework.Console | |||
117 | /// <param name="args">WriteLine-style message arguments</param> | 348 | /// <param name="args">WriteLine-style message arguments</param> |
118 | public void Notice(string sender, string format, params object[] args) | 349 | public void Notice(string sender, string format, params object[] args) |
119 | { | 350 | { |
120 | WritePrefixLine(DeriveColor(sender), sender); | 351 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.White, format, args); |
121 | WriteNewLine(ConsoleColor.White, format, args); | ||
122 | } | 352 | } |
123 | |||
124 | /// <summary> | 353 | /// <summary> |
125 | /// Sends an error to the current console output | 354 | /// Sends an error to the current console output |
126 | /// </summary> | 355 | /// </summary> |
@@ -139,8 +368,7 @@ namespace OpenSim.Framework.Console | |||
139 | /// <param name="args">WriteLine-style message arguments</param> | 368 | /// <param name="args">WriteLine-style message arguments</param> |
140 | public void Error(string sender, string format, params object[] args) | 369 | public void Error(string sender, string format, params object[] args) |
141 | { | 370 | { |
142 | WritePrefixLine(DeriveColor(sender), sender); | 371 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Red, format, args); |
143 | Error(format, args); | ||
144 | } | 372 | } |
145 | 373 | ||
146 | /// <summary> | 374 | /// <summary> |
@@ -161,8 +389,7 @@ namespace OpenSim.Framework.Console | |||
161 | /// <param name="args">WriteLine-style message arguments</param> | 389 | /// <param name="args">WriteLine-style message arguments</param> |
162 | public void Status(string sender, string format, params object[] args) | 390 | public void Status(string sender, string format, params object[] args) |
163 | { | 391 | { |
164 | WritePrefixLine(DeriveColor(sender), sender); | 392 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Blue, format, args); |
165 | WriteNewLine(ConsoleColor.Blue, format, args); | ||
166 | } | 393 | } |
167 | 394 | ||
168 | [Conditional("DEBUG")] | 395 | [Conditional("DEBUG")] |
@@ -174,12 +401,60 @@ namespace OpenSim.Framework.Console | |||
174 | [Conditional("DEBUG")] | 401 | [Conditional("DEBUG")] |
175 | public void Debug(string sender, string format, params object[] args) | 402 | public void Debug(string sender, string format, params object[] args) |
176 | { | 403 | { |
177 | WritePrefixLine(DeriveColor(sender), sender); | 404 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Gray, format, args); |
178 | WriteNewLine(ConsoleColor.Gray, format, args); | 405 | } |
406 | |||
407 | private void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args) | ||
408 | { | ||
409 | lock (cmdline) | ||
410 | { | ||
411 | if (y != -1) | ||
412 | { | ||
413 | System.Console.CursorTop = y; | ||
414 | System.Console.CursorLeft = 0; | ||
415 | |||
416 | int count = cmdline.Length; | ||
417 | |||
418 | System.Console.Write(" "); | ||
419 | while (count-- > 0) | ||
420 | System.Console.Write(" "); | ||
421 | |||
422 | System.Console.CursorTop = y; | ||
423 | System.Console.CursorLeft = 0; | ||
424 | } | ||
425 | WritePrefixLine(senderColor, sender); | ||
426 | WriteConsoleLine(color, format, args); | ||
427 | if (y != -1) | ||
428 | y = System.Console.CursorTop; | ||
429 | } | ||
179 | } | 430 | } |
180 | 431 | ||
181 | private void WriteNewLine(ConsoleColor color, string format, params object[] args) | 432 | private void WriteNewLine(ConsoleColor color, string format, params object[] args) |
182 | { | 433 | { |
434 | lock (cmdline) | ||
435 | { | ||
436 | if (y != -1) | ||
437 | { | ||
438 | System.Console.CursorTop = y; | ||
439 | System.Console.CursorLeft = 0; | ||
440 | |||
441 | int count = cmdline.Length; | ||
442 | |||
443 | System.Console.Write(" "); | ||
444 | while (count-- > 0) | ||
445 | System.Console.Write(" "); | ||
446 | |||
447 | System.Console.CursorTop = y; | ||
448 | System.Console.CursorLeft = 0; | ||
449 | } | ||
450 | WriteConsoleLine(color, format, args); | ||
451 | if (y != -1) | ||
452 | y = System.Console.CursorTop; | ||
453 | } | ||
454 | } | ||
455 | |||
456 | private void WriteConsoleLine(ConsoleColor color, string format, params object[] args) | ||
457 | { | ||
183 | try | 458 | try |
184 | { | 459 | { |
185 | lock (m_syncRoot) | 460 | lock (m_syncRoot) |
@@ -240,108 +515,150 @@ namespace OpenSim.Framework.Console | |||
240 | } | 515 | } |
241 | } | 516 | } |
242 | 517 | ||
243 | public string ReadLine() | 518 | private void Help(string module, string[] cmd) |
244 | { | 519 | { |
245 | try | 520 | List<string> help = Commands.GetHelp(); |
246 | { | 521 | |
247 | string line = System.Console.ReadLine(); | 522 | foreach (string s in help) |
523 | Output(s); | ||
524 | } | ||
248 | 525 | ||
249 | while (line == null) | 526 | private void Show() |
527 | { | ||
528 | lock (cmdline) | ||
529 | { | ||
530 | if (y == -1 || System.Console.BufferWidth == 0) | ||
531 | return; | ||
532 | |||
533 | int xc = prompt.Length + cp; | ||
534 | int new_x = xc % System.Console.BufferWidth; | ||
535 | int new_y = y + xc / System.Console.BufferWidth; | ||
536 | int end_y = y + (cmdline.Length + prompt.Length) / System.Console.BufferWidth; | ||
537 | if (end_y / System.Console.BufferWidth >= h) | ||
538 | h++; | ||
539 | if (end_y >= System.Console.BufferHeight) // wrap | ||
250 | { | 540 | { |
251 | line = System.Console.ReadLine(); | 541 | y--; |
542 | new_y--; | ||
543 | System.Console.CursorLeft = 0; | ||
544 | System.Console.CursorTop = System.Console.BufferHeight-1; | ||
545 | System.Console.WriteLine(" "); | ||
252 | } | 546 | } |
253 | 547 | ||
254 | return line; | 548 | System.Console.CursorTop = y; |
255 | } | 549 | System.Console.CursorLeft = 0; |
256 | catch (Exception e) | ||
257 | { | ||
258 | m_log.Error("[Console]: System.Console.ReadLine exception " + e.ToString()); | ||
259 | return String.Empty; | ||
260 | } | ||
261 | } | ||
262 | 550 | ||
263 | public int Read() | 551 | if (echo) |
264 | { | 552 | System.Console.Write("{0}{1}", prompt, cmdline); |
265 | return System.Console.Read(); | 553 | else |
554 | System.Console.Write("{0}", prompt); | ||
555 | |||
556 | System.Console.CursorLeft = new_x; | ||
557 | System.Console.CursorTop = new_y; | ||
558 | } | ||
266 | } | 559 | } |
267 | 560 | ||
268 | public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue) | 561 | public void LockOutput() |
269 | { | 562 | { |
270 | IPAddress address; | 563 | System.Threading.Monitor.Enter(cmdline); |
271 | string addressStr; | 564 | try |
272 | |||
273 | while (true) | ||
274 | { | 565 | { |
275 | addressStr = CmdPrompt(prompt, defaultvalue); | 566 | if (y != -1) |
276 | if (IPAddress.TryParse(addressStr, out address)) | ||
277 | { | 567 | { |
278 | break; | 568 | System.Console.CursorTop = y; |
279 | } | 569 | System.Console.CursorLeft = 0; |
280 | else | 570 | |
281 | { | 571 | int count = cmdline.Length + prompt.Length; |
282 | m_log.Error("Illegal address. Please re-enter."); | 572 | |
573 | while (count-- > 0) | ||
574 | System.Console.Write(" "); | ||
575 | |||
576 | System.Console.CursorTop = y; | ||
577 | System.Console.CursorLeft = 0; | ||
578 | |||
283 | } | 579 | } |
284 | } | 580 | } |
285 | 581 | catch (Exception) | |
286 | return address; | 582 | { |
583 | } | ||
287 | } | 584 | } |
288 | 585 | ||
289 | public uint CmdPromptIPPort(string prompt, string defaultvalue) | 586 | public void UnlockOutput() |
290 | { | 587 | { |
291 | uint port; | 588 | if (y != -1) |
292 | string portStr; | 589 | { |
590 | y = System.Console.CursorTop; | ||
591 | Show(); | ||
592 | } | ||
593 | System.Threading.Monitor.Exit(cmdline); | ||
594 | } | ||
293 | 595 | ||
294 | while (true) | 596 | public void Output(string text) |
597 | { | ||
598 | lock (cmdline) | ||
295 | { | 599 | { |
296 | portStr = CmdPrompt(prompt, defaultvalue); | 600 | if (y == -1) |
297 | if (uint.TryParse(portStr, out port)) | ||
298 | { | 601 | { |
299 | if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort) | 602 | System.Console.WriteLine(text); |
300 | { | 603 | |
301 | break; | 604 | return; |
302 | } | ||
303 | } | 605 | } |
304 | 606 | ||
305 | m_log.Error("Illegal address. Please re-enter."); | 607 | System.Console.CursorTop = y; |
306 | } | 608 | System.Console.CursorLeft = 0; |
307 | 609 | ||
308 | return port; | 610 | int count = cmdline.Length + prompt.Length; |
309 | } | ||
310 | 611 | ||
311 | // Displays a prompt and waits for the user to enter a string, then returns that string | 612 | while (count-- > 0) |
312 | // (Done with no echo and suitable for passwords - currently disabled) | 613 | System.Console.Write(" "); |
313 | public string PasswdPrompt(string prompt) | 614 | |
314 | { | 615 | System.Console.CursorTop = y; |
315 | // FIXME: Needs to be better abstracted | 616 | System.Console.CursorLeft = 0; |
316 | System.Console.WriteLine(String.Format("{0}: ", prompt)); | 617 | |
317 | //ConsoleColor oldfg = System.Console.ForegroundColor; | 618 | System.Console.WriteLine(text); |
318 | //System.Console.ForegroundColor = System.Console.BackgroundColor; | 619 | |
319 | string temp = System.Console.ReadLine(); | 620 | y = System.Console.CursorTop; |
320 | //System.Console.ForegroundColor = oldfg; | 621 | |
321 | return temp; | 622 | Show(); |
623 | } | ||
322 | } | 624 | } |
323 | 625 | ||
324 | // Displays a command prompt and waits for the user to enter a string, then returns that string | 626 | private void ContextHelp() |
325 | public string CmdPrompt(string prompt) | ||
326 | { | 627 | { |
327 | System.Console.WriteLine(String.Format("{0}: ", prompt)); | 628 | string[] words = Parser.Parse(cmdline.ToString()); |
328 | return ReadLine(); | 629 | |
630 | string[] opts = Commands.FindNextOption(words, cmdline.ToString().EndsWith(" ")); | ||
631 | |||
632 | if (opts[0].StartsWith("Command help:")) | ||
633 | Output(opts[0]); | ||
634 | else | ||
635 | Output(String.Format("Options: {0}", String.Join(" ", opts))); | ||
329 | } | 636 | } |
330 | 637 | ||
331 | // Displays a command prompt and returns a default value if the user simply presses enter | 638 | public void Prompt() |
332 | public string CmdPrompt(string prompt, string defaultresponse) | ||
333 | { | 639 | { |
334 | string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse)); | 640 | string line = ReadLine(m_defaultPrompt, true, true); |
335 | if (temp == String.Empty) | 641 | |
336 | { | 642 | if (line != String.Empty) |
337 | return defaultresponse; | ||
338 | } | ||
339 | else | ||
340 | { | 643 | { |
341 | return temp; | 644 | m_log.Info("Invalid command"); |
342 | } | 645 | } |
343 | } | 646 | } |
344 | 647 | ||
648 | public string CmdPrompt(string p) | ||
649 | { | ||
650 | return ReadLine(String.Format("{0}: ", p), false, true); | ||
651 | } | ||
652 | |||
653 | public string CmdPrompt(string p, string def) | ||
654 | { | ||
655 | string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); | ||
656 | if (ret == String.Empty) | ||
657 | ret = def; | ||
658 | |||
659 | return ret; | ||
660 | } | ||
661 | |||
345 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | 662 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options |
346 | public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) | 663 | public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) |
347 | { | 664 | { |
@@ -362,85 +679,137 @@ namespace OpenSim.Framework.Console | |||
362 | return temp; | 679 | return temp; |
363 | } | 680 | } |
364 | 681 | ||
365 | // Runs a command with a number of parameters | 682 | // Displays a prompt and waits for the user to enter a string, then returns that string |
366 | public Object RunCmd(string Cmd, string[] cmdparams) | 683 | // (Done with no echo and suitable for passwords) |
367 | { | 684 | public string PasswdPrompt(string p) |
368 | m_cmdParser.RunCmd(Cmd, cmdparams); | ||
369 | return null; | ||
370 | } | ||
371 | |||
372 | // Shows data about something | ||
373 | public void ShowCommands(string ShowWhat) | ||
374 | { | 685 | { |
375 | m_cmdParser.Show(new string[] { ShowWhat }); | 686 | return ReadLine(p, false, false); |
376 | } | 687 | } |
377 | 688 | ||
378 | public void Prompt() | 689 | public void RunCommand(string cmd) |
379 | { | 690 | { |
380 | string tempstr = CmdPrompt(m_defaultPrompt); | 691 | string[] parts = Parser.Parse(cmd); |
381 | RunCommand(tempstr); | 692 | Commands.Resolve(parts); |
382 | } | 693 | } |
383 | 694 | ||
384 | public void RunCommand(string cmdline) | 695 | public string ReadLine(string p, bool isCommand, bool e) |
385 | { | 696 | { |
386 | Regex Extractor = new Regex(@"(['""][^""]+['""])\s*|([^\s]+)\s*", RegexOptions.Compiled); | 697 | h = 1; |
387 | char[] delims = {' ', '"'}; | 698 | cp = 0; |
388 | MatchCollection matches = Extractor.Matches(cmdline); | 699 | prompt = p; |
389 | // Get matches | 700 | echo = e; |
701 | int historyLine = history.Count; | ||
390 | 702 | ||
391 | if (matches.Count == 0) | 703 | System.Console.CursorLeft = 0; // Needed for mono |
392 | return; | 704 | System.Console.Write(" "); // Needed for mono |
393 | 705 | ||
394 | string cmd = matches[0].Value.Trim(delims); | 706 | y = System.Console.CursorTop; |
395 | string[] cmdparams = new string[matches.Count - 1]; | 707 | cmdline = new StringBuilder(); |
396 | 708 | ||
397 | for (int i = 1; i < matches.Count; i++) | 709 | while(true) |
398 | { | 710 | { |
399 | cmdparams[i-1] = matches[i].Value.Trim(delims); | 711 | Show(); |
400 | } | ||
401 | 712 | ||
402 | try | 713 | ConsoleKeyInfo key = System.Console.ReadKey(true); |
403 | { | 714 | char c = key.KeyChar; |
404 | RunCmd(cmd, cmdparams); | ||
405 | } | ||
406 | catch (Exception e) | ||
407 | { | ||
408 | m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", cmdline, e.ToString()); | ||
409 | m_log.Error(e.StackTrace); | ||
410 | } | ||
411 | } | ||
412 | 715 | ||
413 | public string LineInfo | 716 | if (!Char.IsControl(c)) |
414 | { | 717 | { |
415 | get | 718 | if (cp >= 318) |
416 | { | 719 | continue; |
417 | string result = String.Empty; | ||
418 | 720 | ||
419 | string stacktrace = Environment.StackTrace; | 721 | if (c == '?' && isCommand) |
420 | List<string> lines = new List<string>(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None)); | 722 | { |
723 | ContextHelp(); | ||
724 | continue; | ||
725 | } | ||
421 | 726 | ||
422 | if (lines.Count > 4) | 727 | cmdline.Insert(cp, c); |
728 | cp++; | ||
729 | } | ||
730 | else | ||
423 | { | 731 | { |
424 | lines.RemoveRange(0, 4); | 732 | switch (key.Key) |
733 | { | ||
734 | case ConsoleKey.Backspace: | ||
735 | if (cp == 0) | ||
736 | break; | ||
737 | cmdline.Remove(cp-1, 1); | ||
738 | cp--; | ||
425 | 739 | ||
426 | string tmpLine = lines[0]; | 740 | System.Console.CursorLeft = 0; |
741 | System.Console.CursorTop = y; | ||
427 | 742 | ||
428 | int inIndex = tmpLine.IndexOf(" in "); | 743 | System.Console.Write("{0}{1} ", prompt, cmdline); |
429 | 744 | ||
430 | if (inIndex > -1) | 745 | break; |
431 | { | 746 | case ConsoleKey.End: |
432 | result = tmpLine.Substring(0, inIndex); | 747 | cp = cmdline.Length; |
748 | break; | ||
749 | case ConsoleKey.Home: | ||
750 | cp = 0; | ||
751 | break; | ||
752 | case ConsoleKey.UpArrow: | ||
753 | if (historyLine < 1) | ||
754 | break; | ||
755 | historyLine--; | ||
756 | LockOutput(); | ||
757 | cmdline = new StringBuilder(history[historyLine]); | ||
758 | cp = cmdline.Length; | ||
759 | UnlockOutput(); | ||
760 | break; | ||
761 | case ConsoleKey.DownArrow: | ||
762 | if (historyLine >= history.Count) | ||
763 | break; | ||
764 | historyLine++; | ||
765 | LockOutput(); | ||
766 | if (historyLine == history.Count) | ||
767 | cmdline = new StringBuilder(); | ||
768 | else | ||
769 | cmdline = new StringBuilder(history[historyLine]); | ||
770 | cp = cmdline.Length; | ||
771 | UnlockOutput(); | ||
772 | break; | ||
773 | case ConsoleKey.LeftArrow: | ||
774 | if (cp > 0) | ||
775 | cp--; | ||
776 | break; | ||
777 | case ConsoleKey.RightArrow: | ||
778 | if (cp < cmdline.Length) | ||
779 | cp++; | ||
780 | break; | ||
781 | case ConsoleKey.Enter: | ||
782 | System.Console.CursorLeft = 0; | ||
783 | System.Console.CursorTop = y; | ||
784 | |||
785 | System.Console.WriteLine("{0}{1}", prompt, cmdline); | ||
433 | 786 | ||
434 | int lineIndex = tmpLine.IndexOf(":line "); | 787 | y = -1; |
435 | 788 | ||
436 | if (lineIndex > -1) | 789 | if (isCommand) |
437 | { | 790 | { |
438 | lineIndex += 6; | 791 | string[] cmd = Commands.Resolve(Parser.Parse(cmdline.ToString())); |
439 | result += ", line " + tmpLine.Substring(lineIndex, (tmpLine.Length - lineIndex) - 5); | 792 | |
793 | if (cmd.Length != 0) | ||
794 | { | ||
795 | int i; | ||
796 | |||
797 | for (i=0 ; i < cmd.Length ; i++) | ||
798 | { | ||
799 | if (cmd[i].Contains(" ")) | ||
800 | cmd[i] = "\"" + cmd[i] + "\""; | ||
801 | } | ||
802 | AddToHistory(String.Join(" ", cmd)); | ||
803 | return String.Empty; | ||
804 | } | ||
440 | } | 805 | } |
806 | |||
807 | AddToHistory(cmdline.ToString()); | ||
808 | return cmdline.ToString(); | ||
809 | default: | ||
810 | break; | ||
441 | } | 811 | } |
442 | } | 812 | } |
443 | return result; | ||
444 | } | 813 | } |
445 | } | 814 | } |
446 | } | 815 | } |
diff --git a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs deleted file mode 100644 index d37c47a..0000000 --- a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | namespace OpenSim.Framework.Console | ||
29 | { | ||
30 | public interface conscmd_callback | ||
31 | { | ||
32 | void RunCmd(string cmd, string[] cmdparams); | ||
33 | void Show(string[] showParams); | ||
34 | } | ||
35 | } | ||
diff --git a/OpenSim/Framework/Console/OpenSimAppender.cs b/OpenSim/Framework/Console/OpenSimAppender.cs index b07617f..6193bac 100644 --- a/OpenSim/Framework/Console/OpenSimAppender.cs +++ b/OpenSim/Framework/Console/OpenSimAppender.cs | |||
@@ -37,6 +37,14 @@ namespace OpenSim.Framework.Console | |||
37 | /// </summary> | 37 | /// </summary> |
38 | public class OpenSimAppender : AnsiColorTerminalAppender | 38 | public class OpenSimAppender : AnsiColorTerminalAppender |
39 | { | 39 | { |
40 | private ConsoleBase m_console = null; | ||
41 | |||
42 | public ConsoleBase Console | ||
43 | { | ||
44 | get { return m_console; } | ||
45 | set { m_console = value; } | ||
46 | } | ||
47 | |||
40 | private static readonly ConsoleColor[] Colors = { | 48 | private static readonly ConsoleColor[] Colors = { |
41 | // the dark colors don't seem to be visible on some black background terminals like putty :( | 49 | // the dark colors don't seem to be visible on some black background terminals like putty :( |
42 | //ConsoleColor.DarkBlue, | 50 | //ConsoleColor.DarkBlue, |
@@ -55,6 +63,9 @@ namespace OpenSim.Framework.Console | |||
55 | 63 | ||
56 | override protected void Append(LoggingEvent le) | 64 | override protected void Append(LoggingEvent le) |
57 | { | 65 | { |
66 | if (m_console != null) | ||
67 | m_console.LockOutput(); | ||
68 | |||
58 | try | 69 | try |
59 | { | 70 | { |
60 | string loggingMessage = RenderLoggingEvent(le); | 71 | string loggingMessage = RenderLoggingEvent(le); |
@@ -96,6 +107,11 @@ namespace OpenSim.Framework.Console | |||
96 | { | 107 | { |
97 | System.Console.WriteLine("Couldn't write out log message: {0}", e.ToString()); | 108 | System.Console.WriteLine("Couldn't write out log message: {0}", e.ToString()); |
98 | } | 109 | } |
110 | finally | ||
111 | { | ||
112 | if (m_console != null) | ||
113 | m_console.UnlockOutput(); | ||
114 | } | ||
99 | } | 115 | } |
100 | 116 | ||
101 | private void WriteColorText(ConsoleColor color, string sender) | 117 | private void WriteColorText(ConsoleColor color, string sender) |
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index ce74b46..493c626 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using OpenSim.Framework.Console; | ||
30 | 31 | ||
31 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
32 | { | 33 | { |
@@ -88,5 +89,7 @@ namespace OpenSim.Framework | |||
88 | 89 | ||
89 | T RequestModuleInterface<T>(); | 90 | T RequestModuleInterface<T>(); |
90 | T[] RequestModuleInterfaces<T>(); | 91 | T[] RequestModuleInterfaces<T>(); |
92 | |||
93 | void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback); | ||
91 | } | 94 | } |
92 | } | 95 | } |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 473991a..cc75df4 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -98,7 +98,45 @@ namespace OpenSim.Framework.Servers | |||
98 | /// <summary> | 98 | /// <summary> |
99 | /// Must be overriden by child classes for their own server specific startup behaviour. | 99 | /// Must be overriden by child classes for their own server specific startup behaviour. |
100 | /// </summary> | 100 | /// </summary> |
101 | protected abstract void StartupSpecific(); | 101 | protected virtual void StartupSpecific() |
102 | { | ||
103 | if (m_console != null) | ||
104 | { | ||
105 | SetConsoleLogLevel(new string[] { "ALL" }); | ||
106 | |||
107 | m_console.Commands.AddCommand("base", "quit", | ||
108 | "quit", | ||
109 | "Quit the application", HandleQuit); | ||
110 | |||
111 | m_console.Commands.AddCommand("base", "shutdown", | ||
112 | "shutdown", | ||
113 | "Quit the application", HandleQuit); | ||
114 | |||
115 | m_console.Commands.AddCommand("base", "set log level", | ||
116 | "set log level <level>", | ||
117 | "Set the console logging level", HandleLogLevel); | ||
118 | |||
119 | m_console.Commands.AddCommand("base", "show info", | ||
120 | "show info", | ||
121 | "Show general information", HandleShow); | ||
122 | |||
123 | m_console.Commands.AddCommand("base", "show stats", | ||
124 | "show stats", | ||
125 | "Show statistics", HandleShow); | ||
126 | |||
127 | m_console.Commands.AddCommand("base", "show threads", | ||
128 | "show threads", | ||
129 | "Show thread status", HandleShow); | ||
130 | |||
131 | m_console.Commands.AddCommand("base", "show uptime", | ||
132 | "show uptime", | ||
133 | "Show server uptime", HandleShow); | ||
134 | |||
135 | m_console.Commands.AddCommand("base", "show version", | ||
136 | "show version", | ||
137 | "Show server version", HandleShow); | ||
138 | } | ||
139 | } | ||
102 | 140 | ||
103 | /// <summary> | 141 | /// <summary> |
104 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | 142 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing |
@@ -212,6 +250,8 @@ namespace OpenSim.Framework.Servers | |||
212 | return; | 250 | return; |
213 | } | 251 | } |
214 | 252 | ||
253 | consoleAppender.Console = m_console; | ||
254 | |||
215 | if (setParams.Length > 0) | 255 | if (setParams.Length > 0) |
216 | { | 256 | { |
217 | Level consoleLevel = repository.LevelMap[setParams[0]]; | 257 | Level consoleLevel = repository.LevelMap[setParams[0]]; |
@@ -261,56 +301,18 @@ namespace OpenSim.Framework.Servers | |||
261 | Environment.Exit(0); | 301 | Environment.Exit(0); |
262 | } | 302 | } |
263 | 303 | ||
264 | /// <summary> | 304 | private void HandleQuit(string module, string[] args) |
265 | /// Runs commands issued by the server console from the operator | ||
266 | /// </summary> | ||
267 | /// <param name="command">The first argument of the parameter (the command)</param> | ||
268 | /// <param name="cmdparams">Additional arguments passed to the command</param> | ||
269 | public virtual void RunCmd(string command, string[] cmdparams) | ||
270 | { | 305 | { |
271 | switch (command) | 306 | Shutdown(); |
272 | { | ||
273 | case "help": | ||
274 | ShowHelp(cmdparams); | ||
275 | Notice(""); | ||
276 | break; | ||
277 | |||
278 | case "set": | ||
279 | Set(cmdparams); | ||
280 | break; | ||
281 | |||
282 | case "show": | ||
283 | if (cmdparams.Length > 0) | ||
284 | { | ||
285 | Show(cmdparams); | ||
286 | } | ||
287 | break; | ||
288 | |||
289 | case "quit": | ||
290 | case "shutdown": | ||
291 | Shutdown(); | ||
292 | break; | ||
293 | } | ||
294 | } | 307 | } |
295 | 308 | ||
296 | /// <summary> | 309 | private void HandleLogLevel(string module, string[] cmd) |
297 | /// Set an OpenSim parameter | ||
298 | /// </summary> | ||
299 | /// <param name="setArgs"> | ||
300 | /// The arguments given to the set command. | ||
301 | /// </param> | ||
302 | public virtual void Set(string[] setArgs) | ||
303 | { | 310 | { |
304 | // Temporary while we only have one command which takes at least two parameters | 311 | if (cmd.Length > 3) |
305 | if (setArgs.Length < 2) | ||
306 | return; | ||
307 | |||
308 | if (setArgs[0] == "log" && setArgs[1] == "level") | ||
309 | { | 312 | { |
310 | string[] setParams = new string[setArgs.Length - 2]; | 313 | string level = cmd[3]; |
311 | Array.Copy(setArgs, 2, setParams, 0, setArgs.Length - 2); | ||
312 | 314 | ||
313 | SetConsoleLogLevel(setParams); | 315 | SetConsoleLogLevel(new string[] { level }); |
314 | } | 316 | } |
315 | } | 317 | } |
316 | 318 | ||
@@ -324,18 +326,6 @@ namespace OpenSim.Framework.Servers | |||
324 | 326 | ||
325 | if (helpArgs.Length == 0) | 327 | if (helpArgs.Length == 0) |
326 | { | 328 | { |
327 | List<string> helpTopics = GetHelpTopics(); | ||
328 | |||
329 | if (helpTopics.Count > 0) | ||
330 | { | ||
331 | Notice( | ||
332 | "As well as the help information below, you can also type help <topic> to get more information on the following areas:"); | ||
333 | Notice(string.Format(" {0}", string.Join(", ", helpTopics.ToArray()))); | ||
334 | Notice(""); | ||
335 | } | ||
336 | |||
337 | Notice("quit - equivalent to shutdown."); | ||
338 | |||
339 | Notice("set log level [level] - change the console logging level only. For example, off or debug."); | 329 | Notice("set log level [level] - change the console logging level only. For example, off or debug."); |
340 | Notice("show info - show server information (e.g. startup path)."); | 330 | Notice("show info - show server information (e.g. startup path)."); |
341 | 331 | ||
@@ -345,21 +335,20 @@ namespace OpenSim.Framework.Servers | |||
345 | Notice("show threads - list tracked threads"); | 335 | Notice("show threads - list tracked threads"); |
346 | Notice("show uptime - show server startup time and uptime."); | 336 | Notice("show uptime - show server startup time and uptime."); |
347 | Notice("show version - show server version."); | 337 | Notice("show version - show server version."); |
348 | Notice("shutdown - shutdown the server."); | ||
349 | Notice(""); | 338 | Notice(""); |
350 | 339 | ||
351 | return; | 340 | return; |
352 | } | 341 | } |
353 | } | 342 | } |
354 | 343 | ||
355 | /// <summary> | 344 | public virtual void HandleShow(string module, string[] cmd) |
356 | /// Outputs to the console information about the region | ||
357 | /// </summary> | ||
358 | /// <param name="showParams"> | ||
359 | /// What information to display (valid arguments are "uptime", "users", ...) | ||
360 | /// </param> | ||
361 | public virtual void Show(string[] showParams) | ||
362 | { | 345 | { |
346 | List<string> args = new List<string>(cmd); | ||
347 | |||
348 | args.RemoveAt(0); | ||
349 | |||
350 | string[] showParams = args.ToArray(); | ||
351 | |||
363 | switch (showParams[0]) | 352 | switch (showParams[0]) |
364 | { | 353 | { |
365 | case "info": | 354 | case "info": |
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 060c473..c71e53f 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs | |||
@@ -43,7 +43,7 @@ namespace OpenSim.Grid.AssetServer | |||
43 | /// <summary> | 43 | /// <summary> |
44 | /// An asset server | 44 | /// An asset server |
45 | /// </summary> | 45 | /// </summary> |
46 | public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback | 46 | public class OpenAsset_Main : BaseOpenSimServer |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
@@ -76,7 +76,7 @@ namespace OpenSim.Grid.AssetServer | |||
76 | 76 | ||
77 | public OpenAsset_Main() | 77 | public OpenAsset_Main() |
78 | { | 78 | { |
79 | m_console = new ConsoleBase("Asset", this); | 79 | m_console = new ConsoleBase("Asset"); |
80 | 80 | ||
81 | MainConsole.Instance = m_console; | 81 | MainConsole.Instance = m_console; |
82 | } | 82 | } |
@@ -99,6 +99,8 @@ namespace OpenSim.Grid.AssetServer | |||
99 | AddHttpHandlers(); | 99 | AddHttpHandlers(); |
100 | 100 | ||
101 | m_httpServer.Start(); | 101 | m_httpServer.Start(); |
102 | |||
103 | base.StartupSpecific(); | ||
102 | } | 104 | } |
103 | 105 | ||
104 | protected void AddHttpHandlers() | 106 | protected void AddHttpHandlers() |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 68edbd2..3fb07b5 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Grid.GridServer | |||
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// </summary> | 41 | /// </summary> |
42 | public class GridServerBase : BaseOpenSimServer, conscmd_callback | 42 | public class GridServerBase : BaseOpenSimServer |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
@@ -59,43 +59,34 @@ namespace OpenSim.Grid.GridServer | |||
59 | 59 | ||
60 | public GridServerBase() | 60 | public GridServerBase() |
61 | { | 61 | { |
62 | m_console = new ConsoleBase("Grid", this); | 62 | m_console = new ConsoleBase("Grid"); |
63 | MainConsole.Instance = m_console; | 63 | MainConsole.Instance = m_console; |
64 | } | 64 | } |
65 | 65 | ||
66 | public override void RunCmd(string cmd, string[] cmdparams) | 66 | private void HandleRegistration(string module, string[] cmd) |
67 | { | 67 | { |
68 | base.RunCmd(cmd, cmdparams); | 68 | switch (cmd[0]) |
69 | |||
70 | switch (cmd) | ||
71 | { | 69 | { |
72 | case "disable-reg": | 70 | case "enable": |
73 | m_config.AllowRegionRegistration = false; | 71 | m_config.AllowRegionRegistration = true; |
74 | m_log.Info("Region registration disabled"); | 72 | m_log.Info("Region registration enabled"); |
75 | break; | 73 | break; |
76 | case "enable-reg": | 74 | case "disable": |
77 | m_config.AllowRegionRegistration = true; | 75 | m_config.AllowRegionRegistration = false; |
78 | m_log.Info("Region registration enabled"); | 76 | m_log.Info("Region registration disabled"); |
79 | break; | 77 | break; |
80 | } | 78 | } |
81 | } | 79 | } |
82 | |||
83 | public override void Show(string[] showParams) | ||
84 | { | ||
85 | base.Show(showParams); | ||
86 | 80 | ||
87 | switch (showParams[0]) | 81 | private void HandleShowStatus(string module, string[] cmd) |
82 | { | ||
83 | if (m_config.AllowRegionRegistration) | ||
88 | { | 84 | { |
89 | case "status": | 85 | m_log.Info("Region registration enabled."); |
90 | if (m_config.AllowRegionRegistration) | 86 | } |
91 | { | 87 | else |
92 | m_log.Info("Region registration enabled."); | 88 | { |
93 | } | 89 | m_log.Info("Region registration disabled."); |
94 | else | ||
95 | { | ||
96 | m_log.Info("Region registration disabled."); | ||
97 | } | ||
98 | break; | ||
99 | } | 90 | } |
100 | } | 91 | } |
101 | 92 | ||
@@ -120,6 +111,20 @@ namespace OpenSim.Grid.GridServer | |||
120 | // Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. | 111 | // Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. |
121 | // simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); | 112 | // simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); |
122 | // simCheckTimer.Enabled = true; | 113 | // simCheckTimer.Enabled = true; |
114 | |||
115 | base.StartupSpecific(); | ||
116 | |||
117 | m_console.Commands.AddCommand("gridserver", "enable registration", | ||
118 | "enable registration", | ||
119 | "Enable new regions to register", HandleRegistration); | ||
120 | |||
121 | m_console.Commands.AddCommand("gridserver", "disable registration", | ||
122 | "disable registration", | ||
123 | "Disable registering new regions", HandleRegistration); | ||
124 | |||
125 | m_console.Commands.AddCommand("gridserver", "show status", | ||
126 | "show status", | ||
127 | "Show registration status", HandleShowStatus); | ||
123 | } | 128 | } |
124 | 129 | ||
125 | protected void AddHttpHandlers() | 130 | protected void AddHttpHandlers() |
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 81a6a03..4727f6e 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs | |||
@@ -38,7 +38,7 @@ using OpenSim.Framework.Servers; | |||
38 | 38 | ||
39 | namespace OpenSim.Grid.InventoryServer | 39 | namespace OpenSim.Grid.InventoryServer |
40 | { | 40 | { |
41 | public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback | 41 | public class OpenInventory_Main : BaseOpenSimServer |
42 | { | 42 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 44 | ||
@@ -58,7 +58,7 @@ namespace OpenSim.Grid.InventoryServer | |||
58 | 58 | ||
59 | public OpenInventory_Main() | 59 | public OpenInventory_Main() |
60 | { | 60 | { |
61 | m_console = new ConsoleBase("Inventory", this); | 61 | m_console = new ConsoleBase("Inventory"); |
62 | MainConsole.Instance = m_console; | 62 | MainConsole.Instance = m_console; |
63 | } | 63 | } |
64 | 64 | ||
@@ -77,6 +77,12 @@ namespace OpenSim.Grid.InventoryServer | |||
77 | m_httpServer.Start(); | 77 | m_httpServer.Start(); |
78 | 78 | ||
79 | m_log.Info("[" + LogName + "]: Started HTTP server"); | 79 | m_log.Info("[" + LogName + "]: Started HTTP server"); |
80 | |||
81 | base.StartupSpecific(); | ||
82 | |||
83 | m_console.Commands.AddCommand("inventoryserver", "add user", | ||
84 | "add user", | ||
85 | "Add a random user inventory", HandleAddUser); | ||
80 | } | 86 | } |
81 | 87 | ||
82 | protected void AddHttpHandlers() | 88 | protected void AddHttpHandlers() |
@@ -146,16 +152,9 @@ namespace OpenSim.Grid.InventoryServer | |||
146 | } | 152 | } |
147 | } | 153 | } |
148 | 154 | ||
149 | public override void RunCmd(string cmd, string[] cmdparams) | 155 | private void HandleAddUser(string module, string[] args) |
150 | { | 156 | { |
151 | base.RunCmd(cmd, cmdparams); | 157 | m_inventoryService.CreateUsersInventory(UUID.Random().Guid); |
152 | |||
153 | switch (cmd) | ||
154 | { | ||
155 | case "add-user": | ||
156 | m_inventoryService.CreateUsersInventory(UUID.Random().Guid); | ||
157 | break; | ||
158 | } | ||
159 | } | 158 | } |
160 | } | 159 | } |
161 | } | 160 | } |
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index e83da7a..9b7e731 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Grid.MessagingServer | |||
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// </summary> | 43 | /// </summary> |
44 | public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback | 44 | public class OpenMessage_Main : BaseOpenSimServer |
45 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
@@ -64,7 +64,7 @@ namespace OpenSim.Grid.MessagingServer | |||
64 | 64 | ||
65 | public OpenMessage_Main() | 65 | public OpenMessage_Main() |
66 | { | 66 | { |
67 | m_console = new ConsoleBase("Messaging", this); | 67 | m_console = new ConsoleBase("Messaging"); |
68 | MainConsole.Instance = m_console; | 68 | MainConsole.Instance = m_console; |
69 | } | 69 | } |
70 | 70 | ||
@@ -124,6 +124,16 @@ namespace OpenSim.Grid.MessagingServer | |||
124 | registerWithUserServer(); | 124 | registerWithUserServer(); |
125 | 125 | ||
126 | m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete"); | 126 | m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete"); |
127 | |||
128 | base.StartupSpecific(); | ||
129 | |||
130 | m_console.Commands.AddCommand("messageserver", "clear cache", | ||
131 | "clear cache", | ||
132 | "Clear presence cache", HandleClearCache); | ||
133 | |||
134 | m_console.Commands.AddCommand("messageserver", "register", | ||
135 | "register", | ||
136 | "Re-register with user server(s)", HandleRegister); | ||
127 | } | 137 | } |
128 | 138 | ||
129 | public void do_create(string what) | 139 | public void do_create(string what) |
@@ -154,29 +164,17 @@ namespace OpenSim.Grid.MessagingServer | |||
154 | } | 164 | } |
155 | } | 165 | } |
156 | 166 | ||
157 | public override void RunCmd(string cmd, string[] cmdparams) | 167 | private void HandleClearCache(string module, string[] cmd) |
158 | { | 168 | { |
159 | base.RunCmd(cmd, cmdparams); | 169 | int entries = msgsvc.ClearRegionCache(); |
160 | 170 | m_console.Notice("Region cache cleared! Cleared " + | |
161 | switch (cmd) | 171 | entries.ToString() + " entries"); |
162 | { | ||
163 | case "clear-cache": | ||
164 | int entries = msgsvc.ClearRegionCache(); | ||
165 | m_console.Notice("Region cache cleared! Cleared " + entries.ToString() + " entries"); | ||
166 | break; | ||
167 | case "register": | ||
168 | deregisterFromUserServer(); | ||
169 | registerWithUserServer(); | ||
170 | break; | ||
171 | } | ||
172 | } | 172 | } |
173 | 173 | ||
174 | protected override void ShowHelp(string[] helpArgs) | 174 | private void HandleRegister(string module, string[] cmd) |
175 | { | 175 | { |
176 | base.ShowHelp(helpArgs); | 176 | deregisterFromUserServer(); |
177 | 177 | registerWithUserServer(); | |
178 | m_console.Notice("clear-cache - Clears region cache. Should be done when regions change position. The region cache gets stale after a while."); | ||
179 | m_console.Notice("register - (Re-)registers with user-server. This might be necessary if the userserver crashed/restarted"); | ||
180 | } | 178 | } |
181 | 179 | ||
182 | public override void ShutdownSpecific() | 180 | public override void ShutdownSpecific() |
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index be26ab3..0b0bee1 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Grid.UserServer | |||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Grid user server main class | 47 | /// Grid user server main class |
48 | /// </summary> | 48 | /// </summary> |
49 | public class OpenUser_Main : BaseOpenSimServer, conscmd_callback | 49 | public class OpenUser_Main : BaseOpenSimServer |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
@@ -73,7 +73,7 @@ namespace OpenSim.Grid.UserServer | |||
73 | 73 | ||
74 | public OpenUser_Main() | 74 | public OpenUser_Main() |
75 | { | 75 | { |
76 | m_console = new ConsoleBase("User", this); | 76 | m_console = new ConsoleBase("User"); |
77 | MainConsole.Instance = m_console; | 77 | MainConsole.Instance = m_console; |
78 | } | 78 | } |
79 | 79 | ||
@@ -119,6 +119,37 @@ namespace OpenSim.Grid.UserServer | |||
119 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); | 119 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); |
120 | AddHttpHandlers(); | 120 | AddHttpHandlers(); |
121 | m_httpServer.Start(); | 121 | m_httpServer.Start(); |
122 | |||
123 | base.StartupSpecific(); | ||
124 | |||
125 | m_console.Commands.AddCommand("userserver", "create user", | ||
126 | "create user [<first> [<last> [<x> <y> [email]]]]", | ||
127 | "Create a new user account", RunCommand); | ||
128 | |||
129 | m_console.Commands.AddCommand("userserver", "reset user password", | ||
130 | "reset user password [<first> [<last> [<new password>]]]", | ||
131 | "Reset a user's password", RunCommand); | ||
132 | |||
133 | m_console.Commands.AddCommand("userserver", "login level", | ||
134 | "login level <level>", | ||
135 | "Set the minimum user level to log in", HandleLoginCommand); | ||
136 | |||
137 | m_console.Commands.AddCommand("userserver", "login reset", | ||
138 | "login reset", | ||
139 | "Reset the login level to allow all users", | ||
140 | HandleLoginCommand); | ||
141 | |||
142 | m_console.Commands.AddCommand("userserver", "login text", | ||
143 | "login text <text>", | ||
144 | "Set the text users will see on login", HandleLoginCommand); | ||
145 | |||
146 | m_console.Commands.AddCommand("userserver", "test-inventory", | ||
147 | "test-inventory", | ||
148 | "Perform a test inventory transaction", RunCommand); | ||
149 | |||
150 | m_console.Commands.AddCommand("userserver", "logoff-user", | ||
151 | "logoff-user <first> <last> <message>", | ||
152 | "Log off a named user", RunCommand); | ||
122 | } | 153 | } |
123 | 154 | ||
124 | /// <summary> | 155 | /// <summary> |
@@ -301,39 +332,54 @@ namespace OpenSim.Grid.UserServer | |||
301 | m_userManager.ResetUserPassword(firstName, lastName, newPassword); | 332 | m_userManager.ResetUserPassword(firstName, lastName, newPassword); |
302 | } | 333 | } |
303 | 334 | ||
304 | public override void RunCmd(string cmd, string[] cmdparams) | 335 | private void HandleLoginCommand(string module, string[] cmd) |
305 | { | 336 | { |
306 | base.RunCmd(cmd, cmdparams); | 337 | string subcommand = cmd[1]; |
307 | switch (cmd) | 338 | |
339 | switch (subcommand) | ||
308 | { | 340 | { |
309 | case "create": | 341 | case "level": |
310 | do_create(cmdparams); | 342 | // Set the minimal level to allow login |
311 | break; | 343 | // Useful to allow grid update without worrying about users. |
312 | 344 | // or fixing critical issues | |
313 | case "reset": | 345 | // |
314 | Reset(cmdparams); | 346 | if (cmd.Length > 2) |
315 | break; | ||
316 | |||
317 | |||
318 | case "login-level": | ||
319 | // Set the minimal level to allow login | ||
320 | // Usefull to allow grid update without worrying about users. | ||
321 | // or fixing critical issue | ||
322 | if (cmdparams.Length == 1) | ||
323 | { | 347 | { |
324 | int level = Convert.ToInt32(cmdparams[0]); | 348 | int level = Convert.ToInt32(cmd[2]); |
325 | m_loginService.setloginlevel(level); | 349 | m_loginService.setloginlevel(level); |
326 | } | 350 | } |
327 | break; | 351 | break; |
328 | case "login-reset": | 352 | case "reset": |
329 | m_loginService.setloginlevel(0); | 353 | m_loginService.setloginlevel(0); |
330 | break; | 354 | break; |
331 | case "login-text": | 355 | case "text": |
332 | if (cmdparams.Length == 1) | 356 | if (cmd.Length > 2) |
333 | { | 357 | { |
334 | m_loginService.setwelcometext(cmdparams[0]); | 358 | m_loginService.setwelcometext(cmd[2]); |
335 | } | 359 | } |
336 | break; | 360 | break; |
361 | } | ||
362 | } | ||
363 | |||
364 | public void RunCommand(string module, string[] cmd) | ||
365 | { | ||
366 | List<string> args = new List<string>(cmd); | ||
367 | string command = cmd[0]; | ||
368 | |||
369 | args.RemoveAt(0); | ||
370 | |||
371 | string[] cmdparams = args.ToArray(); | ||
372 | |||
373 | switch (command) | ||
374 | { | ||
375 | case "create": | ||
376 | do_create(cmdparams); | ||
377 | break; | ||
378 | |||
379 | case "reset": | ||
380 | Reset(cmdparams); | ||
381 | break; | ||
382 | |||
337 | 383 | ||
338 | case "test-inventory": | 384 | case "test-inventory": |
339 | // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); | 385 | // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); |
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index a8e1499..7a427dc 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs | |||
@@ -34,6 +34,7 @@ using log4net.Config; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Region.Framework.Scenes; | ||
37 | 38 | ||
38 | namespace OpenSim | 39 | namespace OpenSim |
39 | { | 40 | { |
@@ -46,6 +47,8 @@ namespace OpenSim | |||
46 | public static bool m_saveCrashDumps = false; | 47 | public static bool m_saveCrashDumps = false; |
47 | public static string m_crashDir = "crashes"; | 48 | public static string m_crashDir = "crashes"; |
48 | 49 | ||
50 | protected static OpenSimBase m_sim = null; | ||
51 | |||
49 | //could move our main function into OpenSimMain and kill this class | 52 | //could move our main function into OpenSimMain and kill this class |
50 | public static void Main(string[] args) | 53 | public static void Main(string[] args) |
51 | { | 54 | { |
@@ -93,18 +96,18 @@ namespace OpenSim | |||
93 | 96 | ||
94 | if (background) | 97 | if (background) |
95 | { | 98 | { |
96 | OpenSimBase sim = new OpenSimBackground(configSource); | 99 | m_sim = new OpenSimBackground(configSource); |
97 | sim.Startup(); | 100 | m_sim.Startup(); |
98 | } | 101 | } |
99 | else | 102 | else |
100 | { | 103 | { |
101 | OpenSimBase sim = null; | 104 | m_sim = null; |
102 | if (hgrid) | 105 | if (hgrid) |
103 | sim = new HGOpenSimNode(configSource); | 106 | m_sim = new HGOpenSimNode(configSource); |
104 | else | 107 | else |
105 | sim = new OpenSim(configSource); | 108 | m_sim = new OpenSim(configSource); |
106 | 109 | ||
107 | sim.Startup(); | 110 | m_sim.Startup(); |
108 | 111 | ||
109 | while (true) | 112 | while (true) |
110 | { | 113 | { |
diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs index 4941fb4..2de9ddf 100644 --- a/OpenSim/Region/Application/HGOpenSimNode.cs +++ b/OpenSim/Region/Application/HGOpenSimNode.cs | |||
@@ -77,6 +77,9 @@ namespace OpenSim | |||
77 | m_log.Info("===================================================================="); | 77 | m_log.Info("===================================================================="); |
78 | 78 | ||
79 | base.StartupSpecific(); | 79 | base.StartupSpecific(); |
80 | |||
81 | MainConsole.Instance.Commands.AddCommand("hypergrid", "link-mapping", "link-mapping [<x> <y>] <cr>", "Set local coordinate to map HG regions to", RunCommand); | ||
82 | MainConsole.Instance.Commands.AddCommand("hypergrid", "link-region", "link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> <cr>", "Link a hypergrid region", RunCommand); | ||
80 | } | 83 | } |
81 | 84 | ||
82 | protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder) | 85 | protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder) |
@@ -143,11 +146,18 @@ namespace OpenSim | |||
143 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); | 146 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); |
144 | } | 147 | } |
145 | 148 | ||
146 | public override void RunCmd(string command, string[] cmdparams) | 149 | public void RunCommand(string module, string[] cp) |
147 | { | 150 | { |
151 | List<string> cmdparams = new List<string>(cp); | ||
152 | if (cmdparams.Count < 1) | ||
153 | return; | ||
154 | |||
155 | string command = cmdparams[0]; | ||
156 | cmdparams.RemoveAt(0); | ||
157 | |||
148 | if (command.Equals("link-mapping")) | 158 | if (command.Equals("link-mapping")) |
149 | { | 159 | { |
150 | if (cmdparams.Length == 2) | 160 | if (cmdparams.Count == 2) |
151 | { | 161 | { |
152 | try | 162 | try |
153 | { | 163 | { |
@@ -166,11 +176,11 @@ namespace OpenSim | |||
166 | else if (command.Equals("link-region")) | 176 | else if (command.Equals("link-region")) |
167 | { | 177 | { |
168 | // link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> | 178 | // link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> |
169 | if (cmdparams.Length < 4) | 179 | if (cmdparams.Count < 4) |
170 | { | 180 | { |
171 | if ((cmdparams.Length == 1) || (cmdparams.Length ==2)) | 181 | if ((cmdparams.Count == 1) || (cmdparams.Count ==2)) |
172 | { | 182 | { |
173 | LoadXmlLinkFile(cmdparams); | 183 | LoadXmlLinkFile(cmdparams.ToArray()); |
174 | } | 184 | } |
175 | else | 185 | else |
176 | { | 186 | { |
@@ -201,19 +211,16 @@ namespace OpenSim | |||
201 | 211 | ||
202 | if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) | 212 | if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) |
203 | { | 213 | { |
204 | if (cmdparams.Length >= 5) | 214 | if (cmdparams.Count >= 5) |
205 | { | 215 | { |
206 | regInfo.RegionName = ""; | 216 | regInfo.RegionName = ""; |
207 | for (int i = 4; i < cmdparams.Length; i++) | 217 | for (int i = 4; i < cmdparams.Count; i++) |
208 | regInfo.RegionName += cmdparams[i] + " "; | 218 | regInfo.RegionName += cmdparams[i] + " "; |
209 | } | 219 | } |
210 | } | 220 | } |
211 | 221 | ||
212 | return; | 222 | return; |
213 | } | 223 | } |
214 | |||
215 | base.RunCmd(command, cmdparams); | ||
216 | |||
217 | } | 224 | } |
218 | 225 | ||
219 | private void LoadXmlLinkFile(string[] cmdparams) | 226 | private void LoadXmlLinkFile(string[] cmdparams) |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index af42a3d..37066c2 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -49,7 +49,7 @@ namespace OpenSim | |||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Interactive OpenSim region server | 50 | /// Interactive OpenSim region server |
51 | /// </summary> | 51 | /// </summary> |
52 | public class OpenSim : OpenSimBase, conscmd_callback | 52 | public class OpenSim : OpenSimBase |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
@@ -59,11 +59,6 @@ namespace OpenSim | |||
59 | private string m_timedScript = "disabled"; | 59 | private string m_timedScript = "disabled"; |
60 | private Timer m_scriptTimer; | 60 | private Timer m_scriptTimer; |
61 | 61 | ||
62 | /// <summary> | ||
63 | /// List of Console Plugin Commands | ||
64 | /// </summary> | ||
65 | private static List<ConsolePluginCommand> m_PluginCommandInfos = new List<ConsolePluginCommand>(); | ||
66 | |||
67 | public OpenSim(IConfigSource configSource) : base(configSource) | 62 | public OpenSim(IConfigSource configSource) : base(configSource) |
68 | { | 63 | { |
69 | } | 64 | } |
@@ -97,9 +92,189 @@ namespace OpenSim | |||
97 | //GCSettings.LatencyMode = GCLatencyMode.Batch; | 92 | //GCSettings.LatencyMode = GCLatencyMode.Batch; |
98 | //m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString()); | 93 | //m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString()); |
99 | 94 | ||
100 | m_console = new ConsoleBase("Region", this); | 95 | m_console = new ConsoleBase("Region"); |
101 | MainConsole.Instance = m_console; | 96 | MainConsole.Instance = m_console; |
102 | 97 | ||
98 | m_console.Commands.AddCommand("region", "clear assets", | ||
99 | "clear assets", | ||
100 | "Clear the asset cache", HandleClearAssets); | ||
101 | |||
102 | m_console.Commands.AddCommand("region", "force update", | ||
103 | "force update", | ||
104 | "Force the update of all objects on clients", | ||
105 | HandleForceUpdate); | ||
106 | |||
107 | m_console.Commands.AddCommand("region", "debug packet", | ||
108 | "debug packet <level>", | ||
109 | "Turn on packet debugging", Debug); | ||
110 | |||
111 | m_console.Commands.AddCommand("region", "debug scene", | ||
112 | "debug scene <cripting> <collisions> <physics>", | ||
113 | "Turn on scene debugging", Debug); | ||
114 | |||
115 | m_console.Commands.AddCommand("region", "change region", | ||
116 | "change region <region name>", | ||
117 | "Change current console region", ChangeSelectedRegion); | ||
118 | |||
119 | m_console.Commands.AddCommand("region", "save xml", | ||
120 | "save xml", | ||
121 | "Save a region's data in XML format", SaveXml); | ||
122 | |||
123 | m_console.Commands.AddCommand("region", "save xml2", | ||
124 | "save xml2", | ||
125 | "Save a region's data in XML2 format", SaveXml2); | ||
126 | |||
127 | m_console.Commands.AddCommand("region", "load xml", | ||
128 | "load xml [-newIDs [<x> <y> <z>]]", | ||
129 | "Load a region's data from XML format", LoadXml); | ||
130 | |||
131 | m_console.Commands.AddCommand("region", "load xml2", | ||
132 | "load xml2", | ||
133 | "Load a region's data from XML2 format", LoadXml2); | ||
134 | |||
135 | m_console.Commands.AddCommand("region", "save prims xml2", | ||
136 | "save prims xml2 [<prim name> <file name>]", | ||
137 | "Save named prim to XML2", SavePrimsXml2); | ||
138 | |||
139 | m_console.Commands.AddCommand("region", "load oar", | ||
140 | "load oar <oar name>", | ||
141 | "Load a region's data from OAR archive", LoadOar); | ||
142 | |||
143 | m_console.Commands.AddCommand("region", "save oar", | ||
144 | "save oar <oar name>", | ||
145 | "Save a region's data to an OAR archive", SaveOar); | ||
146 | |||
147 | m_console.Commands.AddCommand("region", "save inventory", | ||
148 | "save inventory <first> <last> <path> <file>", | ||
149 | "Save user inventory data", SaveInv); | ||
150 | |||
151 | m_console.Commands.AddCommand("region", "load inventory", | ||
152 | "load inventory <first> <last> <path> <file>", | ||
153 | "Load user inventory data", LoadInv); | ||
154 | |||
155 | m_console.Commands.AddCommand("region", "edit scale", | ||
156 | "edit scale <name> <x> <y> <z>", | ||
157 | "Change the scale of a named prim", HandleEditScale); | ||
158 | |||
159 | m_console.Commands.AddCommand("region", "kick user", | ||
160 | "kick user <first> <last>", | ||
161 | "Kick a user off the simulator", HandleEditScale); | ||
162 | |||
163 | m_console.Commands.AddCommand("region", "show assets", | ||
164 | "show assets", | ||
165 | "Show asset data", HandleShow); | ||
166 | |||
167 | m_console.Commands.AddCommand("region", "show users", | ||
168 | "show users [full]", | ||
169 | "Show user data", HandleShow); | ||
170 | |||
171 | m_console.Commands.AddCommand("region", "show users full", | ||
172 | "show users full", | ||
173 | String.Empty, HandleShow); | ||
174 | |||
175 | m_console.Commands.AddCommand("region", "show modules", | ||
176 | "show modules", | ||
177 | "Show module data", HandleShow); | ||
178 | |||
179 | m_console.Commands.AddCommand("region", "show regions", | ||
180 | "show regions", | ||
181 | "Show region data", HandleShow); | ||
182 | |||
183 | m_console.Commands.AddCommand("region", "show queues", | ||
184 | "show queues", | ||
185 | "Show queue data", HandleShow); | ||
186 | |||
187 | m_console.Commands.AddCommand("region", "alert", | ||
188 | "alert <first> <last> <message>", | ||
189 | "Send an alert to a user", RunCommand); | ||
190 | |||
191 | m_console.Commands.AddCommand("region", "alert general", | ||
192 | "alert general <message>", | ||
193 | "Send an alert everyone", RunCommand); | ||
194 | |||
195 | m_console.Commands.AddCommand("region", "backup", | ||
196 | "backup", | ||
197 | "Persist objects to the database now", RunCommand); | ||
198 | |||
199 | m_console.Commands.AddCommand("region", "create region", | ||
200 | "create region", | ||
201 | "Create a new region", HandleCreateRegion); | ||
202 | |||
203 | m_console.Commands.AddCommand("region", "login enable", | ||
204 | "login enable", | ||
205 | "Enable logins to the simulator", HandleLoginEnable); | ||
206 | |||
207 | m_console.Commands.AddCommand("region", "login disable", | ||
208 | "login disable", | ||
209 | "Disable logins to the simulator", HandleLoginDisable); | ||
210 | |||
211 | m_console.Commands.AddCommand("region", "login status", | ||
212 | "login status", | ||
213 | "Display status of logins", HandleLoginStatus); | ||
214 | |||
215 | m_console.Commands.AddCommand("region", "restart", | ||
216 | "restart", | ||
217 | "Restart all sims in this instance", RunCommand); | ||
218 | |||
219 | m_console.Commands.AddCommand("region", "config set", | ||
220 | "config set <section> <field> <value>", | ||
221 | "Set a config option", HandleConfig); | ||
222 | |||
223 | m_console.Commands.AddCommand("region", "config get", | ||
224 | "config get <section> <field>", | ||
225 | "Read a config option", HandleConfig); | ||
226 | |||
227 | m_console.Commands.AddCommand("region", "config save", | ||
228 | "config save", | ||
229 | "Save current configuration", HandleConfig); | ||
230 | |||
231 | m_console.Commands.AddCommand("region", "command-script", | ||
232 | "command-script <script>", | ||
233 | "Run a command script from file", RunCommand); | ||
234 | |||
235 | m_console.Commands.AddCommand("region", "export-map", | ||
236 | "export-map <file>", | ||
237 | "Save an image of the world map", RunCommand); | ||
238 | |||
239 | m_console.Commands.AddCommand("region", "remove-region", | ||
240 | "remove-region <name>", | ||
241 | "Remove a region from this simulator", RunCommand); | ||
242 | |||
243 | m_console.Commands.AddCommand("region", "delete-region", | ||
244 | "delete-region <name>", | ||
245 | "Delete a region from disk", RunCommand); | ||
246 | |||
247 | m_console.Commands.AddCommand("region", "predecode-j2k", | ||
248 | "predecode-j2k [<num threads>]>", | ||
249 | "Precache assets,decode j2k layerdata", RunCommand); | ||
250 | |||
251 | m_console.Commands.AddCommand("region", "modules list", | ||
252 | "modules list", | ||
253 | "List modules", HandleModules); | ||
254 | |||
255 | m_console.Commands.AddCommand("region", "modules load", | ||
256 | "modules load <name>", | ||
257 | "Load a module", HandleModules); | ||
258 | |||
259 | m_console.Commands.AddCommand("region", "modules unload", | ||
260 | "modules unload <name>", | ||
261 | "Unload a module", HandleModules); | ||
262 | |||
263 | m_console.Commands.AddCommand("region", "Add-InventoryHost", | ||
264 | "Add-InventoryHost <host>", | ||
265 | String.Empty, RunCommand); | ||
266 | |||
267 | if (ConfigurationSettings.Standalone) | ||
268 | { | ||
269 | m_console.Commands.AddCommand("region", "create user", | ||
270 | "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]", | ||
271 | "Create a new user", HandleCreateUser); | ||
272 | |||
273 | m_console.Commands.AddCommand("region", "reset user password", | ||
274 | "reset user password [<first> [<last> [<password>]]]", | ||
275 | "Reset a user password", HandleResetUserPassword); | ||
276 | } | ||
277 | |||
103 | base.StartupSpecific(); | 278 | base.StartupSpecific(); |
104 | 279 | ||
105 | //Run Startup Commands | 280 | //Run Startup Commands |
@@ -122,11 +297,9 @@ namespace OpenSim | |||
122 | } | 297 | } |
123 | 298 | ||
124 | PrintFileToConsole("startuplogo.txt"); | 299 | PrintFileToConsole("startuplogo.txt"); |
125 | RegisterCmd("echoTest", RunEchoTest, "this echos your command args to see how they are parsed"); | ||
126 | RegisterCmd("kickuser", KickUserCommand, "kickuser [first] [last] - attempts to log off a user from any region we are serving"); | ||
127 | 300 | ||
128 | // For now, start at the 'root' level by default | 301 | // For now, start at the 'root' level by default |
129 | ChangeSelectedRegion(new string[] {"root"}); | 302 | ChangeSelectedRegion("region", new string[] {"change", "region", "root"}); |
130 | } | 303 | } |
131 | 304 | ||
132 | public override void ShutdownSpecific() | 305 | public override void ShutdownSpecific() |
@@ -148,17 +321,9 @@ namespace OpenSim | |||
148 | 321 | ||
149 | #region Console Commands | 322 | #region Console Commands |
150 | 323 | ||
151 | private void RunEchoTest(string[] cmdparams) | 324 | private void KickUserCommand(string module, string[] cmdparams) |
152 | { | 325 | { |
153 | for (int i = 0; i < cmdparams.Length; i++) | 326 | if (cmdparams.Length < 4) |
154 | { | ||
155 | m_log.Info("[EchoTest]: <arg" + i + ">"+cmdparams[i]+"</arg" + i + ">"); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | private void KickUserCommand(string[] cmdparams) | ||
160 | { | ||
161 | if (cmdparams.Length < 2) | ||
162 | return; | 327 | return; |
163 | 328 | ||
164 | IList agents = m_sceneManager.GetCurrentSceneAvatars(); | 329 | IList agents = m_sceneManager.GetCurrentSceneAvatars(); |
@@ -167,7 +332,7 @@ namespace OpenSim | |||
167 | { | 332 | { |
168 | RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); | 333 | RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); |
169 | 334 | ||
170 | if (presence.Firstname.ToLower().Contains(cmdparams[0].ToLower()) && presence.Lastname.ToLower().Contains(cmdparams[1].ToLower())) | 335 | if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && presence.Lastname.ToLower().Contains(cmdparams[3].ToLower())) |
171 | { | 336 | { |
172 | m_console.Notice( | 337 | m_console.Notice( |
173 | String.Format( | 338 | String.Format( |
@@ -219,302 +384,261 @@ namespace OpenSim | |||
219 | } | 384 | } |
220 | } | 385 | } |
221 | 386 | ||
222 | /// <summary> | 387 | private void HandleClearAssets(string module, string[] args) |
223 | /// Runs commands issued by the server console from the operator | ||
224 | /// </summary> | ||
225 | /// <param name="command">The first argument of the parameter (the command)</param> | ||
226 | /// <param name="cmdparams">Additional arguments passed to the command</param> | ||
227 | public override void RunCmd(string command, string[] cmdparams) | ||
228 | { | 388 | { |
229 | base.RunCmd(command, cmdparams); | 389 | m_assetCache.Clear(); |
230 | RunPluginCommands(command , cmdparams); | 390 | } |
231 | |||
232 | switch (command) | ||
233 | { | ||
234 | case "clear-assets": | ||
235 | m_assetCache.Clear(); | ||
236 | break; | ||
237 | |||
238 | case "force-update": | ||
239 | m_console.Notice("Updating all clients"); | ||
240 | m_sceneManager.ForceCurrentSceneClientUpdate(); | ||
241 | break; | ||
242 | |||
243 | case "edit-scale": | ||
244 | if (cmdparams.Length == 4) | ||
245 | { | ||
246 | m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams); | ||
247 | } | ||
248 | break; | ||
249 | |||
250 | case "debug": | ||
251 | Debug(cmdparams); | ||
252 | break; | ||
253 | |||
254 | case "save-xml": | ||
255 | SaveXml(cmdparams); | ||
256 | break; | ||
257 | |||
258 | case "load-xml": | ||
259 | LoadXml(cmdparams); | ||
260 | break; | ||
261 | |||
262 | case "save-xml2": | ||
263 | SaveXml2(cmdparams); | ||
264 | break; | ||
265 | 391 | ||
266 | case "load-xml2": | 392 | private void HandleForceUpdate(string module, string[] args) |
267 | LoadXml2(cmdparams); | 393 | { |
268 | break; | 394 | m_console.Notice("Updating all clients"); |
395 | m_sceneManager.ForceCurrentSceneClientUpdate(); | ||
396 | } | ||
269 | 397 | ||
270 | case "save-prims-xml2": | 398 | private void HandleEditScale(string module, string[] args) |
271 | if (cmdparams.Length > 1) | 399 | { |
272 | { | 400 | if (args.Length == 5) |
273 | m_sceneManager.SaveNamedPrimsToXml2(cmdparams[0], cmdparams[1]); | 401 | { |
274 | } | 402 | m_sceneManager.HandleEditCommandOnCurrentScene(args); |
275 | else | 403 | } |
276 | { | 404 | else |
277 | m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME); | 405 | { |
278 | } | 406 | m_console.Notice("Argument error: edit scale <prim name> <x> <y> <z>"); |
279 | break; | 407 | } |
408 | } | ||
280 | 409 | ||
281 | case "load-oar": | 410 | private void HandleCreateRegion(string module, string[] cmd) |
282 | LoadOar(cmdparams); | 411 | { |
283 | break; | 412 | if (cmd.Length < 4) |
413 | { | ||
414 | m_console.Error("Usage: create region <region name> <region_file.xml>"); | ||
415 | return; | ||
416 | } | ||
284 | 417 | ||
285 | case "save-oar": | 418 | string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); |
286 | SaveOar(cmdparams); | 419 | string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]); |
287 | break; | 420 | // Allow absolute and relative specifiers |
421 | if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith("..")) | ||
422 | regionFile = cmd[3]; | ||
288 | 423 | ||
289 | case "save-inv": | 424 | CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true); |
290 | SaveInv(cmdparams); | 425 | } |
291 | break; | ||
292 | 426 | ||
293 | case "load-inv": | 427 | private void HandleLoginEnable(string module, string[] cmd) |
294 | LoadInv(cmdparams); | 428 | { |
295 | break; | 429 | ProcessLogin(true); |
430 | } | ||
296 | 431 | ||
297 | case "plugin": | 432 | private void HandleLoginDisable(string module, string[] cmd) |
298 | m_sceneManager.SendCommandToPluginModules(cmdparams); | 433 | { |
299 | break; | 434 | ProcessLogin(false); |
435 | } | ||
300 | 436 | ||
301 | case "command-script": | 437 | private void HandleLoginStatus(string module, string[] cmd) |
302 | if (cmdparams.Length > 0) | 438 | { |
303 | { | 439 | if (m_commsManager.GridService.RegionLoginsEnabled == false) |
304 | RunCommandScript(cmdparams[0]); | ||
305 | } | ||
306 | break; | ||
307 | 440 | ||
308 | case "backup": | 441 | m_log.Info("[ Login ] Login are disabled "); |
309 | m_sceneManager.BackupCurrentScene(); | 442 | else |
310 | break; | 443 | m_log.Info("[ Login ] Login are enabled"); |
444 | } | ||
311 | 445 | ||
312 | case "alert": | 446 | private void HandleConfig(string module, string[] cmd) |
313 | m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams); | 447 | { |
314 | break; | 448 | List<string> args = new List<string>(cmd); |
449 | args.RemoveAt(0); | ||
450 | string[] cmdparams = args.ToArray(); | ||
451 | string n = "CONFIG"; | ||
315 | 452 | ||
316 | case "create": | 453 | if (cmdparams.Length > 0) |
317 | Create(cmdparams); | 454 | { |
318 | break; | 455 | switch (cmdparams[0].ToLower()) |
456 | { | ||
457 | case "set": | ||
458 | if (cmdparams.Length < 4) | ||
459 | { | ||
460 | m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); | ||
461 | m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | // IConfig c = DefaultConfig().Configs[cmdparams[1]]; | ||
466 | // if (c == null) | ||
467 | // c = DefaultConfig().AddConfig(cmdparams[1]); | ||
468 | IConfig c; | ||
469 | IConfigSource source = new IniConfigSource(); | ||
470 | c = source.AddConfig(cmdparams[1]); | ||
471 | if (c != null) | ||
472 | { | ||
473 | string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); | ||
474 | c.Set(cmdparams[2], _value); | ||
475 | m_config.Source.Merge(source); | ||
319 | 476 | ||
320 | case "login-enable": | 477 | m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + |
321 | ProcessLogin(true); | 478 | _value); |
322 | break; | 479 | } |
323 | case "login-disable": | 480 | } |
324 | ProcessLogin(false); | 481 | break; |
325 | break; | 482 | case "get": |
326 | case "login-status": | 483 | if (cmdparams.Length < 3) |
327 | if (m_commsManager.GridService.RegionLoginsEnabled == false) | 484 | { |
485 | m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY"); | ||
486 | m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); | ||
487 | } | ||
488 | else | ||
489 | { | ||
490 | IConfig c = m_config.Source.Configs[cmdparams[1]]; // DefaultConfig().Configs[cmdparams[1]]; | ||
491 | if (c == null) | ||
492 | { | ||
493 | m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); | ||
494 | break; | ||
495 | } | ||
496 | else | ||
497 | { | ||
498 | m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + | ||
499 | c.GetString(cmdparams[2])); | ||
500 | } | ||
501 | } | ||
328 | 502 | ||
329 | m_log.Info("[ Login ] Login are disabled "); | ||
330 | else | ||
331 | m_log.Info("[ Login ] Login are enabled"); | ||
332 | break; | ||
333 | case "create-region": | ||
334 | if (cmdparams.Length < 2) | ||
335 | { | ||
336 | m_console.Error("Usage: create-region <region name> <region_file.xml>"); | ||
337 | break; | 503 | break; |
338 | } | 504 | case "save": |
505 | m_console.Notice("Saving configuration file: " + Application.iniFilePath); | ||
506 | m_config.Save(Application.iniFilePath); | ||
507 | break; | ||
508 | } | ||
509 | } | ||
510 | } | ||
339 | 511 | ||
340 | string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); | 512 | private void HandleModules(string module, string[] cmd) |
341 | string regionFile = String.Format("{0}/{1}", regionsDir, cmdparams[1]); | 513 | { |
342 | // Allow absolute and relative specifiers | 514 | List<string> args = new List<string>(cmd); |
343 | if (cmdparams[1].StartsWith("/") || cmdparams[1].StartsWith("\\") || cmdparams[1].StartsWith("..")) | 515 | args.RemoveAt(0); |
344 | regionFile = cmdparams[1]; | 516 | string[] cmdparams = args.ToArray(); |
345 | 517 | ||
346 | CreateRegion(new RegionInfo(cmdparams[0], regionFile, false, ConfigSource.Source), true); | 518 | if (cmdparams.Length > 0) |
347 | break; | 519 | { |
520 | switch (cmdparams[0].ToLower()) | ||
521 | { | ||
522 | case "list": | ||
523 | foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) | ||
524 | { | ||
525 | m_console.Notice("Shared region module: " + irm.Name); | ||
526 | } | ||
527 | break; | ||
528 | case "unload": | ||
529 | if (cmdparams.Length > 1) | ||
530 | { | ||
531 | foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules)) | ||
532 | { | ||
533 | if (rm.Name.ToLower() == cmdparams[1].ToLower()) | ||
534 | { | ||
535 | m_console.Notice("Unloading module: " + rm.Name); | ||
536 | m_moduleLoader.UnloadModule(rm); | ||
537 | } | ||
538 | } | ||
539 | } | ||
540 | break; | ||
541 | case "load": | ||
542 | if (cmdparams.Length > 1) | ||
543 | { | ||
544 | foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) | ||
545 | { | ||
348 | 546 | ||
349 | case "remove-region": | 547 | m_console.Notice("Loading module: " + cmdparams[1]); |
350 | string regRemoveName = CombineParams(cmdparams, 0); | 548 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); |
549 | } | ||
550 | } | ||
551 | break; | ||
552 | } | ||
553 | } | ||
554 | } | ||
351 | 555 | ||
352 | Scene removeScene; | ||
353 | if (m_sceneManager.TryGetScene(regRemoveName, out removeScene)) | ||
354 | RemoveRegion(removeScene, false); | ||
355 | else | ||
356 | m_console.Error("no region with that name"); | ||
357 | break; | ||
358 | 556 | ||
359 | case "delete-region": | 557 | /// <summary> |
360 | string regDeleteName = CombineParams(cmdparams, 0); | 558 | /// Runs commands issued by the server console from the operator |
559 | /// </summary> | ||
560 | /// <param name="command">The first argument of the parameter (the command)</param> | ||
561 | /// <param name="cmdparams">Additional arguments passed to the command</param> | ||
562 | public void RunCommand(string module, string[] cmdparams) | ||
563 | { | ||
564 | List<string> args = new List<string>(cmdparams); | ||
565 | if (args.Count < 1) | ||
566 | return; | ||
361 | 567 | ||
362 | Scene killScene; | 568 | string command = args[0]; |
363 | if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) | 569 | args.RemoveAt(0); |
364 | RemoveRegion(killScene, true); | ||
365 | else | ||
366 | m_console.Error("no region with that name"); | ||
367 | break; | ||
368 | 570 | ||
369 | case "restart": | 571 | cmdparams = args.ToArray(); |
370 | m_sceneManager.RestartCurrentScene(); | ||
371 | break; | ||
372 | 572 | ||
373 | case "change-region": | 573 | switch (command) |
374 | ChangeSelectedRegion(cmdparams); | 574 | { |
375 | break; | 575 | case "command-script": |
576 | if (cmdparams.Length > 0) | ||
577 | { | ||
578 | RunCommandScript(cmdparams[0]); | ||
579 | } | ||
580 | break; | ||
376 | 581 | ||
377 | case "export-map": | 582 | case "backup": |
378 | if (cmdparams.Length > 0) | 583 | m_sceneManager.BackupCurrentScene(); |
379 | { | 584 | break; |
380 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]); | ||
381 | } | ||
382 | else | ||
383 | { | ||
384 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg"); | ||
385 | } | ||
386 | break; | ||
387 | 585 | ||
388 | case "config": | 586 | case "alert": |
389 | string n = command.ToUpper(); | 587 | m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams); |
390 | if (cmdparams.Length > 0) | 588 | break; |
391 | { | ||
392 | switch (cmdparams[0].ToLower()) | ||
393 | { | ||
394 | case "set": | ||
395 | if (cmdparams.Length < 4) | ||
396 | { | ||
397 | m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); | ||
398 | m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); | ||
399 | } | ||
400 | else | ||
401 | { | ||
402 | // IConfig c = DefaultConfig().Configs[cmdparams[1]]; | ||
403 | // if (c == null) | ||
404 | // c = DefaultConfig().AddConfig(cmdparams[1]); | ||
405 | IConfig c; | ||
406 | IConfigSource source = new IniConfigSource(); | ||
407 | c = source.AddConfig(cmdparams[1]); | ||
408 | if (c != null) | ||
409 | { | ||
410 | string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); | ||
411 | c.Set(cmdparams[2], _value); | ||
412 | m_config.Source.Merge(source); | ||
413 | |||
414 | m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + | ||
415 | _value); | ||
416 | } | ||
417 | } | ||
418 | break; | ||
419 | case "get": | ||
420 | if (cmdparams.Length < 3) | ||
421 | { | ||
422 | m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY"); | ||
423 | m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); | ||
424 | } | ||
425 | else | ||
426 | { | ||
427 | IConfig c = m_config.Source.Configs[cmdparams[1]]; // DefaultConfig().Configs[cmdparams[1]]; | ||
428 | if (c == null) | ||
429 | { | ||
430 | m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); | ||
431 | break; | ||
432 | } | ||
433 | else | ||
434 | { | ||
435 | m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + | ||
436 | c.GetString(cmdparams[2])); | ||
437 | } | ||
438 | } | ||
439 | 589 | ||
440 | break; | 590 | case "remove-region": |
441 | case "save": | 591 | string regRemoveName = CombineParams(cmdparams, 0); |
442 | m_console.Notice("Saving configuration file: " + Application.iniFilePath); | ||
443 | m_config.Save(Application.iniFilePath); | ||
444 | break; | ||
445 | } | ||
446 | } | ||
447 | break; | ||
448 | 592 | ||
449 | case "modules": | 593 | Scene removeScene; |
450 | if (cmdparams.Length > 0) | 594 | if (m_sceneManager.TryGetScene(regRemoveName, out removeScene)) |
451 | { | 595 | RemoveRegion(removeScene, false); |
452 | switch (cmdparams[0].ToLower()) | 596 | else |
453 | { | 597 | m_console.Error("no region with that name"); |
454 | case "list": | 598 | break; |
455 | foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) | ||
456 | { | ||
457 | m_console.Notice("Shared region module: " + irm.Name); | ||
458 | } | ||
459 | break; | ||
460 | case "unload": | ||
461 | if (cmdparams.Length > 1) | ||
462 | { | ||
463 | foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules)) | ||
464 | { | ||
465 | if (rm.Name.ToLower() == cmdparams[1].ToLower()) | ||
466 | { | ||
467 | m_console.Notice("Unloading module: " + rm.Name); | ||
468 | m_moduleLoader.UnloadModule(rm); | ||
469 | } | ||
470 | } | ||
471 | } | ||
472 | break; | ||
473 | case "load": | ||
474 | if (cmdparams.Length > 1) | ||
475 | { | ||
476 | foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) | ||
477 | { | ||
478 | 599 | ||
479 | m_console.Notice("Loading module: " + cmdparams[1]); | 600 | case "delete-region": |
480 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); | 601 | string regDeleteName = CombineParams(cmdparams, 0); |
481 | } | ||
482 | } | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | 602 | ||
487 | break; | 603 | Scene killScene; |
604 | if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) | ||
605 | RemoveRegion(killScene, true); | ||
606 | else | ||
607 | m_console.Error("no region with that name"); | ||
608 | break; | ||
488 | 609 | ||
489 | case "Add-InventoryHost": | 610 | case "restart": |
490 | if (cmdparams.Length > 0) | 611 | m_sceneManager.RestartCurrentScene(); |
491 | { | 612 | break; |
492 | m_commsManager.AddInventoryService(cmdparams[0]); | ||
493 | } | ||
494 | break; | ||
495 | 613 | ||
496 | case "reset": | 614 | case "export-map": |
497 | Reset(cmdparams); | 615 | if (cmdparams.Length > 0) |
498 | break; | 616 | { |
499 | 617 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]); | |
500 | case "predecode-j2k": | 618 | } |
501 | if (cmdparams.Length > 0) | 619 | else |
502 | { | 620 | { |
503 | m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0])); | 621 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg"); |
504 | } | 622 | } |
505 | else | 623 | break; |
506 | { | ||
507 | m_sceneManager.CacheJ2kDecode(1); | ||
508 | } | ||
509 | break; | ||
510 | 624 | ||
511 | default: | 625 | case "Add-InventoryHost": |
512 | string[] tmpPluginArgs = new string[cmdparams.Length + 1]; | 626 | if (cmdparams.Length > 0) |
513 | cmdparams.CopyTo(tmpPluginArgs, 1); | 627 | { |
514 | tmpPluginArgs[0] = command; | 628 | m_commsManager.AddInventoryService(cmdparams[0]); |
629 | } | ||
630 | break; | ||
515 | 631 | ||
516 | m_sceneManager.SendCommandToPluginModules(tmpPluginArgs); | 632 | case "predecode-j2k": |
517 | break; | 633 | if (cmdparams.Length > 0) |
634 | { | ||
635 | m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0])); | ||
636 | } | ||
637 | else | ||
638 | { | ||
639 | m_sceneManager.CacheJ2kDecode(1); | ||
640 | } | ||
641 | break; | ||
518 | } | 642 | } |
519 | } | 643 | } |
520 | 644 | ||
@@ -522,46 +646,39 @@ namespace OpenSim | |||
522 | /// Change the currently selected region. The selected region is that operated upon by single region commands. | 646 | /// Change the currently selected region. The selected region is that operated upon by single region commands. |
523 | /// </summary> | 647 | /// </summary> |
524 | /// <param name="cmdParams"></param> | 648 | /// <param name="cmdParams"></param> |
525 | protected void ChangeSelectedRegion(string[] cmdparams) | 649 | protected void ChangeSelectedRegion(string module, string[] cmdparams) |
526 | { | 650 | { |
527 | if (cmdparams.Length > 0) | 651 | if (cmdparams.Length > 2) |
528 | { | 652 | { |
529 | string newRegionName = CombineParams(cmdparams, 0); | 653 | string newRegionName = CombineParams(cmdparams, 2); |
530 | 654 | ||
531 | if (!m_sceneManager.TrySetCurrentScene(newRegionName)) | 655 | if (!m_sceneManager.TrySetCurrentScene(newRegionName)) |
532 | m_console.Error("Couldn't select region " + newRegionName); | 656 | m_console.Error("Couldn't select region " + newRegionName); |
533 | } | 657 | } |
534 | else | 658 | else |
535 | { | 659 | { |
536 | m_console.Error("Usage: change-region <region name>"); | 660 | m_console.Error("Usage: change region <region name>"); |
537 | } | 661 | } |
538 | 662 | ||
539 | string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName); | 663 | string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName); |
540 | m_console.Notice(String.Format("Currently selected region is {0}", regionName)); | 664 | m_console.Notice(String.Format("Currently selected region is {0}", regionName)); |
541 | m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName); | 665 | m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName); |
666 | m_console.ConsoleScene = m_sceneManager.CurrentScene; | ||
542 | } | 667 | } |
543 | 668 | ||
544 | /// <summary> | 669 | /// <summary> |
545 | /// Execute switch for some of the create commands | 670 | /// Execute switch for some of the create commands |
546 | /// </summary> | 671 | /// </summary> |
547 | /// <param name="args"></param> | 672 | /// <param name="args"></param> |
548 | protected void Create(string[] args) | 673 | private void HandleCreateUser(string module, string[] cmd) |
549 | { | 674 | { |
550 | if (args.Length == 0) | 675 | if (ConfigurationSettings.Standalone) |
551 | return; | ||
552 | |||
553 | switch (args[0]) | ||
554 | { | 676 | { |
555 | case "user": | 677 | CreateUser(cmd); |
556 | if (ConfigurationSettings.Standalone) | 678 | } |
557 | { | 679 | else |
558 | CreateUser(args); | 680 | { |
559 | } | 681 | m_console.Notice("Create user is not available in grid mode, use the user server."); |
560 | else | ||
561 | { | ||
562 | m_console.Notice("Create user is not available in grid mode, use the user server."); | ||
563 | } | ||
564 | break; | ||
565 | } | 682 | } |
566 | } | 683 | } |
567 | 684 | ||
@@ -569,30 +686,15 @@ namespace OpenSim | |||
569 | /// Execute switch for some of the reset commands | 686 | /// Execute switch for some of the reset commands |
570 | /// </summary> | 687 | /// </summary> |
571 | /// <param name="args"></param> | 688 | /// <param name="args"></param> |
572 | protected void Reset(string[] args) | 689 | protected void HandleResetUserPassword(string module, string[] cmd) |
573 | { | 690 | { |
574 | if (args.Length == 0) | 691 | if (ConfigurationSettings.Standalone) |
575 | return; | ||
576 | |||
577 | switch (args[0]) | ||
578 | { | 692 | { |
579 | case "user": | 693 | ResetUserPassword(cmd); |
580 | 694 | } | |
581 | switch (args[1]) | 695 | else |
582 | { | 696 | { |
583 | case "password": | 697 | m_console.Notice("Reset user password is not available in grid mode, use the user-server."); |
584 | if (ConfigurationSettings.Standalone) | ||
585 | { | ||
586 | ResetUserPassword(args); | ||
587 | } | ||
588 | else | ||
589 | { | ||
590 | m_console.Notice("Reset user password is not available in grid mode, use the user-server."); | ||
591 | } | ||
592 | break; | ||
593 | } | ||
594 | |||
595 | break; | ||
596 | } | 698 | } |
597 | } | 699 | } |
598 | 700 | ||
@@ -600,18 +702,18 @@ namespace OpenSim | |||
600 | /// Turn on some debugging values for OpenSim. | 702 | /// Turn on some debugging values for OpenSim. |
601 | /// </summary> | 703 | /// </summary> |
602 | /// <param name="args"></param> | 704 | /// <param name="args"></param> |
603 | protected void Debug(string[] args) | 705 | protected void Debug(string module, string[] args) |
604 | { | 706 | { |
605 | if (args.Length == 0) | 707 | if (args.Length == 1) |
606 | return; | 708 | return; |
607 | 709 | ||
608 | switch (args[0]) | 710 | switch (args[1]) |
609 | { | 711 | { |
610 | case "packet": | 712 | case "packet": |
611 | if (args.Length > 1) | 713 | if (args.Length > 2) |
612 | { | 714 | { |
613 | int newDebug; | 715 | int newDebug; |
614 | if (int.TryParse(args[1], out newDebug)) | 716 | if (int.TryParse(args[2], out newDebug)) |
615 | { | 717 | { |
616 | m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug); | 718 | m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug); |
617 | } | 719 | } |
@@ -625,17 +727,17 @@ namespace OpenSim | |||
625 | break; | 727 | break; |
626 | 728 | ||
627 | case "scene": | 729 | case "scene": |
628 | if (args.Length == 4) | 730 | if (args.Length == 5) |
629 | { | 731 | { |
630 | if (m_sceneManager.CurrentScene == null) | 732 | if (m_sceneManager.CurrentScene == null) |
631 | { | 733 | { |
632 | m_console.Error("CONSOLE", "Please use 'change-region <regioname>' first"); | 734 | m_console.Notice("Please use 'change region <regioname>' first"); |
633 | } | 735 | } |
634 | else | 736 | else |
635 | { | 737 | { |
636 | bool scriptingOn = !Convert.ToBoolean(args[1]); | 738 | bool scriptingOn = !Convert.ToBoolean(args[2]); |
637 | bool collisionsOn = !Convert.ToBoolean(args[2]); | 739 | bool collisionsOn = !Convert.ToBoolean(args[3]); |
638 | bool physicsOn = !Convert.ToBoolean(args[3]); | 740 | bool physicsOn = !Convert.ToBoolean(args[4]); |
639 | m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn); | 741 | m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn); |
640 | 742 | ||
641 | m_console.Notice( | 743 | m_console.Notice( |
@@ -658,87 +760,12 @@ namespace OpenSim | |||
658 | } | 760 | } |
659 | } | 761 | } |
660 | 762 | ||
661 | protected override void ShowHelp(string[] helpArgs) | ||
662 | { | ||
663 | base.ShowHelp(helpArgs); | ||
664 | |||
665 | if (helpArgs.Length == 0) | ||
666 | { | ||
667 | m_console.Notice("alert - send alert to a designated user or all users."); | ||
668 | m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); | ||
669 | m_console.Notice(" alert general [Message] - send an alert to all users."); | ||
670 | m_console.Notice("backup - persist simulator objects to the database ahead of the normal schedule."); | ||
671 | m_console.Notice("clear-assets - clear the asset cache"); | ||
672 | m_console.Notice("create-region <name> <regionfile.xml> - create a new region"); | ||
673 | m_console.Notice("change-region <name> - select the region that single region commands operate upon."); | ||
674 | m_console.Notice("command-script [filename] - Execute command in a file."); | ||
675 | m_console.Notice("debug - debugging commands"); | ||
676 | m_console.Notice(" debug packet 0..255 - print incoming/outgoing packets (0=off)"); | ||
677 | m_console.Notice(" debug scene [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False"); | ||
678 | m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim"); | ||
679 | m_console.Notice("export-map [filename] - save image of world map"); | ||
680 | m_console.Notice("force-update - force an update of prims in the scene"); | ||
681 | m_console.Notice("restart - disconnects all clients and restarts the sims in the instance."); | ||
682 | m_console.Notice("remove-region [name] - remove a region"); | ||
683 | m_console.Notice("delete-region [name] - delete a region and its associated region file"); | ||
684 | m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)"); | ||
685 | m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)"); | ||
686 | m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); | ||
687 | m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format"); | ||
688 | m_console.Notice("load-oar [filename] - load an OpenSimulator region archive. This replaces everything in the current region."); | ||
689 | m_console.Notice("save-oar [filename] - Save the current region to an OpenSimulator region archive."); | ||
690 | m_console.Notice("script - manually trigger scripts? or script commands?"); | ||
691 | m_console.Notice("show assets - show state of asset cache."); | ||
692 | m_console.Notice("show modules - shows info about loaded modules."); | ||
693 | m_console.Notice("show queues - show packet queues length for all clients."); | ||
694 | m_console.Notice("show regions - show running region information."); | ||
695 | m_console.Notice("show users - show info about connected users (only root agents)."); | ||
696 | m_console.Notice("show users full - show info about connected users (root and child agents)."); | ||
697 | m_console.Notice("config set section field value - set a config value"); | ||
698 | m_console.Notice("config get section field - get a config value"); | ||
699 | m_console.Notice("config save - save OpenSim.ini"); | ||
700 | m_console.Notice("login-enable - Allows login at sim level"); | ||
701 | m_console.Notice("login-disable - Disable login at sim level"); | ||
702 | m_console.Notice("login-status - Show the actual login status"); | ||
703 | m_console.Notice("predecode-j2k - Precache assets,decode j2k layerdata, First parameter is threads to use"); | ||
704 | ShowPluginCommandsHelp(CombineParams(helpArgs, 0), m_console); | ||
705 | |||
706 | if (ConfigurationSettings.Standalone) | ||
707 | { | ||
708 | m_console.Notice(""); | ||
709 | m_console.Notice("create user - adds a new user."); | ||
710 | m_console.Notice("reset user password - reset a user's password."); | ||
711 | } | ||
712 | } | ||
713 | else | ||
714 | { | ||
715 | // Messily we want to join all the help params back here | ||
716 | //string helpSubject = string.Join(" ", helpArgs); | ||
717 | |||
718 | // FIXME: Very cheap hack to get transition help working. Will disappear very shortly. | ||
719 | if (helpArgs.Length == 1) | ||
720 | { | ||
721 | ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(helpArgs[0]); | ||
722 | if (moduleCommander != null) | ||
723 | { | ||
724 | m_console.Notice(moduleCommander.Help); | ||
725 | } | ||
726 | } | ||
727 | else | ||
728 | { | ||
729 | ICommand command = SceneManager.CurrentOrFirstScene.GetCommand(helpArgs[1]); | ||
730 | if (command != null) | ||
731 | { | ||
732 | m_console.Notice(command.Help); | ||
733 | } | ||
734 | } | ||
735 | } | ||
736 | } | ||
737 | |||
738 | // see BaseOpenSimServer | 763 | // see BaseOpenSimServer |
739 | public override void Show(string[] showParams) | 764 | private void HandleShow(string mod, string[] cmd) |
740 | { | 765 | { |
741 | base.Show(showParams); | 766 | List<string> args = new List<string>(cmd); |
767 | args.RemoveAt(0); | ||
768 | string[] showParams = args.ToArray(); | ||
742 | 769 | ||
743 | switch (showParams[0]) | 770 | switch (showParams[0]) |
744 | { | 771 | { |
@@ -864,29 +891,29 @@ namespace OpenSim | |||
864 | uint regX = 1000; | 891 | uint regX = 1000; |
865 | uint regY = 1000; | 892 | uint regY = 1000; |
866 | 893 | ||
867 | if (cmdparams.Length < 2) | 894 | if (cmdparams.Length < 3) |
868 | firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); | 895 | firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); |
869 | else firstName = cmdparams[1]; | 896 | else firstName = cmdparams[2]; |
870 | 897 | ||
871 | if ( cmdparams.Length < 3 ) | 898 | if ( cmdparams.Length < 4 ) |
872 | lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); | 899 | lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); |
873 | else lastName = cmdparams[2]; | 900 | else lastName = cmdparams[3]; |
874 | 901 | ||
875 | if (cmdparams.Length < 4) | 902 | if (cmdparams.Length < 5) |
876 | password = MainConsole.Instance.PasswdPrompt("Password"); | 903 | password = MainConsole.Instance.PasswdPrompt("Password"); |
877 | else password = cmdparams[3]; | 904 | else password = cmdparams[4]; |
878 | 905 | ||
879 | if ( cmdparams.Length < 5 ) | 906 | if ( cmdparams.Length < 6 ) |
880 | regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); | 907 | regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); |
881 | else regX = Convert.ToUInt32(cmdparams[4]); | 908 | else regX = Convert.ToUInt32(cmdparams[5]); |
882 | 909 | ||
883 | if ( cmdparams.Length < 6 ) | 910 | if ( cmdparams.Length < 7 ) |
884 | regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); | 911 | regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); |
885 | else regY = Convert.ToUInt32(cmdparams[5]); | 912 | else regY = Convert.ToUInt32(cmdparams[6]); |
886 | 913 | ||
887 | if (cmdparams.Length < 7) | 914 | if (cmdparams.Length < 8) |
888 | email = MainConsole.Instance.CmdPrompt("Email", ""); | 915 | email = MainConsole.Instance.CmdPrompt("Email", ""); |
889 | else email = cmdparams[6]; | 916 | else email = cmdparams[7]; |
890 | 917 | ||
891 | if (null == m_commsManager.UserService.GetUserProfile(firstName, lastName)) | 918 | if (null == m_commsManager.UserService.GetUserProfile(firstName, lastName)) |
892 | { | 919 | { |
@@ -908,28 +935,40 @@ namespace OpenSim | |||
908 | string lastName; | 935 | string lastName; |
909 | string newPassword; | 936 | string newPassword; |
910 | 937 | ||
911 | if (cmdparams.Length < 3) | 938 | if (cmdparams.Length < 4) |
912 | firstName = MainConsole.Instance.CmdPrompt("First name"); | 939 | firstName = MainConsole.Instance.CmdPrompt("First name"); |
913 | else firstName = cmdparams[2]; | 940 | else firstName = cmdparams[3]; |
914 | 941 | ||
915 | if ( cmdparams.Length < 4 ) | 942 | if ( cmdparams.Length < 5 ) |
916 | lastName = MainConsole.Instance.CmdPrompt("Last name"); | 943 | lastName = MainConsole.Instance.CmdPrompt("Last name"); |
917 | else lastName = cmdparams[3]; | 944 | else lastName = cmdparams[4]; |
918 | 945 | ||
919 | if ( cmdparams.Length < 5 ) | 946 | if ( cmdparams.Length < 6 ) |
920 | newPassword = MainConsole.Instance.PasswdPrompt("New password"); | 947 | newPassword = MainConsole.Instance.PasswdPrompt("New password"); |
921 | else newPassword = cmdparams[4]; | 948 | else newPassword = cmdparams[5]; |
922 | 949 | ||
923 | m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword); | 950 | m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword); |
924 | } | 951 | } |
925 | 952 | ||
926 | protected void SaveXml(string[] cmdparams) | 953 | protected void SavePrimsXml2(string module, string[] cmdparams) |
954 | { | ||
955 | if (cmdparams.Length > 5) | ||
956 | { | ||
957 | m_sceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]); | ||
958 | } | ||
959 | else | ||
960 | { | ||
961 | m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME); | ||
962 | } | ||
963 | } | ||
964 | |||
965 | protected void SaveXml(string module, string[] cmdparams) | ||
927 | { | 966 | { |
928 | m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); | 967 | m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); |
929 | 968 | ||
930 | if (cmdparams.Length > 0) | 969 | if (cmdparams.Length > 0) |
931 | { | 970 | { |
932 | m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]); | 971 | m_sceneManager.SaveCurrentSceneToXml(cmdparams[2]); |
933 | } | 972 | } |
934 | else | 973 | else |
935 | { | 974 | { |
@@ -937,30 +976,30 @@ namespace OpenSim | |||
937 | } | 976 | } |
938 | } | 977 | } |
939 | 978 | ||
940 | protected void LoadXml(string[] cmdparams) | 979 | protected void LoadXml(string module, string[] cmdparams) |
941 | { | 980 | { |
942 | m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); | 981 | m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); |
943 | 982 | ||
944 | Vector3 loadOffset = new Vector3(0, 0, 0); | 983 | Vector3 loadOffset = new Vector3(0, 0, 0); |
945 | if (cmdparams.Length > 0) | 984 | if (cmdparams.Length > 2) |
946 | { | 985 | { |
947 | bool generateNewIDS = false; | 986 | bool generateNewIDS = false; |
948 | if (cmdparams.Length > 1) | 987 | if (cmdparams.Length > 3) |
949 | { | 988 | { |
950 | if (cmdparams[1] == "-newUID") | 989 | if (cmdparams[3] == "-newUID") |
951 | { | 990 | { |
952 | generateNewIDS = true; | 991 | generateNewIDS = true; |
953 | } | 992 | } |
954 | if (cmdparams.Length > 2) | 993 | if (cmdparams.Length > 4) |
955 | { | 994 | { |
956 | loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); | 995 | loadOffset.X = (float) Convert.ToDecimal(cmdparams[4]); |
957 | if (cmdparams.Length > 3) | 996 | if (cmdparams.Length > 5) |
958 | { | 997 | { |
959 | loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); | 998 | loadOffset.Y = (float) Convert.ToDecimal(cmdparams[5]); |
960 | } | 999 | } |
961 | if (cmdparams.Length > 4) | 1000 | if (cmdparams.Length > 6) |
962 | { | 1001 | { |
963 | loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); | 1002 | loadOffset.Z = (float) Convert.ToDecimal(cmdparams[6]); |
964 | } | 1003 | } |
965 | m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + | 1004 | m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + |
966 | loadOffset.Z + ">"); | 1005 | loadOffset.Z + ">"); |
@@ -981,11 +1020,11 @@ namespace OpenSim | |||
981 | } | 1020 | } |
982 | } | 1021 | } |
983 | 1022 | ||
984 | protected void SaveXml2(string[] cmdparams) | 1023 | protected void SaveXml2(string module, string[] cmdparams) |
985 | { | 1024 | { |
986 | if (cmdparams.Length > 0) | 1025 | if (cmdparams.Length > 2) |
987 | { | 1026 | { |
988 | m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]); | 1027 | m_sceneManager.SaveCurrentSceneToXml2(cmdparams[2]); |
989 | } | 1028 | } |
990 | else | 1029 | else |
991 | { | 1030 | { |
@@ -993,11 +1032,11 @@ namespace OpenSim | |||
993 | } | 1032 | } |
994 | } | 1033 | } |
995 | 1034 | ||
996 | protected void LoadXml2(string[] cmdparams) | 1035 | protected void LoadXml2(string module, string[] cmdparams) |
997 | { | 1036 | { |
998 | if (cmdparams.Length > 0) | 1037 | if (cmdparams.Length > 2) |
999 | { | 1038 | { |
1000 | m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]); | 1039 | m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[2]); |
1001 | } | 1040 | } |
1002 | else | 1041 | else |
1003 | { | 1042 | { |
@@ -1007,7 +1046,7 @@ namespace OpenSim | |||
1007 | } | 1046 | } |
1008 | catch | 1047 | catch |
1009 | { | 1048 | { |
1010 | m_console.Error("Default xml not found. Usage: load-xml2 <filename>"); | 1049 | m_console.Error("Default xml not found. Usage: load xml2 <filename>"); |
1011 | } | 1050 | } |
1012 | } | 1051 | } |
1013 | } | 1052 | } |
@@ -1016,11 +1055,11 @@ namespace OpenSim | |||
1016 | /// Load a whole region from an opensim archive. | 1055 | /// Load a whole region from an opensim archive. |
1017 | /// </summary> | 1056 | /// </summary> |
1018 | /// <param name="cmdparams"></param> | 1057 | /// <param name="cmdparams"></param> |
1019 | protected void LoadOar(string[] cmdparams) | 1058 | protected void LoadOar(string module, string[] cmdparams) |
1020 | { | 1059 | { |
1021 | if (cmdparams.Length > 0) | 1060 | if (cmdparams.Length > 2) |
1022 | { | 1061 | { |
1023 | m_sceneManager.LoadArchiveToCurrentScene(cmdparams[0]); | 1062 | m_sceneManager.LoadArchiveToCurrentScene(cmdparams[2]); |
1024 | } | 1063 | } |
1025 | else | 1064 | else |
1026 | { | 1065 | { |
@@ -1039,11 +1078,11 @@ namespace OpenSim | |||
1039 | /// Save a region to a file, including all the assets needed to restore it. | 1078 | /// Save a region to a file, including all the assets needed to restore it. |
1040 | /// </summary> | 1079 | /// </summary> |
1041 | /// <param name="cmdparams"></param> | 1080 | /// <param name="cmdparams"></param> |
1042 | protected void SaveOar(string[] cmdparams) | 1081 | protected void SaveOar(string module, string[] cmdparams) |
1043 | { | 1082 | { |
1044 | if (cmdparams.Length > 0) | 1083 | if (cmdparams.Length > 2) |
1045 | { | 1084 | { |
1046 | m_sceneManager.SaveCurrentSceneToArchive(cmdparams[0]); | 1085 | m_sceneManager.SaveCurrentSceneToArchive(cmdparams[2]); |
1047 | } | 1086 | } |
1048 | else | 1087 | else |
1049 | { | 1088 | { |
@@ -1055,19 +1094,19 @@ namespace OpenSim | |||
1055 | /// Load inventory from an inventory file archive | 1094 | /// Load inventory from an inventory file archive |
1056 | /// </summary> | 1095 | /// </summary> |
1057 | /// <param name="cmdparams"></param> | 1096 | /// <param name="cmdparams"></param> |
1058 | protected void LoadInv(string[] cmdparams) | 1097 | protected void LoadInv(string module, string[] cmdparams) |
1059 | { | 1098 | { |
1060 | m_log.Error("[CONSOLE]: This command has not yet been implemented!"); | 1099 | m_log.Error("[CONSOLE]: This command has not yet been implemented!"); |
1061 | if (cmdparams.Length < 3) | 1100 | if (cmdparams.Length < 5) |
1062 | { | 1101 | { |
1063 | m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]"); | 1102 | m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]"); |
1064 | return; | 1103 | return; |
1065 | } | 1104 | } |
1066 | 1105 | ||
1067 | string firstName = cmdparams[0]; | 1106 | string firstName = cmdparams[2]; |
1068 | string lastName = cmdparams[1]; | 1107 | string lastName = cmdparams[3]; |
1069 | string invPath = cmdparams[2]; | 1108 | string invPath = cmdparams[4]; |
1070 | string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); | 1109 | string loadPath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME); |
1071 | 1110 | ||
1072 | new InventoryArchiveReadRequest( | 1111 | new InventoryArchiveReadRequest( |
1073 | m_sceneManager.CurrentOrFirstScene, m_commsManager).execute( | 1112 | m_sceneManager.CurrentOrFirstScene, m_commsManager).execute( |
@@ -1078,19 +1117,19 @@ namespace OpenSim | |||
1078 | /// Save inventory to a file archive | 1117 | /// Save inventory to a file archive |
1079 | /// </summary> | 1118 | /// </summary> |
1080 | /// <param name="cmdparams"></param> | 1119 | /// <param name="cmdparams"></param> |
1081 | protected void SaveInv(string[] cmdparams) | 1120 | protected void SaveInv(string module, string[] cmdparams) |
1082 | { | 1121 | { |
1083 | m_log.Error("[CONSOLE]: This command has not yet been implemented!"); | 1122 | m_log.Error("[CONSOLE]: This command has not yet been implemented!"); |
1084 | if (cmdparams.Length < 3) | 1123 | if (cmdparams.Length < 5) |
1085 | { | 1124 | { |
1086 | m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); | 1125 | m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); |
1087 | return; | 1126 | return; |
1088 | } | 1127 | } |
1089 | 1128 | ||
1090 | string firstName = cmdparams[0]; | 1129 | string firstName = cmdparams[2]; |
1091 | string lastName = cmdparams[1]; | 1130 | string lastName = cmdparams[3]; |
1092 | string invPath = cmdparams[2]; | 1131 | string invPath = cmdparams[4]; |
1093 | string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); | 1132 | string savePath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME); |
1094 | 1133 | ||
1095 | new InventoryArchiveWriteRequest( | 1134 | new InventoryArchiveWriteRequest( |
1096 | m_sceneManager.CurrentOrFirstScene,m_commsManager).execute( | 1135 | m_sceneManager.CurrentOrFirstScene,m_commsManager).execute( |
@@ -1108,62 +1147,6 @@ namespace OpenSim | |||
1108 | return result; | 1147 | return result; |
1109 | } | 1148 | } |
1110 | 1149 | ||
1111 | /// <summary> | ||
1112 | /// Runs the best matching plugin command | ||
1113 | /// </summary> | ||
1114 | /// <param name="cmd"></param> | ||
1115 | /// <param name="withParams"></param> | ||
1116 | /// <returns>true if a match was found, false otherwise</returns> | ||
1117 | public bool RunPluginCommands(string cmd, string[] withParams) | ||
1118 | { | ||
1119 | ConsolePluginCommand bestMatch = null; | ||
1120 | int bestLength = 0; | ||
1121 | String cmdWithParams = cmd + " " + String.Join(" ",withParams); | ||
1122 | |||
1123 | foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos) | ||
1124 | { | ||
1125 | int matchLen = cmdinfo.matchLength(cmdWithParams); | ||
1126 | if (matchLen > bestLength) | ||
1127 | { | ||
1128 | bestMatch = cmdinfo; | ||
1129 | bestLength = matchLen; | ||
1130 | } | ||
1131 | } | ||
1132 | |||
1133 | if (bestMatch == null) return false; | ||
1134 | bestMatch.Run(cmd,withParams);//.Substring(bestLength)); | ||
1135 | return true; | ||
1136 | } | ||
1137 | |||
1138 | /// <summary> | ||
1139 | /// Show the matching plugins command help | ||
1140 | /// </summary> | ||
1141 | public void ShowPluginCommandsHelp(string cmdWithParams, ConsoleBase console) | ||
1142 | { | ||
1143 | foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos) | ||
1144 | { | ||
1145 | if (cmdinfo.IsHelpfull(cmdWithParams)) | ||
1146 | { | ||
1147 | cmdinfo.ShowHelp(console); | ||
1148 | } | ||
1149 | } | ||
1150 | } | ||
1151 | |||
1152 | /// <summary> | ||
1153 | /// Registers a new console plugin command | ||
1154 | /// </summary> | ||
1155 | public static void RegisterCmd(string cmd, ConsoleCommand deligate, string help) | ||
1156 | { | ||
1157 | RegisterConsolePluginCommand(new ConsolePluginCommand(cmd, deligate, help)); | ||
1158 | } | ||
1159 | |||
1160 | /// <summary> | ||
1161 | /// Registers a new console plugin command | ||
1162 | /// </summary> | ||
1163 | public static void RegisterConsolePluginCommand(ConsolePluginCommand pluginCommand) | ||
1164 | { | ||
1165 | m_PluginCommandInfos.Add(pluginCommand); | ||
1166 | } | ||
1167 | #endregion | 1150 | #endregion |
1168 | } | 1151 | } |
1169 | } | 1152 | } |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index a7ff0e2..4d56147 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -198,6 +198,46 @@ namespace OpenSim | |||
198 | 198 | ||
199 | // Only enable logins to the regions once we have completely finished starting up (apart from scripts) | 199 | // Only enable logins to the regions once we have completely finished starting up (apart from scripts) |
200 | m_commsManager.GridService.RegionLoginsEnabled = true; | 200 | m_commsManager.GridService.RegionLoginsEnabled = true; |
201 | |||
202 | List<string> topics = GetHelpTopics(); | ||
203 | |||
204 | foreach (string topic in topics) | ||
205 | { | ||
206 | m_console.Commands.AddCommand("plugin", "help "+topic, | ||
207 | "help "+topic, | ||
208 | "Get help on plugin command '"+topic+"'", | ||
209 | HandleCommanderHelp); | ||
210 | |||
211 | m_console.Commands.AddCommand("plugin", topic, | ||
212 | topic, | ||
213 | "Execute subcommand for plugin '"+topic+"'", | ||
214 | null); | ||
215 | |||
216 | ICommander commander = | ||
217 | SceneManager.CurrentOrFirstScene.GetCommanders()[topic]; | ||
218 | |||
219 | if (commander == null) | ||
220 | continue; | ||
221 | |||
222 | foreach (string command in commander.Commands.Keys) | ||
223 | { | ||
224 | m_console.Commands.AddCommand(topic, topic+" "+command, | ||
225 | topic+" "+commander.Commands[command].ShortHelp(), | ||
226 | String.Empty, HandleCommanderCommand); | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | private void HandleCommanderCommand(string module, string[] cmd) | ||
232 | { | ||
233 | m_sceneManager.SendCommandToPluginModules(cmd); | ||
234 | } | ||
235 | |||
236 | private void HandleCommanderHelp(string module, string[] cmd) | ||
237 | { | ||
238 | ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1]); | ||
239 | if (moduleCommander != null) | ||
240 | m_console.Notice(moduleCommander.Help); | ||
201 | } | 241 | } |
202 | 242 | ||
203 | /// <summary> | 243 | /// <summary> |
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 0921dbd..dcc17a7 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs | |||
@@ -108,6 +108,8 @@ namespace OpenSim.Region.ClientStack | |||
108 | 108 | ||
109 | m_log.Info("[REGION]: Starting HTTP server"); | 109 | m_log.Info("[REGION]: Starting HTTP server"); |
110 | m_httpServer.Start(); | 110 | m_httpServer.Start(); |
111 | |||
112 | base.StartupSpecific(); | ||
111 | } | 113 | } |
112 | 114 | ||
113 | /// <summary> | 115 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs index 0ad95ae..b6114e8 100644 --- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs +++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Command.cs | |||
@@ -88,6 +88,18 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander | |||
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | public string ShortHelp() | ||
92 | { | ||
93 | string help = m_name; | ||
94 | |||
95 | foreach (CommandArgument arg in m_args) | ||
96 | { | ||
97 | help += " <" + arg.Name + ">"; | ||
98 | } | ||
99 | |||
100 | return help; | ||
101 | } | ||
102 | |||
91 | public void ShowConsoleHelp() | 103 | public void ShowConsoleHelp() |
92 | { | 104 | { |
93 | Console.WriteLine("== " + Name + " =="); | 105 | Console.WriteLine("== " + Name + " =="); |
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index 060a4f4..e48ef13 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs | |||
@@ -32,21 +32,20 @@ using System.Collections; | |||
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using log4net; | 34 | using log4net; |
35 | using OpenSim; | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Region.Environment.Modules.Framework; | 39 | using OpenSim.Region.Environment.Modules.Framework; |
39 | using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander; | ||
40 | using OpenSim.Framework.Communications.Cache; | 40 | using OpenSim.Framework.Communications.Cache; |
41 | 41 | ||
42 | namespace OpenSim.Region.Environment.Modules.World.Permissions | 42 | namespace OpenSim.Region.Environment.Modules.World.Permissions |
43 | { | 43 | { |
44 | public class PermissionsModule : IRegionModule, ICommandableModule | 44 | public class PermissionsModule : IRegionModule |
45 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | protected Scene m_scene; | 48 | protected Scene m_scene; |
49 | private readonly Commander m_commander = new Commander("permissions"); | ||
50 | 49 | ||
51 | #region Constants | 50 | #region Constants |
52 | // These are here for testing. They will be taken out | 51 | // These are here for testing. They will be taken out |
@@ -94,60 +93,6 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions | |||
94 | 93 | ||
95 | #endregion | 94 | #endregion |
96 | 95 | ||
97 | #region ICommandableModule Members | ||
98 | |||
99 | public ICommander CommandInterface | ||
100 | { | ||
101 | get { throw new System.NotImplementedException(); } | ||
102 | } | ||
103 | |||
104 | private void InterfaceDebugPermissions(Object[] args) | ||
105 | { | ||
106 | if ((bool)args[0] == true) | ||
107 | { | ||
108 | m_debugPermissions = true; | ||
109 | m_log.Info("[PERMISSIONS]: Permissions Debugging Enabled."); | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | m_debugPermissions = false; | ||
114 | m_log.Info("[PERMISSIONS]: Permissions Debugging Disabled."); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | private void InterfaceBypassPermissions(Object[] args) | ||
119 | { | ||
120 | if ((bool)args[0] == true) | ||
121 | { | ||
122 | m_log.Info("[PERMISSIONS]: Permissions Bypass Enabled."); | ||
123 | m_bypassPermissionsValue = (bool)args[1]; | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | m_bypassPermissions = false; | ||
128 | m_log.Info("[PERMISSIONS]: Permissions Bypass Disabled. Normal Operation."); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Processes commandline input. Do not call directly. | ||
134 | /// </summary> | ||
135 | /// <param name="args">Commandline arguments</param> | ||
136 | private void EventManager_OnPluginConsole(string[] args) | ||
137 | { | ||
138 | if (args[0] == "permissions") | ||
139 | { | ||
140 | string[] tmpArgs = new string[args.Length - 2]; | ||
141 | int i; | ||
142 | for (i = 2; i < args.Length; i++) | ||
143 | tmpArgs[i - 2] = args[i]; | ||
144 | |||
145 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | #endregion | ||
150 | |||
151 | #region IRegionModule Members | 96 | #region IRegionModule Members |
152 | 97 | ||
153 | public void Initialise(Scene scene, IConfigSource config) | 98 | public void Initialise(Scene scene, IConfigSource config) |
@@ -226,20 +171,89 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions | |||
226 | 171 | ||
227 | m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED | 172 | m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED |
228 | 173 | ||
229 | //Register Debug Commands | 174 | m_scene.AddCommand("permissions", "bypass permissions", |
230 | Command bypassCommand = new Command("bypass", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBypassPermissions, "Force the permissions a specific way to test permissions"); | 175 | "bypass permissions <true / false>", |
231 | bypassCommand.AddArgument("enable_bypass_perms", "true to enable bypassing all perms", "Boolean"); | 176 | "Bypass permission checks", |
232 | bypassCommand.AddArgument("bypass_perms_value", "true/false: true will ignore all perms; false will restrict everything", "Boolean"); | 177 | HandleBypassPermissions); |
178 | |||
179 | m_scene.AddCommand("permissions", "force permissions", | ||
180 | "force permissions <true / false>", | ||
181 | "Force permissions on or off", | ||
182 | HandleForcePermissions); | ||
183 | |||
184 | m_scene.AddCommand("permissions", "debug permissions", | ||
185 | "debug permissions <true / false>", | ||
186 | "Enable permissions debugging", | ||
187 | HandleDebugPermissions); | ||
188 | } | ||
189 | |||
190 | public void HandleBypassPermissions(string module, string[] args) | ||
191 | { | ||
192 | if (m_scene.ConsoleScene() != null && | ||
193 | m_scene.ConsoleScene() != m_scene) | ||
194 | { | ||
195 | return; | ||
196 | } | ||
197 | |||
198 | if (args.Length > 2) | ||
199 | { | ||
200 | bool val; | ||
201 | |||
202 | if (!bool.TryParse(args[2], out val)) | ||
203 | return; | ||
204 | |||
205 | m_bypassPermissions = val; | ||
206 | |||
207 | m_log.InfoFormat("[PERMISSIONS] Set permissions bypass to {0} for {1}", m_bypassPermissions, m_scene.RegionInfo.RegionName); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | public void HandleForcePermissions(string module, string[] args) | ||
212 | { | ||
213 | if (m_scene.ConsoleScene() != null && | ||
214 | m_scene.ConsoleScene() != m_scene) | ||
215 | { | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | if (!m_bypassPermissions) | ||
220 | { | ||
221 | m_log.Error("[PERMISSIONS] Permissions can't be forced unless they are bypassed first"); | ||
222 | return; | ||
223 | } | ||
233 | 224 | ||
234 | m_commander.RegisterCommand("bypass", bypassCommand); | 225 | if (args.Length > 2) |
226 | { | ||
227 | bool val; | ||
235 | 228 | ||
236 | Command debugCommand = new Command("debug", CommandIntentions.COMMAND_STATISTICAL, InterfaceDebugPermissions, "Force the permissions a specific way to test permissions"); | 229 | if (!bool.TryParse(args[2], out val)) |
237 | debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean"); | 230 | return; |
238 | 231 | ||
239 | m_commander.RegisterCommand("debug", debugCommand); | 232 | m_bypassPermissionsValue = val; |
240 | m_scene.RegisterModuleCommander(m_commander); | ||
241 | 233 | ||
242 | m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); | 234 | m_log.InfoFormat("[PERMISSIONS] Forced permissions to {0} in {1}", m_bypassPermissionsValue, m_scene.RegionInfo.RegionName); |
235 | } | ||
236 | } | ||
237 | |||
238 | public void HandleDebugPermissions(string module, string[] args) | ||
239 | { | ||
240 | if (m_scene.ConsoleScene() != null && | ||
241 | m_scene.ConsoleScene() != m_scene) | ||
242 | { | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | if (args.Length > 2) | ||
247 | { | ||
248 | bool val; | ||
249 | |||
250 | if (!bool.TryParse(args[2], out val)) | ||
251 | return; | ||
252 | |||
253 | m_debugPermissions = val; | ||
254 | |||
255 | m_log.InfoFormat("[PERMISSIONS] Set permissions debugging to {0} in {1}", m_debugPermissions, m_scene.RegionInfo.RegionName); | ||
256 | } | ||
243 | } | 257 | } |
244 | 258 | ||
245 | public void PostInitialise() | 259 | public void PostInitialise() |
diff --git a/OpenSim/Region/Framework/Interfaces/ICommand.cs b/OpenSim/Region/Framework/Interfaces/ICommand.cs index 1551b58..15e55c4 100644 --- a/OpenSim/Region/Framework/Interfaces/ICommand.cs +++ b/OpenSim/Region/Framework/Interfaces/ICommand.cs | |||
@@ -46,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
46 | 46 | ||
47 | void Run(object[] args); | 47 | void Run(object[] args); |
48 | void ShowConsoleHelp(); | 48 | void ShowConsoleHelp(); |
49 | string ShortHelp(); | ||
49 | } | 50 | } |
50 | } | 51 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f07391d..55fc02a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -37,6 +37,7 @@ using OpenMetaverse; | |||
37 | using OpenMetaverse.Imaging; | 37 | using OpenMetaverse.Imaging; |
38 | using OpenMetaverse.Packets; | 38 | using OpenMetaverse.Packets; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Communications; | 41 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Cache; | 42 | using OpenSim.Framework.Communications.Cache; |
42 | using OpenSim.Framework.Servers; | 43 | using OpenSim.Framework.Servers; |
@@ -3384,7 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3384 | /// <param name="cmdparams"></param> | 3385 | /// <param name="cmdparams"></param> |
3385 | public void HandleEditCommand(string[] cmdparams) | 3386 | public void HandleEditCommand(string[] cmdparams) |
3386 | { | 3387 | { |
3387 | Console.WriteLine("Searching for Primitive: '" + cmdparams[0] + "'"); | 3388 | Console.WriteLine("Searching for Primitive: '" + cmdparams[2] + "'"); |
3388 | 3389 | ||
3389 | List<EntityBase> EntityList = GetEntities(); | 3390 | List<EntityBase> EntityList = GetEntities(); |
3390 | 3391 | ||
@@ -3395,11 +3396,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3395 | SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); | 3396 | SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); |
3396 | if (part != null) | 3397 | if (part != null) |
3397 | { | 3398 | { |
3398 | if (part.Name == cmdparams[0]) | 3399 | if (part.Name == cmdparams[2]) |
3399 | { | 3400 | { |
3400 | part.Resize( | 3401 | part.Resize( |
3401 | new Vector3(Convert.ToSingle(cmdparams[1]), Convert.ToSingle(cmdparams[2]), | 3402 | new Vector3(Convert.ToSingle(cmdparams[3]), Convert.ToSingle(cmdparams[4]), |
3402 | Convert.ToSingle(cmdparams[3]))); | 3403 | Convert.ToSingle(cmdparams[5]))); |
3403 | 3404 | ||
3404 | Console.WriteLine("Edited scale of Primitive: " + part.Name); | 3405 | Console.WriteLine("Edited scale of Primitive: " + part.Name); |
3405 | } | 3406 | } |
@@ -4235,5 +4236,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4235 | } | 4236 | } |
4236 | } | 4237 | } |
4237 | } | 4238 | } |
4239 | |||
4240 | public Scene ConsoleScene() | ||
4241 | { | ||
4242 | if (MainConsole.Instance == null) | ||
4243 | return null; | ||
4244 | if (MainConsole.Instance.ConsoleScene is Scene) | ||
4245 | return (Scene)MainConsole.Instance.ConsoleScene; | ||
4246 | return null; | ||
4247 | } | ||
4238 | } | 4248 | } |
4239 | } | 4249 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index e58d3ce..cee9037 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -32,6 +32,7 @@ using System.Threading; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | 38 | ||
@@ -458,5 +459,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | break; | 459 | break; |
459 | } | 460 | } |
460 | } | 461 | } |
462 | |||
463 | public void AddCommand(string module, string command, string shorthelp, string longhelp, CommandDelegate callback) | ||
464 | { | ||
465 | if (MainConsole.Instance == null) | ||
466 | return; | ||
467 | MainConsole.Instance.Commands.AddCommand(module, command, shorthelp, longhelp, callback); | ||
468 | } | ||
461 | } | 469 | } |
462 | } | 470 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1484638..0825bf8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -128,12 +128,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
128 | get { return m_ScriptEngine.World; } | 128 | get { return m_ScriptEngine.World; } |
129 | } | 129 | } |
130 | 130 | ||
131 | // Extension commands use this: | ||
132 | public ICommander GetCommander(string name) | ||
133 | { | ||
134 | return World.GetCommander(name); | ||
135 | } | ||
136 | |||
137 | public void state(string newState) | 131 | public void state(string newState) |
138 | { | 132 | { |
139 | m_ScriptEngine.SetState(m_itemID, newState); | 133 | m_ScriptEngine.SetState(m_itemID, newState); |
diff --git a/OpenSim/TestSuite/BotManager.cs b/OpenSim/TestSuite/BotManager.cs index 8eb2027..0838214 100644 --- a/OpenSim/TestSuite/BotManager.cs +++ b/OpenSim/TestSuite/BotManager.cs | |||
@@ -40,7 +40,7 @@ namespace OpenSim.TestSuite | |||
40 | /// <summary> | 40 | /// <summary> |
41 | /// Thread/Bot manager for the application | 41 | /// Thread/Bot manager for the application |
42 | /// </summary> | 42 | /// </summary> |
43 | public class BotManager : conscmd_callback | 43 | public class BotManager |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
@@ -58,8 +58,6 @@ namespace OpenSim.TestSuite | |||
58 | public BotManager() | 58 | public BotManager() |
59 | { | 59 | { |
60 | m_log.Info("In bot manager"); | 60 | m_log.Info("In bot manager"); |
61 | // m_console = CreateConsole(); | ||
62 | // MainConsole.Instance = m_console; | ||
63 | m_lBot = new List<PhysicsBot>(); | 61 | m_lBot = new List<PhysicsBot>(); |
64 | } | 62 | } |
65 | 63 | ||
@@ -169,52 +167,5 @@ namespace OpenSim.TestSuite | |||
169 | pb.shutdown(); | 167 | pb.shutdown(); |
170 | } | 168 | } |
171 | } | 169 | } |
172 | |||
173 | /// <summary> | ||
174 | /// Standard CreateConsole routine | ||
175 | /// </summary> | ||
176 | /// <returns></returns> | ||
177 | protected ConsoleBase CreateConsole() | ||
178 | { | ||
179 | return new ConsoleBase("Region", this); | ||
180 | } | ||
181 | |||
182 | /// <summary> | ||
183 | /// Command runnint tool.. Currently use it to add bots, shutdown and (dangerous)Forcequit | ||
184 | /// </summary> | ||
185 | /// <param name="command"></param> | ||
186 | /// <param name="cmdparams"></param> | ||
187 | public void RunCmd(string command, string[] cmdparams) | ||
188 | { | ||
189 | switch (command) | ||
190 | { | ||
191 | case "shutdown": | ||
192 | m_console.Warn("BOTMANAGER", "Shutting down bots"); | ||
193 | doBotShutdown(); | ||
194 | break; | ||
195 | case "quit": | ||
196 | m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit"); | ||
197 | Environment.Exit(0); | ||
198 | break; | ||
199 | case "addbots": | ||
200 | int newbots; | ||
201 | Int32.TryParse(cmdparams[0], out newbots); | ||
202 | |||
203 | if (newbots > 0) | ||
204 | addbots(newbots); | ||
205 | break; | ||
206 | case "help": | ||
207 | m_console.Notice("HELP", "\nshutdown - graceful shutdown\naddbots <n> - adds n bots to the test\nquit - forcequits, dangerous if you have not already run shutdown"); | ||
208 | break; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | /// <summary> | ||
213 | /// Required method to implement the conscmd_callback interface | ||
214 | /// </summary> | ||
215 | /// <param name="showParams">What to show</param> | ||
216 | public void Show(string[] showParams) | ||
217 | { | ||
218 | } | ||
219 | } | 170 | } |
220 | } | 171 | } |
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 100f2d4..3b08adc 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -31,6 +31,9 @@ using System.Reflection; | |||
31 | using System.Threading; | 31 | using System.Threading; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using log4net; | 33 | using log4net; |
34 | using log4net.Appender; | ||
35 | using log4net.Core; | ||
36 | using log4net.Repository; | ||
34 | using Nini.Config; | 37 | using Nini.Config; |
35 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
@@ -40,7 +43,7 @@ namespace pCampBot | |||
40 | /// <summary> | 43 | /// <summary> |
41 | /// Thread/Bot manager for the application | 44 | /// Thread/Bot manager for the application |
42 | /// </summary> | 45 | /// </summary> |
43 | public class BotManager : conscmd_callback | 46 | public class BotManager |
44 | { | 47 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 49 | ||
@@ -59,6 +62,36 @@ namespace pCampBot | |||
59 | { | 62 | { |
60 | m_console = CreateConsole(); | 63 | m_console = CreateConsole(); |
61 | MainConsole.Instance = m_console; | 64 | MainConsole.Instance = m_console; |
65 | |||
66 | // Make log4net see the console | ||
67 | // | ||
68 | ILoggerRepository repository = LogManager.GetRepository(); | ||
69 | IAppender[] appenders = repository.GetAppenders(); | ||
70 | OpenSimAppender consoleAppender = null; | ||
71 | |||
72 | foreach (IAppender appender in appenders) | ||
73 | { | ||
74 | if (appender.Name == "Console") | ||
75 | { | ||
76 | consoleAppender = (OpenSimAppender)appender; | ||
77 | consoleAppender.Console = m_console; | ||
78 | break; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | m_console.Commands.AddCommand("bot", "shutdown", | ||
83 | "shutdown", | ||
84 | "Gracefully shut down bots", HandleShutdown); | ||
85 | |||
86 | m_console.Commands.AddCommand("bot", "quit", | ||
87 | "quit", | ||
88 | "Force quit (DANGEROUS, try shutdown first)", | ||
89 | HandleShutdown); | ||
90 | |||
91 | m_console.Commands.AddCommand("bot", "add bots", | ||
92 | "add bots <number>", | ||
93 | "Add more bots", HandleAddBots); | ||
94 | |||
62 | m_lBot = new List<PhysicsBot>(); | 95 | m_lBot = new List<PhysicsBot>(); |
63 | } | 96 | } |
64 | 97 | ||
@@ -175,45 +208,31 @@ namespace pCampBot | |||
175 | /// <returns></returns> | 208 | /// <returns></returns> |
176 | protected ConsoleBase CreateConsole() | 209 | protected ConsoleBase CreateConsole() |
177 | { | 210 | { |
178 | return new ConsoleBase("Region", this); | 211 | return new ConsoleBase("Region"); |
179 | } | 212 | } |
180 | 213 | ||
181 | /// <summary> | 214 | private void HandleShutdown(string module, string[] cmd) |
182 | /// Command runnint tool.. Currently use it to add bots, shutdown and (dangerous)Forcequit | ||
183 | /// </summary> | ||
184 | /// <param name="command"></param> | ||
185 | /// <param name="cmdparams"></param> | ||
186 | public void RunCmd(string command, string[] cmdparams) | ||
187 | { | 215 | { |
188 | switch (command) | 216 | m_console.Warn("BOTMANAGER", "Shutting down bots"); |
189 | { | 217 | doBotShutdown(); |
190 | case "shutdown": | 218 | } |
191 | m_console.Warn("BOTMANAGER", "Shutting down bots"); | ||
192 | doBotShutdown(); | ||
193 | break; | ||
194 | case "quit": | ||
195 | m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit"); | ||
196 | Environment.Exit(0); | ||
197 | break; | ||
198 | case "addbots": | ||
199 | int newbots; | ||
200 | Int32.TryParse(cmdparams[0], out newbots); | ||
201 | 219 | ||
202 | if (newbots > 0) | 220 | private void HandleQuit(string module, string[] cmd) |
203 | addbots(newbots); | 221 | { |
204 | break; | 222 | m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit"); |
205 | case "help": | 223 | Environment.Exit(0); |
206 | m_console.Notice("HELP", "\nshutdown - graceful shutdown\naddbots <n> - adds n bots to the test\nquit - forcequits, dangerous if you have not already run shutdown"); | ||
207 | break; | ||
208 | } | ||
209 | } | 224 | } |
210 | 225 | ||
211 | /// <summary> | 226 | private void HandleAddBots(string module, string[] cmd) |
212 | /// Required method to implement the conscmd_callback interface | ||
213 | /// </summary> | ||
214 | /// <param name="showParams">What to show</param> | ||
215 | public void Show(string[] showParams) | ||
216 | { | 227 | { |
228 | int newbots = 0; | ||
229 | |||
230 | if (cmd.Length > 2) | ||
231 | { | ||
232 | Int32.TryParse(cmd[2], out newbots); | ||
233 | } | ||
234 | if (newbots > 0) | ||
235 | addbots(newbots); | ||
217 | } | 236 | } |
218 | } | 237 | } |
219 | } | 238 | } |