/// <summary> /// override the method to handle adding stealthnet links to downloads. /// the message is send by the class program.cs /// </summary> /// <param name="m">recieved message</param> protected override void WndProc(ref Message m) { switch (m.Msg) { // respond only to the copydata message case Win32APIWrapper.WM_COPYDATA: Win32APIWrapper.CopyDataStruct st = (Win32APIWrapper.CopyDataStruct)Marshal.PtrToStructure(m.LParam, typeof(Win32APIWrapper.CopyDataStruct)); string strData = Marshal.PtrToStringUni(st.lpData); try { if (strData.EndsWith(".sncollection")) { Core.ParseStealthNetCollection(strData); } else { StealthNetLink stealthNetLink = new StealthNetLink(strData); Core.AddDownload(stealthNetLink.FileHash, stealthNetLink.FileName, stealthNetLink.FileSize, null); } } catch { // ignore invalid links } break; default: // let the base class deal with it base.WndProc(ref m); break; } }
private void DownloadDialog_Load(object sender, EventArgs e) { string clipboardText = Clipboard.GetText(); if (Regex.IsMatch(clipboardText, "^[0-9A-F]{128,128}$", RegexOptions.IgnoreCase)) { stealthnetLinkTextBox.Text = clipboardText; } else { try { StealthNetLink stealthNetLink = new StealthNetLink(clipboardText); stealthnetLinkTextBox.Text = clipboardText; } catch { } } }
private void DownloadDialog_Load(object sender, EventArgs e) { string clipboardText = Clipboard.GetText(); if (Regex.IsMatch(clipboardText, "^[0-9A-F]{128,128}$", RegexOptions.IgnoreCase)) { stealthnetLinkTextBox.Text = clipboardText; } else { try { StealthNetLink stealthNetLink = new StealthNetLink(clipboardText); stealthnetLinkTextBox.Text = clipboardText; } catch { } } }
private void fileHashTextBox_TextChanged(object sender, EventArgs e) { // 2007-11-10 T.Norad check if the text is a valid stealthnet link // 2008-01-20 T.Norad hack for old hashes. could removed in further version if (Regex.IsMatch(stealthnetLinkTextBox.Text, "^[0-9A-F]{128,128}$", RegexOptions.IgnoreCase)) { downloadButton.Enabled = true; } else { try { StealthNetLink stealthNetLink = new StealthNetLink(stealthnetLinkTextBox.Text); downloadButton.Enabled = true; } catch { downloadButton.Enabled = false; } } }
//2008-03-20 Nochbaer Limit removed private void downloadButton_Click(object sender, EventArgs e) { try { // 2008-01-20 T.Norad hack for old hashes. could removed in further version if (Regex.IsMatch(stealthnetLinkTextBox.Text, "^[0-9A-F]{128,128}$", RegexOptions.IgnoreCase)) { Core.AddDownload(Core.FileHashStringToFileHash(stealthnetLinkTextBox.Text), stealthnetLinkTextBox.Text, 0, subFolderTextBox.Text); Close(); } else { // 2007-11-10 T.Norad create a stealthnet link and add download StealthNetLink stealthNetLink = new StealthNetLink(stealthnetLinkTextBox.Text); Core.AddDownload(stealthNetLink.FileHash, stealthNetLink.FileName, stealthNetLink.FileSize, subFolderTextBox.Text); Close(); } } catch (Exception ex) { toolStripStatusLabel.Image = Properties.Resources.error_16x16; toolStripStatusLabel.Text = ex.Message; } }
//2008-03-20 Nochbaer Limit removed private void downloadButton_Click(object sender, EventArgs e) { try { // 2008-01-20 T.Norad hack for old hashes. could removed in further version if (Regex.IsMatch(stealthnetLinkTextBox.Text, "^[0-9A-F]{128,128}$", RegexOptions.IgnoreCase)) { Core.AddDownload(Core.FileHashStringToFileHash(stealthnetLinkTextBox.Text), stealthnetLinkTextBox.Text, 0, subFolderTextBox.Text); Close(); } else { // 2007-11-10 T.Norad create a stealthnet link and add download StealthNetLink stealthNetLink = new StealthNetLink(stealthnetLinkTextBox.Text); Core.AddDownload(stealthNetLink.FileHash, stealthNetLink.FileName, stealthNetLink.FileSize, subFolderTextBox.Text); Close(); } } catch (Exception ex) { toolStripStatusLabel.Image = Properties.Resources.error_16x16; toolStripStatusLabel.Text = ex.Message; } }
private static void StartDownloadByLink2(string command) { if (command == null) throw new ArgumentNullException("command"); Console.WriteLine(); try { StealthNetLink link = new StealthNetLink(command); Core.AddDownload(link.FileHash, link.FileName, link.FileSize, string.Empty); if (Core.DownloadsAndQueue.Count <= Constants.MaximumDownloadsCount) Console.WriteLine("The download has been started..."); else Console.WriteLine("The download has been queued..."); } catch (Exception ex) { string s = "An exception was thrown while starting the download!"; Console.WriteLine(s); Logger.Instance.Log(ex, s); } Console.WriteLine(); }
public static void ParseStealthNetCollection(string filepath) { try { String subfolder = ""; if (bool.Parse(Settings.Instance["SubFoldersForCollections"])) { subfolder = Path.GetFileNameWithoutExtension(filepath); } String line = ""; if (File.Exists(filepath)) { System.IO.StreamReader sr = new StreamReader(filepath); while ((line = sr.ReadLine()) != null) { StealthNetLink link = new StealthNetLink(line); Core.AddDownload(link.FileHash, link.FileName, link.FileSize, subfolder); } sr.Close(); } } catch (Exception ex) { m_Logger.Log(ex, "An exception was thrown while parsing {0}!", filepath); } }
private void fileHashTextBox_TextChanged(object sender, EventArgs e) { // 2007-11-10 T.Norad check if the text is a valid stealthnet link // 2008-01-20 T.Norad hack for old hashes. could removed in further version if (Regex.IsMatch(stealthnetLinkTextBox.Text, "^[0-9A-F]{128,128}$", RegexOptions.IgnoreCase)) { downloadButton.Enabled = true; } else { try { StealthNetLink stealthNetLink = new StealthNetLink(stealthnetLinkTextBox.Text); downloadButton.Enabled = true; } catch { downloadButton.Enabled = false; } } }
/// <summary> /// override the method to handle adding stealthnet links to downloads. /// the message is send by the class program.cs /// </summary> /// <param name="m">recieved message</param> protected override void WndProc(ref Message m) { switch (m.Msg) { // respond only to the copydata message case Win32APIWrapper.WM_COPYDATA: Win32APIWrapper.CopyDataStruct st = (Win32APIWrapper.CopyDataStruct)Marshal.PtrToStructure(m.LParam, typeof(Win32APIWrapper.CopyDataStruct)); string strData = Marshal.PtrToStringUni(st.lpData); try { if (strData.EndsWith(".sncollection")) { Core.ParseStealthNetCollection(strData); } else { StealthNetLink stealthNetLink = new StealthNetLink(strData); Core.AddDownload(stealthNetLink.FileHash, stealthNetLink.FileName, stealthNetLink.FileSize, null); } } catch { // ignore invalid links } break; default: // let the base class deal with it base.WndProc(ref m); break; } }