protected override void OnLinkClicked(LinkClickedEventArgs e) { base.OnLinkClicked(e); if (e.LinkText.StartsWith("\\\\arlnk://")) { DecryptedHashlink hashlink = Hashlink.DecodeHashlink(e.LinkText.Substring(10)); if (hashlink != null) { this.HashlinkClicked(hashlink, EventArgs.Empty); } } else if (e.LinkText.StartsWith("\\\\cb0t://script/?file=")) { String str = e.LinkText.Substring(22); if (!String.IsNullOrEmpty(str)) { Scripting.ScriptManager.InstallScript(str); } } else if (e.LinkText.StartsWith("\\\\voice_clip_#")) { String vc_check = e.LinkText.Substring(14); uint vc_finder = 0; if (uint.TryParse(vc_check, out vc_finder)) { VoicePlayerItem vc = VoicePlayer.Records.Find(x => x.ShortCut == vc_finder); if (vc != null) { vc.Auto = false; VoicePlayer.QueueItem(vc); } } } else { String check = e.LinkText.ToUpper(); if (check.StartsWith("HTTP://") || check.StartsWith("HTTPS://") || check.StartsWith("WWW.")) { Scripting.JSOutboundTextItem cb = new Scripting.JSOutboundTextItem(); cb.Type = Scripting.JSOutboundTextItemType.Link; cb.Text = e.LinkText; cb.EndPoint = this.EndPoint; Scripting.ScriptManager.PendingUIText.Enqueue(cb); } } }
private void button1_Click(object sender, EventArgs e) { String hashlink = this.textBox1.Text.Trim(' ', '\r', '\n'); if (hashlink.StartsWith("arlnk://")) { hashlink = hashlink.Substring(8); } DecryptedHashlink h = Hashlink.DecodeHashlink(hashlink); if (h != null) { this.JoinFromHashlink(h, EventArgs.Empty); } else { MessageBox.Show("Invalid hashlink", "cb0t", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static DecryptedHashlink DecodeHashlink(String hashlink) { DecryptedHashlink room = new DecryptedHashlink(); try { if (hashlink.ToUpper().StartsWith("CHATROOM:")) // not encrypted { hashlink = hashlink.Substring(9); int split = hashlink.IndexOf(":"); room.IP = IPAddress.Parse(hashlink.Substring(0, split)); hashlink = hashlink.Substring(split + 1); split = hashlink.IndexOf("|"); room.Port = ushort.Parse(hashlink.Substring(0, split)); room.Name = hashlink.Substring(split + 1); return(room); } else // encrypted { byte[] buf = Convert.FromBase64String(hashlink); buf = d67(buf, 28435); buf = Zip.Decompress(buf); HashlinkReader reader = new HashlinkReader(buf); reader.SkipBytes(32); room.IP = reader; room.Port = reader; reader.SkipBytes(4); room.Name = reader; return(room); } } catch // badly formed hashlink { return(null); } }
private void toolStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Equals(this.toolStripButton2)) { this.accuTextBox1.AppendText("\x00026"); this.accuTextBox1.SelectionStart = this.accuTextBox1.Text.Length; } else if (e.ClickedItem.Equals(this.toolStripButton3)) { this.accuTextBox1.AppendText("\x00029"); this.accuTextBox1.SelectionStart = this.accuTextBox1.Text.Length; } else if (e.ClickedItem.Equals(this.toolStripButton4)) { this.accuTextBox1.AppendText("\x00027"); this.accuTextBox1.SelectionStart = this.accuTextBox1.Text.Length; } else if (e.ClickedItem.Equals(this.toolStripButton5)) { SharedUI.CMenu.StartPosition = FormStartPosition.Manual; SharedUI.CMenu.Location = new Point(MousePosition.X - 40, MousePosition.Y - 164); SharedUI.CMenu.SetCallback(this, false); SharedUI.CMenu.Show(); } else if (e.ClickedItem.Equals(this.toolStripButton6)) { SharedUI.CMenu.StartPosition = FormStartPosition.Manual; SharedUI.CMenu.Location = new Point(MousePosition.X - 40, MousePosition.Y - 164); SharedUI.CMenu.SetCallback(this, true); SharedUI.CMenu.Show(); } else if (e.ClickedItem.Equals(this.toolStripButton7)) { SharedUI.EMenu.StartPosition = FormStartPosition.Manual; SharedUI.EMenu.Location = new Point(MousePosition.X - 40, MousePosition.Y - 300); SharedUI.EMenu.SetCallback(this); SharedUI.EMenu.Show(); } else if (e.ClickedItem.Equals(this.toolStripButton9)) { this.WantScribble(null, EventArgs.Empty); } else if (e.ClickedItem.Equals(this.toolStripLabel1)) { if (this.url_tag.StartsWith("\\\\arlnk://")) { DecryptedHashlink hashlink = Hashlink.DecodeHashlink(this.url_tag.Substring(10)); if (hashlink != null) { this.HashlinkClicked(hashlink, EventArgs.Empty); } } else if (this.url_tag.StartsWith("arlnk://")) { DecryptedHashlink hashlink = Hashlink.DecodeHashlink(this.url_tag.Substring(8)); if (hashlink != null) { this.HashlinkClicked(hashlink, EventArgs.Empty); } } else { String check = this.url_tag.ToUpper(); if (check.StartsWith("HTTP://") || check.StartsWith("HTTPS://") || check.StartsWith("WWW.")) { Scripting.JSOutboundTextItem cb = new Scripting.JSOutboundTextItem(); cb.Type = Scripting.JSOutboundTextItemType.Link; cb.Text = this.url_tag; cb.EndPoint = this.EndPoint; Scripting.ScriptManager.PendingUIText.Enqueue(cb); } } } }
private void ClientConnected(IAsyncResult result) { this.listener.EndWaitForConnection(result); List <byte> list = new List <byte>(); byte[] buf = new byte[1024]; int size = 0; while ((size = listener.Read(buf, 0, 1024)) > 0) { list.AddRange(buf.Take(size)); } String str = Encoding.UTF8.GetString(list.ToArray()); if (!String.IsNullOrEmpty(str)) { if (str.StartsWith("cb0t://")) { str = str.Substring(7); if (str.StartsWith("script/?file=")) { String filename = str.Substring(13); if (!String.IsNullOrEmpty(filename)) { Scripting.ScriptManager.InstallScript(filename); } } else { DecryptedHashlink dh = Hashlink.DecodeHashlink(str); if (dh == null) { if (str.EndsWith("/")) { str = str.Substring(0, str.Length - 1); } } dh = Hashlink.DecodeHashlink(str); if (dh != null) { this.HashlinkReceived(null, new IPCListenerEventArgs { Hashlink = dh }); } } } else if (str.StartsWith("cbjl_")) { str = str.Substring(5); this.CommandReceived(null, new IPCListenerEventArgs { Command = str }); } } this.listener.Disconnect(); this.listener.BeginWaitForConnection(new AsyncCallback(this.ClientConnected), null); }