private void button1_Click(object sender, EventArgs e) { bool withoption = useTorrentLoadDialogCheckBox.Enabled ? useTorrentLoadDialogCheckBox.Checked : false; if (Program.DaemonDescriptor.Version >= 1.50 && !withoption) { Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.TorrentAddByUrl(urlTextBox.Text, addOurCookiesCheckBox.Checked))); this.Close(); } else { try { string target = Path.GetTempFileName(); toolStripStatusLabel.Text = OtherStrings.Downloading + "..."; downloadProgressBar.Value = 0; downloadProgressBar.Visible = true; okDialogButton.Enabled = false; WebClient webClient = new TransmissionWebClient(false, false); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted); webClient.DownloadFileAsync(this.currentUri, target, target); } catch (Exception ex) { HandleException(ex); } } }
public static TransmissionWebClient RequestAsync(JsonObject data, bool allowRecursion) { TransmissionWebClient wc = new TransmissionWebClient(true, true); byte[] bdata = GetBytes(data.ToString()); int r = requestid++; #if LOGRPC Program.LogDebug("RPC request: " + r, data.ToString()); #endif wc.UploadDataCompleted += new UploadDataCompletedEventHandler(wc_UploadDataCompleted); wc.UploadDataAsync(new Uri(Program.Settings.Current.RpcUrl), null, bdata, new TransmissonRequest(r, bdata, allowRecursion)); return wc; }
public static TransmissionWebClient RequestAsync(JsonObject data, bool allowRecursion) { TransmissionWebClient wc = new TransmissionWebClient(true, true); byte[] bdata = GetBytes(data.ToString()); int r = _requestid++; #if LOGRPC Program.LogDebug("RPC request: " + r, data.ToString()); #endif wc.UploadDataCompleted += wc_UploadDataCompleted; wc.UploadDataAsync(new Uri(Program.Settings.Current.RpcUrl), null, bdata, new TransmissonRequest(r, bdata, allowRecursion)); return(wc); }
private void AddTorrentFromRss(bool options) { try { RssItem ri = rssItemsListView.SelectedItems[0].Tag as RssItem; string target = Path.GetTempFileName(); toolStripStatusLabel1.Text = OtherStrings.Downloading + "..."; toolStripDownloadProgressBar.Value = 0; toolStripDownloadProgressBar.Visible = true; WebClient webClient = new TransmissionWebClient(false, false); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); webClient.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) { webClient_DownloadFileCompleted(sender, e, target, options); }; webClient.DownloadFileAsync(new Uri(ri.Link), target); } catch (Exception ex) { HandleException(ex); } }
private void DoCheckGeoip(bool alwaysnotify) { Directory.CreateDirectory(Toolbox.GetApplicationData()); TransmissionWebClient client = new TransmissionWebClient(false, false); client.DownloadFileCompleted += delegate (object sender, AsyncCompletedEventArgs e) { geoip_DownloadFileCompleted(e, alwaysnotify); }; #if PORTABLE client.DownloadFileAsync(new Uri("http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"), Toolbox.LocateFile(GeoIPCountry.GEOIP_DATABASE_FILE_COMPRESSED, false, Toolbox.GetExecuteDirectory())); #else client.DownloadFileAsync(new Uri("http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"), Toolbox.LocateFile(GeoIPCountry.GEOIP_DATABASE_FILE_COMPRESSED, false, Toolbox.GetApplicationData())); #endif }
private void checkVersionWorker_DoWork(object sender, DoWorkEventArgs e) { TransmissionWebClient client = new TransmissionWebClient(false, false); string response = client.DownloadString(Program.Settings.UpdateToBeta ? LATEST_VERSION_BETA : LATEST_VERSION); if (!response.StartsWith("#LATESTVERSION#")) throw new FormatException("Response didn't contain the identification prefix."); string[] latestVersion = response.Remove(0, 15).Split('.'); if (latestVersion.Length != 4) throw new FormatException("Incorrect number format"); e.Result = new Version(int.Parse(latestVersion[0]), int.Parse(latestVersion[1]), int.Parse(latestVersion[2]), int.Parse(latestVersion[3])); }
public TransmissionWebClient SetupAction(TransmissionWebClient twc) { twc.Completed += new EventHandler<ResultEventArgs>(twc_Completed); return twc; }
private void AddTorrentFromRss(bool options) { try { RssItem ri = rssItemsListView.SelectedItems[0].Tag as RssItem; string target = Path.GetTempFileName(); toolStripStatusLabel1.Text = OtherStrings.Downloading + "..."; toolStripDownloadProgressBar.Value = 0; toolStripDownloadProgressBar.Visible = true; WebClient webClient = new TransmissionWebClient(false, false); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); webClient.DownloadFileCompleted += delegate (object sender, AsyncCompletedEventArgs e) { webClient_DownloadFileCompleted(sender, e, target, options); }; webClient.DownloadFileAsync(new Uri(ri.Link), target); } catch (Exception ex) { HandleException(ex); } }