mirror of
https://github.com/reactos/reactos
synced 2025-10-08 01:12:58 +02:00
Compare commits
42 Commits
ReactOS-0.
...
backups/po
Author | SHA1 | Date | |
---|---|---|---|
|
7bd6f1e793 | ||
|
15d98ae976 | ||
|
c1cc61b87a | ||
|
4969e3d34c | ||
|
b17784fa55 | ||
|
fe91699e83 | ||
|
3e2620637d | ||
|
e19545890e | ||
|
31b6cbfb8a | ||
|
a62d227e18 | ||
|
4369ecad32 | ||
|
d1ebc9d7cb | ||
|
218f6238b0 | ||
|
41d1e3c17f | ||
|
6e09f5904c | ||
|
abb1072de8 | ||
|
6bfd850c13 | ||
|
4903cf0db8 | ||
|
e625607fb9 | ||
|
deba115385 | ||
|
cb39fd5820 | ||
|
cc130cd0d5 | ||
|
8338983157 | ||
|
7a3fc87c74 | ||
|
a7ca02296b | ||
|
6fd8a37cc2 | ||
|
8fe743e51c | ||
|
54811ff04e | ||
|
fc73dbb494 | ||
|
e8c9d41dfe | ||
|
3f8abbe149 | ||
|
31f327218a | ||
|
50d2f8119a | ||
|
867ac19a73 | ||
|
398ae0efb7 | ||
|
256ed98f60 | ||
|
26cf1dcb7f | ||
|
5b9de03a76 | ||
|
5c69119650 | ||
|
2e7695dcfc | ||
|
51360ae1c2 | ||
|
8eed64e68d |
46
cis/ReactOS.ApiStatus/Default.build
Normal file
46
cis/ReactOS.ApiStatus/Default.build
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Copyright (C) 2005 Casper S. Hornstrup
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
-->
|
||||
<project name="ReactOS.ApiStatus" default="publish">
|
||||
|
||||
<property name="reactos.dir" value="reactos" />
|
||||
<property name="apistatus.xsl" value="rapistatus.xsl" />
|
||||
<property name="apistatus.xml" value="rapistatus.xml" />
|
||||
<property name="apistatus.html" value="index2.html" />
|
||||
<include buildfile="config.include" />
|
||||
|
||||
<target name="publish">
|
||||
<delete dir="${reactos.dir}" if="${directory::exists(reactos.dir)}" />
|
||||
<exec program="svn" commandline="export -r HEAD ${source.url} ${reactos.dir}" />
|
||||
<exec program="rgenstat" commandline="reactos\apistatus.lst ${apistatus.xml}" />
|
||||
<style style="${apistatus.xsl}" destdir="${reactos.dir}" in="${apistatus.xml}" out="${apistatus.html}" />
|
||||
<copy todir="${publish.dir}" overwrite="true">
|
||||
<fileset basedir=".">
|
||||
<include name="${apistatus.xml}" />
|
||||
<include name="${apistatus.html}" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<delete>
|
||||
<fileset basedir=".">
|
||||
<include name="${apistatus.xml}" />
|
||||
<include name="${apistatus.html}" />
|
||||
</fileset>
|
||||
</delete>
|
||||
<delete dir="${reactos.dir}" if="${directory::exists(reactos.dir)}" />
|
||||
</target>
|
||||
</project>
|
22
cis/ReactOS.ApiStatus/config.template.include
Normal file
22
cis/ReactOS.ApiStatus/config.template.include
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2005 Casper S. Hornstrup
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
-->
|
||||
<project>
|
||||
<property name="source.url" value="svn://svn.reactos.com/trunk/reactos" />
|
||||
<property name="publish.dir" value="C:\api" />
|
||||
</project>
|
199
cis/ReactOS.ApiStatus/rapistatus.xsl
Executable file
199
cis/ReactOS.ApiStatus/rapistatus.xsl
Executable file
@@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" ?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:output method="html" indent="no"/>
|
||||
<!-- <xsl:output method="xml"/>-->
|
||||
<!-- Will not work: <xsl:strip-space elements="*"/> -->
|
||||
|
||||
<xsl:template match="/">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
ReactOS API Status
|
||||
</TITLE>
|
||||
<SCRIPT src="rapistatus.js"></SCRIPT>
|
||||
<LINK rel="stylesheet" type="text/css" href="rapistatus.css"></LINK>
|
||||
</HEAD>
|
||||
<BODY onLoad="onLoad();">
|
||||
<P>
|
||||
<H1>ReactOS API Status</H1>
|
||||
</P>
|
||||
<P>
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD> <INPUT type="checkbox" ID="implemented" onClick="selectImplemented();" checked="1"/> </TD>
|
||||
<TD> <IMG src="i.gif"/> </TD>
|
||||
<TD> Implemented </TD>
|
||||
<TD width="20"/>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD> <INPUT type="checkbox" ID="unimplemented" onClick="selectUnimplemented();" checked="1"/> </TD>
|
||||
<TD> <IMG src="u.gif"/> </TD>
|
||||
<TD> Unimplemented </TD>
|
||||
<TD width="20"/>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</P>
|
||||
<DIV ID="ROOT">
|
||||
<xsl:apply-templates/>
|
||||
</DIV>
|
||||
<P>
|
||||
Legend :<BR/>
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD> <IMG src="c.gif"/> </TD>
|
||||
<TD> Component </TD>
|
||||
<TD> <IMG src="i.gif"/> </TD>
|
||||
<TD> Implemented </TD>
|
||||
<TD> <IMG src="sc.gif"/> </TD>
|
||||
<TD> Complete </TD>
|
||||
<TR>
|
||||
</TR>
|
||||
<TD> <IMG src="f.gif"/> </TD>
|
||||
<TD> Function </TD>
|
||||
<TD> <IMG src="u.gif"/> </TD>
|
||||
<TD> Unimplemented </TD>
|
||||
<TD></TD>
|
||||
<TD></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- component -->
|
||||
<xsl:template match="/components">
|
||||
<xsl:apply-templates select="component">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="components/component[@implemented_total or @unimplemented_total]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">c</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="base"><xsl:value-of select="@base"/></xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- function -->
|
||||
<xsl:template match="functions">
|
||||
<xsl:param name="base"/>
|
||||
<xsl:apply-templates select="f">
|
||||
<xsl:sort select="@n"/>
|
||||
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="functions/f">
|
||||
<xsl:param name="base"/>
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">f</xsl:with-param>
|
||||
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates/>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- support templates -->
|
||||
|
||||
<xsl:template name="ELEMENT">
|
||||
<xsl:param name="class"/>
|
||||
<xsl:param name="base"/>
|
||||
<xsl:param name="image"/>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="$class"/>
|
||||
<xsl:text>_</xsl:text>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="toggle"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="local-name() != 'component' and @i = 'true'">
|
||||
<img src="i.gif" class="i"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="local-name() != 'component' and @i = 'false'">
|
||||
<img src="u.gif" class="u"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="local-name() = 'component' and @complete >= 100">
|
||||
<img src="sc.gif"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@i"/><img src="tb.gif" with="12" height="12"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$image">
|
||||
<img src="{$image}.gif" class="t"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<img src="{$class}.gif" class="t"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:call-template name="name"/>
|
||||
<xsl:call-template name="n"/>
|
||||
<xsl:call-template name="file">
|
||||
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="status"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="status">
|
||||
<xsl:if test="@complete and @complete != 0">
|
||||
<SPAN class="st">
|
||||
<img src="sc.gif"/>
|
||||
<xsl:text>: </xsl:text>
|
||||
<xsl:value-of select="@complete"/>
|
||||
<xsl:text>%</xsl:text>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
<xsl:if test="@implemented_total">
|
||||
<SPAN class="st">
|
||||
<img src="i.gif"/>: <xsl:value-of select="@implemented_total"/>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
<xsl:if test="@unimplemented_total">
|
||||
<SPAN class="st">
|
||||
<img src="u.gif"/>: <xsl:value-of select="@unimplemented_total"/>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="toggle">
|
||||
<xsl:choose>
|
||||
<xsl:when test="local-name() = 'component'">
|
||||
<IMG src="tp.gif" class="t"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<IMG src="tb.gif"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="name">
|
||||
<xsl:if test="@name">
|
||||
<SPAN class="l"><xsl:value-of select="@name"/></SPAN>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="n">
|
||||
<xsl:if test="@n">
|
||||
<SPAN class="l"><xsl:value-of select="@n"/></SPAN>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="file">
|
||||
<xsl:param name="base"/>
|
||||
<xsl:if test="@f">
|
||||
<SPAN class="h"><xsl:value-of select="$base"/><xsl:value-of select="@f"/></SPAN>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
10
cis/ReactOS.CustomRevisionAction/App.config
Normal file
10
cis/ReactOS.CustomRevisionAction/App.config
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="publishPath" value="c:\iso" /> <!-- c:\iso or ftp://ftp.server.com/iso -->
|
||||
<add key="smtpServer" value="localhost" />
|
||||
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
|
||||
<add key="makeParameters" value="" />
|
||||
<add key="fastDisk" value="" />
|
||||
</appSettings>
|
||||
</configuration>
|
14
cis/ReactOS.CustomRevisionAction/AssemblyInfo.cs
Normal file
14
cis/ReactOS.CustomRevisionAction/AssemblyInfo.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("ReactOS Sin Custom Revision Action")]
|
||||
[assembly: AssemblyDescription("ReactOS Sin Custom Revision Action")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("ReactOS Project")]
|
||||
[assembly: AssemblyProduct("React Operating System")]
|
||||
[assembly: AssemblyCopyright("Copyright 2005 ReactOS Project")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
20
cis/ReactOS.CustomRevisionAction/Default.build
Normal file
20
cis/ReactOS.CustomRevisionAction/Default.build
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="ReactOS.CustomRevisionAction" default="build">
|
||||
|
||||
<property name="output.dir" value="bin" />
|
||||
|
||||
<target name="build" description="Build component">
|
||||
<mkdir dir="${output.dir}" />
|
||||
<csc target="exe"
|
||||
output="${output.dir}\ReactOS.CustomRevisionAction.exe"
|
||||
optimize="true"
|
||||
debug="true"
|
||||
doc="${output.dir}\ReactOS.CustomRevisionAction.xml"
|
||||
warninglevel="0">
|
||||
<sources>
|
||||
<include name="*.cs" />
|
||||
</sources>
|
||||
</csc>
|
||||
</target>
|
||||
|
||||
</project>
|
1054
cis/ReactOS.CustomRevisionAction/FtpClient.cs
Normal file
1054
cis/ReactOS.CustomRevisionAction/FtpClient.cs
Normal file
File diff suppressed because it is too large
Load Diff
340
cis/ReactOS.CustomRevisionAction/Main.cs
Normal file
340
cis/ReactOS.CustomRevisionAction/Main.cs
Normal file
@@ -0,0 +1,340 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Configuration;
|
||||
using System.Web.Mail;
|
||||
|
||||
namespace ReactOS.CustomRevisionAction
|
||||
{
|
||||
public class MainClass
|
||||
{
|
||||
/// <summary>
|
||||
/// Path to store published binaries at.
|
||||
/// </summary>
|
||||
private static string publishPath;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to publish ISOs to a remote destination via FTP.
|
||||
/// </summary>
|
||||
private static bool PublishToRemoteFtpLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return publishPath.StartsWith("ftp://");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the application.
|
||||
/// </summary>
|
||||
/// <param name="script">Script to run.</param>
|
||||
/// <param name="args">Arguments to pass to script.</param>
|
||||
/// <param name="workingDirectory">Working directory.</param>
|
||||
/// <param name="standardOutput">Receives standard output.</param>
|
||||
/// <param name="standardError">Receives standard error.</param>
|
||||
/// <returns>
|
||||
/// Exit code.
|
||||
/// </returns>
|
||||
private static int RunScript(string script,
|
||||
string args,
|
||||
string workingDirectory,
|
||||
out string standardOutput,
|
||||
out string standardError)
|
||||
{
|
||||
ProcessStartInfo scriptProcessStartInfo = new ProcessStartInfo(script,
|
||||
args);
|
||||
scriptProcessStartInfo.CreateNoWindow = true;
|
||||
/*
|
||||
* All standard streams must be redirected.
|
||||
* Otherwise DuplicateHandle() will fail.
|
||||
*/
|
||||
scriptProcessStartInfo.RedirectStandardInput = true;
|
||||
scriptProcessStartInfo.RedirectStandardError = true;
|
||||
scriptProcessStartInfo.RedirectStandardOutput = true;
|
||||
scriptProcessStartInfo.UseShellExecute = false;
|
||||
scriptProcessStartInfo.WorkingDirectory = workingDirectory;
|
||||
RedirectableProcess redirectableProcess = new RedirectableProcess(scriptProcessStartInfo);
|
||||
standardOutput = redirectableProcess.ProcessOutput;
|
||||
standardError = redirectableProcess.ProcessError;
|
||||
return redirectableProcess.ExitCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve value of configuration from configuration file.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of configuration option.</param>
|
||||
/// <param name="defaultValue">
|
||||
/// Default value to be returned if the option does not exist.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Value of configuration option or null if the option does not
|
||||
/// exist and no default value is provided.
|
||||
/// </returns>
|
||||
private static string GetConfigurationOption(string name,
|
||||
string defaultValue)
|
||||
{
|
||||
if (ConfigurationSettings.AppSettings[name] != null)
|
||||
return ConfigurationSettings.AppSettings[name];
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send an email.
|
||||
/// </summary>
|
||||
/// <param name="subject">Subject of the email.</param>
|
||||
/// <param name="body">Content of the email.</param>
|
||||
private static void SendErrorMail(string subject, string body)
|
||||
{
|
||||
try
|
||||
{
|
||||
string smtpServer = GetConfigurationOption("smtpServer", "localhost");
|
||||
string toEmail = GetConfigurationOption("errorEmail", null);
|
||||
if (toEmail == null)
|
||||
return;
|
||||
string fromEmail = GetConfigurationOption("fromEmail", null);
|
||||
if (fromEmail == null)
|
||||
fromEmail = toEmail;
|
||||
MailMessage mm = new MailMessage();
|
||||
mm.Priority = MailPriority.Normal;
|
||||
mm.From = toEmail;
|
||||
mm.To = toEmail;
|
||||
mm.Subject = subject;
|
||||
mm.Body += body;
|
||||
mm.Body += "<br>";
|
||||
mm.BodyFormat = MailFormat.Html;
|
||||
SmtpMail.SmtpServer = smtpServer;
|
||||
SmtpMail.Send(mm);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fail with an error message.
|
||||
/// </summary>
|
||||
/// <param name="revision">Repository revision.</param>
|
||||
/// <param name="text">Error message.</param>
|
||||
private static void Fail(int revision,
|
||||
string text)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
Console.Error.WriteLine(text);
|
||||
SendErrorMail(String.Format("[{0}] ReactOS Publish Error", revision), text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fail with an error message.
|
||||
/// </summary>
|
||||
/// <param name="text">Error message.</param>
|
||||
private static void Fail(string text)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
Console.Error.WriteLine(text);
|
||||
SendErrorMail("ReactOS Publish Error", text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate filename of distribution.
|
||||
/// </summary>
|
||||
/// <param name="branch">Branch.</param>
|
||||
/// <param name="revision">Revision.</param>
|
||||
private static string GetDistributionFilename(string branch,
|
||||
int revision)
|
||||
{
|
||||
return String.Format("ReactOS-{0}-r{1}.iso",
|
||||
branch,
|
||||
revision);
|
||||
}
|
||||
|
||||
private static void SplitRemotePublishPath(string publishPath,
|
||||
out string server,
|
||||
out string directory)
|
||||
{
|
||||
string searchString = "://";
|
||||
int index = publishPath.IndexOf(searchString);
|
||||
if (index == -1)
|
||||
throw new InvalidOperationException();
|
||||
int endOfProtocolIndex = index + searchString.Length;
|
||||
string withoutProtocol = publishPath.Remove(0, endOfProtocolIndex);
|
||||
index = withoutProtocol.IndexOf("/");
|
||||
if (index == -1)
|
||||
{
|
||||
server = withoutProtocol;
|
||||
directory = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
server = withoutProtocol.Substring(0, index);
|
||||
directory = withoutProtocol.Remove(0, index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy ISO to the (remote) destination.
|
||||
/// </summary>
|
||||
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
|
||||
/// <param name="branch">Branch.</param>
|
||||
/// <param name="revision">Revision.</param>
|
||||
/// <remarks>
|
||||
/// Structure is ftp://ftp.server.com/whereever/<branch>/ReactOS-<branch>-r<revision>.iso.
|
||||
/// </remarks>
|
||||
private static void CopyISOToRemoteFtpDestination(string sourceFilename,
|
||||
string branch,
|
||||
int revision)
|
||||
{
|
||||
string distributionFilename = GetDistributionFilename(branch,
|
||||
revision);
|
||||
string destinationFilename = Path.Combine(Path.GetDirectoryName(sourceFilename),
|
||||
distributionFilename);
|
||||
File.Move(sourceFilename, destinationFilename);
|
||||
string server;
|
||||
string directory;
|
||||
SplitRemotePublishPath(publishPath, out server, out directory);
|
||||
FtpClient ftpClient = new FtpClient(server, "anonymous", "sin@svn.reactos.com");
|
||||
ftpClient.Login();
|
||||
if (directory != "")
|
||||
ftpClient.ChangeDir(directory);
|
||||
/* Create destination directory if it does not already exist */
|
||||
if (!ftpClient.DirectoryExists(branch))
|
||||
ftpClient.MakeDir(branch);
|
||||
ftpClient.ChangeDir(branch);
|
||||
ftpClient.Upload(destinationFilename);
|
||||
ftpClient.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy ISO to the (local) destination.
|
||||
/// </summary>
|
||||
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
|
||||
/// <param name="branch">Branch.</param>
|
||||
/// <param name="revision">Revision.</param>
|
||||
/// <remarks>
|
||||
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
|
||||
/// </remarks>
|
||||
private static void CopyISOToLocalDestination(string sourceFilename,
|
||||
string branch,
|
||||
int revision)
|
||||
{
|
||||
string distributionFilename = GetDistributionFilename(branch,
|
||||
revision);
|
||||
string destinationDirectory = Path.Combine(publishPath,
|
||||
branch);
|
||||
string destinationFilename = Path.Combine(destinationDirectory,
|
||||
distributionFilename);
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
File.Copy(sourceFilename,
|
||||
destinationFilename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy ISO to the destination.
|
||||
/// </summary>
|
||||
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
|
||||
/// <param name="branch">Branch.</param>
|
||||
/// <param name="revision">Revision.</param>
|
||||
/// <remarks>
|
||||
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
|
||||
/// </remarks>
|
||||
private static void CopyISOToDestination(string sourceFilename,
|
||||
string branch,
|
||||
int revision)
|
||||
{
|
||||
if (PublishToRemoteFtpLocation)
|
||||
CopyISOToRemoteFtpDestination(sourceFilename, branch, revision);
|
||||
else
|
||||
CopyISOToLocalDestination(sourceFilename, branch, revision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Publish a revision of ReactOS.
|
||||
/// </summary>
|
||||
/// <param name="text">Error message.</param>
|
||||
private static int Publish(string branch,
|
||||
int revision,
|
||||
string workingDirectory)
|
||||
{
|
||||
string make = "mingw32-make";
|
||||
string makeParameters = GetConfigurationOption("makeParameters", "");
|
||||
string reactosDirectory = Path.Combine(workingDirectory,
|
||||
"reactos");
|
||||
Console.WriteLine(String.Format("ReactOS directory is {0}",
|
||||
reactosDirectory));
|
||||
string standardOutput;
|
||||
string standardError;
|
||||
int exitCode = RunScript(make,
|
||||
makeParameters + " bootcd",
|
||||
reactosDirectory,
|
||||
out standardOutput,
|
||||
out standardError);
|
||||
if (exitCode != 0)
|
||||
{
|
||||
Fail(revision,
|
||||
String.Format("make bootcd failed: (error: {0}) {1}",
|
||||
standardError,
|
||||
standardOutput));
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
string sourceFilename = Path.Combine(reactosDirectory,
|
||||
"ReactOS.iso");
|
||||
if (File.Exists(sourceFilename))
|
||||
CopyISOToDestination(sourceFilename,
|
||||
branch,
|
||||
revision);
|
||||
else
|
||||
{
|
||||
Fail(revision,
|
||||
"make bootcd produced no ReactOS.iso");
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Program entry point.
|
||||
/// </summary>
|
||||
/// <param name="args">Arguments from command line.</param>
|
||||
/// <remarks>
|
||||
/// If exit code is 0, then the commit was processed successfully.
|
||||
/// If exit code is 1, then the commit was not processed successfully.
|
||||
/// </remarks>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Environment.ExitCode = 1;
|
||||
|
||||
publishPath = ConfigurationSettings.AppSettings["publishPath"];
|
||||
if (publishPath == null)
|
||||
{
|
||||
Fail("PublishPath option not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length < 3)
|
||||
{
|
||||
Fail("Usage: ReactOS.CustomRevisionAction action branch revision");
|
||||
return;
|
||||
}
|
||||
|
||||
string action = args[0]; /* bootcd */
|
||||
string branch = args[1];
|
||||
int revision = Int32.Parse(args[2]);
|
||||
|
||||
System.Environment.ExitCode = Publish(branch,
|
||||
revision,
|
||||
System.Environment.CurrentDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Fail(String.Format("Exception: {0}", ex));
|
||||
System.Environment.ExitCode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
145
cis/ReactOS.CustomRevisionAction/RedirectableProcess.cs
Normal file
145
cis/ReactOS.CustomRevisionAction/RedirectableProcess.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* When using the ProcessStartInfo.RedirectStandardXxx properties there is a chance of
|
||||
* the parent and child process blocking due to a race condition. This class handles the
|
||||
* problem.
|
||||
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclassredirectstandardoutputtopic.asp
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ReactOS.CustomRevisionAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Process that redirects standard output and standard error streams.
|
||||
/// </summary>
|
||||
public class RedirectableProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Process.
|
||||
/// </summary>
|
||||
private Process process;
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard error stream.
|
||||
/// </summary>
|
||||
private string processError;
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard output stream.
|
||||
/// </summary>
|
||||
private string processOutput;
|
||||
|
||||
/// <summary>
|
||||
/// Exit code.
|
||||
/// </summary>
|
||||
private int exitCode;
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard error stream.
|
||||
/// </summary>
|
||||
public string ProcessError
|
||||
{
|
||||
get
|
||||
{
|
||||
return processError;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard output stream.
|
||||
/// </summary>
|
||||
public string ProcessOutput
|
||||
{
|
||||
get
|
||||
{
|
||||
return processOutput;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exit code.
|
||||
/// </summary>
|
||||
public int ExitCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run an excutable and redirect standard error and/or standard output safely.
|
||||
/// </summary>
|
||||
public RedirectableProcess(ProcessStartInfo processStartInfo)
|
||||
{
|
||||
Run(processStartInfo, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run an excutable and redirect standard error and/or standard output safely.
|
||||
/// </summary>
|
||||
public RedirectableProcess(ProcessStartInfo processStartInfo, string input)
|
||||
{
|
||||
Run(processStartInfo, input);
|
||||
}
|
||||
|
||||
private void Run(ProcessStartInfo processStartInfo, string input)
|
||||
{
|
||||
process = new Process();
|
||||
process.StartInfo = processStartInfo;
|
||||
process.Start();
|
||||
if (processStartInfo.RedirectStandardInput && input != null)
|
||||
{
|
||||
process.StandardInput.AutoFlush = true;
|
||||
process.StandardInput.WriteLine(input);
|
||||
}
|
||||
Thread readStandardError = null;
|
||||
if (processStartInfo.RedirectStandardError)
|
||||
{
|
||||
readStandardError = new Thread(new ThreadStart(ReadStandardError));
|
||||
readStandardError.Start();
|
||||
}
|
||||
Thread readStandardOutput = null;
|
||||
if (processStartInfo.RedirectStandardOutput)
|
||||
{
|
||||
readStandardOutput = new Thread(new ThreadStart(ReadStandardOutput));
|
||||
readStandardOutput.Start();
|
||||
}
|
||||
if (processStartInfo.RedirectStandardError)
|
||||
{
|
||||
readStandardError.Join();
|
||||
}
|
||||
if (processStartInfo.RedirectStandardOutput)
|
||||
{
|
||||
readStandardOutput.Join();
|
||||
}
|
||||
process.WaitForExit();
|
||||
exitCode = process.ExitCode;
|
||||
process = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read standard error thread entry-point.
|
||||
/// </summary>
|
||||
private void ReadStandardError()
|
||||
{
|
||||
if (process != null)
|
||||
{
|
||||
processError = process.StandardError.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read standard output thread entry-point.
|
||||
/// </summary>
|
||||
private void ReadStandardOutput()
|
||||
{
|
||||
if (process != null)
|
||||
{
|
||||
processOutput = process.StandardOutput.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
cis/ReactOS.RevisionISO/config.template.php
Normal file
8
cis/ReactOS.RevisionISO/config.template.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
/* Rename to config.php */
|
||||
|
||||
define(ISO_BASE_URL, "http://www.server.com/iso/");
|
||||
define(ISO_PATH, "C:\\iso\\");
|
||||
|
||||
?>
|
230
cis/ReactOS.RevisionISO/index.php
Normal file
230
cis/ReactOS.RevisionISO/index.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
include ('config.php');
|
||||
|
||||
function dm_usort_cmp ($a, $b) {
|
||||
if ($a == $b) return 0;
|
||||
return ($a > $b) ? -1 : 1;
|
||||
}
|
||||
|
||||
function dm_usort_cmp_desc ($a, $b) {
|
||||
if ($a == $b) return 0;
|
||||
return ($a > $b) ? 1 : -1;
|
||||
}
|
||||
|
||||
function printHeader()
|
||||
{
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>ReactOS Revison ISOs</title>
|
||||
<meta name="generator" content="Editpad">
|
||||
<meta name="keywords" content="OS, ReactOS, operating system">
|
||||
<meta name="author" content="ReactOS Project (ros-dev@reactos.com)">
|
||||
<style>
|
||||
.box
|
||||
{
|
||||
padding: 0px;
|
||||
background-color: #88aadd;
|
||||
border-left: 1px solid #f0f0f0;
|
||||
border-right: 1px solid #000000;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
border-bottom: 1px solid #000000;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="#88aadd">
|
||||
<form method="post" action="">
|
||||
<?php
|
||||
}
|
||||
|
||||
function printMenu($revision)
|
||||
{
|
||||
?>
|
||||
<table border="0" class="box" cellpadding="5">
|
||||
<tr>
|
||||
<td height="2px">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<b>Branch:</b>
|
||||
</td>
|
||||
<td>
|
||||
<select name="branch" tabindex="1">
|
||||
<?php
|
||||
|
||||
$d = dir(ISO_PATH);
|
||||
$i = 0;
|
||||
$dirlist = array();
|
||||
while (false !== ($entry = $d->read())) {
|
||||
if ((strcasecmp($entry, ".") != 0) && (strcasecmp($entry, "..") != 0) && is_dir(ISO_PATH . "\\" . $entry) == "dir") {
|
||||
$dirlist[$i++] = $entry;
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
|
||||
if (is_array($dirlist)) {
|
||||
usort($dirlist, "dm_usort_cmp");
|
||||
reset($dirlist);
|
||||
while (list($key, $val) = each($dirlist)) {
|
||||
$branch = $val;
|
||||
if ($branch == $_POST["branch"] || (!isset($_POST["branch"]) && $branch == "trunk"))
|
||||
$selected = " selected";
|
||||
else
|
||||
$selected = "";
|
||||
echo "<option$selected>$branch</option>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<b>Revision:</b>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
echo "<input type=\"text\" name=\"revision\" size=\"10\" maxlength=\"10\" tabindex=\"2\" value=\"" . $revision . "\"></input>";
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="getiso" value="Download" tabindex="3" style="border: 1px solid #000000"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<hr size="2" width="100%" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<input type="submit" name="getnextiso" value="Next ISO" tabindex="4" style="border: 1px solid #000000"></input>
|
||||
</td>
|
||||
<td colspan="3" align="right">
|
||||
<input type="submit" name="getlatestiso" value="Latest ISO" tabindex="5" style="border: 1px solid #000000"></input>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="2px">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
function printFooter()
|
||||
{
|
||||
?>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var revision = document.getElementById('revision');
|
||||
if (revision) revision.focus();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
function locateRevisionISO($branch, $revision, $latest)
|
||||
{
|
||||
$revision = intval($revision);
|
||||
$path = ISO_PATH . "\\" . $branch;
|
||||
$d = dir($path);
|
||||
$i = 0;
|
||||
$filelist = array();
|
||||
while (false !== ($entry = $d->read())) {
|
||||
if (is_dir($path . "\\" . $entry) != "dir")
|
||||
$filelist[$i++] = $entry;
|
||||
}
|
||||
$d->close();
|
||||
|
||||
if (is_array($filelist)) {
|
||||
$sortFunction = $latest ? "dm_usort_cmp" : "dm_usort_cmp_desc";
|
||||
usort($filelist, $sortFunction);
|
||||
reset($filelist);
|
||||
while (list($key, $filename) = each($filelist)) {
|
||||
if (ereg('ReactOS-' . $branch . '-r([0-9]*).iso', $filename, $regs))
|
||||
{
|
||||
$thisRevision = intval($regs[1]);
|
||||
if (($latest) && ($thisRevision < $revision))
|
||||
return $regs[1];
|
||||
else if ($thisRevision > $revision)
|
||||
return $regs[1];
|
||||
$lastRevision = $thisRevision;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function getNextRevisionISO($branch, $revision)
|
||||
{
|
||||
return locateRevisionISO($branch, $revision, false);
|
||||
}
|
||||
|
||||
function getLatestRevisionISO($branch)
|
||||
{
|
||||
return locateRevisionISO($branch, 999999, true);
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
$branch = $_POST["branch"];
|
||||
$revision = $_POST["revision"];
|
||||
|
||||
$filename = "ReactOS-" . $branch . "-r" . $revision . ".iso";
|
||||
if (file_exists(ISO_PATH . $branch . "\\" . $filename))
|
||||
{
|
||||
$location = ISO_BASE_URL . $branch . "/" . $filename;
|
||||
header("Location: $location");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
printHeader();
|
||||
printMenu($_POST["revision"]);
|
||||
echo "<br><b>No ISO exist for branch '" . $branch . "' and revision " . $revision . ".</b><br><br>";
|
||||
printFooter();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST["getiso"]) && !empty($_POST["branch"]) && !empty($_POST["revision"]) && is_numeric($_POST["revision"]))
|
||||
main();
|
||||
else if (!empty($_POST["getnextiso"]) && !empty($_POST["branch"]) && !empty($_POST["revision"]) && is_numeric($_POST["revision"]))
|
||||
{
|
||||
printHeader();
|
||||
printMenu(getNextRevisionISO($_POST["branch"], $_POST["revision"]));
|
||||
printFooter();
|
||||
}
|
||||
else if (!empty($_POST["getlatestiso"]) && !empty($_POST["branch"]))
|
||||
{
|
||||
printHeader();
|
||||
printMenu(getLatestRevisionISO($_POST["branch"]));
|
||||
printFooter();
|
||||
}
|
||||
else
|
||||
{
|
||||
printHeader();
|
||||
printMenu($_POST["revision"]);
|
||||
printFooter();
|
||||
}
|
||||
|
||||
?>
|
9
cis/ReactOS.Verify/App.config
Normal file
9
cis/ReactOS.Verify/App.config
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="smtpServer" value="localhost" />
|
||||
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
|
||||
<add key="makeParameters" value="" />
|
||||
<add key="fastDisk" value="" />
|
||||
</appSettings>
|
||||
</configuration>
|
14
cis/ReactOS.Verify/AssemblyInfo.cs
Normal file
14
cis/ReactOS.Verify/AssemblyInfo.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("ReactOS Sin Verifier")]
|
||||
[assembly: AssemblyDescription("ReactOS Sin Verifier")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("ReactOS Project")]
|
||||
[assembly: AssemblyProduct("React Operating System")]
|
||||
[assembly: AssemblyCopyright("Copyright 2005 ReactOS Project")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
20
cis/ReactOS.Verify/Default.build
Normal file
20
cis/ReactOS.Verify/Default.build
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="ReactOS.Verify" default="build">
|
||||
|
||||
<property name="output.dir" value="bin" />
|
||||
|
||||
<target name="build" description="Build component">
|
||||
<mkdir dir="${output.dir}" />
|
||||
<csc target="exe"
|
||||
output="${output.dir}\ReactOS.Verify.exe"
|
||||
optimize="true"
|
||||
debug="true"
|
||||
doc="${output.dir}\ReactOS.Verify.xml"
|
||||
warninglevel="0">
|
||||
<sources>
|
||||
<include name="*.cs" />
|
||||
</sources>
|
||||
</csc>
|
||||
</target>
|
||||
|
||||
</project>
|
279
cis/ReactOS.Verify/Main.cs
Normal file
279
cis/ReactOS.Verify/Main.cs
Normal file
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Configuration;
|
||||
using System.Web.Mail;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace ReactOS.Verify
|
||||
{
|
||||
public class MainClass
|
||||
{
|
||||
/// <summary>
|
||||
/// Run the application.
|
||||
/// </summary>
|
||||
/// <param name="script">Script to run.</param>
|
||||
/// <param name="args">Arguments to pass to script.</param>
|
||||
/// <param name="workingDirectory">Working directory.</param>
|
||||
/// <param name="standardOutput">Receives standard output.</param>
|
||||
/// <param name="standardError">Receives standard error.</param>
|
||||
/// <returns>
|
||||
/// Exit code.
|
||||
/// </returns>
|
||||
private static int RunScript(string script,
|
||||
string args,
|
||||
string workingDirectory,
|
||||
StringDictionary environmentVarables,
|
||||
out string standardOutput,
|
||||
out string standardError)
|
||||
{
|
||||
ProcessStartInfo scriptProcessStartInfo = new ProcessStartInfo(script,
|
||||
args);
|
||||
scriptProcessStartInfo.CreateNoWindow = true;
|
||||
/*
|
||||
* All standard streams must be redirected.
|
||||
* Otherwise DuplicateHandle() will fail.
|
||||
*/
|
||||
scriptProcessStartInfo.RedirectStandardInput = true;
|
||||
scriptProcessStartInfo.RedirectStandardError = true;
|
||||
scriptProcessStartInfo.RedirectStandardOutput = true;
|
||||
scriptProcessStartInfo.UseShellExecute = false;
|
||||
scriptProcessStartInfo.WorkingDirectory = workingDirectory;
|
||||
if (environmentVarables != null)
|
||||
{
|
||||
foreach (DictionaryEntry de in environmentVarables)
|
||||
scriptProcessStartInfo.EnvironmentVariables.Add(de.Key as string, de.Value as string);
|
||||
}
|
||||
RedirectableProcess redirectableProcess = new RedirectableProcess(scriptProcessStartInfo);
|
||||
standardOutput = redirectableProcess.ProcessOutput;
|
||||
standardError = redirectableProcess.ProcessError;
|
||||
return redirectableProcess.ExitCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve value of configuration from configuration file.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of configuration option.</param>
|
||||
/// <param name="defaultValue">
|
||||
/// Default value to be returned if the option does not exist.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Value of configuration option or null if the option does not
|
||||
/// exist and no default value is provided.
|
||||
/// </returns>
|
||||
private static string GetConfigurationOption(string name,
|
||||
string defaultValue)
|
||||
{
|
||||
if (ConfigurationSettings.AppSettings[name] != null)
|
||||
{
|
||||
string s = ConfigurationSettings.AppSettings[name].Trim();
|
||||
return s.Equals(String.Empty) ? defaultValue : s;
|
||||
}
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send an email.
|
||||
/// </summary>
|
||||
/// <param name="subject">Subject of the email.</param>
|
||||
/// <param name="body">Content of the email.</param>
|
||||
private static void SendErrorMail(string subject, string body)
|
||||
{
|
||||
try
|
||||
{
|
||||
string smtpServer = GetConfigurationOption("smtpServer", "localhost");
|
||||
string email = GetConfigurationOption("errorEmail", null);
|
||||
if (email == null)
|
||||
return;
|
||||
MailMessage mm = new MailMessage();
|
||||
mm.Priority = MailPriority.Normal;
|
||||
mm.From = email;
|
||||
mm.To = email;
|
||||
mm.Subject = subject;
|
||||
mm.Body += body;
|
||||
mm.Body += "<br>";
|
||||
mm.BodyFormat = MailFormat.Html;
|
||||
SmtpMail.SmtpServer = smtpServer;
|
||||
SmtpMail.Send(mm);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fail with an error message.
|
||||
/// </summary>
|
||||
/// <param name="text">Error message.</param>
|
||||
private static void Fail(string text)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paths to fast disk for temporary files.
|
||||
/// </summary>
|
||||
private static string TemporaryFastDisk
|
||||
{
|
||||
get
|
||||
{
|
||||
string temporaryFastDisk = GetConfigurationOption("temporaryFastDisk", null);
|
||||
if (temporaryFastDisk == null || temporaryFastDisk.Trim().Equals(String.Empty))
|
||||
return null;
|
||||
return temporaryFastDisk.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paths to fast disk for intermediate files.
|
||||
/// </summary>
|
||||
private static string IntermediateFastDisk
|
||||
{
|
||||
get
|
||||
{
|
||||
string intermediateFastDisk = GetConfigurationOption("intermediateFastDisk", null);
|
||||
if (intermediateFastDisk == null || intermediateFastDisk.Trim().Equals(String.Empty))
|
||||
return null;
|
||||
return intermediateFastDisk.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paths to fast disk for output files.
|
||||
/// </summary>
|
||||
private static string OutputFastDisk
|
||||
{
|
||||
get
|
||||
{
|
||||
string outputFastDisk = GetConfigurationOption("outputFastDisk", null);
|
||||
if (outputFastDisk == null || outputFastDisk.Trim().Equals(String.Empty))
|
||||
return null;
|
||||
return outputFastDisk.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return collection of environment variables.
|
||||
/// </summary>
|
||||
/// <returns>Collection of environment variables or null if there is none.</returns>
|
||||
private static StringDictionary GetEnvironmentVarables()
|
||||
{
|
||||
StringDictionary environmentVarables = new StringDictionary();
|
||||
if (TemporaryFastDisk != null)
|
||||
environmentVarables.Add("ROS_TEMPORARY", TemporaryFastDisk);
|
||||
if (IntermediateFastDisk != null)
|
||||
environmentVarables.Add("ROS_INTERMEDIATE", IntermediateFastDisk);
|
||||
if (OutputFastDisk != null)
|
||||
environmentVarables.Add("ROS_OUTPUT", OutputFastDisk);
|
||||
return environmentVarables;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run make.
|
||||
/// </summary>
|
||||
/// <param name="arguments">Arguments.</param>
|
||||
/// <param name="standardOutput">Receives standard output.</param>
|
||||
/// <param name="standardError">Receives standard error.</param>
|
||||
/// <returns>Make exit code.</returns>
|
||||
private static int RunMake(string arguments,
|
||||
out string standardOutput,
|
||||
out string standardError)
|
||||
{
|
||||
string make = "mingw32-make";
|
||||
string makeParameters = GetConfigurationOption("makeParameters", "");
|
||||
string reactosDirectory = Path.Combine(System.Environment.CurrentDirectory,
|
||||
"reactos");
|
||||
return RunScript(make,
|
||||
makeParameters + " " + arguments,
|
||||
reactosDirectory,
|
||||
GetEnvironmentVarables(),
|
||||
out standardOutput,
|
||||
out standardError);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify a revision of ReactOS by building it all.
|
||||
/// </summary>
|
||||
private static int VerifyFull()
|
||||
{
|
||||
string standardOutput;
|
||||
string standardError;
|
||||
int exitCode = RunMake("bootcd",
|
||||
out standardOutput,
|
||||
out standardError);
|
||||
if (exitCode != 0)
|
||||
{
|
||||
Fail(String.Format("make bootcd failed: (error: {0}) {1}",
|
||||
standardError,
|
||||
standardOutput));
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
string reactosDirectory = Path.Combine(System.Environment.CurrentDirectory,
|
||||
"reactos");
|
||||
string isoFilename = Path.Combine(reactosDirectory,
|
||||
"ReactOS.iso");
|
||||
if (!File.Exists(isoFilename))
|
||||
Fail("make bootcd produced no ReactOS.iso");
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify a revision of ReactOS by building parts.
|
||||
/// </summary>
|
||||
/// <param name="components">Comma separated list of components to build.</param>
|
||||
private static int VerifyPartial(string components)
|
||||
{
|
||||
string standardOutput;
|
||||
string standardError;
|
||||
string componentParameters = "\"" + components.Replace(",", "\" \"") + "\"";
|
||||
int exitCode = RunMake(componentParameters,
|
||||
out standardOutput,
|
||||
out standardError);
|
||||
if (exitCode != 0)
|
||||
Fail(String.Format("make failed for targets {0}: (error: {1}) {2}",
|
||||
componentParameters,
|
||||
standardError,
|
||||
standardOutput));
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify a revision of ReactOS.
|
||||
/// </summary>
|
||||
/// <param name="args">Arguments from command line.</param>
|
||||
private static int Verify(string[] args)
|
||||
{
|
||||
if (args.Length > 0)
|
||||
return VerifyPartial(args[0]);
|
||||
else
|
||||
return VerifyFull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Program entry point.
|
||||
/// </summary>
|
||||
/// <param name="args">Arguments from command line.</param>
|
||||
/// <remarks>
|
||||
/// If exit code is 0, then the commit was processed successfully.
|
||||
/// If exit code is 1, then the commit was not processed successfully.
|
||||
/// </remarks>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Environment.ExitCode = Verify(args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string text = String.Format("Exception: {0}", ex);
|
||||
SendErrorMail("ReactOS Verify Error", text);
|
||||
System.Environment.ExitCode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
145
cis/ReactOS.Verify/RedirectableProcess.cs
Normal file
145
cis/ReactOS.Verify/RedirectableProcess.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* When using the ProcessStartInfo.RedirectStandardXxx properties there is a chance of
|
||||
* the parent and child process blocking due to a race condition. This class handles the
|
||||
* problem.
|
||||
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclassredirectstandardoutputtopic.asp
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ReactOS.Verify
|
||||
{
|
||||
/// <summary>
|
||||
/// Process that redirects standard output and standard error streams.
|
||||
/// </summary>
|
||||
public class RedirectableProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Process.
|
||||
/// </summary>
|
||||
private Process process;
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard error stream.
|
||||
/// </summary>
|
||||
private string processError;
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard output stream.
|
||||
/// </summary>
|
||||
private string processOutput;
|
||||
|
||||
/// <summary>
|
||||
/// Exit code.
|
||||
/// </summary>
|
||||
private int exitCode;
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard error stream.
|
||||
/// </summary>
|
||||
public string ProcessError
|
||||
{
|
||||
get
|
||||
{
|
||||
return processError;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Redirected standard output stream.
|
||||
/// </summary>
|
||||
public string ProcessOutput
|
||||
{
|
||||
get
|
||||
{
|
||||
return processOutput;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exit code.
|
||||
/// </summary>
|
||||
public int ExitCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run an excutable and redirect standard error and/or standard output safely.
|
||||
/// </summary>
|
||||
public RedirectableProcess(ProcessStartInfo processStartInfo)
|
||||
{
|
||||
Run(processStartInfo, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run an excutable and redirect standard error and/or standard output safely.
|
||||
/// </summary>
|
||||
public RedirectableProcess(ProcessStartInfo processStartInfo, string input)
|
||||
{
|
||||
Run(processStartInfo, input);
|
||||
}
|
||||
|
||||
private void Run(ProcessStartInfo processStartInfo, string input)
|
||||
{
|
||||
process = new Process();
|
||||
process.StartInfo = processStartInfo;
|
||||
process.Start();
|
||||
if (processStartInfo.RedirectStandardInput && input != null)
|
||||
{
|
||||
process.StandardInput.AutoFlush = true;
|
||||
process.StandardInput.WriteLine(input);
|
||||
}
|
||||
Thread readStandardError = null;
|
||||
if (processStartInfo.RedirectStandardError)
|
||||
{
|
||||
readStandardError = new Thread(new ThreadStart(ReadStandardError));
|
||||
readStandardError.Start();
|
||||
}
|
||||
Thread readStandardOutput = null;
|
||||
if (processStartInfo.RedirectStandardOutput)
|
||||
{
|
||||
readStandardOutput = new Thread(new ThreadStart(ReadStandardOutput));
|
||||
readStandardOutput.Start();
|
||||
}
|
||||
if (processStartInfo.RedirectStandardError)
|
||||
{
|
||||
readStandardError.Join();
|
||||
}
|
||||
if (processStartInfo.RedirectStandardOutput)
|
||||
{
|
||||
readStandardOutput.Join();
|
||||
}
|
||||
process.WaitForExit();
|
||||
exitCode = process.ExitCode;
|
||||
process = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read standard error thread entry-point.
|
||||
/// </summary>
|
||||
private void ReadStandardError()
|
||||
{
|
||||
if (process != null)
|
||||
{
|
||||
processError = process.StandardError.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read standard output thread entry-point.
|
||||
/// </summary>
|
||||
private void ReadStandardOutput()
|
||||
{
|
||||
if (process != null)
|
||||
{
|
||||
processOutput = process.StandardOutput.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1 +1,27 @@
|
||||
semprini
|
||||
shit
|
||||
fuck
|
||||
pussy
|
||||
ass
|
||||
ass-
|
||||
-ass
|
||||
dumbass
|
||||
jackass
|
||||
fatass
|
||||
asshole
|
||||
smartass
|
||||
cunt
|
||||
fucker
|
||||
bitch
|
||||
dick
|
||||
penile
|
||||
stfu
|
||||
omfg
|
||||
lmao
|
||||
ass.
|
||||
-ass.
|
||||
semprini
|
||||
goat.cx
|
||||
ekush
|
||||
akshor
|
||||
poop
|
||||
guten morgen
|
||||
|
@@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{72E5CCA1-6318-4D62-964D-CB23A5C743B5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CHMLibrary</RootNamespace>
|
||||
<AssemblyName>CHMLibrary</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Category.cs" />
|
||||
<Compile Include="CHMDecoding\BinaryReaderHelp.cs" />
|
||||
<Compile Include="CHMDecoding\CHMBtree.cs" />
|
||||
<Compile Include="CHMDecoding\CHMFile.cs" />
|
||||
<Compile Include="CHMDecoding\CHMIdxhdr.cs" />
|
||||
<Compile Include="CHMDecoding\CHMStrings.cs" />
|
||||
<Compile Include="CHMDecoding\CHMSystem.cs" />
|
||||
<Compile Include="CHMDecoding\CHMTocidx.cs" />
|
||||
<Compile Include="CHMDecoding\CHMTopics.cs" />
|
||||
<Compile Include="CHMDecoding\CHMUrlstr.cs" />
|
||||
<Compile Include="CHMDecoding\CHMUrltable.cs" />
|
||||
<Compile Include="CHMDecoding\DumpingInfo.cs" />
|
||||
<Compile Include="CHMDecoding\enumerations.cs" />
|
||||
<Compile Include="CHMDecoding\FullTextEngine.cs" />
|
||||
<Compile Include="CHMDecoding\HHCParser.cs" />
|
||||
<Compile Include="CHMDecoding\HHCParser2.cs" />
|
||||
<Compile Include="CHMDecoding\HHKParser.cs" />
|
||||
<Compile Include="CHMDecoding\TopicEntry.cs" />
|
||||
<Compile Include="CHMDecoding\UrlTableEntry.cs" />
|
||||
<Compile Include="ChmFileInfo.cs" />
|
||||
<Compile Include="HtmlHelpSystem.cs" />
|
||||
<Compile Include="HttpUtility.cs" />
|
||||
<Compile Include="Index.cs" />
|
||||
<Compile Include="IndexItem.cs" />
|
||||
<Compile Include="IndexTopic.cs" />
|
||||
<Compile Include="InformationType.cs" />
|
||||
<Compile Include="Storage\CHMStream.cs" />
|
||||
<Compile Include="TableOfContents.cs" />
|
||||
<Compile Include="TOCItem.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Compression\Compression.csproj">
|
||||
<Project>{E32307F1-623A-4E62-826F-56CDD4B23A54}</Project>
|
||||
<Name>Compression</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{E32307F1-623A-4E62-826F-56CDD4B23A54}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Compression</RootNamespace>
|
||||
<AssemblyName>Compression</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Checksums\Adler32.cs" />
|
||||
<Compile Include="Checksums\CRC32.cs" />
|
||||
<Compile Include="Checksums\IChecksum.cs" />
|
||||
<Compile Include="Checksums\StrangeCRC.cs" />
|
||||
<Compile Include="Deflater.cs" />
|
||||
<Compile Include="DeflaterConstants.cs" />
|
||||
<Compile Include="DeflaterEngine.cs" />
|
||||
<Compile Include="DeflaterHuffman.cs" />
|
||||
<Compile Include="DeflaterPending.cs" />
|
||||
<Compile Include="Inflater.cs" />
|
||||
<Compile Include="InflaterDynHeader.cs" />
|
||||
<Compile Include="InflaterHuffmanTree.cs" />
|
||||
<Compile Include="PendingBuffer.cs" />
|
||||
<Compile Include="Streams\DeflaterOutputStream.cs" />
|
||||
<Compile Include="Streams\InflaterInputStream.cs" />
|
||||
<Compile Include="Streams\OutputWindow.cs" />
|
||||
<Compile Include="Streams\StreamManipulator.cs" />
|
||||
<Compile Include="ZipException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
</Project>
|
14
irc/TechBot/Default.build
Normal file
14
irc/TechBot/Default.build
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="TechBot" default="build">
|
||||
|
||||
<target name="build" description="Build components">
|
||||
<delete dir="bin" failonerror="false" />
|
||||
<nant buildfile="Compression/Default.build" />
|
||||
<nant buildfile="CHMLibrary/Default.build" />
|
||||
<nant buildfile="TechBot.IRCLibrary/Default.build" />
|
||||
<nant buildfile="TechBot.Library/Default.build" />
|
||||
<nant buildfile="TechBot.Console/Default.build" />
|
||||
<nant buildfile="TechBot/Default.build" />
|
||||
</target>
|
||||
|
||||
</project>
|
@@ -1,7 +1,5 @@
|
||||
<?xml version="1.0" ?>
|
||||
<HresultList>
|
||||
<Hresult text="S_OK" value="00000000" />
|
||||
<Hresult text="S_FALSE" value="00000001" />
|
||||
<Hresult text="STG_S_CONVERTED" value="00030200" />
|
||||
<Hresult text="STG_S_BLOCK" value="00030201" />
|
||||
<Hresult text="STG_S_RETRYNOW" value="00030202" />
|
||||
|
@@ -2,69 +2,8 @@
|
||||
<NtstatusList>
|
||||
<Ntstatus text="STATUS_SUCCESS" value="00000000"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0" value="00000000"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 1" value="00000001"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 2" value="00000002"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 3" value="00000003"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 4" value="00000004"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 5" value="00000005"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 6" value="00000006"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 7" value="00000007"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 8" value="00000008"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 9" value="00000009"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 10" value="0000000A"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 11" value="0000000B"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 12" value="0000000C"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 13" value="0000000D"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 14" value="0000000E"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 15" value="0000000F"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 16" value="00000010"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 17" value="00000011"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 18" value="00000012"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 19" value="00000013"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 20" value="00000014"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 21" value="00000015"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 22" value="00000016"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 23" value="00000017"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 24" value="00000018"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 25" value="00000019"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 26" value="0000001A"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 27" value="0000001B"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 28" value="0000001C"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 29" value="0000001D"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 30" value="0000001E"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 31" value="0000001F"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 32" value="00000020"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 33" value="00000021"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 34" value="00000022"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 35" value="00000023"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 36" value="00000024"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 37" value="00000025"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 38" value="00000026"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 39" value="00000027"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 40" value="00000028"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 41" value="00000029"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 42" value="0000002A"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 43" value="0000002B"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 44" value="0000002C"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 45" value="0000002D"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 46" value="0000002E"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 47" value="0000002F"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 48" value="00000030"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 49" value="00000031"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 50" value="00000032"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 51" value="00000033"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 52" value="00000034"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 53" value="00000035"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 54" value="00000036"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 55" value="00000037"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 56" value="00000038"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 57" value="00000039"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 58" value="0000003A"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 59" value="0000003B"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 60" value="0000003C"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 61" value="0000003D"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 62" value="0000003E"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_0 + 63" value="0000003F"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_1" value="00000001"></Ntstatus>
|
||||
<Ntstatus text="STATUS_WAIT_63" value="0000003F"></Ntstatus>
|
||||
<Ntstatus text="STATUS_ABANDONED" value="00000080"></Ntstatus>
|
||||
<Ntstatus text="STATUS_ABANDONED_WAIT_0" value="00000080"></Ntstatus>
|
||||
<Ntstatus text="STATUS_ABANDONED_WAIT_63" value="000000BF"></Ntstatus>
|
||||
|
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
public abstract class BugCommand : Command
|
||||
{
|
||||
// private string m_BugID = null;
|
||||
|
||||
public BugCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public string BugID
|
||||
{
|
||||
get { return Parameters; }
|
||||
set { Parameters = value; }
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (string.IsNullOrEmpty(BugID))
|
||||
{
|
||||
Say("Please provide a valid bug number.");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Say(BugUrl, Int32.Parse(BugID));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Say("{0} is not a valid bug number.", BugID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract string BugUrl { get; }
|
||||
}
|
||||
}
|
@@ -1,180 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Collections;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("error", Help = "!error <value>")]
|
||||
public class ErrorCommand : Command
|
||||
{
|
||||
private NtStatusCommand ntStatus;
|
||||
private WinErrorCommand winerror;
|
||||
private HResultCommand hresult;
|
||||
|
||||
public ErrorCommand()
|
||||
{
|
||||
this.ntStatus = new NtStatusCommand();
|
||||
this.winerror = new WinErrorCommand();
|
||||
this.hresult = new HResultCommand();
|
||||
}
|
||||
|
||||
private static int GetSeverity(long error)
|
||||
{
|
||||
return (int)((error >> 30) & 0x3);
|
||||
}
|
||||
|
||||
private static bool IsCustomer(long error)
|
||||
{
|
||||
return (error & 0x20000000) != 0;
|
||||
}
|
||||
|
||||
private static bool IsReserved(long error)
|
||||
{
|
||||
return (error & 0x10000000) != 0;
|
||||
}
|
||||
|
||||
private static int GetFacility(long error)
|
||||
{
|
||||
return (int)((error >> 16) & 0xFFF);
|
||||
}
|
||||
|
||||
private static short GetCode(long error)
|
||||
{
|
||||
return (short)((error >> 0) & 0xFFFF);
|
||||
}
|
||||
|
||||
private static string FormatSeverity(long error)
|
||||
{
|
||||
int severity = GetSeverity(error);
|
||||
switch (severity)
|
||||
{
|
||||
case 0: return "SUCCESS";
|
||||
case 1: return "INFORMATIONAL";
|
||||
case 2: return "WARNING";
|
||||
case 3: return "ERROR";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string FormatFacility(long error)
|
||||
{
|
||||
int facility = GetFacility(error);
|
||||
return facility.ToString();
|
||||
}
|
||||
|
||||
private static string FormatCode(long error)
|
||||
{
|
||||
int code = GetCode(error);
|
||||
return code.ToString();
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (Parameters.Equals(String.Empty))
|
||||
{
|
||||
Say("Please provide an Error Code.");
|
||||
return;
|
||||
}
|
||||
|
||||
string errorText = Parameters;
|
||||
|
||||
retry:
|
||||
NumberParser np = new NumberParser();
|
||||
long error = np.Parse(errorText);
|
||||
if (np.Error)
|
||||
{
|
||||
Say("{0} is not a valid Error Code.", Parameters);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList descriptions = new ArrayList();
|
||||
|
||||
// Error is out of bounds
|
||||
if ((ulong)error > uint.MaxValue)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
// Error is outside of the range [0, 65535]: it cannot be a plain Win32 error code
|
||||
else if ((ulong)error > ushort.MaxValue)
|
||||
{
|
||||
// Customer bit is set: custom error code
|
||||
if (IsCustomer(error))
|
||||
{
|
||||
string description = String.Format("[custom, severity {0}, facility {1}, code {2}]",
|
||||
FormatSeverity(error),
|
||||
FormatFacility(error),
|
||||
FormatCode(error));
|
||||
descriptions.Add(description);
|
||||
}
|
||||
// Reserved bit is set: HRESULT_FROM_NT(ntstatus)
|
||||
else if (IsReserved(error))
|
||||
{
|
||||
int status = (int)(error & 0xCFFFFFFF);
|
||||
string description = ntStatus.GetNtstatusDescription(status);
|
||||
|
||||
if (description == null)
|
||||
description = status.ToString("X");
|
||||
|
||||
description = String.Format("HRESULT_FROM_NT({0})", description);
|
||||
descriptions.Add(description);
|
||||
}
|
||||
// Win32 facility: HRESULT_FROM_WIN32(winerror)
|
||||
else if (GetFacility(error) == 7)
|
||||
{
|
||||
// Must be an error code
|
||||
if (GetSeverity(error) == 2)
|
||||
{
|
||||
short err = GetCode(error);
|
||||
string description = winerror.GetWinerrorDescription(err);
|
||||
|
||||
if (description == null)
|
||||
description = err.ToString("D");
|
||||
|
||||
description = String.Format("HRESULT_FROM_WIN32({0})", description);
|
||||
descriptions.Add(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string winerrorDescription = winerror.GetWinerrorDescription(error);
|
||||
string ntstatusDescription = ntStatus.GetNtstatusDescription(error);
|
||||
string hresultDescription = hresult.GetHresultDescription(error);
|
||||
|
||||
if (winerrorDescription != null)
|
||||
descriptions.Add(winerrorDescription);
|
||||
if (ntstatusDescription != null)
|
||||
descriptions.Add(ntstatusDescription);
|
||||
if (hresultDescription != null)
|
||||
descriptions.Add(hresultDescription);
|
||||
|
||||
if (descriptions.Count == 0)
|
||||
{
|
||||
// Last chance heuristics: attempt to parse a 8-digit decimal as hexadecimal
|
||||
if (errorText.Length == 8)
|
||||
{
|
||||
errorText = "0x" + errorText;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
Say("I don't know about Error Code {0}.",
|
||||
Parameters);
|
||||
}
|
||||
else if (descriptions.Count == 1)
|
||||
{
|
||||
string description = (string)descriptions[0];
|
||||
Say("{0} is {1}.",
|
||||
Parameters,
|
||||
description);
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("{0} could be:", Parameters);
|
||||
|
||||
foreach (string description in descriptions)
|
||||
Say("\t{0}", description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("hresult", Help = "!hresult <value>")]
|
||||
public class HResultCommand : XmlLookupCommand
|
||||
{
|
||||
public HResultCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.HResultXml; }
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
{
|
||||
Say("Please provide a valid HRESULT value.");
|
||||
}
|
||||
else
|
||||
{
|
||||
NumberParser np = new NumberParser();
|
||||
long hresult = np.Parse(Text);
|
||||
if (np.Error)
|
||||
{
|
||||
Say("{0} is not a valid HRESULT value.", Text);
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetHresultDescription(hresult);
|
||||
if (description != null)
|
||||
{
|
||||
Say("{0} is {1}.",
|
||||
Text,
|
||||
description);
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("I don't know about HRESULT {0}.", Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHresultDescription(long hresult)
|
||||
{
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
|
||||
hresult.ToString("X8")));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("ntstatus", Help = "!ntstatus <value>")]
|
||||
public class NtStatusCommand : XmlLookupCommand
|
||||
{
|
||||
public NtStatusCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.NtStatusXml; }
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
{
|
||||
Say("Please provide a valid NTSTATUS value.");
|
||||
}
|
||||
else
|
||||
{
|
||||
NumberParser np = new NumberParser();
|
||||
long ntstatus = np.Parse(Text);
|
||||
if (np.Error)
|
||||
{
|
||||
Say("{0} is not a valid NTSTATUS value.", Text);
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetNtstatusDescription(ntstatus);
|
||||
if (description != null)
|
||||
{
|
||||
Say("{0} is {1}.",
|
||||
Text,
|
||||
description);
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("I don't know about NTSTATUS {0}.", Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetNtstatusDescription(long ntstatus)
|
||||
{
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
|
||||
ntstatus.ToString("X8")));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TechBot.Commands.Common")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Sand")]
|
||||
[assembly: AssemblyProduct("TechBot.Commands.Common")]
|
||||
[assembly: AssemblyCopyright("Copyright © Sand 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5d39d6f8-37fb-423b-ba88-1d5d8e5a1317")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("rosbug", Help = "!rosbug <number>", Description = "Will give you a link to the reqested ReactOS bug")]
|
||||
class ReactOSBugUrl : BugCommand
|
||||
{
|
||||
public ReactOSBugUrl()
|
||||
{
|
||||
}
|
||||
|
||||
protected override string BugUrl
|
||||
{
|
||||
get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id={0}"; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("sambabug", Help = "!sambabug <number>", Description = "Will give you a link to the reqested Samba bug")]
|
||||
class SambaBugUrl : BugCommand
|
||||
{
|
||||
public SambaBugUrl()
|
||||
{
|
||||
}
|
||||
|
||||
protected override string BugUrl
|
||||
{
|
||||
get { return "https://bugzilla.samba.org/show_bug.cgi?id={0}"; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TechBot.Commands.Common {
|
||||
|
||||
|
||||
[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"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
namespace TechBot.Commands.Common {
|
||||
|
||||
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Commands.Common" 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>
|
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("svn", Help = "!svn" , Description="Where the ROS SVN repository is located")]
|
||||
public class SvnCommand : Command
|
||||
{
|
||||
private string m_SvnRoot;
|
||||
|
||||
public SvnCommand()
|
||||
{
|
||||
m_SvnRoot = Settings.Default.SVNRoot;
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
Say("svn co {0}", m_SvnRoot);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot.Commands.Common</RootNamespace>
|
||||
<AssemblyName>TechBot.Commands.Common</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\BugCommand.cs" />
|
||||
<Compile Include="ErrorCommand.cs" />
|
||||
<Compile Include="HResultCommand.cs" />
|
||||
<Compile Include="NtStatusCommand.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReactOSBugUrl.cs" />
|
||||
<Compile Include="SambaBugUrl.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="Settings.Designer.cs">
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="SvnCommand.cs" />
|
||||
<Compile Include="WineBugUrl.cs" />
|
||||
<Compile Include="WinerrorCommand.cs" />
|
||||
<Compile Include="WMCommand.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
|
||||
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
|
||||
<Name>TechBot.Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("wm" , Help = "!wm <value> or !wm <name>")]
|
||||
public class WMCommand : XmlCommand
|
||||
{
|
||||
public WMCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.WMXml; }
|
||||
}
|
||||
|
||||
[CommandParameter("wm", "The windows message to check" , DefaultParameter = true)]
|
||||
public string WMText
|
||||
{
|
||||
get { return Parameters; }
|
||||
set { Parameters = value; }
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (string.IsNullOrEmpty(WMText))
|
||||
{
|
||||
Say("Please provide a valid window message value or name.");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
NumberParser np = new NumberParser();
|
||||
long wm = np.Parse(WMText);
|
||||
string output;
|
||||
if (np.Error)
|
||||
{
|
||||
// Assume "!wm <name>" form.
|
||||
output = GetWmNumber(WMText);
|
||||
}
|
||||
else
|
||||
{
|
||||
output = GetWmDescription(wm);
|
||||
}
|
||||
|
||||
if (output != null)
|
||||
{
|
||||
Say("{0} is {1}.",
|
||||
WMText,
|
||||
output);
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("I don't know about window message {0}.", WMText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetWmDescription(long wm)
|
||||
{
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
|
||||
wm));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetWmNumber(string wmName)
|
||||
{
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
|
||||
wmName));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute value = node.Attributes["value"];
|
||||
if (value == null)
|
||||
throw new Exception("Node has no value attribute.");
|
||||
return value.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("winebug", Help = "!winebug <number>" , Description="Will give you a link to the reqested Wine bug")]
|
||||
class WineBugUrl : BugCommand
|
||||
{
|
||||
public WineBugUrl()
|
||||
{
|
||||
}
|
||||
|
||||
protected override string BugUrl
|
||||
{
|
||||
get { return "http://bugs.winehq.org/show_bug.cgi?id={0}"; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.Common
|
||||
{
|
||||
[Command("winerror", Help = "!winerror <value>")]
|
||||
public class WinErrorCommand : XmlLookupCommand
|
||||
{
|
||||
public WinErrorCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.WinErrorXml; }
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
{
|
||||
Say("Please provide a valid System Error Code value.");
|
||||
}
|
||||
else
|
||||
{
|
||||
NumberParser np = new NumberParser();
|
||||
long winerror = np.Parse(Text);
|
||||
if (np.Error)
|
||||
{
|
||||
Say("{0} is not a valid System Error Code value.", Text);
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetWinerrorDescription(winerror);
|
||||
if (description != null)
|
||||
{
|
||||
Say("{0} is {1}.",
|
||||
Text,
|
||||
description);
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("I don't know about System Error Code {0}.", Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetWinerrorDescription(long winerror)
|
||||
{
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
|
||||
winerror.ToString()));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
<?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.Commands.Common.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<TechBot.Commands.Common.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.Commands.Common.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
@@ -1,309 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using HtmlHelp;
|
||||
using HtmlHelp.ChmDecoding;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Commands.MSDN
|
||||
{
|
||||
[Command("api", Help = "!api <apiname>")]
|
||||
public class ApiCommand : Command
|
||||
{
|
||||
private bool IsVerbose = false;
|
||||
|
||||
private HtmlHelpSystem chm;
|
||||
|
||||
public ApiCommand()
|
||||
{
|
||||
LoadCHM();
|
||||
}
|
||||
|
||||
[CommandParameter("api", "The API name")]
|
||||
public string API
|
||||
{
|
||||
get { return Parameters; }
|
||||
set { Parameters = value; }
|
||||
}
|
||||
|
||||
private void WriteIfVerbose(string message)
|
||||
{
|
||||
if (IsVerbose)
|
||||
Say(message);
|
||||
}
|
||||
|
||||
private void LoadCHM()
|
||||
{
|
||||
string CHMFilename = Path.Combine(Settings.Default.ChmPath, Settings.Default.MainChm);
|
||||
chm = new HtmlHelpSystem();
|
||||
chm.OpenFile(CHMFilename, null);
|
||||
|
||||
Console.WriteLine(String.Format("Loaded main CHM: {0}",
|
||||
Path.GetFileName(CHMFilename)));
|
||||
foreach (string filename in Directory.GetFiles(Settings.Default.ChmPath))
|
||||
{
|
||||
if (!Path.GetExtension(filename).ToLower().Equals(".chm"))
|
||||
continue;
|
||||
if (Path.GetFileName(filename).ToLower().Equals(Settings.Default.MainChm))
|
||||
continue;
|
||||
|
||||
Console.WriteLine(String.Format("Loading CHM: {0}",
|
||||
Path.GetFileName(filename)));
|
||||
try
|
||||
{
|
||||
chm.MergeFile(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}",
|
||||
Path.GetFileName(filename),
|
||||
ex));
|
||||
}
|
||||
}
|
||||
Console.WriteLine(String.Format("Loaded {0} CHMs",
|
||||
chm.FileList.Length));
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (Name.Trim().Equals(String.Empty))
|
||||
{
|
||||
Say("Please give me a keyword.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Search(Name);
|
||||
}
|
||||
}
|
||||
|
||||
private bool SearchIndex(
|
||||
string keyword)
|
||||
{
|
||||
if (chm.HasIndex)
|
||||
{
|
||||
IndexItem item = chm.Index.SearchIndex(keyword,
|
||||
IndexType.KeywordLinks);
|
||||
if (item != null && item.Topics.Count > 0)
|
||||
{
|
||||
WriteIfVerbose(String.Format("Keyword {0} found in index",
|
||||
item.KeyWord));
|
||||
IndexTopic indexTopic = item.Topics[0] as IndexTopic;
|
||||
return DisplayResult( keyword,
|
||||
indexTopic);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteIfVerbose(String.Format("Keyword {0} not found in index",
|
||||
keyword));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SearchFullText(string keyword)
|
||||
{
|
||||
string sort = "Rating ASC";
|
||||
WriteIfVerbose(String.Format("Searching fulltext database for {0}",
|
||||
keyword));
|
||||
|
||||
bool partialMatches = false;
|
||||
bool titlesOnly = true;
|
||||
int maxResults = 100;
|
||||
DataTable results = chm.PerformSearch(keyword,
|
||||
maxResults,
|
||||
partialMatches,
|
||||
titlesOnly);
|
||||
WriteIfVerbose(String.Format("results.Rows.Count = {0}",
|
||||
results != null ?
|
||||
results.Rows.Count.ToString() : "(none)"));
|
||||
if (results != null && results.Rows.Count > 0)
|
||||
{
|
||||
results.DefaultView.Sort = sort;
|
||||
if (!DisplayResult(keyword,
|
||||
results))
|
||||
{
|
||||
Say("No result");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("No result");
|
||||
}
|
||||
}
|
||||
|
||||
private void Search(string keyword)
|
||||
{
|
||||
if (!SearchIndex(keyword))
|
||||
SearchFullText(keyword);
|
||||
}
|
||||
|
||||
private bool DisplayResult(string keyword,
|
||||
IndexTopic indexTopic)
|
||||
{
|
||||
keyword = keyword.Trim().ToLower();
|
||||
string url = indexTopic.URL;
|
||||
WriteIfVerbose(String.Format("URL from index search {0}",
|
||||
url));
|
||||
string prototype = ExtractPrototype(url);
|
||||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||
return false;
|
||||
string formattedPrototype = FormatPrototype(prototype);
|
||||
Say(formattedPrototype);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DisplayResult(string keyword,
|
||||
DataTable results)
|
||||
{
|
||||
keyword = keyword.Trim().ToLower();
|
||||
for (int i = 0; i < results.DefaultView.Count; i++)
|
||||
{
|
||||
DataRowView row = results.DefaultView[i];
|
||||
string title = row["Title"].ToString();
|
||||
WriteIfVerbose(String.Format("Examining {0}", title));
|
||||
if (title.Trim().ToLower().Equals(keyword))
|
||||
{
|
||||
string location = row["Location"].ToString();
|
||||
string rating = row["Rating"].ToString();
|
||||
string url = row["Url"].ToString();
|
||||
string prototype = ExtractPrototype(url);
|
||||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||
continue;
|
||||
string formattedPrototype = FormatPrototype(prototype);
|
||||
Say(formattedPrototype);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DisplayNoResult(MessageContext context,
|
||||
string keyword)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about keyword {0}",
|
||||
keyword));
|
||||
}
|
||||
|
||||
private string ReplaceComments(string s)
|
||||
{
|
||||
return Regex.Replace(s, "//(.+)\r\n", "");
|
||||
}
|
||||
|
||||
private string ReplaceLineEndings(string s)
|
||||
{
|
||||
return Regex.Replace(s, "(\r\n)+", " ");
|
||||
}
|
||||
|
||||
private string ReplaceSpaces(string s)
|
||||
{
|
||||
return Regex.Replace(s, @" +", " ");
|
||||
}
|
||||
|
||||
private string ReplaceSpacesBeforeLeftParenthesis(string s)
|
||||
{
|
||||
return Regex.Replace(s, @"\( ", @"(");
|
||||
}
|
||||
|
||||
private string ReplaceSpacesBeforeRightParenthesis(string s)
|
||||
{
|
||||
return Regex.Replace(s, @" \)", @")");
|
||||
}
|
||||
|
||||
private string ReplaceSemicolon(string s)
|
||||
{
|
||||
return Regex.Replace(s, @";", @"");
|
||||
}
|
||||
|
||||
private string FormatPrototype(string prototype)
|
||||
{
|
||||
string s = ReplaceComments(prototype);
|
||||
s = ReplaceLineEndings(s);
|
||||
s = ReplaceSpaces(s);
|
||||
s = ReplaceSpacesBeforeLeftParenthesis(s);
|
||||
s = ReplaceSpacesBeforeRightParenthesis(s);
|
||||
s = ReplaceSemicolon(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private string ExtractPrototype(string url)
|
||||
{
|
||||
string page = GetPage(url);
|
||||
Match match = Regex.Match(page,
|
||||
"<PRE class=\"?syntax\"?>(.+)</PRE>",
|
||||
RegexOptions.Multiline |
|
||||
RegexOptions.Singleline);
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
string prototype = match.Groups[1].ToString();
|
||||
return StripHtml(StripAfterSlashPre(prototype));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private string StripAfterSlashPre(string html)
|
||||
{
|
||||
int index = html.IndexOf("</PRE>");
|
||||
if (index != -1)
|
||||
{
|
||||
return html.Substring(0, index);
|
||||
}
|
||||
else
|
||||
return html;
|
||||
}
|
||||
|
||||
private string StripHtml(string html)
|
||||
{
|
||||
return Regex.Replace(html, @"<(.|\n)*?>", String.Empty);
|
||||
}
|
||||
|
||||
private string GetPage(string url)
|
||||
{
|
||||
string CHMFileName = "";
|
||||
string topicName = "";
|
||||
string anchor = "";
|
||||
CHMStream.CHMStream baseStream;
|
||||
if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor))
|
||||
{
|
||||
baseStream = chm.BaseStream;
|
||||
CHMFileName = baseStream.CHMFileName;
|
||||
topicName = url;
|
||||
anchor = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
baseStream = GetBaseStreamFromCHMFileName(CHMFileName);
|
||||
}
|
||||
|
||||
if ((topicName == "") || (CHMFileName == "") || (baseStream == null))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return baseStream.ExtractTextFile(topicName);
|
||||
}
|
||||
|
||||
private CHMStream.CHMStream GetBaseStreamFromCHMFileName(string CHMFileName)
|
||||
{
|
||||
foreach (CHMFile file in chm.FileList)
|
||||
{
|
||||
WriteIfVerbose(String.Format("Compare: {0} <> {1}",
|
||||
file.ChmFilePath,
|
||||
CHMFileName));
|
||||
if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower()))
|
||||
{
|
||||
return file.BaseStream;
|
||||
}
|
||||
}
|
||||
WriteIfVerbose(String.Format("Could not find loaded CHM file in list: {0}",
|
||||
CHMFileName));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TechBot.Commands.MSDN")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Sand")]
|
||||
[assembly: AssemblyProduct("TechBot.Commands.MSDN")]
|
||||
[assembly: AssemblyCopyright("Copyright © Sand 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8a6332ce-82e3-4fbd-a799-8f4b8d025955")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -1,50 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TechBot.Commands.MSDN {
|
||||
|
||||
|
||||
[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.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("C:\\IRC\\TechBot\\CHM")]
|
||||
public string ChmPath {
|
||||
get {
|
||||
return ((string)(this["ChmPath"]));
|
||||
}
|
||||
set {
|
||||
this["ChmPath"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("kmarch.chm")]
|
||||
public string MainChm {
|
||||
get {
|
||||
return ((string)(this["MainChm"]));
|
||||
}
|
||||
set {
|
||||
this["MainChm"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Commands.MSDN" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="ChmPath" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">C:\IRC\TechBot\CHM</Value>
|
||||
</Setting>
|
||||
<Setting Name="MainChm" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">kmarch.chm</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@@ -1,69 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot.Commands.MSDN</RootNamespace>
|
||||
<AssemblyName>TechBot.Commands.MSDN</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApiCommand.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CHMLibrary\CHMLibrary.csproj">
|
||||
<Project>{72E5CCA1-6318-4D62-964D-CB23A5C743B5}</Project>
|
||||
<Name>CHMLibrary</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
|
||||
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
|
||||
<Name>TechBot.Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -1,5 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="TechBot.Commands.MSDN.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<TechBot.Commands.MSDN.Settings>
|
||||
<setting name="ChmPath" serializeAs="String">
|
||||
<value>C:\IRC\TechBot\CHM</value>
|
||||
</setting>
|
||||
<setting name="MainChm" serializeAs="String">
|
||||
<value>kmarch.chm</value>
|
||||
</setting>
|
||||
</TechBot.Commands.MSDN.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
@@ -1,27 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="TechBot.Console.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<TechBot.Console.Settings>
|
||||
<setting name="IRCServerHostName" serializeAs="String">
|
||||
<value>irc.eu.freenode.net</value>
|
||||
</setting>
|
||||
<setting name="IRCChannelNames" serializeAs="String">
|
||||
<value>rbuildbottest2</value>
|
||||
</setting>
|
||||
<setting name="IRCBotName" serializeAs="String">
|
||||
<value>RBuildBot2</value>
|
||||
</setting>
|
||||
<setting name="IRCBotPassword" serializeAs="String">
|
||||
<value>qwerty</value>
|
||||
</setting>
|
||||
<setting name="IRCServerHostPort" serializeAs="String">
|
||||
<value>6667</value>
|
||||
</setting>
|
||||
</TechBot.Console.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="IRCServerHostName" value="irc.eu.freenode.net" />
|
||||
<add key="IRCServerHostPort" value="6667" />
|
||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||
<add key="IRCBotName" value="MyBot" />
|
||||
<add key="IRCBotPassword" value="MyPassword" />
|
||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||
<add key="MainChm" value="kmarch.chm" />
|
||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
||||
<add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
|
||||
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
||||
<add key="WmXml" value="C:\IRC\TechBot\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}" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Console
|
||||
{
|
||||
public class ConsoleServiceOutput : IServiceOutput
|
||||
{
|
||||
public void WriteLine(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
System.Console.WriteLine(message);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConsoleTechBotService : TechBotService
|
||||
{
|
||||
public ConsoleTechBotService()
|
||||
: base(new ConsoleServiceOutput())
|
||||
{
|
||||
System.Console.WriteLine("TechBot running console service...");
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
//Call the base class
|
||||
base.Run();
|
||||
|
||||
while (true)
|
||||
{
|
||||
InjectMessage(System.Console.ReadLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,29 +1,260 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Console
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
TechBotService m_TechBot = null;
|
||||
|
||||
if (args.Length > 0 && args[0].ToLower().Equals("irc"))
|
||||
{
|
||||
m_TechBot = new IrcTechBotService(Settings.Default.IRCServerHostName,
|
||||
Settings.Default.IRCServerHostPort,
|
||||
Settings.Default.IRCChannelNames,
|
||||
Settings.Default.IRCBotName,
|
||||
Settings.Default.IRCBotPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TechBot = new ConsoleTechBotService();
|
||||
}
|
||||
|
||||
m_TechBot.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot.Console
|
||||
{
|
||||
public class ConsoleServiceOutput : IServiceOutput
|
||||
{
|
||||
public void WriteLine(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
System.Console.WriteLine(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MainClass
|
||||
{
|
||||
private static void VerifyRequiredOption(string optionName,
|
||||
string optionValue)
|
||||
{
|
||||
if (optionValue == null)
|
||||
{
|
||||
throw new Exception(String.Format("Option '{0}' not set.",
|
||||
optionName));
|
||||
}
|
||||
}
|
||||
|
||||
private static string IRCServerHostName
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "IRCServerHostName";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static int IRCServerHostPort
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "IRCServerHostPort";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return Int32.Parse(s);
|
||||
}
|
||||
}
|
||||
|
||||
private static string IRCChannelNames
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "IRCChannelNames";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string IRCBotName
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "IRCBotName";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string IRCBotPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "IRCBotPassword";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string ChmPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "ChmPath";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string MainChm
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "MainChm";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string NtstatusXml
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "NtstatusXml";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string WinerrorXml
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "WinerrorXml";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string HresultXml
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "HresultXml";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string WmXml
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "WmXml";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string SvnCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "SvnCommand";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string BugUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "BugUrl";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private static string WineBugUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "WineBugUrl";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static string SambaBugUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionName = "SambaBugUrl";
|
||||
string s = ConfigurationSettings.AppSettings[optionName];
|
||||
VerifyRequiredOption(optionName,
|
||||
s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void RunIrcService()
|
||||
{
|
||||
IrcService ircService = new IrcService(IRCServerHostName,
|
||||
IRCServerHostPort,
|
||||
IRCChannelNames,
|
||||
IRCBotName,
|
||||
IRCBotPassword,
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
WinerrorXml,
|
||||
HresultXml,
|
||||
WmXml,
|
||||
SvnCommand,
|
||||
BugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
ircService.Run();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Length > 0 && args[0].ToLower().Equals("irc"))
|
||||
{
|
||||
RunIrcService();
|
||||
return;
|
||||
}
|
||||
|
||||
System.Console.WriteLine("TechBot running console service...");
|
||||
TechBotService service = new TechBotService(new ConsoleServiceOutput(),
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
WinerrorXml,
|
||||
HresultXml,
|
||||
WmXml,
|
||||
SvnCommand,
|
||||
BugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
service.Run();
|
||||
while (true)
|
||||
{
|
||||
string s = System.Console.ReadLine();
|
||||
service.InjectMessage(null,
|
||||
s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
86
irc/TechBot/TechBot.Console/Settings.Designer.cs
generated
86
irc/TechBot/TechBot.Console/Settings.Designer.cs
generated
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TechBot.Console {
|
||||
|
||||
|
||||
[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.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")]
|
||||
public string IRCServerHostName {
|
||||
get {
|
||||
return ((string)(this["IRCServerHostName"]));
|
||||
}
|
||||
set {
|
||||
this["IRCServerHostName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest2")]
|
||||
public string IRCChannelNames {
|
||||
get {
|
||||
return ((string)(this["IRCChannelNames"]));
|
||||
}
|
||||
set {
|
||||
this["IRCChannelNames"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("RBuildBot2")]
|
||||
public string IRCBotName {
|
||||
get {
|
||||
return ((string)(this["IRCBotName"]));
|
||||
}
|
||||
set {
|
||||
this["IRCBotName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("qwerty")]
|
||||
public string IRCBotPassword {
|
||||
get {
|
||||
return ((string)(this["IRCBotPassword"]));
|
||||
}
|
||||
set {
|
||||
this["IRCBotPassword"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("6667")]
|
||||
public int IRCServerHostPort {
|
||||
get {
|
||||
return ((int)(this["IRCServerHostPort"]));
|
||||
}
|
||||
set {
|
||||
this["IRCServerHostPort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Console" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="IRCServerHostName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">irc.eu.freenode.net</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCChannelNames" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">rbuildbottest2</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCBotName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">RBuildBot2</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCBotPassword" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">qwerty</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCServerHostPort" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">6667</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot.Console</RootNamespace>
|
||||
<AssemblyName>TechBot.Console</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="ConsoleTechBotService.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TechBot.Commands.Common\TechBot.Commands.Common.csproj">
|
||||
<Project>{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}</Project>
|
||||
<Name>TechBot.Commands.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TechBot.Commands.RBuild\TechBot.Commands.RBuild.csproj">
|
||||
<Project>{D676FEDE-62DD-4B4D-94C6-308598E827F9}</Project>
|
||||
<Name>TechBot.Commands.RBuild</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
|
||||
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
|
||||
<Name>TechBot.IRCLibrary</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
|
||||
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
|
||||
<Name>TechBot.Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -16,10 +16,6 @@ namespace TechBot.IRCLibrary
|
||||
/// </summary>
|
||||
public delegate void ChannelUserDatabaseChangedHandler(IrcChannel channel);
|
||||
|
||||
public delegate void OnConnectHandler ();
|
||||
public delegate void OnDisconnectHandler();
|
||||
public delegate void OnConnectionLostHandler();
|
||||
|
||||
/// <summary>
|
||||
/// An IRC client.
|
||||
/// </summary>
|
||||
@@ -206,10 +202,6 @@ namespace TechBot.IRCLibrary
|
||||
|
||||
public event ChannelUserDatabaseChangedHandler ChannelUserDatabaseChanged;
|
||||
|
||||
public event OnConnectHandler OnConnect;
|
||||
public event OnConnectionLostHandler OnConnectionLost;
|
||||
public event OnDisconnectHandler OnDisconnect;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
@@ -299,39 +291,20 @@ namespace TechBot.IRCLibrary
|
||||
/// <param name="ar">IAsyncResult object.</param>
|
||||
private void ReadComplete(IAsyncResult ar)
|
||||
{
|
||||
try
|
||||
{
|
||||
StateObject stateObject = (StateObject)ar.AsyncState;
|
||||
if (stateObject.Stream.CanRead)
|
||||
{
|
||||
int bytesReceived = stateObject.Stream.EndRead(ar);
|
||||
if (bytesReceived > 0)
|
||||
{
|
||||
messageStream.Write(Encoding.GetString(stateObject.Buffer, 0, bytesReceived));
|
||||
while (messageStream.DataAvailable)
|
||||
{
|
||||
OnMessageReceived(new IrcMessage(messageStream.Read()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Receive();
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
if (OnConnectionLost != null)
|
||||
OnConnectionLost();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (OnConnectionLost != null)
|
||||
OnConnectionLost();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (OnConnectionLost != null)
|
||||
OnConnectionLost();
|
||||
}
|
||||
StateObject stateObject = (StateObject) ar.AsyncState;
|
||||
if (stateObject.Stream.CanRead)
|
||||
{
|
||||
int bytesReceived = stateObject.Stream.EndRead(ar);
|
||||
if (bytesReceived > 0)
|
||||
{
|
||||
messageStream.Write(Encoding.GetString(stateObject.Buffer, 0, bytesReceived));
|
||||
while (messageStream.DataAvailable)
|
||||
{
|
||||
OnMessageReceived(new IrcMessage(messageStream.Read()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Receive();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -525,9 +498,6 @@ namespace TechBot.IRCLibrary
|
||||
connected = false;
|
||||
tcpClient.Close();
|
||||
tcpClient = null;
|
||||
|
||||
if (OnDisconnect != null)
|
||||
OnDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,37 +507,19 @@ namespace TechBot.IRCLibrary
|
||||
/// <param name="message">The message to be sent.</param>
|
||||
public void SendMessage(IrcMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!connected)
|
||||
{
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
||||
/* Serialize sending messages */
|
||||
lock (typeof(IrcClient))
|
||||
{
|
||||
NetworkStream networkStream = tcpClient.GetStream();
|
||||
byte[] bytes = Encoding.GetBytes(message.Line);
|
||||
networkStream.Write(bytes, 0, bytes.Length);
|
||||
networkStream.Flush();
|
||||
}
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
if (OnConnectionLost != null)
|
||||
OnConnectionLost();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (OnConnectionLost != null)
|
||||
OnConnectionLost();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (OnConnectionLost != null)
|
||||
OnConnectionLost();
|
||||
}
|
||||
if (!connected)
|
||||
{
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
||||
/* Serialize sending messages */
|
||||
lock (typeof(IrcClient))
|
||||
{
|
||||
NetworkStream networkStream = tcpClient.GetStream();
|
||||
byte[] bytes = Encoding.GetBytes(message.Line);
|
||||
networkStream.Write(bytes, 0, bytes.Length);
|
||||
networkStream.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot.IRCLibrary</RootNamespace>
|
||||
<AssemblyName>TechBot.IRCLibrary</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="IRC.cs" />
|
||||
<Compile Include="IrcChannel.cs" />
|
||||
<Compile Include="IrcClient.cs" />
|
||||
<Compile Include="IrcException.cs" />
|
||||
<Compile Include="IrcMessage.cs" />
|
||||
<Compile Include="IrcUser.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="TechBot.IRCLibrary.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<TechBot.IRCLibrary.Settings>
|
||||
<setting name="CommandPrefix" serializeAs="String">
|
||||
<value>@</value>
|
||||
</setting>
|
||||
</TechBot.IRCLibrary.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
351
irc/TechBot/TechBot.Library/ApiCommand.cs
Normal file
351
irc/TechBot/TechBot.Library/ApiCommand.cs
Normal file
@@ -0,0 +1,351 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
using HtmlHelp;
|
||||
using HtmlHelp.ChmDecoding;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class ApiCommand : BaseCommand, ICommand
|
||||
{
|
||||
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;
|
||||
Run();
|
||||
}
|
||||
|
||||
private void WriteIfVerbose(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
if (IsVerbose)
|
||||
serviceOutput.WriteLine(context,
|
||||
message);
|
||||
}
|
||||
|
||||
private void Run()
|
||||
{
|
||||
string CHMFilename = Path.Combine(chmPath, mainChm);
|
||||
chm = new HtmlHelpSystem();
|
||||
chm.OpenFile(CHMFilename, null);
|
||||
|
||||
Console.WriteLine(String.Format("Loaded main CHM: {0}",
|
||||
Path.GetFileName(CHMFilename)));
|
||||
foreach (string filename in Directory.GetFiles(chmPath))
|
||||
{
|
||||
if (!Path.GetExtension(filename).ToLower().Equals(".chm"))
|
||||
continue;
|
||||
if (Path.GetFileName(filename).ToLower().Equals(mainChm))
|
||||
continue;
|
||||
|
||||
Console.WriteLine(String.Format("Loading CHM: {0}",
|
||||
Path.GetFileName(filename)));
|
||||
try
|
||||
{
|
||||
chm.MergeFile(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}",
|
||||
Path.GetFileName(filename),
|
||||
ex));
|
||||
}
|
||||
}
|
||||
Console.WriteLine(String.Format("Loaded {0} CHMs",
|
||||
chm.FileList.Length));
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "api" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
if (parameters.Trim().Equals(String.Empty))
|
||||
DisplayNoKeyword(context);
|
||||
else
|
||||
Search(context,
|
||||
parameters);
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!api <apiname>";
|
||||
}
|
||||
|
||||
private bool SearchIndex(MessageContext context,
|
||||
string keyword)
|
||||
{
|
||||
if (chm.HasIndex)
|
||||
{
|
||||
IndexItem item = chm.Index.SearchIndex(keyword,
|
||||
IndexType.KeywordLinks);
|
||||
if (item != null && item.Topics.Count > 0)
|
||||
{
|
||||
WriteIfVerbose(context,
|
||||
String.Format("Keyword {0} found in index",
|
||||
item.KeyWord));
|
||||
IndexTopic indexTopic = item.Topics[0] as IndexTopic;
|
||||
return DisplayResult(context,
|
||||
keyword,
|
||||
indexTopic);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteIfVerbose(context,
|
||||
String.Format("Keyword {0} not found in index",
|
||||
keyword));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SearchFullText(MessageContext context,
|
||||
string keyword)
|
||||
{
|
||||
string sort = "Rating ASC";
|
||||
WriteIfVerbose(context,
|
||||
String.Format("Searching fulltext database for {0}",
|
||||
keyword));
|
||||
|
||||
bool partialMatches = false;
|
||||
bool titlesOnly = true;
|
||||
int maxResults = 100;
|
||||
DataTable results = chm.PerformSearch(keyword,
|
||||
maxResults,
|
||||
partialMatches,
|
||||
titlesOnly);
|
||||
WriteIfVerbose(context,
|
||||
String.Format("results.Rows.Count = {0}",
|
||||
results != null ?
|
||||
results.Rows.Count.ToString() : "(none)"));
|
||||
if (results != null && results.Rows.Count > 0)
|
||||
{
|
||||
results.DefaultView.Sort = sort;
|
||||
if (!DisplayResult(context,
|
||||
keyword,
|
||||
results))
|
||||
{
|
||||
DisplayNoResult(context,
|
||||
keyword);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayNoResult(context,
|
||||
keyword);
|
||||
}
|
||||
}
|
||||
|
||||
private void Search(MessageContext context,
|
||||
string keyword)
|
||||
{
|
||||
if (!SearchIndex(context,
|
||||
keyword))
|
||||
SearchFullText(context,
|
||||
keyword);
|
||||
}
|
||||
|
||||
private bool DisplayResult(MessageContext context,
|
||||
string keyword,
|
||||
IndexTopic indexTopic)
|
||||
{
|
||||
keyword = keyword.Trim().ToLower();
|
||||
string url = indexTopic.URL;
|
||||
WriteIfVerbose(context,
|
||||
String.Format("URL from index search {0}",
|
||||
url));
|
||||
string prototype = ExtractPrototype(context,
|
||||
url);
|
||||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||
return false;
|
||||
string formattedPrototype = FormatPrototype(prototype);
|
||||
serviceOutput.WriteLine(context,
|
||||
formattedPrototype);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DisplayResult(MessageContext context,
|
||||
string keyword,
|
||||
DataTable results)
|
||||
{
|
||||
keyword = keyword.Trim().ToLower();
|
||||
for (int i = 0; i < results.DefaultView.Count; i++)
|
||||
{
|
||||
DataRowView row = results.DefaultView[i];
|
||||
string title = row["Title"].ToString();
|
||||
WriteIfVerbose(context,
|
||||
String.Format("Examining {0}", title));
|
||||
if (title.Trim().ToLower().Equals(keyword))
|
||||
{
|
||||
string location = row["Location"].ToString();
|
||||
string rating = row["Rating"].ToString();
|
||||
string url = row["Url"].ToString();
|
||||
string prototype = ExtractPrototype(context,
|
||||
url);
|
||||
if (prototype == null || prototype.Trim().Equals(String.Empty))
|
||||
continue;
|
||||
string formattedPrototype = FormatPrototype(prototype);
|
||||
serviceOutput.WriteLine(context,
|
||||
formattedPrototype);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DisplayNoResult(MessageContext context,
|
||||
string keyword)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("I don't know about keyword {0}",
|
||||
keyword));
|
||||
}
|
||||
|
||||
private void DisplayNoKeyword(MessageContext context)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please give me a keyword.");
|
||||
}
|
||||
|
||||
private string ReplaceComments(string s)
|
||||
{
|
||||
return Regex.Replace(s, "//(.+)\r\n", "");
|
||||
}
|
||||
|
||||
private string ReplaceLineEndings(string s)
|
||||
{
|
||||
return Regex.Replace(s, "(\r\n)+", " ");
|
||||
}
|
||||
|
||||
private string ReplaceSpaces(string s)
|
||||
{
|
||||
return Regex.Replace(s, @" +", " ");
|
||||
}
|
||||
|
||||
private string ReplaceSpacesBeforeLeftParenthesis(string s)
|
||||
{
|
||||
return Regex.Replace(s, @"\( ", @"(");
|
||||
}
|
||||
|
||||
private string ReplaceSpacesBeforeRightParenthesis(string s)
|
||||
{
|
||||
return Regex.Replace(s, @" \)", @")");
|
||||
}
|
||||
|
||||
private string ReplaceSemicolon(string s)
|
||||
{
|
||||
return Regex.Replace(s, @";", @"");
|
||||
}
|
||||
|
||||
private string FormatPrototype(string prototype)
|
||||
{
|
||||
string s = ReplaceComments(prototype);
|
||||
s = ReplaceLineEndings(s);
|
||||
s = ReplaceSpaces(s);
|
||||
s = ReplaceSpacesBeforeLeftParenthesis(s);
|
||||
s = ReplaceSpacesBeforeRightParenthesis(s);
|
||||
s = ReplaceSemicolon(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private string ExtractPrototype(MessageContext context,
|
||||
string url)
|
||||
{
|
||||
string page = GetPage(context,
|
||||
url);
|
||||
Match match = Regex.Match(page,
|
||||
"<PRE class=\"?syntax\"?>(.+)</PRE>",
|
||||
RegexOptions.Multiline |
|
||||
RegexOptions.Singleline);
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
string prototype = match.Groups[1].ToString();
|
||||
return StripHtml(StripAfterSlashPre(prototype));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private string StripAfterSlashPre(string html)
|
||||
{
|
||||
int index = html.IndexOf("</PRE>");
|
||||
if (index != -1)
|
||||
{
|
||||
return html.Substring(0, index);
|
||||
}
|
||||
else
|
||||
return html;
|
||||
}
|
||||
|
||||
private string StripHtml(string html)
|
||||
{
|
||||
return Regex.Replace(html, @"<(.|\n)*?>", String.Empty);
|
||||
}
|
||||
|
||||
private string GetPage(MessageContext context,
|
||||
string url)
|
||||
{
|
||||
string CHMFileName = "";
|
||||
string topicName = "";
|
||||
string anchor = "";
|
||||
CHMStream.CHMStream baseStream;
|
||||
if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor))
|
||||
{
|
||||
baseStream = chm.BaseStream;
|
||||
CHMFileName = baseStream.CHMFileName;
|
||||
topicName = url;
|
||||
anchor = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
baseStream = GetBaseStreamFromCHMFileName(context,
|
||||
CHMFileName);
|
||||
}
|
||||
|
||||
if ((topicName == "") || (CHMFileName == "") || (baseStream == null))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return baseStream.ExtractTextFile(topicName);
|
||||
}
|
||||
|
||||
private CHMStream.CHMStream GetBaseStreamFromCHMFileName(MessageContext context,
|
||||
string CHMFileName)
|
||||
{
|
||||
foreach (CHMFile file in chm.FileList)
|
||||
{
|
||||
WriteIfVerbose(context,
|
||||
String.Format("Compare: {0} <> {1}",
|
||||
file.ChmFilePath,
|
||||
CHMFileName));
|
||||
if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower()))
|
||||
{
|
||||
return file.BaseStream;
|
||||
}
|
||||
}
|
||||
WriteIfVerbose(context,
|
||||
String.Format("Could not find loaded CHM file in list: {0}",
|
||||
CHMFileName));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
32
irc/TechBot/TechBot.Library/AssemblyInfo.cs
Normal file
32
irc/TechBot/TechBot.Library/AssemblyInfo.cs
Normal file
@@ -0,0 +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("")]
|
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class CommandAttribute : Attribute
|
||||
{
|
||||
private string m_Name = null;
|
||||
private string m_Help = "No help for this command is available";
|
||||
private string m_Desc = "No description for this command is available";
|
||||
|
||||
public CommandAttribute(string name)
|
||||
{
|
||||
m_Name = name;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return m_Name; }
|
||||
}
|
||||
|
||||
public string Help
|
||||
{
|
||||
get { return m_Help; }
|
||||
set { m_Help = value; }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return m_Desc; }
|
||||
set { m_Desc = value; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// This class implements an alias attribute to work in conjunction
|
||||
/// with the <see cref="CommandLineSwitchAttribute">CommandLineSwitchAttribute</see>
|
||||
/// attribute. If the CommandLineSwitchAttribute exists, then this attribute
|
||||
/// defines an alias for it.
|
||||
/// </summary>
|
||||
[AttributeUsage( AttributeTargets.Property )]
|
||||
public class CommandParameterAliasAttribute : Attribute
|
||||
{
|
||||
#region Private Variables
|
||||
protected string m_Alias = "";
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
public string Alias
|
||||
{
|
||||
get { return m_Alias; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public CommandParameterAliasAttribute(string alias)
|
||||
{
|
||||
m_Alias = alias;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
/// <summary>Implements a basic command-line switch by taking the
|
||||
/// switching name and the associated description.</summary>
|
||||
/// <remark>Only currently is implemented for properties, so all
|
||||
/// auto-switching variables should have a get/set method supplied.</remark>
|
||||
[AttributeUsage( AttributeTargets.Property )]
|
||||
public class CommandParameterAttribute : Attribute
|
||||
{
|
||||
#region Private Variables
|
||||
private string m_name = "";
|
||||
private string m_description = "";
|
||||
private bool m_Required = true;
|
||||
private bool m_Default = false;
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>Accessor for retrieving the switch-name for an associated
|
||||
/// property.</summary>
|
||||
public string Name { get { return m_name; } }
|
||||
|
||||
/// <summary>Accessor for retrieving the description for a switch of
|
||||
/// an associated property.</summary>
|
||||
public string Description { get { return m_description; } }
|
||||
|
||||
public bool Required { get { return m_Required; } }
|
||||
|
||||
public bool DefaultParameter
|
||||
{
|
||||
get { return m_Default; }
|
||||
set { m_Default = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Attribute constructor.
|
||||
/// </summary>
|
||||
public CommandParameterAttribute(string name, string description)
|
||||
{
|
||||
m_name = name;
|
||||
m_description = description;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
71
irc/TechBot/TechBot.Library/BugCommand.cs
Normal file
71
irc/TechBot/TechBot.Library/BugCommand.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class BugCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string RosBugUrl;
|
||||
private string WineBugUrl;
|
||||
private string SambaBugUrl;
|
||||
|
||||
public BugCommand(IServiceOutput serviceOutput,
|
||||
string RosBugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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>";
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class CommandBuilderCollection : List<CommandBuilder>
|
||||
{
|
||||
public CommandBuilder Find(string name)
|
||||
{
|
||||
foreach (CommandBuilder command in this)
|
||||
{
|
||||
if (command.Name == name)
|
||||
return command;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public abstract class Command
|
||||
{
|
||||
protected TechBotService m_TechBotService = null;
|
||||
protected MessageContext m_Context = null;
|
||||
protected string m_Params = null;
|
||||
|
||||
public TechBotService TechBot
|
||||
{
|
||||
get { return m_TechBotService; }
|
||||
set { m_TechBotService = value; }
|
||||
}
|
||||
|
||||
public MessageContext Context
|
||||
{
|
||||
get { return m_Context; }
|
||||
set { m_Context = value; }
|
||||
}
|
||||
|
||||
public virtual bool AnswerInPublic
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
CommandAttribute commandAttribute = (CommandAttribute)
|
||||
Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute));
|
||||
|
||||
return commandAttribute.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string Parameters
|
||||
{
|
||||
get { return m_Params; }
|
||||
set { m_Params = value; }
|
||||
}
|
||||
|
||||
protected virtual void Say()
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(Context, string.Empty);
|
||||
}
|
||||
|
||||
protected virtual void Say(string message)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(Context, message);
|
||||
}
|
||||
|
||||
protected virtual void Say(string format , params object[] args)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args));
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (Context is ChannelMessageContext)
|
||||
{
|
||||
if (AnswerInPublic)
|
||||
{
|
||||
ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("Sorry, I only respond '{0}' in private , PM me!", Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void ExecuteCommand();
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void DeInitialize()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
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()
|
||||
{
|
||||
m_XmlDocument = new XmlDocument();
|
||||
m_XmlDocument.Load(XmlFile);
|
||||
}
|
||||
|
||||
public abstract string XmlFile { get; }
|
||||
|
||||
public XmlDocument XmlDocument
|
||||
{
|
||||
get { return m_XmlDocument; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public abstract class XmlLookupCommand : XmlCommand
|
||||
{
|
||||
public virtual string Text
|
||||
{
|
||||
get { return Parameters; }
|
||||
set { Parameters = value; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
[Command("help", Help = "!help or !help -name:[CommandName]", Description = "Shows this help , type 'help -name:[CommandName]'")]
|
||||
public class HelpCommand : Command
|
||||
{
|
||||
public HelpCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool AnswerInPublic
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[CommandParameter("Name", "The command name to show help")]
|
||||
public string CommandName
|
||||
{
|
||||
get { return Parameters; }
|
||||
set { Parameters = value; }
|
||||
}
|
||||
|
||||
public override void ExecuteCommand()
|
||||
{
|
||||
if (string.IsNullOrEmpty(CommandName))
|
||||
{
|
||||
Say("I support the following commands:");
|
||||
|
||||
foreach (CommandBuilder command in TechBot.Commands)
|
||||
{
|
||||
Say("{0}{1} - {2}",
|
||||
Settings.Default.CommandPrefix,
|
||||
command.Name,
|
||||
command.Description);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName);
|
||||
|
||||
if (cmdBuilder == null)
|
||||
{
|
||||
Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Say("Command '{0}' help:", CommandName);
|
||||
Say();
|
||||
Say(cmdBuilder.Description);
|
||||
Say();
|
||||
Say(cmdBuilder.Help);
|
||||
Say();
|
||||
Say("Parameters :");
|
||||
Say();
|
||||
|
||||
PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
foreach (PropertyInfo propertyInfo in propertyInfoArray)
|
||||
{
|
||||
CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[])
|
||||
Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute));
|
||||
|
||||
foreach (CommandParameterAttribute parameter in commandAttributes)
|
||||
{
|
||||
Say("\t-{0}: [{1}]",
|
||||
parameter.Name,
|
||||
parameter.Description);
|
||||
}
|
||||
}
|
||||
|
||||
Say();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
irc/TechBot/TechBot.Library/Default.build
Normal file
24
irc/TechBot/TechBot.Library/Default.build
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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>
|
91
irc/TechBot/TechBot.Library/ErrorCommand.cs
Normal file
91
irc/TechBot/TechBot.Library/ErrorCommand.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class ErrorCommand : BaseCommand, ICommand
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "error" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string errorText = parameters;
|
||||
if (errorText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please provide an Error Code.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long error = np.Parse(errorText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid Error Code.",
|
||||
errorText));
|
||||
return;
|
||||
}
|
||||
|
||||
string description = null;
|
||||
if (winerror.GetWinerrorDescription(error) != null)
|
||||
{
|
||||
description = winerror.GetWinerrorDescription(error);
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
error,
|
||||
description));
|
||||
}
|
||||
if (ntStatus.GetNtstatusDescription(error) != null)
|
||||
{
|
||||
description = ntStatus.GetNtstatusDescription(error);
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
errorText,
|
||||
description));
|
||||
}
|
||||
if (hresult.GetHresultDescription(error) != null)
|
||||
{
|
||||
description = hresult.GetHresultDescription(error);
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
errorText,
|
||||
description));
|
||||
}
|
||||
if(description == null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("I don't know about Error Code {0}.",
|
||||
errorText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!error <value>";
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class CommandBuilder
|
||||
{
|
||||
private Type m_CommandType;
|
||||
private string m_CommandName;
|
||||
private string m_CommandHelp;
|
||||
private string m_CommandDesc;
|
||||
|
||||
public CommandBuilder(Type commandType)
|
||||
{
|
||||
m_CommandType = commandType;
|
||||
|
||||
CommandAttribute commandAttribute = (CommandAttribute)
|
||||
Attribute.GetCustomAttribute(commandType, typeof(CommandAttribute));
|
||||
|
||||
m_CommandName = commandAttribute.Name;
|
||||
m_CommandHelp = commandAttribute.Help;
|
||||
m_CommandDesc = commandAttribute.Description;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return m_CommandName; }
|
||||
}
|
||||
|
||||
public string Help
|
||||
{
|
||||
get { return m_CommandHelp; }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return m_CommandDesc; }
|
||||
}
|
||||
|
||||
public Type Type
|
||||
{
|
||||
get { return m_CommandType; }
|
||||
}
|
||||
|
||||
public Command CreateCommand()
|
||||
{
|
||||
return (Command)Type.Assembly.CreateInstance(Type.FullName, true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class CommandFactory
|
||||
{
|
||||
private static CommandBuilderCollection m_Commands = new CommandBuilderCollection();
|
||||
|
||||
private CommandFactory()
|
||||
{
|
||||
}
|
||||
|
||||
public static void LoadPlugins()
|
||||
{
|
||||
//get the file names of the dll files in the current directory.
|
||||
foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "*.dll"))
|
||||
{
|
||||
LoadPluginsFromDLLFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadPluginsFromDLLFile(string sFile)
|
||||
{
|
||||
Assembly assPlugin = Assembly.LoadFile(sFile);
|
||||
|
||||
Console.WriteLine("Loading plugins from : {0}", assPlugin.Location);
|
||||
|
||||
if (assPlugin != null)
|
||||
{
|
||||
foreach (Type pluginType in assPlugin.GetTypes())
|
||||
{
|
||||
if (pluginType.IsSubclassOf(typeof(Command)))
|
||||
{
|
||||
if (pluginType.IsAbstract == false)
|
||||
{
|
||||
CommandBuilder cmdBuilder = new CommandBuilder(pluginType);
|
||||
|
||||
Console.WriteLine("{0}:{1}",
|
||||
cmdBuilder.Name,
|
||||
cmdBuilder.Description);
|
||||
|
||||
//Add it to the list.
|
||||
Commands.Add(new CommandBuilder(pluginType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CommandBuilderCollection Commands
|
||||
{
|
||||
get { return m_Commands; }
|
||||
}
|
||||
}
|
||||
}
|
42
irc/TechBot/TechBot.Library/HelpCommand.cs
Normal file
42
irc/TechBot/TechBot.Library/HelpCommand.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class HelpCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private ArrayList commands;
|
||||
|
||||
public HelpCommand(IServiceOutput serviceOutput,
|
||||
ArrayList commands)
|
||||
{
|
||||
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()
|
||||
{
|
||||
return "!help";
|
||||
}
|
||||
}
|
||||
}
|
86
irc/TechBot/TechBot.Library/HresultCommand.cs
Normal file
86
irc/TechBot/TechBot.Library/HresultCommand.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class HresultCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string hresultXml;
|
||||
private XmlDocument hresultXmlDocument;
|
||||
|
||||
public HresultCommand(IServiceOutput serviceOutput,
|
||||
string hresultXml)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.hresultXml = hresultXml;
|
||||
hresultXmlDocument = new XmlDocument();
|
||||
hresultXmlDocument.Load(hresultXml);
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "hresult" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string hresultText = parameters;
|
||||
if (hresultText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please provide a valid HRESULT value.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long hresult = np.Parse(hresultText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid HRESULT value.",
|
||||
hresultText));
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetHresultDescription(hresult);
|
||||
if (description != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
hresultText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("I don't know about HRESULT {0}.",
|
||||
hresultText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!hresult <value>";
|
||||
}
|
||||
|
||||
public string GetHresultDescription(long hresult)
|
||||
{
|
||||
XmlElement root = hresultXmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
|
||||
hresult.ToString("X8")));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
29
irc/TechBot/TechBot.Library/ICommand.cs
Normal file
29
irc/TechBot/TechBot.Library/ICommand.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
293
irc/TechBot/TechBot.Library/IrcService.cs
Normal file
293
irc/TechBot/TechBot.Library/IrcService.cs
Normal file
@@ -0,0 +1,293 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using TechBot.IRCLibrary;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class IrcService : IServiceOutput
|
||||
{
|
||||
private string hostname;
|
||||
private int port;
|
||||
private string channelnames;
|
||||
private string botname;
|
||||
private string password;
|
||||
private string chmPath;
|
||||
private string mainChm;
|
||||
private string ntstatusXml;
|
||||
private string winerrorXml;
|
||||
private string hresultXml;
|
||||
private string wmXml;
|
||||
private string svnCommand;
|
||||
private string bugUrl, WineBugUrl, SambaBugUrl;
|
||||
private IrcClient client;
|
||||
private ArrayList channels = new ArrayList(); /* IrcChannel */
|
||||
private TechBotService service;
|
||||
private bool isStopped = false;
|
||||
|
||||
public IrcService(string hostname,
|
||||
int port,
|
||||
string channelnames,
|
||||
string botname,
|
||||
string password,
|
||||
string chmPath,
|
||||
string mainChm,
|
||||
string ntstatusXml,
|
||||
string winerrorXml,
|
||||
string hresultXml,
|
||||
string wmXml,
|
||||
string svnCommand,
|
||||
string BugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
{
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
this.channelnames = channelnames;
|
||||
this.botname = botname;
|
||||
if (password == null || password.Trim() == "")
|
||||
this.password = null;
|
||||
else
|
||||
this.password = password;
|
||||
this.chmPath = chmPath;
|
||||
this.mainChm = mainChm;
|
||||
this.ntstatusXml = ntstatusXml;
|
||||
this.winerrorXml = winerrorXml;
|
||||
this.hresultXml = hresultXml;
|
||||
this.wmXml = wmXml;
|
||||
this.svnCommand = svnCommand;
|
||||
this.bugUrl = BugUrl;
|
||||
this.WineBugUrl = WineBugUrl;
|
||||
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 Stop()
|
||||
{
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
private void JoinChannels()
|
||||
{
|
||||
foreach (string channelname in channelnames.Split(new char[] { ';' }))
|
||||
{
|
||||
IrcChannel channel = client.JoinChannel(channelname);
|
||||
channels.Add(channel);
|
||||
System.Console.WriteLine(String.Format("Joined channel #{0}...",
|
||||
channel.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private void PartChannels()
|
||||
{
|
||||
foreach (IrcChannel channel in channels)
|
||||
{
|
||||
client.PartChannel(channel, "Caught in the bitstream...");
|
||||
System.Console.WriteLine(String.Format("Parted channel #{0}...",
|
||||
channel.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private string GetMessageSource(MessageContext context)
|
||||
{
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
return String.Format("#{0}",
|
||||
channelContext.Channel.Name);
|
||||
}
|
||||
else if (context is UserMessageContext)
|
||||
{
|
||||
UserMessageContext userContext = context as UserMessageContext;
|
||||
return userContext.User.Nickname;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
|
||||
context.GetType()));
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteLine(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
channelContext.Channel.Talk(message);
|
||||
}
|
||||
else if (context is UserMessageContext)
|
||||
{
|
||||
UserMessageContext userContext = context as UserMessageContext;
|
||||
userContext.User.Talk(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
|
||||
context.GetType()));
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtractMessage(string parameters,
|
||||
out string message)
|
||||
{
|
||||
int startIndex = parameters.IndexOf(':');
|
||||
if (startIndex != -1)
|
||||
{
|
||||
message = parameters.Substring(startIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = parameters;
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetChannelName(IrcMessage message,
|
||||
out string channelName)
|
||||
{
|
||||
if (message.Parameters == null || !message.Parameters.StartsWith("#"))
|
||||
{
|
||||
channelName = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = message.Parameters.IndexOf(' ');
|
||||
if (index == -1)
|
||||
index = message.Parameters.Length;
|
||||
else
|
||||
index = index - 1;
|
||||
channelName = message.Parameters.Substring(1, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool GetTargetNickname(IrcMessage message,
|
||||
out string nickname)
|
||||
{
|
||||
if (message.Parameters == null)
|
||||
{
|
||||
nickname = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = message.Parameters.IndexOf(' ');
|
||||
if (index == -1)
|
||||
index = message.Parameters.Length;
|
||||
nickname = message.Parameters.Substring(0, index);
|
||||
Console.WriteLine("nickname: " + nickname);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ShouldAcceptMessage(IrcMessage message,
|
||||
out MessageContext context)
|
||||
{
|
||||
if (message.Command.ToUpper().Equals("PRIVMSG"))
|
||||
{
|
||||
string channelName;
|
||||
string nickname;
|
||||
if (GetChannelName(message,
|
||||
out channelName))
|
||||
{
|
||||
foreach (IrcChannel channel in channels)
|
||||
{
|
||||
if (String.Compare(channel.Name, channelName, true) == 0)
|
||||
{
|
||||
context = new ChannelMessageContext(channel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GetTargetNickname(message,
|
||||
out nickname))
|
||||
{
|
||||
IrcUser targetUser = new IrcUser(client,
|
||||
nickname);
|
||||
if (String.Compare(targetUser.Nickname, botname, true) == 0)
|
||||
{
|
||||
IrcUser sourceUser = new IrcUser(client,
|
||||
message.PrefixNickname);
|
||||
context = new UserMessageContext(sourceUser);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
context = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void client_MessageReceived(IrcMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (message.Command != null &&
|
||||
message.Parameters != null)
|
||||
{
|
||||
string injectMessage;
|
||||
ExtractMessage(message.Parameters,
|
||||
out injectMessage);
|
||||
MessageContext context;
|
||||
if (ShouldAcceptMessage(message,
|
||||
out context))
|
||||
{
|
||||
Console.WriteLine(String.Format("Injecting: {0} from {1}",
|
||||
injectMessage,
|
||||
GetMessageSource(context)));
|
||||
service.InjectMessage(context,
|
||||
injectMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Received: " + message.Line);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Received: " + message.Line);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(String.Format("Exception: {0}", ex));
|
||||
}
|
||||
}
|
||||
|
||||
private void client_ChannelUserDatabaseChanged(IrcChannel channel)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,33 +7,43 @@ namespace TechBot.Library
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ChannelMessageContext : MessageContext
|
||||
{
|
||||
private IrcChannel m_IrcChannel;
|
||||
private IrcChannel channel;
|
||||
|
||||
public IrcChannel Channel
|
||||
{
|
||||
get { return m_IrcChannel; }
|
||||
}
|
||||
public IrcChannel Channel
|
||||
{
|
||||
get
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
|
||||
public ChannelMessageContext(IrcChannel channel)
|
||||
{
|
||||
m_IrcChannel = channel;
|
||||
this.channel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class UserMessageContext : MessageContext
|
||||
{
|
||||
private IrcUser m_IrcUser;
|
||||
private IrcUser user;
|
||||
|
||||
public IrcUser User
|
||||
{
|
||||
get { return m_IrcUser; }
|
||||
}
|
||||
public IrcUser User
|
||||
{
|
||||
get
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
public UserMessageContext(IrcUser user)
|
||||
{
|
||||
m_IrcUser = user;
|
||||
this.user = user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
86
irc/TechBot/TechBot.Library/NtStatusCommand.cs
Normal file
86
irc/TechBot/TechBot.Library/NtStatusCommand.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class NtStatusCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string ntstatusXml;
|
||||
private XmlDocument ntstatusXmlDocument;
|
||||
|
||||
public NtStatusCommand(IServiceOutput serviceOutput,
|
||||
string ntstatusXml)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.ntstatusXml = ntstatusXml;
|
||||
ntstatusXmlDocument = new XmlDocument();
|
||||
ntstatusXmlDocument.Load(ntstatusXml);
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "ntstatus" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string ntstatusText = parameters;
|
||||
if (ntstatusText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please provide a valid NTSTATUS value.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long ntstatus = np.Parse(ntstatusText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid NTSTATUS value.",
|
||||
ntstatusText));
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetNtstatusDescription(ntstatus);
|
||||
if (description != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
ntstatusText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("I don't know about NTSTATUS {0}.",
|
||||
ntstatusText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!ntstatus <value>";
|
||||
}
|
||||
|
||||
public string GetNtstatusDescription(long ntstatus)
|
||||
{
|
||||
XmlElement root = ntstatusXmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
|
||||
ntstatus.ToString("X8")));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,7 +9,7 @@ namespace TechBot.Library
|
||||
|
||||
private const string SpecialHexCharacters = "ABCDEF";
|
||||
|
||||
private static bool IsSpecialHexCharacter(char ch)
|
||||
private bool IsSpecialHexCharacter(char ch)
|
||||
{
|
||||
foreach (char specialChar in SpecialHexCharacters)
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace TechBot.Library
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool HasSpecialHexCharacters(string s)
|
||||
private bool HasSpecialHexCharacters(string s)
|
||||
{
|
||||
foreach (char ch in s)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ namespace TechBot.Library
|
||||
{
|
||||
Error = false;
|
||||
bool useHex = false;
|
||||
if (s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (s.StartsWith("0x"))
|
||||
{
|
||||
s = s.Substring(2);
|
||||
useHex = true;
|
||||
|
@@ -1,32 +0,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("")]
|
@@ -2,8 +2,9 @@ using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public interface IServiceOutput
|
||||
{
|
||||
void WriteLine(MessageContext context, string message);
|
||||
}
|
||||
public interface IServiceOutput
|
||||
{
|
||||
void WriteLine(MessageContext context,
|
||||
string message);
|
||||
}
|
||||
}
|
||||
|
80
irc/TechBot/TechBot.Library/Settings.Designer.cs
generated
80
irc/TechBot/TechBot.Library/Settings.Designer.cs
generated
@@ -1,80 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// 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"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("@")]
|
||||
public string CommandPrefix {
|
||||
get {
|
||||
return ((string)(this["CommandPrefix"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
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.
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
<?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>
|
||||
<Setting Name="CommandPrefix" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">@</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
36
irc/TechBot/TechBot.Library/SvnCommand.cs
Normal file
36
irc/TechBot/TechBot.Library/SvnCommand.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class SvnCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string svnCommand;
|
||||
|
||||
public SvnCommand(IServiceOutput serviceOutput,
|
||||
string svnCommand)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.svnCommand = svnCommand;
|
||||
}
|
||||
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "svn" });
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
svnCommand);
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!svn";
|
||||
}
|
||||
}
|
||||
}
|
16
irc/TechBot/TechBot.Library/TechBot.Library.cmbx
Normal file
16
irc/TechBot/TechBot.Library/TechBot.Library.cmbx
Normal file
@@ -0,0 +1,16 @@
|
||||
<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>
|
@@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot.Library</RootNamespace>
|
||||
<AssemblyName>TechBot.Library</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Compile Include="Attributes\CommandAttribute.cs" />
|
||||
<Compile Include="Attributes\CommandParameterAliasAttribute.cs" />
|
||||
<Compile Include="Attributes\CommandParameterAttribute.cs" />
|
||||
<Compile Include="Collections\CommandBuilderCollection.cs" />
|
||||
<Compile Include="Commands\Base\XmlLookupCommand.cs" />
|
||||
<Compile Include="Factory\CommandBuilder.cs" />
|
||||
<Compile Include="Factory\CommandFactory.cs" />
|
||||
<Compile Include="Commands\Base\Command.cs" />
|
||||
<Compile Include="Commands\Base\XmlCommand.cs" />
|
||||
<Compile Include="Commands\HelpCommand.cs" />
|
||||
<Compile Include="MessageContext.cs" />
|
||||
<Compile Include="NumberParser.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.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="TechBotIrcService.cs" />
|
||||
<Compile Include="TechBotService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
|
||||
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
|
||||
<Name>TechBot.IRCLibrary</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
43
irc/TechBot/TechBot.Library/TechBot.Library.prjx
Normal file
43
irc/TechBot/TechBot.Library/TechBot.Library.prjx
Normal file
@@ -0,0 +1,43 @@
|
||||
<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>
|
@@ -1,304 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
|
||||
using TechBot.IRCLibrary;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class IrcServiceOutput : IServiceOutput
|
||||
{
|
||||
public void WriteLine(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
Thread.Sleep (500);
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
channelContext.Channel.Talk(message);
|
||||
}
|
||||
else if (context is UserMessageContext)
|
||||
{
|
||||
UserMessageContext userContext = context as UserMessageContext;
|
||||
userContext.User.Talk(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
|
||||
context.GetType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class IrcTechBotService : TechBotService
|
||||
{
|
||||
private int port;
|
||||
private string hostname;
|
||||
private string channelnames;
|
||||
private string botname;
|
||||
private string password;
|
||||
private IrcClient m_IrcClient;
|
||||
private ArrayList channels = new ArrayList();
|
||||
private bool isStopped = false;
|
||||
|
||||
public IrcTechBotService(string hostname,
|
||||
int port,
|
||||
string channelnames,
|
||||
string botname,
|
||||
string password)
|
||||
: base (new IrcServiceOutput())
|
||||
{
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
this.channelnames = channelnames;
|
||||
this.botname = botname;
|
||||
if (password == null || password.Trim() == "")
|
||||
this.password = null;
|
||||
else
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
//Call the base class
|
||||
base.Run();
|
||||
|
||||
m_IrcClient = new IrcClient();
|
||||
m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1");
|
||||
m_IrcClient.OnConnect += new OnConnectHandler(m_IrcClient_OnConnect);
|
||||
m_IrcClient.OnConnectionLost += new OnConnectionLostHandler(m_IrcClient_OnConnectionLost);
|
||||
m_IrcClient.OnDisconnect += new OnDisconnectHandler(m_IrcClient_OnDisconnect);
|
||||
m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
|
||||
m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
|
||||
|
||||
Connect();
|
||||
}
|
||||
|
||||
void m_IrcClient_OnConnect()
|
||||
{
|
||||
Console.WriteLine("Connected...");
|
||||
}
|
||||
|
||||
private void Connect()
|
||||
{
|
||||
Console.WriteLine("Connecting to {0} port {1}",
|
||||
hostname,
|
||||
port);
|
||||
m_IrcClient.Connect(hostname, port);
|
||||
|
||||
m_IrcClient.Register(botname, password, null);
|
||||
Console.WriteLine("Registered as {0}...", botname);
|
||||
JoinChannels();
|
||||
|
||||
while (!isStopped)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
PartChannels();
|
||||
m_IrcClient.Diconnect();
|
||||
}
|
||||
|
||||
void m_IrcClient_OnDisconnect()
|
||||
{
|
||||
Console.WriteLine("Disconnected...");
|
||||
}
|
||||
|
||||
void m_IrcClient_OnConnectionLost()
|
||||
{
|
||||
//Dispose old connection
|
||||
Disconnect();
|
||||
|
||||
//Sleep for 1 minute
|
||||
Thread.Sleep(1000 * 60);
|
||||
|
||||
//Try to reconnect
|
||||
Connect();
|
||||
}
|
||||
|
||||
private void Disconnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_IrcClient.Diconnect();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
isStopped = true;
|
||||
}
|
||||
|
||||
private void JoinChannels()
|
||||
{
|
||||
foreach (string channelname in channelnames.Split(new char[] { ';' }))
|
||||
{
|
||||
IrcChannel channel = m_IrcClient.JoinChannel(channelname);
|
||||
channels.Add(channel);
|
||||
System.Console.WriteLine(String.Format("Joined channel #{0}...",
|
||||
channel.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private void PartChannels()
|
||||
{
|
||||
foreach (IrcChannel channel in channels)
|
||||
{
|
||||
m_IrcClient.PartChannel(channel, "Caught in the bitstream...");
|
||||
System.Console.WriteLine(String.Format("Parted channel #{0}...",
|
||||
channel.Name));
|
||||
}
|
||||
}
|
||||
|
||||
private string GetMessageSource(MessageContext context)
|
||||
{
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
return String.Format("#{0}",
|
||||
channelContext.Channel.Name);
|
||||
}
|
||||
else if (context is UserMessageContext)
|
||||
{
|
||||
UserMessageContext userContext = context as UserMessageContext;
|
||||
return userContext.User.Nickname;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
|
||||
context.GetType()));
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtractMessage(string parameters,
|
||||
out string message)
|
||||
{
|
||||
int startIndex = parameters.IndexOf(':');
|
||||
if (startIndex != -1)
|
||||
{
|
||||
message = parameters.Substring(startIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = parameters;
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetChannelName(IrcMessage message,
|
||||
out string channelName)
|
||||
{
|
||||
if (message.Parameters == null || !message.Parameters.StartsWith("#"))
|
||||
{
|
||||
channelName = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = message.Parameters.IndexOf(' ');
|
||||
if (index == -1)
|
||||
index = message.Parameters.Length;
|
||||
else
|
||||
index = index - 1;
|
||||
channelName = message.Parameters.Substring(1, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool GetTargetNickname(IrcMessage message,
|
||||
out string nickname)
|
||||
{
|
||||
if (message.Parameters == null)
|
||||
{
|
||||
nickname = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = message.Parameters.IndexOf(' ');
|
||||
if (index == -1)
|
||||
index = message.Parameters.Length;
|
||||
nickname = message.Parameters.Substring(0, index);
|
||||
Console.WriteLine("nickname: " + nickname);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ShouldAcceptMessage(IrcMessage message,
|
||||
out MessageContext context)
|
||||
{
|
||||
if (message.Command.ToUpper().Equals("PRIVMSG"))
|
||||
{
|
||||
string channelName;
|
||||
string nickname;
|
||||
if (GetChannelName(message,
|
||||
out channelName))
|
||||
{
|
||||
foreach (IrcChannel channel in channels)
|
||||
{
|
||||
if (String.Compare(channel.Name, channelName, true) == 0)
|
||||
{
|
||||
context = new ChannelMessageContext(channel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GetTargetNickname(message,
|
||||
out nickname))
|
||||
{
|
||||
IrcUser targetUser = new IrcUser(m_IrcClient,
|
||||
nickname);
|
||||
if (String.Compare(targetUser.Nickname, botname, true) == 0)
|
||||
{
|
||||
IrcUser sourceUser = new IrcUser(m_IrcClient,
|
||||
message.PrefixNickname);
|
||||
context = new UserMessageContext(sourceUser);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
context = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void client_MessageReceived(IrcMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (message.Command != null &&
|
||||
message.Parameters != null)
|
||||
{
|
||||
string injectMessage;
|
||||
ExtractMessage(message.Parameters,
|
||||
out injectMessage);
|
||||
MessageContext context;
|
||||
if (ShouldAcceptMessage(message,
|
||||
out context))
|
||||
{
|
||||
Console.WriteLine(String.Format("Injecting: {0} from {1}",
|
||||
injectMessage,
|
||||
GetMessageSource(context)));
|
||||
InjectMessage(context,
|
||||
injectMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Received: " + message.Line);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Received: " + message.Line);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(String.Format("Exception: {0}", ex));
|
||||
}
|
||||
}
|
||||
|
||||
private void client_ChannelUserDatabaseChanged(IrcChannel channel)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,101 +1,117 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
|
||||
using TechBot.IRCLibrary;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public abstract class TechBotService
|
||||
{
|
||||
protected IServiceOutput m_ServiceOutput;
|
||||
|
||||
public TechBotService(IServiceOutput serviceOutput)
|
||||
{
|
||||
m_ServiceOutput = serviceOutput;
|
||||
}
|
||||
|
||||
public virtual void Run()
|
||||
{
|
||||
CommandFactory.LoadPlugins();
|
||||
}
|
||||
|
||||
public IServiceOutput ServiceOutput
|
||||
{
|
||||
get { return m_ServiceOutput; }
|
||||
}
|
||||
|
||||
public CommandBuilderCollection Commands
|
||||
{
|
||||
get { return CommandFactory.Commands; }
|
||||
}
|
||||
|
||||
public void InjectMessage(MessageContext context, string message)
|
||||
{
|
||||
ParseCommandMessage(context,
|
||||
message);
|
||||
}
|
||||
|
||||
private bool IsCommandMessage(string message)
|
||||
{
|
||||
return message.StartsWith(Settings.Default.CommandPrefix);
|
||||
}
|
||||
|
||||
public void InjectMessage(string message)
|
||||
{
|
||||
ParseCommandMessage(null, message);
|
||||
}
|
||||
|
||||
public void ParseCommandMessage(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
if (!IsCommandMessage(message))
|
||||
return;
|
||||
|
||||
message = message.Substring(1).Trim();
|
||||
int index = message.IndexOf(' ');
|
||||
string commandName;
|
||||
string commandParams = "";
|
||||
if (index != -1)
|
||||
{
|
||||
commandName = message.Substring(0, index).Trim();
|
||||
commandParams = message.Substring(index).Trim();
|
||||
}
|
||||
else
|
||||
commandName = message.Trim();
|
||||
|
||||
foreach (CommandBuilder command in Commands)
|
||||
{
|
||||
if (command.Name == commandName)
|
||||
{
|
||||
//Create a new instance of the required command type
|
||||
Command cmd = command.CreateCommand();
|
||||
|
||||
cmd.TechBot = this;
|
||||
cmd.Context = context;
|
||||
cmd.Parameters = commandParams;
|
||||
|
||||
try
|
||||
{
|
||||
cmd.Initialize();
|
||||
cmd.Run();
|
||||
cmd.DeInitialize();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ServiceOutput.WriteLine(context, string.Format("Uops! Just crashed with exception '{0}' at {1}",
|
||||
e.Message,
|
||||
e.Source));
|
||||
|
||||
ServiceOutput.WriteLine(context, e.StackTrace);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
using TechBot.IRCLibrary;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class TechBotService
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string chmPath;
|
||||
private string mainChm;
|
||||
private string ntstatusXml;
|
||||
private string winerrorXml;
|
||||
private string hresultXml;
|
||||
private string wmXml;
|
||||
private string svnCommand;
|
||||
private string bugUrl, WineBugUrl, SambaBugUrl;
|
||||
private ArrayList commands = new ArrayList();
|
||||
|
||||
public TechBotService(IServiceOutput serviceOutput,
|
||||
string chmPath,
|
||||
string mainChm,
|
||||
string ntstatusXml,
|
||||
string winerrorXml,
|
||||
string hresultXml,
|
||||
string wmXml,
|
||||
string svnCommand,
|
||||
string bugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.chmPath = chmPath;
|
||||
this.mainChm = mainChm;
|
||||
this.ntstatusXml = ntstatusXml;
|
||||
this.winerrorXml = winerrorXml;
|
||||
this.hresultXml = hresultXml;
|
||||
this.wmXml = wmXml;
|
||||
this.svnCommand = svnCommand;
|
||||
this.bugUrl = bugUrl;
|
||||
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 InjectMessage(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
if (message.StartsWith("!"))
|
||||
ParseCommandMessage(context,
|
||||
message);
|
||||
}
|
||||
|
||||
private bool IsCommandMessage(string message)
|
||||
{
|
||||
return message.StartsWith("!");
|
||||
}
|
||||
|
||||
public void ParseCommandMessage(MessageContext context,
|
||||
string message)
|
||||
{
|
||||
if (!IsCommandMessage(message))
|
||||
return;
|
||||
|
||||
message = message.Substring(1).Trim();
|
||||
int index = message.IndexOf(' ');
|
||||
string commandName;
|
||||
string parameters = "";
|
||||
if (index != -1)
|
||||
{
|
||||
commandName = message.Substring(0, index).Trim();
|
||||
parameters = message.Substring(index).Trim();
|
||||
}
|
||||
else
|
||||
commandName = message.Trim();
|
||||
|
||||
foreach (ICommand command in commands)
|
||||
{
|
||||
if (command.CanHandle(commandName))
|
||||
{
|
||||
command.Handle(context,
|
||||
commandName, parameters);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
86
irc/TechBot/TechBot.Library/WinerrorCommand.cs
Normal file
86
irc/TechBot/TechBot.Library/WinerrorCommand.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class WinerrorCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string winerrorXml;
|
||||
private XmlDocument winerrorXmlDocument;
|
||||
|
||||
public WinerrorCommand(IServiceOutput serviceOutput,
|
||||
string winerrorXml)
|
||||
{
|
||||
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,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string winerrorText = parameters;
|
||||
if (winerrorText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please provide a valid System Error Code value.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long winerror = np.Parse(winerrorText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid System Error Code value.",
|
||||
winerrorText));
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetWinerrorDescription(winerror);
|
||||
if (description != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
winerrorText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("I don't know about System Error Code {0}.",
|
||||
winerrorText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!winerror <value>";
|
||||
}
|
||||
|
||||
public string GetWinerrorDescription(long winerror)
|
||||
{
|
||||
XmlElement root = winerrorXmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
|
||||
winerror));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
104
irc/TechBot/TechBot.Library/WmCommand.cs
Normal file
104
irc/TechBot/TechBot.Library/WmCommand.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class WmCommand : BaseCommand, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string wmXml;
|
||||
private XmlDocument wmXmlDocument;
|
||||
|
||||
public WmCommand(IServiceOutput serviceOutput,
|
||||
string wmXml)
|
||||
{
|
||||
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,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string wmText = parameters;
|
||||
if (wmText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
"Please provide a valid window message value or name.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long wm = np.Parse(wmText);
|
||||
string output;
|
||||
if (np.Error)
|
||||
{
|
||||
// Assume "!wm <name>" form.
|
||||
output = GetWmNumber(wmText);
|
||||
}
|
||||
else
|
||||
{
|
||||
output = GetWmDescription(wm);
|
||||
}
|
||||
|
||||
if (output != null)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
wmText,
|
||||
output));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format("I don't know about window message {0}.",
|
||||
wmText));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!wm <value> or !wm <name>";
|
||||
}
|
||||
|
||||
private string GetWmDescription(long wm)
|
||||
{
|
||||
XmlElement root = wmXmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
|
||||
wm));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetWmNumber(string wmName)
|
||||
{
|
||||
XmlElement root = wmXmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
|
||||
wmName));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute value = node.Attributes["value"];
|
||||
if (value == null)
|
||||
throw new Exception("Node has no value attribute.");
|
||||
return value.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
<?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>
|
||||
<setting name="CommandPrefix" serializeAs="String">
|
||||
<value>@</value>
|
||||
</setting>
|
||||
</TechBot.Library.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
36
irc/TechBot/TechBot.cmbx
Normal file
36
irc/TechBot/TechBot.cmbx
Normal file
@@ -0,0 +1,36 @@
|
||||
<Combine fileversion="1.0" name="TechBot" description="">
|
||||
<StartMode startupentry="TechBot" single="True">
|
||||
<Execute entry="TechBot" type="None" />
|
||||
<Execute entry="TechBot.Library" type="None" />
|
||||
<Execute entry="CHMLibrary" type="None" />
|
||||
<Execute entry="Compression" type="None" />
|
||||
<Execute entry="TechBot.Console" type="None" />
|
||||
<Execute entry="TechBot.IRCLibrary" type="None" />
|
||||
</StartMode>
|
||||
<Entries>
|
||||
<Entry filename=".\TechBot\TechBot.prjx" />
|
||||
<Entry filename=".\TechBot.Library\TechBot.Library.prjx" />
|
||||
<Entry filename=".\CHMLibrary\CHMLibrary.prjx" />
|
||||
<Entry filename=".\Compression\Compression.prjx" />
|
||||
<Entry filename=".\TechBot.Console\TechBot.Console.prjx" />
|
||||
<Entry filename=".\TechBot.IRCLibrary\TechBot.IRCLibrary.prjx" />
|
||||
</Entries>
|
||||
<Configurations active="Debug">
|
||||
<Configuration name="Release">
|
||||
<Entry name="TechBot" configurationname="Debug" build="False" />
|
||||
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
|
||||
<Entry name="CHMLibrary" configurationname="Debug" build="False" />
|
||||
<Entry name="Compression" configurationname="Debug" build="False" />
|
||||
<Entry name="TechBot.Console" configurationname="Debug" build="False" />
|
||||
<Entry name="TechBot.IRCLibrary" configurationname="Debug" build="False" />
|
||||
</Configuration>
|
||||
<Configuration name="Debug">
|
||||
<Entry name="TechBot" configurationname="Debug" build="False" />
|
||||
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
|
||||
<Entry name="CHMLibrary" configurationname="Debug" build="False" />
|
||||
<Entry name="Compression" configurationname="Debug" build="False" />
|
||||
<Entry name="TechBot.Console" configurationname="Debug" build="False" />
|
||||
<Entry name="TechBot.IRCLibrary" configurationname="Debug" build="False" />
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</Combine>
|
@@ -1,68 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot", "TechBot\TechBot.csproj", "{106F437D-424B-4758-A69C-862D08D26F3D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compression", "Compression\Compression.csproj", "{E32307F1-623A-4E62-826F-56CDD4B23A54}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CHMLibrary", "CHMLibrary\CHMLibrary.csproj", "{72E5CCA1-6318-4D62-964D-CB23A5C743B5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Console", "TechBot.Console\TechBot.Console.csproj", "{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.IRCLibrary", "TechBot.IRCLibrary\TechBot.IRCLibrary.csproj", "{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Library", "TechBot.Library\TechBot.Library.csproj", "{1114F34D-F388-4F38-AE27-C0EE1B10B777}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.Common", "TechBot.Commands.Common\TechBot.Commands.Common.csproj", "{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.MSDN", "TechBot.Commands.MSDN\TechBot.Commands.MSDN.csproj", "{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.RBuild", "TechBot.Commands.RBuild\TechBot.Commands.RBuild.csproj", "{D676FEDE-62DD-4B4D-94C6-308598E827F9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D676FEDE-62DD-4B4D-94C6-308598E827F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D676FEDE-62DD-4B4D-94C6-308598E827F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D676FEDE-62DD-4B4D-94C6-308598E827F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D676FEDE-62DD-4B4D-94C6-308598E827F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@@ -1,44 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="TechBot.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="IRCServerHostName" value="irc.eu.freenode.net" />
|
||||
<add key="IRCServerHostPort" value="6667" />
|
||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||
<add key="IRCBotName" value="MyBot" />
|
||||
<add key="IRCBotPassword" value="MyPassword" />
|
||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||
<add key="MainChm" value="kmarch.chm" />
|
||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
||||
<add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
|
||||
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
||||
<add key="WmXml" value="C:\IRC\TechBot\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}" />
|
||||
</appSettings>
|
||||
<userSettings>
|
||||
<TechBot.Settings>
|
||||
<setting name="IRCServerHostName" serializeAs="String">
|
||||
<value>irc.eu.freenode.net</value>
|
||||
</setting>
|
||||
<setting name="IRCChannelNames" serializeAs="String">
|
||||
<value>rbuildbottest</value>
|
||||
</setting>
|
||||
<setting name="IRCBotName" serializeAs="String">
|
||||
<value>RBuildBot</value>
|
||||
</setting>
|
||||
<setting name="IRCBotPassword" serializeAs="String">
|
||||
<value>qwerty</value>
|
||||
</setting>
|
||||
<setting name="IRCServerHostPort" serializeAs="String">
|
||||
<value>6667</value>
|
||||
</setting>
|
||||
</TechBot.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="IRCServerHostName" value="irc.eu.freenode.net" />
|
||||
<add key="IRCServerHostPort" value="6667" />
|
||||
<add key="IRCChannelNames" value="channel1;channel2" />
|
||||
<add key="IRCBotName" value="MyBot" />
|
||||
<add key="IRCBotPassword" value="MyPassword" />
|
||||
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
|
||||
<add key="MainChm" value="kmarch.chm" />
|
||||
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
|
||||
<add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
|
||||
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
||||
<add key="WmXml" value="C:\IRC\TechBot\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}" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ServiceProcess;
|
||||
using System.Configuration.Install;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TechBot
|
||||
{
|
||||
[RunInstaller(true)]
|
||||
public class ProjectInstaller : Installer
|
||||
{
|
||||
public ProjectInstaller()
|
||||
{
|
||||
ServiceProcessInstaller spi = null;
|
||||
ServiceInstaller si = null;
|
||||
|
||||
spi = new ServiceProcessInstaller();
|
||||
spi.Account = ServiceAccount.LocalSystem;
|
||||
|
||||
si = new ServiceInstaller();
|
||||
si.ServiceName = "TechBot";
|
||||
si.StartType = ServiceStartMode.Automatic;
|
||||
|
||||
Installers.AddRange(new Installer[] { spi, si });
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,43 +1,84 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot
|
||||
{
|
||||
public class ServiceThread
|
||||
{
|
||||
private EventLog m_EventLog;
|
||||
|
||||
public ServiceThread(EventLog eventLog)
|
||||
{
|
||||
m_EventLog = eventLog;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
System.Console.WriteLine("TechBot irc service...");
|
||||
|
||||
IrcTechBotService ircService = new IrcTechBotService(
|
||||
Settings.Default.IRCServerHostName,
|
||||
Settings.Default.IRCServerHostPort,
|
||||
Settings.Default.IRCChannelNames,
|
||||
Settings.Default.IRCBotName,
|
||||
Settings.Default.IRCBotPassword);
|
||||
|
||||
ircService.Run();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_EventLog.WriteEntry(String.Format("Ex. {0}", ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using TechBot.Library;
|
||||
|
||||
namespace TechBot
|
||||
{
|
||||
public class ServiceThread
|
||||
{
|
||||
private string IRCServerHostName;
|
||||
private int IRCServerHostPort;
|
||||
private string IRCChannelNames;
|
||||
private string IRCBotName;
|
||||
private string IRCBotPassword;
|
||||
private string ChmPath;
|
||||
private string MainChm;
|
||||
private string NtstatusXml;
|
||||
private string HresultXml;
|
||||
private string WmXml;
|
||||
private string WinerrorXml;
|
||||
private string SvnCommand;
|
||||
private string BugUrl, WineBugUrl, SambaBugUrl;
|
||||
private EventLog eventLog;
|
||||
|
||||
public ServiceThread(EventLog eventLog)
|
||||
{
|
||||
this.eventLog = eventLog;
|
||||
}
|
||||
|
||||
private void SetupConfiguration()
|
||||
{
|
||||
IRCServerHostName = ConfigurationSettings.AppSettings["IRCServerHostName"];
|
||||
IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
|
||||
IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
|
||||
IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
|
||||
IRCBotPassword = ConfigurationSettings.AppSettings["IRCBotPassword"];
|
||||
ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
|
||||
MainChm = ConfigurationSettings.AppSettings["MainChm"];
|
||||
NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
|
||||
HresultXml = ConfigurationSettings.AppSettings["HresultXml"];
|
||||
WmXml = ConfigurationSettings.AppSettings["WmXml"];
|
||||
WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];
|
||||
SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];
|
||||
BugUrl = ConfigurationSettings.AppSettings["BugUrl"];
|
||||
WineBugUrl = ConfigurationSettings.AppSettings["WineBugUrl"];
|
||||
SambaBugUrl = ConfigurationSettings.AppSettings["SambaBugUrl"];
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
SetupConfiguration();
|
||||
System.Console.WriteLine("TechBot irc service...");
|
||||
|
||||
IrcService ircService = new IrcService(IRCServerHostName,
|
||||
IRCServerHostPort,
|
||||
IRCChannelNames,
|
||||
IRCBotName,
|
||||
IRCBotPassword,
|
||||
ChmPath,
|
||||
MainChm,
|
||||
NtstatusXml,
|
||||
WinerrorXml,
|
||||
HresultXml,
|
||||
WmXml,
|
||||
SvnCommand,
|
||||
BugUrl,
|
||||
WineBugUrl,
|
||||
SambaBugUrl);
|
||||
ircService.Run();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
eventLog.WriteEntry(String.Format("Ex. {0}", ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
86
irc/TechBot/TechBot/Settings.Designer.cs
generated
86
irc/TechBot/TechBot/Settings.Designer.cs
generated
@@ -1,86 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TechBot {
|
||||
|
||||
|
||||
[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.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")]
|
||||
public string IRCServerHostName {
|
||||
get {
|
||||
return ((string)(this["IRCServerHostName"]));
|
||||
}
|
||||
set {
|
||||
this["IRCServerHostName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest")]
|
||||
public string IRCChannelNames {
|
||||
get {
|
||||
return ((string)(this["IRCChannelNames"]));
|
||||
}
|
||||
set {
|
||||
this["IRCChannelNames"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("RBuildBot")]
|
||||
public string IRCBotName {
|
||||
get {
|
||||
return ((string)(this["IRCBotName"]));
|
||||
}
|
||||
set {
|
||||
this["IRCBotName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("qwerty")]
|
||||
public string IRCBotPassword {
|
||||
get {
|
||||
return ((string)(this["IRCBotPassword"]));
|
||||
}
|
||||
set {
|
||||
this["IRCBotPassword"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("6667")]
|
||||
public int IRCServerHostPort {
|
||||
get {
|
||||
return ((int)(this["IRCServerHostPort"]));
|
||||
}
|
||||
set {
|
||||
this["IRCServerHostPort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="IRCServerHostName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">irc.eu.freenode.net</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCChannelNames" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">rbuildbottest</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCBotName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">RBuildBot</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCBotPassword" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">qwerty</Value>
|
||||
</Setting>
|
||||
<Setting Name="IRCServerHostPort" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">6667</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{106F437D-424B-4758-A69C-862D08D26F3D}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TechBot</RootNamespace>
|
||||
<AssemblyName>TechBot</AssemblyName>
|
||||
<StartupObject>TechBot.TechBotService</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="ProjectInstaller.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ServiceThread.cs" />
|
||||
<Compile Include="Settings.Designer.cs">
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="TechBotService.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
|
||||
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
|
||||
<Name>TechBot.IRCLibrary</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
|
||||
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
|
||||
<Name>TechBot.Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -9,7 +9,7 @@ using System.Configuration.Install;
|
||||
|
||||
namespace TechBot
|
||||
{
|
||||
public class TechBotService : ServiceBase
|
||||
public class TechBotService : System.ServiceProcess.ServiceBase
|
||||
{
|
||||
private Thread thread;
|
||||
private ServiceThread threadWorker;
|
||||
@@ -80,3 +80,18 @@ namespace TechBot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RunInstaller(true)]
|
||||
public class ProjectInstaller : Installer
|
||||
{
|
||||
public ProjectInstaller()
|
||||
{
|
||||
ServiceProcessInstaller spi = new ServiceProcessInstaller();
|
||||
spi.Account = ServiceAccount.LocalSystem;
|
||||
|
||||
ServiceInstaller si = new ServiceInstaller();
|
||||
si.ServiceName = "TechBot";
|
||||
si.StartType = ServiceStartMode.Automatic;
|
||||
Installers.AddRange(new Installer[] {spi, si});
|
||||
}
|
||||
}
|
||||
|
2
msvc6/.cvsignore
Normal file
2
msvc6/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
*.ncb
|
||||
*.opt
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user