Permalink
Browse files

Irc notifications: add support for ssl and password protected servers

  • Loading branch information...
1 parent f27f302 commit 313946a0ef50ff79320997b00d184053737665da @rolfbjarne rolfbjarne committed Sep 14, 2011
@@ -32,13 +32,19 @@ public partial class DBIrcIdentity : DBRecord
{
private string _name;
private string _servers;
+ private string _password;
private string _channels;
private string _nicks;
+ private bool _use_ssl;
+ private bool _join_channels;
public string @name { get { return _name; } set { _name = value; } }
public string @servers { get { return _servers; } set { _servers = value; } }
+ public string @password { get { return _password; } set { _password = value; } }
public string @channels { get { return _channels; } set { _channels = value; } }
public string @nicks { get { return _nicks; } set { _nicks = value; } }
+ public bool @use_ssl { get { return _use_ssl; } set { _use_ssl = value; } }
+ public bool @join_channels { get { return _join_channels; } set { _join_channels = value; } }
public override string Table
@@ -51,7 +57,7 @@ public override string Table
{
get
{
- return new string [] { "name", "servers", "channels", "nicks" };
+ return new string [] { "name", "servers", "password", "channels", "nicks", "use_ssl", "join_channels" };
}
}
@@ -2,17 +2,21 @@
CodeBehind="Identities.aspx.cs" EnableViewState="false" %>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="Server">
+ <script type="text/javascript" src="Identities.js"></script>
<asp:Table runat="server" CssClass="center">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Center">
<asp:Table ID="tblIrcIdentities" runat="server" CssClass="buildstatus identity">
<asp:TableHeaderRow>
- <asp:TableHeaderCell ColumnSpan="5">IRC Identities</asp:TableHeaderCell>
+ <asp:TableHeaderCell ColumnSpan="8">IRC Identities</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableHeaderRow>
<asp:TableHeaderCell>Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Servers</asp:TableHeaderCell>
+ <asp:TableHeaderCell>Password</asp:TableHeaderCell>
+ <asp:TableHeaderCell>Use SSL</asp:TableHeaderCell>
<asp:TableHeaderCell>Channels</asp:TableHeaderCell>
+ <asp:TableHeaderCell>Join Channels</asp:TableHeaderCell>
<asp:TableHeaderCell>Nicks</asp:TableHeaderCell>
<asp:TableHeaderCell>Actions</asp:TableHeaderCell>
</asp:TableHeaderRow>
@@ -23,9 +27,18 @@
<asp:TableCell>
<asp:TextBox ID="txtIrcServers" runat="server" ToolTip="A comma separated list of irc servers" />
</asp:TableCell>
+ <asp:TableCell>
+ <asp:TextBox ID="txtPassword" runat="server" ToolTip="The password for the server(s) (if any)" />
+ </asp:TableCell>
+ <asp:TableCell>
+ <asp:CheckBox ID="chkUseSsl" Text="" runat="server" ToolTip="If the server(s) require SSL" />
+ </asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="txtIrcChannels" runat="server" ToolTip="A comma separated list of irc channels to join" />
</asp:TableCell>
+ <asp:TableCell>
+ <asp:CheckBox ID="chkJoinChannels" Text="" runat="server" ToolTip="If monkeywrench should join the channels." />
+ </asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="txtIrcNicks" runat="server" ToolTip="A comma separated list of irc nicks to use" />
</asp:TableCell>
@@ -36,6 +36,8 @@ protected void Page_Load (object sender, EventArgs e)
TableRow row;
try {
+ string action = Request ["action"];
+ int id;
foreach (TextBox tb in new TextBox [] { txtEmailEmail, txtEmailName, txtEmailPassword }) {
tb.Attributes.Add ("onfocus", "javascript: document.getElementById ('lblEmailHelp').innerHTML = '" + tb.ToolTip + "';");
@@ -50,13 +52,122 @@ protected void Page_Load (object sender, EventArgs e)
if (response.Exception != null) {
lblMessage.Text = response.Exception.Message;
} else {
+ if (!string.IsNullOrEmpty (action)) {
+ WebServiceResponse rsp;
+
+ switch (action) {
+ case "changeircname":
+ string name = Request ["name"];
+ if (!string.IsNullOrEmpty (name) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v1) => v1.id == id);
+ if (identity != null) {
+ identity.name = name;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "switchircssl":
+ if (int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v2) => v2.id == id);
+ if (identity != null) {
+ identity.use_ssl = !identity.use_ssl;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircchannels":
+ string channels = Request ["channels"];
+ if (!string.IsNullOrEmpty (channels) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v3) => v3.id == id);
+ if (identity != null) {
+ identity.channels = channels;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "switchjoinchannels":
+ if (int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v4) => v4.id == id);
+ if (identity != null) {
+ identity.join_channels = !identity.join_channels;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircnicks":
+ string nicks = Request ["nicks"];
+ if (!string.IsNullOrEmpty (nicks) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v5) => v5.id == id);
+ if (identity != null) {
+ identity.nicks = nicks;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircservers":
+ string servers = Request ["servers"];
+ if (!string.IsNullOrEmpty (servers) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v6) => v6.id == id);
+ if (identity != null) {
+ identity.servers = servers;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircpassword":
+ string password = Request ["password"];
+ if (int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v6) => v6.id == id);
+ if (identity != null) {
+ identity.password = password;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ }
+
+ Response.Redirect ("Identities.aspx", false);
+ return;
+ }
+
if (response.IrcIdentities != null) {
foreach (DBIrcIdentity irc in response.IrcIdentities) {
row = new TableRow ();
- row.Cells.Add (Utils.CreateTableCell (irc.name));
- row.Cells.Add (Utils.CreateTableCell (irc.servers));
- row.Cells.Add (Utils.CreateTableCell (irc.channels));
- row.Cells.Add (Utils.CreateTableCell (irc.nicks));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircname ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.name), HttpUtility.HtmlEncode (irc.name), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircservers ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.servers), HttpUtility.HtmlEncode (irc.servers), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircpassword ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.password), string.IsNullOrEmpty (irc.password) ? "(none)" : HttpUtility.HtmlEncode (irc.password), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='Identities.aspx?action=switchircssl&id={1}'>{0}</a>", irc.use_ssl ? "Yes" : "No", irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircchannels ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.channels), HttpUtility.HtmlEncode (irc.channels), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='Identities.aspx?action=switchjoinchannels&id={1}'>{0}</a>", irc.join_channels ? "Yes" : "No", irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircnicks ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.nicks), HttpUtility.HtmlEncode (irc.nicks), irc.id)));
row.Cells.Add (Utils.CreateTableCell (Utils.CreateLinkButton ("remove_irc_" + irc.id.ToString (), "Remove", "RemoveIrcIdentity", irc.id.ToString (), OnLinkButtonCommand)));
tblIrcIdentities.Rows.AddAt (tblIrcIdentities.Rows.Count - 1, row);
}
@@ -111,7 +222,10 @@ protected void lnkIrcAdd_Click (object sender, EventArgs e)
irc_identity.name = txtIrcName.Text;
irc_identity.nicks = txtIrcNicks.Text;
irc_identity.servers = txtIrcServers.Text;
+ irc_identity.join_channels = chkJoinChannels.Checked;
+ irc_identity.use_ssl = chkUseSsl.Checked;
irc_identity.channels = txtIrcChannels.Text;
+ irc_identity.password = txtPassword.Text ?? string.Empty;
if (string.IsNullOrEmpty (irc_identity.name))
throw new Exception ("You need to specify the name of the irc identity");

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,30 @@
+function changeircservers (id, current) {
+ var servers = prompt("Enter servers:", current);
+ if (servers != null && servers != "" && servers != current)
+ window.location = window.location.pathname + "?action=changeircservers&id=" + id + "&servers=" + encodeURIComponent(servers);
+}
+
+function changeircname(id, current) {
+ var newvalue = prompt("Enter name:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircname&id=" + id + "&name=" + encodeURIComponent(newvalue);
+}
+
+function changeircchannels(id, current) {
+ var newvalue = prompt("Enter channels:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircchannels&id=" + id + "&channels=" + encodeURIComponent(newvalue);
+}
+
+function changeircnicks(id, current) {
+ var newvalue = prompt("Enter nicks:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircnicks&id=" + id + "&nicks=" + encodeURIComponent(newvalue);
+}
+
+function changeircpassword(id, current) {
+ var newvalue = prompt("Enter password:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircpassword&id=" + id + "&password=" + encodeURIComponent(newvalue);
+}
+
@@ -54,6 +54,7 @@
<Content Include="BuildBotStatus.aspx" />
<Content Include="BuildBotStatus.js" />
<Content Include="clientaccesspolicy.xml" />
+ <Content Include="Identities.js" />
<Content Include="DownloadLatestFile.aspx" />
<Content Include="Identities.aspx" />
<Content Include="Master.js" />
@@ -62,7 +62,7 @@
<Project>{EBFBC3BF-10E1-4482-B9BE-A516934C099A}</Project>
<Name>MonkeyWrench</Name>
</ProjectReference>
- <ProjectReference Include="..\SmartIrc4net\SmartIrc4net-0.4.0-src\VisualStudio\2010\SmartIrc4net.csproj">
+ <ProjectReference Include="..\SmartIrc4net\smartirc4net-0.4.5.1\SmartIrc4net.csproj">
<Project>{19607F57-B521-4477-9DE0-F0D9B1A68BC7}</Project>
<Name>SmartIrc4net</Name>
</ProjectReference>
Oops, something went wrong.

0 comments on commit 313946a

Please sign in to comment.