Author: mpiulachs Date: Mon Dec 10 22:08:13 2007 New Revision: 31130
URL: http://svn.reactos.org/svn/reactos?rev=31130&view=rev Log: * refactor the code to make it more OOP and extensible * remove old outdated SD project files * make it use some .NET 2.0 features as generic collections and settings
Added: trunk/irc/TechBot/TechBot.Library/Command.cs (contents, props changed) - copied, changed from r31065, trunk/irc/TechBot/TechBot.Library/ICommand.cs trunk/irc/TechBot/TechBot.Library/Commands/ trunk/irc/TechBot/TechBot.Library/Commands/Base/ trunk/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs (with props) trunk/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs (contents, props changed) - copied, changed from r31065, trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs trunk/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs (with props) trunk/irc/TechBot/TechBot.Library/SambaBugUrl.cs (with props) trunk/irc/TechBot/TechBot.Library/Settings.Designer.cs (with props) trunk/irc/TechBot/TechBot.Library/Settings.cs (with props) trunk/irc/TechBot/TechBot.Library/Settings.settings (with props) trunk/irc/TechBot/TechBot.Library/WineBugUrl.cs (with props) trunk/irc/TechBot/TechBot.Library/app.config (with props) Removed: trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs trunk/irc/TechBot/TechBot.Library/Default.build trunk/irc/TechBot/TechBot.Library/ICommand.cs trunk/irc/TechBot/TechBot.Library/TechBot.Library.cmbx trunk/irc/TechBot/TechBot.Library/TechBot.Library.prjx Modified: trunk/irc/TechBot/TechBot.Console/App.config trunk/irc/TechBot/TechBot.Console/Main.cs trunk/irc/TechBot/TechBot.Console/TechBot.Console.csproj trunk/irc/TechBot/TechBot.Library/ApiCommand.cs trunk/irc/TechBot/TechBot.Library/BugCommand.cs trunk/irc/TechBot/TechBot.Library/ErrorCommand.cs trunk/irc/TechBot/TechBot.Library/HelpCommand.cs trunk/irc/TechBot/TechBot.Library/HresultCommand.cs trunk/irc/TechBot/TechBot.Library/IrcService.cs trunk/irc/TechBot/TechBot.Library/NtStatusCommand.cs trunk/irc/TechBot/TechBot.Library/SvnCommand.cs trunk/irc/TechBot/TechBot.Library/TechBot.Library.csproj trunk/irc/TechBot/TechBot.Library/TechBotService.cs trunk/irc/TechBot/TechBot.Library/WinerrorCommand.cs trunk/irc/TechBot/TechBot.Library/WmCommand.cs trunk/irc/TechBot/TechBot/ServiceThread.cs trunk/irc/TechBot/TechBot/TechBot.csproj
Modified: trunk/irc/TechBot/TechBot.Console/App.config URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Console/App.con... ============================================================================== --- trunk/irc/TechBot/TechBot.Console/App.config (original) +++ trunk/irc/TechBot/TechBot.Console/App.config Mon Dec 10 22:08:13 2007 @@ -8,11 +8,6 @@ <add key="IRCBotPassword" value="MyPassword" /> <add key="ChmPath" value="C:\IRC\TechBot\CHM" /> <add key="MainChm" value="kmarch.chm" /> - <add key="NtstatusXml" value="ntstatus.xml" /> - <add key="WinerrorXml" value="winerror.xml" /> - <add key="HresultXml" value="hresult.xml" /> - <add key="WmXml" value="wm.xml" /> - <add key="SvnCommand" value="svn co svn://svn.reactos.org/trunk/reactos" /> <add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" /> <add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" /> <add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />
Modified: trunk/irc/TechBot/TechBot.Console/Main.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Console/Main.cs... ============================================================================== --- trunk/irc/TechBot/TechBot.Console/Main.cs (original) +++ trunk/irc/TechBot/TechBot.Console/Main.cs Mon Dec 10 22:08:13 2007 @@ -217,11 +217,11 @@ IRCBotPassword, ChmPath, MainChm, - NtstatusXml, - WinerrorXml, - HresultXml, - WmXml, - SvnCommand, + //NtstatusXml, + //WinerrorXml, + //HresultXml, + //WmXml, + //SvnCommand, BugUrl, WineBugUrl, SambaBugUrl); @@ -239,15 +239,15 @@ System.Console.WriteLine("TechBot running console service..."); TechBotService service = new TechBotService(new ConsoleServiceOutput(), ChmPath, - MainChm, - NtstatusXml, - WinerrorXml, - HresultXml, - WmXml, - SvnCommand, - BugUrl, - WineBugUrl, - SambaBugUrl); + MainChm); + //NtstatusXml, + //WinerrorXml, + //HresultXml, + //WmXml, + //SvnCommand, + //BugUrl, + //WineBugUrl, + //SambaBugUrl); service.Run(); while (true) {
Modified: trunk/irc/TechBot/TechBot.Console/TechBot.Console.csproj URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Console/TechBot... ============================================================================== --- trunk/irc/TechBot/TechBot.Console/TechBot.Console.csproj (original) +++ trunk/irc/TechBot/TechBot.Console/TechBot.Console.csproj Mon Dec 10 22:08:13 2007 @@ -54,6 +54,9 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> </Project>
Modified: trunk/irc/TechBot/TechBot.Library/ApiCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/ApiComm... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/ApiCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/ApiCommand.cs Mon Dec 10 22:08:13 2007 @@ -7,22 +7,17 @@
namespace TechBot.Library { - public class ApiCommand : BaseCommand, ICommand + public class ApiCommand : Command { private const bool IsVerbose = false;
private HtmlHelpSystem chm; - private IServiceOutput serviceOutput; private string chmPath; private string mainChm; - - public ApiCommand(IServiceOutput serviceOutput, - string chmPath, - string mainChm) - { - this.serviceOutput = serviceOutput; - this.chmPath = chmPath; - this.mainChm = mainChm; + + public ApiCommand(TechBotService techBot) + : base(techBot) + { Run(); } @@ -30,7 +25,7 @@ string message) { if (IsVerbose) - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, message); }
@@ -65,14 +60,21 @@ Console.WriteLine(String.Format("Loaded {0} CHMs", chm.FileList.Length)); } - + + public override string[] AvailableCommands + { + get { return new string[] { "api" }; } + } + + /* public bool CanHandle(string commandName) { return CanHandle(commandName, new string[] { "api" }); } - - public void Handle(MessageContext context, +*/ + + public override void Handle(MessageContext context, string commandName, string parameters) { @@ -82,8 +84,8 @@ Search(context, parameters); } - - public string Help() + + public override string Help() { return "!api <apiname>"; } @@ -177,7 +179,7 @@ if (prototype == null || prototype.Trim().Equals(String.Empty)) return false; string formattedPrototype = FormatPrototype(prototype); - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, formattedPrototype); return true; } @@ -203,7 +205,7 @@ if (prototype == null || prototype.Trim().Equals(String.Empty)) continue; string formattedPrototype = FormatPrototype(prototype); - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, formattedPrototype); return true; } @@ -214,14 +216,14 @@ private void DisplayNoResult(MessageContext context, string keyword) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("I don't know about keyword {0}", keyword)); }
private void DisplayNoKeyword(MessageContext context) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, "Please give me a keyword."); }
Removed: trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Assembl... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs (original) +++ trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs (removed) @@ -1,32 +1,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")]
Modified: trunk/irc/TechBot/TechBot.Library/BugCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/BugComm... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/BugCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/BugCommand.cs Mon Dec 10 22:08:13 2007 @@ -2,70 +2,49 @@
namespace TechBot.Library { - public class BugCommand : BaseCommand, ICommand + public abstract class BugCommand : Command//, ICommand { - private IServiceOutput serviceOutput; - private string RosBugUrl; - private string WineBugUrl; - private string SambaBugUrl; - - public BugCommand(IServiceOutput serviceOutput, - string RosBugUrl, - string WineBugUrl, - string SambaBugUrl) + public BugCommand(TechBotService techBot) : base (techBot) { - this.serviceOutput = serviceOutput; - this.RosBugUrl = RosBugUrl; - this.WineBugUrl = WineBugUrl; - this.SambaBugUrl = SambaBugUrl; - } - - public bool CanHandle(string commandName) - { - return CanHandle(commandName, - new string[] { "bug" }); }
- public void Handle(MessageContext context, - string commandName, - string parameters) - { - string bugText = parameters; - if (bugText.Equals(String.Empty)) - { - serviceOutput.WriteLine(context, - "Please provide a valid bug number."); - return; - } + public override void Handle(MessageContext context, + string commandName, + string parameters) + { + string bugText = parameters; + if (bugText.Equals(String.Empty)) + { + TechBot.ServiceOutput.WriteLine(context, + "Please provide a valid bug number."); + return; + }
- NumberParser np = new NumberParser(); - long bug = np.Parse(bugText); - if (np.Error) - { - serviceOutput.WriteLine(context, - String.Format("{0} is not a valid bug number.", - bugText)); - return; - } - - string bugUrl = this.RosBugUrl; + NumberParser np = new NumberParser(); + long bug = np.Parse(bugText); + if (np.Error) + { + TechBot.ServiceOutput.WriteLine(context, + String.Format("{0} is not a valid bug number.", + bugText)); + return; + }
- if (context is ChannelMessageContext) - { - ChannelMessageContext channelContext = context as ChannelMessageContext; - if (channelContext.Channel.Name == "winehackers") - bugUrl = this.WineBugUrl; - else if (channelContext.Channel.Name == "samba-technical") - bugUrl = this.SambaBugUrl; - } - - serviceOutput.WriteLine(context, - String.Format(bugUrl, bug)); - } - - public string Help() - { - return "!bug <number>"; - } + /* + string bugUrl = this.RosBugUrl; + + if (context is ChannelMessageContext) + { + ChannelMessageContext channelContext = context as ChannelMessageContext; + if (channelContext.Channel.Name == "winehackers") + bugUrl = this.WineBugUrl; + else if (channelContext.Channel.Name == "samba-technical") + bugUrl = this.SambaBugUrl; + }*/ + + TechBot.ServiceOutput.WriteLine(context, String.Format(BugUrl, bug)); + } + + protected abstract string BugUrl { get; } } }
Copied: trunk/irc/TechBot/TechBot.Library/Command.cs (from r31065, trunk/irc/TechBot/TechBot.Library/ICommand.cs) URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Command... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/ICommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/Command.cs Mon Dec 10 22:08:13 2007 @@ -1,29 +1,53 @@ -using System; - -namespace TechBot.Library -{ - public interface ICommand - { - bool CanHandle(string commandName); - void Handle(MessageContext context, - string commandName, - string parameters); - string Help(); - } - - - - public class BaseCommand - { - protected bool CanHandle(string commandName, - string[] availableCommands) - { - foreach (string availableCommand in availableCommands) - { - if (String.Compare(availableCommand, commandName, true) == 0) - return true; - } - return false; - } - } -} +using System; + +namespace TechBot.Library +{ + /* + public interface ICommand + { + bool CanHandle(string commandName); + void Handle(MessageContext context, + string commandName, + string parameters); + //string Help(); + }*/ + + public abstract class Command + { + protected TechBotService m_TechBotService = null; + + public Command(TechBotService techbot) + { + m_TechBotService = techbot; + } + + public TechBotService TechBot + { + get { return m_TechBotService; } + } + + public abstract string[] AvailableCommands { get; } + + public abstract void Handle(MessageContext context, + string commandName, + string parameters); + + /* + protected bool CanHandle(string commandName, + string[] availableCommands) + { + foreach (string availableCommand in availableCommands) + { + if (String.Compare(availableCommand, commandName, true) == 0) + return true; + } + return false; + } + */ + + public virtual string Help() + { + return "No help is available for this command"; + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/Command.cs ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Command... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs (added) +++ trunk/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs Mon Dec 10 22:08:13 2007 @@ -1,0 +1,26 @@ +using System; +using System.Xml; +using System.Collections.Generic; +using System.Text; + +namespace TechBot.Library +{ + public abstract class XmlCommand : Command + { + protected XmlDocument m_XmlDocument; + + public XmlCommand(TechBotService techBot) + : base(techBot) + { + m_XmlDocument = new XmlDocument(); + m_XmlDocument.Load(XmlFile); + } + + public abstract string XmlFile { get; } + + public XmlDocument XmlDocument + { + get { return m_XmlDocument; } + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs ------------------------------------------------------------------------------ svn:eol-style = native
Removed: trunk/irc/TechBot/TechBot.Library/Default.build URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Default... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/Default.build (original) +++ trunk/irc/TechBot/TechBot.Library/Default.build (removed) @@ -1,24 +1,0 @@ -<?xml version="1.0"?> -<project name="TechBot.Library" default="build"> - - <property name="output.dir" value="..\bin" /> - - <target name="build" description="Build component"> - <mkdir dir="${output.dir}" /> - <csc target="library" - output="${output.dir}\TechBot.Library.dll" - optimize="true" - debug="true" - doc="${output.dir}\TechBot.Library.xml" - warninglevel="0"> - <sources> - <include name="*.cs" /> - </sources> - <references> - <include name="${output.dir}\CHMLibrary.dll" /> - <include name="${output.dir}\TechBot.IRCLibrary.dll" /> - </references> - </csc> - </target> - -</project>
Modified: trunk/irc/TechBot/TechBot.Library/ErrorCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/ErrorCo... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/ErrorCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/ErrorCommand.cs Mon Dec 10 22:08:13 2007 @@ -4,30 +4,32 @@
namespace TechBot.Library { - public class ErrorCommand : BaseCommand, ICommand + public class ErrorCommand : Command { - private IServiceOutput serviceOutput; private NtStatusCommand ntStatus; private WinerrorCommand winerror; - private HresultCommand hresult; - - public ErrorCommand(IServiceOutput serviceOutput, string ntstatusXml, - string winerrorXml, string hresultXml) - { - this.serviceOutput = serviceOutput; - this.ntStatus = new NtStatusCommand(serviceOutput, - ntstatusXml); - this.winerror = new WinerrorCommand(serviceOutput, - winerrorXml); - this.hresult = new HresultCommand(serviceOutput, - hresultXml); + private HResultCommand hresult; + + public ErrorCommand(TechBotService techBot) + : base(techBot) + { + this.ntStatus = new NtStatusCommand(techBot); + this.winerror = new WinerrorCommand(techBot); + this.hresult = new HResultCommand(techBot); } + /* public bool CanHandle(string commandName) { return CanHandle(commandName, new string[] { "error" }); } + */ + + public override string[] AvailableCommands + { + get { return new string[] { "error" }; } + }
private static int GetSeverity(long error) { @@ -79,14 +81,14 @@ return code.ToString(); }
- public void Handle(MessageContext context, + public override void Handle(MessageContext context, string commandName, string parameters) { string originalErrorText = parameters.Trim(); if (originalErrorText.Equals(String.Empty)) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, "Please provide an Error Code."); return; } @@ -98,7 +100,7 @@ long error = np.Parse(errorText); if (np.Error) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is not a valid Error Code.", originalErrorText)); return; @@ -173,30 +175,30 @@ goto retry; }
- serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("I don't know about Error Code {0}.", originalErrorText)); } else if (descriptions.Count == 1) { string description = (string)descriptions[0]; - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is {1}.", originalErrorText, description)); } else { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} could be:", originalErrorText)); foreach(string description in descriptions) - serviceOutput.WriteLine(context, String.Format("\t{0}", description)); - } - } - - public string Help() + TechBot.ServiceOutput.WriteLine(context, String.Format("\t{0}", description)); + } + } + + public override string Help() { return "!error <value>"; }
Modified: trunk/irc/TechBot/TechBot.Library/HelpCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/HelpCom... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/HelpCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/HelpCommand.cs Mon Dec 10 22:08:13 2007 @@ -3,38 +3,33 @@
namespace TechBot.Library { - public class HelpCommand : BaseCommand, ICommand + public class HelpCommand : Command { - private IServiceOutput serviceOutput; - private ArrayList commands; - - public HelpCommand(IServiceOutput serviceOutput, - ArrayList commands) + public HelpCommand(TechBotService techBot) + : base(techBot) { - this.serviceOutput = serviceOutput; - this.commands = commands; }
- public bool CanHandle(string commandName) - { - return CanHandle(commandName, - new string[] { "help" }); - } - - public void Handle(MessageContext context, - string commandName, - string parameters) - { - serviceOutput.WriteLine(context, - "I support the following commands:"); - foreach (ICommand command in commands) - { - serviceOutput.WriteLine(context, - command.Help()); - } - } - - public string Help() + public override string[] AvailableCommands + { + get { return new string[] { "help" }; } + } + + public override void Handle( + MessageContext context, + string commandName, + string parameters) + { + TechBot.ServiceOutput.WriteLine(context, "I support the following commands:"); + + foreach (Command command in TechBot.Commands) + { + TechBot.ServiceOutput.WriteLine(context, + command.Help()); + } + } + + public override string Help() { return "!help"; }
Modified: trunk/irc/TechBot/TechBot.Library/HresultCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Hresult... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/HresultCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/HresultCommand.cs Mon Dec 10 22:08:13 2007 @@ -3,33 +3,39 @@
namespace TechBot.Library { - public class HresultCommand : BaseCommand, ICommand + public class HResultCommand : XmlCommand { - private IServiceOutput serviceOutput; - private XmlDocument hresultXmlDocument; + public HResultCommand(TechBotService techBot) + : base(techBot) + { + }
- public HresultCommand(IServiceOutput serviceOutput, - string hresultXml) - { - this.serviceOutput = serviceOutput; - hresultXmlDocument = new XmlDocument(); - hresultXmlDocument.Load(hresultXml); - } - + public override string XmlFile + { + get { return Settings.Default.HResultXml; } + } + + public override string[] AvailableCommands + { + get { return new string[] { "hresult" }; } + } + + /* public bool CanHandle(string commandName) { return CanHandle(commandName, new string[] { "hresult" }); } + */
- public void Handle(MessageContext context, + public override void Handle(MessageContext context, string commandName, string parameters) { string hresultText = parameters; if (hresultText.Equals(String.Empty)) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, "Please provide a valid HRESULT value."); return; } @@ -38,7 +44,7 @@ long hresult = np.Parse(hresultText); if (np.Error) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is not a valid HRESULT value.", hresultText)); return; @@ -47,27 +53,27 @@ string description = GetHresultDescription(hresult); if (description != null) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is {1}.", hresultText, description)); } else { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("I don't know about HRESULT {0}.", hresultText)); } } - public string Help() + public override string Help() { return "!hresult <value>"; } public string GetHresultDescription(long hresult) { - XmlElement root = hresultXmlDocument.DocumentElement; + XmlElement root = base.m_XmlDocument.DocumentElement; XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']", hresult.ToString("X8"))); if (node != null)
Removed: trunk/irc/TechBot/TechBot.Library/ICommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/IComman... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/ICommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/ICommand.cs (removed) @@ -1,29 +1,0 @@ -using System; - -namespace TechBot.Library -{ - public interface ICommand - { - bool CanHandle(string commandName); - void Handle(MessageContext context, - string commandName, - string parameters); - string Help(); - } - - - - public class BaseCommand - { - protected bool CanHandle(string commandName, - string[] availableCommands) - { - foreach (string availableCommand in availableCommands) - { - if (String.Compare(availableCommand, commandName, true) == 0) - return true; - } - return false; - } - } -}
Modified: trunk/irc/TechBot/TechBot.Library/IrcService.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/IrcServ... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/IrcService.cs (original) +++ trunk/irc/TechBot/TechBot.Library/IrcService.cs Mon Dec 10 22:08:13 2007 @@ -1,6 +1,8 @@ using System; +using System.Text; using System.Collections; using System.Threading; + using TechBot.IRCLibrary;
namespace TechBot.Library @@ -20,7 +22,7 @@ private string wmXml; private string svnCommand; private string bugUrl, WineBugUrl, SambaBugUrl; - private IrcClient client; + private IrcClient m_IrcClient; private ArrayList channels = new ArrayList(); /* IrcChannel */ private TechBotService service; private bool isStopped = false; @@ -32,11 +34,11 @@ string password, string chmPath, string mainChm, - string ntstatusXml, - string winerrorXml, - string hresultXml, - string wmXml, - string svnCommand, + //string ntstatusXml, + //string winerrorXml, + //string hresultXml, + //string wmXml, + //string svnCommand, string BugUrl, string WineBugUrl, string SambaBugUrl) @@ -61,42 +63,43 @@ this.SambaBugUrl = SambaBugUrl; }
- public void Run() - { - service = new TechBotService(this, - chmPath, - mainChm, - ntstatusXml, - winerrorXml, - hresultXml, - wmXml, - svnCommand, - bugUrl, - WineBugUrl, - SambaBugUrl); - service.Run(); - - client = new IrcClient(); - client.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1"); - client.MessageReceived += new MessageReceivedHandler(client_MessageReceived); - client.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged); - System.Console.WriteLine(String.Format("Connecting to {0} port {1}", - hostname, port)); - client.Connect(hostname, port); - System.Console.WriteLine("Connected..."); - client.Register(botname, password, null); - System.Console.WriteLine(String.Format("Registered as {0}...", botname)); - JoinChannels(); - - while (!isStopped) - { - Thread.Sleep(1000); - } - - PartChannels(); - client.Diconnect(); - System.Console.WriteLine("Disconnected..."); - } + public void Run() + { + service = new TechBotService(this, + chmPath, + mainChm); + //ntstatusXml, + //winerrorXml, + //hresultXml, + //wmXml, + //svnCommand, + //bugUrl, + //WineBugUrl, + //SambaBugUrl); + service.Run(); + + m_IrcClient = new IrcClient(); + m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1"); + m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived); + m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged); + Console.WriteLine("Connecting to {0} port {1}", + hostname, + port); + m_IrcClient.Connect(hostname, port); + Console.WriteLine("Connected..."); + m_IrcClient.Register(botname, password, null); + Console.WriteLine("Registered as {0}...", botname); + JoinChannels(); + + while (!isStopped) + { + Thread.Sleep(1000); + } + + PartChannels(); + m_IrcClient.Diconnect(); + Console.WriteLine("Disconnected..."); + }
public void Stop() { @@ -107,7 +110,7 @@ { foreach (string channelname in channelnames.Split(new char[] { ';' })) { - IrcChannel channel = client.JoinChannel(channelname); + IrcChannel channel = m_IrcClient.JoinChannel(channelname); channels.Add(channel); System.Console.WriteLine(String.Format("Joined channel #{0}...", channel.Name)); @@ -118,7 +121,7 @@ { foreach (IrcChannel channel in channels) { - client.PartChannel(channel, "Caught in the bitstream..."); + m_IrcClient.PartChannel(channel, "Caught in the bitstream..."); System.Console.WriteLine(String.Format("Parted channel #{0}...", channel.Name)); } @@ -235,11 +238,11 @@ else if (GetTargetNickname(message, out nickname)) { - IrcUser targetUser = new IrcUser(client, + IrcUser targetUser = new IrcUser(m_IrcClient, nickname); if (String.Compare(targetUser.Nickname, botname, true) == 0) { - IrcUser sourceUser = new IrcUser(client, + IrcUser sourceUser = new IrcUser(m_IrcClient, message.PrefixNickname); context = new UserMessageContext(sourceUser); return true;
Modified: trunk/irc/TechBot/TechBot.Library/NtStatusCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/NtStatu... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/NtStatusCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/NtStatusCommand.cs Mon Dec 10 22:08:13 2007 @@ -3,35 +3,37 @@
namespace TechBot.Library { - public class NtStatusCommand : BaseCommand, ICommand + public class NtStatusCommand : XmlCommand { - private IServiceOutput serviceOutput; - private string ntstatusXml; - private XmlDocument ntstatusXmlDocument; + public NtStatusCommand(TechBotService techBot) + : base(techBot) + { + }
- public NtStatusCommand(IServiceOutput serviceOutput, - string ntstatusXml) - { - this.serviceOutput = serviceOutput; - this.ntstatusXml = ntstatusXml; - ntstatusXmlDocument = new XmlDocument(); - ntstatusXmlDocument.Load(ntstatusXml); - } - + public override string XmlFile + { + get { return Settings.Default.NtStatusXml; } + } + + public override string[] AvailableCommands + { + get { return new string[] { "ntstatus" }; } + } +/* public bool CanHandle(string commandName) { return CanHandle(commandName, new string[] { "ntstatus" }); } - - public void Handle(MessageContext context, +*/ + public override void Handle(MessageContext context, string commandName, string parameters) { string ntstatusText = parameters; if (ntstatusText.Equals(String.Empty)) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, "Please provide a valid NTSTATUS value."); return; } @@ -40,7 +42,7 @@ long ntstatus = np.Parse(ntstatusText); if (np.Error) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is not a valid NTSTATUS value.", ntstatusText)); return; @@ -49,27 +51,27 @@ string description = GetNtstatusDescription(ntstatus); if (description != null) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is {1}.", ntstatusText, description)); } else { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("I don't know about NTSTATUS {0}.", ntstatusText)); } } - - public string Help() + + public override string Help() { return "!ntstatus <value>"; } public string GetNtstatusDescription(long ntstatus) { - XmlElement root = ntstatusXmlDocument.DocumentElement; + XmlElement root = base.m_XmlDocument.DocumentElement; XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']", ntstatus.ToString("X8"))); if (node != null)
Copied: trunk/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs (from r31065, trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs) URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Propert... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/AssemblyInfo.cs (original) +++ trunk/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs Mon Dec 10 22:08:13 2007 @@ -1,32 +1,32 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")]
Propchange: trunk/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/ReactOS... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs (added) +++ trunk/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs Mon Dec 10 22:08:13 2007 @@ -1,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TechBot.Library +{ + class ReactOSBugUrl : BugCommand + { + public ReactOSBugUrl(TechBotService techBot) + : base(techBot) + { + } + + public override string[] AvailableCommands + { + get { return new string[] { "rosbug" }; } + } + + protected override string BugUrl + { + get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id=%7B0%7D"; } + } + + public override string Help() + { + return "!rosbug <number>"; + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/ReactOSBugUrl.cs ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/irc/TechBot/TechBot.Library/SambaBugUrl.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/SambaBu... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/SambaBugUrl.cs (added) +++ trunk/irc/TechBot/TechBot.Library/SambaBugUrl.cs Mon Dec 10 22:08:13 2007 @@ -1,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TechBot.Library +{ + class SambaBugUrl : BugCommand + { + public SambaBugUrl(TechBotService techBot) + : base(techBot) + { + } + + public override string[] AvailableCommands + { + get { return new string[] { "sambabug" }; } + } + + protected override string BugUrl + { + get { return "https://bugzilla.samba.org/show_bug.cgi?id=%7B0%7D"; } + } + + public override string Help() + { + return "!sambabug <number>"; + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/SambaBugUrl.cs ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/irc/TechBot/TechBot.Library/Settings.Designer.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Setting... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/Settings.Designer.cs (added) +++ trunk/irc/TechBot/TechBot.Library/Settings.Designer.cs Mon Dec 10 22:08:13 2007 @@ -1,0 +1,71 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.832 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace TechBot.Library { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\Ros\current\irc\TechBot\Resources\ntstatus.xml")] + public string NtStatusXml { + get { + return ((string)(this["NtStatusXml"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\Ros\current\irc\TechBot\Resources\winerror.xml")] + public string WinErrorXml { + get { + return ((string)(this["WinErrorXml"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\Ros\current\irc\TechBot\Resources\hresult.xml")] + public string HResultXml { + get { + return ((string)(this["HResultXml"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\Ros\current\irc\TechBot\Resources\wm.xml")] + public string WMXml { + get { + return ((string)(this["WMXml"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/trunk/reactos")] + public string SVNRoot { + get { + return ((string)(this["SVNRoot"])); + } + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/Settings.Designer.cs ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/irc/TechBot/TechBot.Library/Settings.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Setting... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/Settings.cs (added) +++ trunk/irc/TechBot/TechBot.Library/Settings.cs Mon Dec 10 22:08:13 2007 @@ -1,0 +1,28 @@ +namespace TechBot.Library { + + + // This class allows you to handle specific events on the settings class: + // The SettingChanging event is raised before a setting's value is changed. + // The PropertyChanged event is raised after a setting's value is changed. + // The SettingsLoaded event is raised after the setting values are loaded. + // The SettingsSaving event is raised before the setting values are saved. + internal sealed partial class Settings { + + public Settings() { + // // To add event handlers for saving and changing settings, uncomment the lines below: + // + // this.SettingChanging += this.SettingChangingEventHandler; + // + // this.SettingsSaving += this.SettingsSavingEventHandler; + // + } + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + // Add code to handle the SettingChangingEvent event here. + } + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + // Add code to handle the SettingsSaving event here. + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/Settings.cs ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/irc/TechBot/TechBot.Library/Settings.settings URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Setting... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/Settings.settings (added) +++ trunk/irc/TechBot/TechBot.Library/Settings.settings Mon Dec 10 22:08:13 2007 @@ -1,0 +1,21 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Library" GeneratedClassName="Settings"> + <Profiles /> + <Settings> + <Setting Name="NtStatusXml" Type="System.String" Scope="Application"> + <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</Value> + </Setting> + <Setting Name="WinErrorXml" Type="System.String" Scope="Application"> + <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\winerror.xml</Value> + </Setting> + <Setting Name="HResultXml" Type="System.String" Scope="Application"> + <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\hresult.xml</Value> + </Setting> + <Setting Name="WMXml" Type="System.String" Scope="Application"> + <Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\wm.xml</Value> + </Setting> + <Setting Name="SVNRoot" Type="System.String" Scope="Application"> + <Value Profile="(Default)">svn://svn.reactos.org/trunk/reactos</Value> + </Setting> + </Settings> +</SettingsFile>
Propchange: trunk/irc/TechBot/TechBot.Library/Settings.settings ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/irc/TechBot/TechBot.Library/SvnCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/SvnComm... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/SvnCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/SvnCommand.cs Mon Dec 10 22:08:13 2007 @@ -2,33 +2,29 @@
namespace TechBot.Library { - public class SvnCommand : BaseCommand, ICommand + public class SvnCommand : Command { - private IServiceOutput serviceOutput; - private string svnCommand; + private string m_SvnRoot;
- public SvnCommand(IServiceOutput serviceOutput, - string svnCommand) + public SvnCommand(TechBotService techBot) + : base(techBot) { - this.serviceOutput = serviceOutput; - this.svnCommand = svnCommand; - } - - public bool CanHandle(string commandName) - { - return CanHandle(commandName, - new string[] { "svn" }); + m_SvnRoot = Settings.Default.SVNRoot; }
- public void Handle(MessageContext context, + public override string[] AvailableCommands + { + get { return new string[] { "svn" }; } + } + + public override void Handle(MessageContext context, string commandName, string parameters) { - serviceOutput.WriteLine(context, - svnCommand); + TechBot.ServiceOutput.WriteLine(context, string.Format("svn co {0}" , m_SvnRoot)); } - - public string Help() + + public override string Help() { return "!svn"; }
Removed: trunk/irc/TechBot/TechBot.Library/TechBot.Library.cmbx URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/TechBot... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/TechBot.Library.cmbx (original) +++ trunk/irc/TechBot/TechBot.Library/TechBot.Library.cmbx (removed) @@ -1,16 +1,0 @@ -<Combine fileversion="1.0" name="TechBot.Library" description=""> - <StartMode startupentry="TechBot.Library" single="True"> - <Execute entry="TechBot.Library" type="None" /> - </StartMode> - <Entries> - <Entry filename=".\.\TechBot.Library.prjx" /> - </Entries> - <Configurations active="Debug"> - <Configuration name="Release"> - <Entry name="TechBot.Library" configurationname="Debug" build="False" /> - </Configuration> - <Configuration name="Debug"> - <Entry name="TechBot.Library" configurationname="Debug" build="False" /> - </Configuration> - </Configurations> -</Combine>
Modified: trunk/irc/TechBot/TechBot.Library/TechBot.Library.csproj URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/TechBot... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/TechBot.Library.csproj (original) +++ trunk/irc/TechBot/TechBot.Library/TechBot.Library.csproj Mon Dec 10 22:08:13 2007 @@ -40,8 +40,10 @@ --> <ItemGroup> <Compile Include="ApiCommand.cs" /> - <Compile Include="AssemblyInfo.cs" /> <Compile Include="BugCommand.cs" /> + <Compile Include="Commands\Base\XmlCommand.cs" /> + <Compile Include="SambaBugUrl.cs" /> + <Compile Include="WineBugUrl.cs" /> <Compile Include="ErrorCommand.cs" /> <Compile Include="HelpCommand.cs" /> <Compile Include="HresultCommand.cs" /> @@ -50,7 +52,15 @@ <Compile Include="MessageContext.cs" /> <Compile Include="NtStatusCommand.cs" /> <Compile Include="NumberParser.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="ReactOSBugUrl.cs" /> <Compile Include="ServiceOutput.cs" /> + <Compile Include="Settings.cs" /> + <Compile Include="Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + <DependentUpon>Settings.settings</DependentUpon> + </Compile> <Compile Include="SvnCommand.cs" /> <Compile Include="TechBotService.cs" /> <Compile Include="WinerrorCommand.cs" /> @@ -72,6 +82,10 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <Folder Include="Properties\" /> + <None Include="app.config" /> + <None Include="Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> </ItemGroup> </Project>
Removed: trunk/irc/TechBot/TechBot.Library/TechBot.Library.prjx URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/TechBot... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/TechBot.Library.prjx (original) +++ trunk/irc/TechBot/TechBot.Library/TechBot.Library.prjx (removed) @@ -1,43 +1,0 @@ -<Project name="TechBot.Library" standardNamespace="TechBot.Library" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#"> - <Contents> - <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\Default.build" subtype="Code" buildaction="Nothing" dependson="" data="" /> - <File name=".\TechBotService.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\ServiceOutput.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\IrcService.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\ApiCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\ICommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\HelpCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\NtStatusCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\NumberParser.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\ErrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\BugCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\WmCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - <File name=".\MessageContext.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> - </Contents> - <References> - <Reference type="Project" refto="CHMLibrary" localcopy="True" /> - <Reference type="Project" refto="TechBot.IRCLibrary" localcopy="True" /> - </References> - <DeploymentInformation target="" script="" strategy="File" /> - <Configuration runwithwarnings="True" name="Debug"> - <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" /> - <Execution commandlineparameters="" consolepause="False" /> - <Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" /> - </Configuration> - <Configurations active="Debug"> - <Configuration runwithwarnings="True" name="Debug"> - <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" /> - <Execution commandlineparameters="" consolepause="False" /> - <Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" /> - </Configuration> - <Configuration runwithwarnings="True" name="Release"> - <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" /> - <Execution commandlineparameters="" consolepause="False" /> - <Output directory="..\bin\Release" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" /> - </Configuration> - </Configurations> -</Project>
Modified: trunk/irc/TechBot/TechBot.Library/TechBotService.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/TechBot... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/TechBotService.cs (original) +++ trunk/irc/TechBot/TechBot.Library/TechBotService.cs Mon Dec 10 22:08:13 2007 @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Data; using System.Threading; @@ -18,19 +19,19 @@ private string wmXml; private string svnCommand; private string bugUrl, WineBugUrl, SambaBugUrl; - private ArrayList commands = new ArrayList(); + private List<Command> commands = new List<Command>(); public TechBotService(IServiceOutput serviceOutput, string chmPath, - string mainChm, - string ntstatusXml, - string winerrorXml, - string hresultXml, - string wmXml, - string svnCommand, - string bugUrl, - string WineBugUrl, - string SambaBugUrl) + string mainChm) + //string ntstatusXml, + //string winerrorXml, + //string hresultXml, + //string wmXml, + //string svnCommand, + //string bugUrl, + //string WineBugUrl, + //string SambaBugUrl) { this.serviceOutput = serviceOutput; this.chmPath = chmPath; @@ -44,33 +45,33 @@ this.WineBugUrl = WineBugUrl; this.SambaBugUrl = SambaBugUrl; } - - public void Run() - { - commands.Add(new HelpCommand(serviceOutput, - commands)); - /*commands.Add(new ApiCommand(serviceOutput, - chmPath, - mainChm));*/ - commands.Add(new NtStatusCommand(serviceOutput, - ntstatusXml)); - commands.Add(new WinerrorCommand(serviceOutput, - winerrorXml)); - commands.Add(new HresultCommand(serviceOutput, - hresultXml)); - commands.Add(new ErrorCommand(serviceOutput, - ntstatusXml, - winerrorXml, - hresultXml)); - commands.Add(new WmCommand(serviceOutput, - wmXml)); - commands.Add(new SvnCommand(serviceOutput, - svnCommand)); - commands.Add(new BugCommand(serviceOutput, - bugUrl, - WineBugUrl, - SambaBugUrl)); - } + + public void Run() + { + commands.Add(new HelpCommand(this)); + /*commands.Add(new ApiCommand(serviceOutput, + chmPath, + mainChm));*/ + commands.Add(new NtStatusCommand(this)); + commands.Add(new WinerrorCommand(this)); + commands.Add(new HResultCommand(this)); + commands.Add(new ErrorCommand(this)); + commands.Add(new WMCommand(this)); + commands.Add(new SvnCommand(this)); + commands.Add(new ReactOSBugUrl(this)); + commands.Add(new SambaBugUrl(this)); + commands.Add(new WineBugUrl(this)); + } + + public IServiceOutput ServiceOutput + { + get { return serviceOutput; } + } + + public IList<Command> Commands + { + get { return commands; } + } public void InjectMessage(MessageContext context, string message) @@ -94,23 +95,27 @@ message = message.Substring(1).Trim(); int index = message.IndexOf(' '); string commandName; - string parameters = ""; + string commandParams = ""; if (index != -1) { commandName = message.Substring(0, index).Trim(); - parameters = message.Substring(index).Trim(); + commandParams = message.Substring(index).Trim(); } else commandName = message.Trim();
- foreach (ICommand command in commands) + foreach (Command command in commands) { - if (command.CanHandle(commandName)) - { - command.Handle(context, - commandName, parameters); - return; - } + foreach (string cmd in command.AvailableCommands) + { + if (cmd == commandName) + { + command.Handle(context, + commandName, + commandParams); + return; + } + } } } }
Added: trunk/irc/TechBot/TechBot.Library/WineBugUrl.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/WineBug... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/WineBugUrl.cs (added) +++ trunk/irc/TechBot/TechBot.Library/WineBugUrl.cs Mon Dec 10 22:08:13 2007 @@ -1,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TechBot.Library +{ + class WineBugUrl : BugCommand + { + public WineBugUrl(TechBotService techBot) + : base(techBot) + { + } + + public override string[] AvailableCommands + { + get { return new string[] { "winebug" }; } + } + + protected override string BugUrl + { + get { return "http://bugs.winehq.org/show_bug.cgi?id=%7B0%7D"; } + } + + public override string Help() + { + return "!winebug <number>"; + } + } +}
Propchange: trunk/irc/TechBot/TechBot.Library/WineBugUrl.cs ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/irc/TechBot/TechBot.Library/WinerrorCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/Winerro... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/WinerrorCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/WinerrorCommand.cs Mon Dec 10 22:08:13 2007 @@ -3,35 +3,31 @@
namespace TechBot.Library { - public class WinerrorCommand : BaseCommand, ICommand + public class WinerrorCommand : XmlCommand { - private IServiceOutput serviceOutput; - private string winerrorXml; - private XmlDocument winerrorXmlDocument; - - public WinerrorCommand(IServiceOutput serviceOutput, - string winerrorXml) + public WinerrorCommand(TechBotService techBot) + : base(techBot) { - this.serviceOutput = serviceOutput; - this.winerrorXml = winerrorXml; - winerrorXmlDocument = new XmlDocument(); - winerrorXmlDocument.Load(winerrorXml); - } - - public bool CanHandle(string commandName) - { - return CanHandle(commandName, - new string[] { "winerror" }); }
- public void Handle(MessageContext context, + public override string XmlFile + { + get { return Settings.Default.WinErrorXml; } + } + + public override string[] AvailableCommands + { + get { return new string[] { "winerror" }; } + } + + public override void Handle(MessageContext context, string commandName, string parameters) { string winerrorText = parameters; if (winerrorText.Equals(String.Empty)) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, "Please provide a valid System Error Code value."); return; } @@ -40,7 +36,7 @@ long winerror = np.Parse(winerrorText); if (np.Error) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is not a valid System Error Code value.", winerrorText)); return; @@ -49,27 +45,27 @@ string description = GetWinerrorDescription(winerror); if (description != null) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is {1}.", winerrorText, description)); } else { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("I don't know about System Error Code {0}.", winerrorText)); } } - - public string Help() + + public override string Help() { return "!winerror <value>"; } public string GetWinerrorDescription(long winerror) { - XmlElement root = winerrorXmlDocument.DocumentElement; + XmlElement root = base.m_XmlDocument.DocumentElement; XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']", winerror)); if (node != null)
Modified: trunk/irc/TechBot/TechBot.Library/WmCommand.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/WmComma... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/WmCommand.cs (original) +++ trunk/irc/TechBot/TechBot.Library/WmCommand.cs Mon Dec 10 22:08:13 2007 @@ -3,35 +3,31 @@
namespace TechBot.Library { - public class WmCommand : BaseCommand, ICommand + public class WMCommand : XmlCommand { - private IServiceOutput serviceOutput; - private string wmXml; - private XmlDocument wmXmlDocument; - - public WmCommand(IServiceOutput serviceOutput, - string wmXml) + public WMCommand(TechBotService techBot) + : base(techBot) { - this.serviceOutput = serviceOutput; - this.wmXml = wmXml; - wmXmlDocument = new XmlDocument(); - wmXmlDocument.Load(wmXml); - } - - public bool CanHandle(string commandName) - { - return CanHandle(commandName, - new string[] { "wm" }); }
- public void Handle(MessageContext context, + public override string XmlFile + { + get { return Settings.Default.WMXml; } + } + + public override string[] AvailableCommands + { + get { return new string[] { "wm" }; } + } + + public override void Handle(MessageContext context, string commandName, string parameters) { string wmText = parameters; if (wmText.Equals(String.Empty)) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, "Please provide a valid window message value or name."); return; } @@ -51,27 +47,27 @@
if (output != null) { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("{0} is {1}.", wmText, output)); } else { - serviceOutput.WriteLine(context, + TechBot.ServiceOutput.WriteLine(context, String.Format("I don't know about window message {0}.", wmText)); } } - - public string Help() + + public override string Help() { return "!wm <value> or !wm <name>"; } private string GetWmDescription(long wm) { - XmlElement root = wmXmlDocument.DocumentElement; + XmlElement root = base.m_XmlDocument.DocumentElement; XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']", wm)); if (node != null) @@ -87,7 +83,7 @@ private string GetWmNumber(string wmName) { - XmlElement root = wmXmlDocument.DocumentElement; + XmlElement root = base.m_XmlDocument.DocumentElement; XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']", wmName)); if (node != null)
Added: trunk/irc/TechBot/TechBot.Library/app.config URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot.Library/app.con... ============================================================================== --- trunk/irc/TechBot/TechBot.Library/app.config (added) +++ trunk/irc/TechBot/TechBot.Library/app.config Mon Dec 10 22:08:13 2007 @@ -1,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <configSections> + <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > + <section name="TechBot.Library.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </sectionGroup> + </configSections> + <applicationSettings> + <TechBot.Library.Settings> + <setting name="NtStatusXml" serializeAs="String"> + <value>C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</value> + </setting> + <setting name="WinErrorXml" serializeAs="String"> + <value>C:\Ros\current\irc\TechBot\Resources\winerror.xml</value> + </setting> + <setting name="HResultXml" serializeAs="String"> + <value>C:\Ros\current\irc\TechBot\Resources\hresult.xml</value> + </setting> + <setting name="WMXml" serializeAs="String"> + <value>C:\Ros\current\irc\TechBot\Resources\wm.xml</value> + </setting> + <setting name="SVNRoot" serializeAs="String"> + <value>svn://svn.reactos.org/trunk/reactos</value> + </setting> + </TechBot.Library.Settings> + </applicationSettings> +</configuration>
Propchange: trunk/irc/TechBot/TechBot.Library/app.config ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/irc/TechBot/TechBot/ServiceThread.cs URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot/ServiceThread.c... ============================================================================== --- trunk/irc/TechBot/TechBot/ServiceThread.cs (original) +++ trunk/irc/TechBot/TechBot/ServiceThread.cs Mon Dec 10 22:08:13 2007 @@ -58,11 +58,11 @@ IRCBotPassword, ChmPath, MainChm, - NtstatusXml, - WinerrorXml, - HresultXml, - WmXml, - SvnCommand, + //NtstatusXml, + //WinerrorXml, + //HresultXml, + //WmXml, + //SvnCommand, BugUrl, WineBugUrl, SambaBugUrl);
Modified: trunk/irc/TechBot/TechBot/TechBot.csproj URL: http://svn.reactos.org/svn/reactos/trunk/irc/TechBot/TechBot/TechBot.csproj?... ============================================================================== --- trunk/irc/TechBot/TechBot/TechBot.csproj (original) +++ trunk/irc/TechBot/TechBot/TechBot.csproj Mon Dec 10 22:08:13 2007 @@ -10,6 +10,7 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>TechBot</RootNamespace> <AssemblyName>TechBot</AssemblyName> + <StartupObject>TechBot.TechBotService</StartupObject> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols>