aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-07-12 19:29:49 +0000
committerJustin Clarke Casey2008-07-12 19:29:49 +0000
commit451c3d1dd7bd7fc64e741882040ae44f8c47518f (patch)
tree86d4c8a2c89d6c45ea3677b5874ed7e5688d9936 /OpenSim/Region/Application
parent* Make archive default tar file modes more permissive (diff)
downloadopensim-SC-451c3d1dd7bd7fc64e741882040ae44f8c47518f.zip
opensim-SC-451c3d1dd7bd7fc64e741882040ae44f8c47518f.tar.gz
opensim-SC-451c3d1dd7bd7fc64e741882040ae44f8c47518f.tar.bz2
opensim-SC-451c3d1dd7bd7fc64e741882040ae44f8c47518f.tar.xz
* Hive off ConsolePluginCommand into its own framework class
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs109
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs1
2 files changed, 1 insertions, 109 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 0616812..d4c7e70 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -44,8 +44,6 @@ using Timer=System.Timers.Timer;
44 44
45namespace OpenSim 45namespace OpenSim
46{ 46{
47 public delegate void ConsoleCommand(string[] comParams);
48
49 /// <summary> 47 /// <summary>
50 /// Interactive OpenSim region server 48 /// Interactive OpenSim region server
51 /// </summary> 49 /// </summary>
@@ -760,111 +758,4 @@ namespace OpenSim
760 } 758 }
761 #endregion 759 #endregion
762 } 760 }
763
764 /// <summary>
765 /// Holder object for a new console plugin command
766 ///
767 /// Override the methods like Run and IsHelpfull (but the defaults might work ok.)
768 /// </summary>
769 public class ConsolePluginCommand
770 {
771 /// <summary>
772 /// command delegate used in running
773 /// </summary>
774 private ConsoleCommand m_commandDelegate;
775 /// <summary>
776 /// help text displayed
777 /// </summary>
778 private string m_helpText;
779 /// <summary>
780 /// command in the form of "showme new commands"
781 /// </summary>
782 private string[] m_cmdText;
783
784 /// <summary>
785 /// Construct a new ConsolePluginCommand
786 ///
787 /// for use with OpenSim.RegisterConsolePluginCommand(myCmd);
788 ///
789 /// </summary>
790 /// <param name="command">in the form of "showme new commands"</param>
791 /// <param name="dlg">ommand delegate used in running</param>
792 /// <param name="help">the text displayed in "help showme new commands"</param>
793 public ConsolePluginCommand(string command, ConsoleCommand dlg, string help)
794 {
795 m_cmdText = command.Split(new char[] { ' ' });
796 m_commandDelegate = dlg;
797 m_helpText = help;
798 }
799
800 /// <summary>
801 /// Returns the match length this command has upon the 'cmdWithParams'
802 /// At least a higher number for "show plugin status" then "show" would return
803 /// This is used to have multi length command verbs
804 ///
805 /// @see OopenSim.RunPluginCommands
806 /// It will only run the one with the highest number
807 ///
808 /// </summary>
809 public int matchLength(string cmdWithParams)
810 {
811 // QUESTION: have a case insensitive flag?
812 cmdWithParams = cmdWithParams.ToLower().Trim();
813 string matchText = String.Join(" ",m_cmdText).ToLower().Trim();
814 if (cmdWithParams.StartsWith(matchText))
815 {
816 // QUESTION Instead return cmdText.Length; ?
817 return matchText.Length;
818 }
819 return 0;
820 }
821
822 /// <summary>
823 /// Run the delegate the incomming string may contain the command, if so, it is chopped off the cmdParams[]
824 /// </summary>
825 public void Run(string cmd, string[] cmdParams)
826 {
827 int skipParams = 0;
828 if (m_cmdText.Length > 1)
829 {
830 int currentParam = 1;
831 while (currentParam < m_cmdText.Length)
832 {
833 if (cmdParams[skipParams].ToLower().Equals(m_cmdText[currentParam].ToLower()))
834 {
835 skipParams++;
836 }
837 currentParam++;
838 }
839
840 }
841 string[] sendCmdParams = cmdParams;
842 if (skipParams > 0)
843 {
844 sendCmdParams = new string[cmdParams.Length-skipParams];
845 for (int i=0;i<sendCmdParams.Length;i++) {
846 sendCmdParams[i] = cmdParams[skipParams++];
847 }
848 }
849 m_commandDelegate(sendCmdParams);//.Trim().Split(new char[] { ' ' }));
850 }
851
852 /// <summary>
853 /// Shows help information on the console's Notice method
854 /// </summary>
855 public void ShowHelp(ConsoleBase console)
856 {
857 console.Notice(String.Join(" ", m_cmdText) + " - " + m_helpText);
858 }
859
860 /// <summary>
861 /// return true if the ShowHelp(..) method might be helpfull
862 /// </summary>
863 public bool IsHelpfull(string cmdWithParams)
864 {
865 cmdWithParams = cmdWithParams.ToLower();
866 return cmdWithParams.Contains(String.Join(" ", m_cmdText).ToLower()) || m_helpText.ToLower().Contains(cmdWithParams);
867 }
868 }
869
870} 761}
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index c6061e1..c9cc062 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -38,6 +38,7 @@ using Mono.Addins;
38using Nini.Config; 38using Nini.Config;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console;
41using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
42using OpenSim.Framework.Statistics; 43using OpenSim.Framework.Statistics;
43using OpenSim.Region.ClientStack; 44using OpenSim.Region.ClientStack;