private void SaveServerButton_Click(object sender, EventArgs e) { System.Diagnostics.Trace.Assert(current != null, "SaveServer button sould disabled if no server is selected"); // DONT translate this TransmissionServer ts = current.Tag as TransmissionServer; ts.StartPaused = StartPausedCheckBox.Checked; ts.Host = current.SubItems[1].Text = HostField.Text; ts.Port = (int)PortField.Value; current.SubItems[2].Text = ts.Port.ToString(); ts.RefreshRate = (int)RefreshRateValue.Value; ts.RefreshRateTray = (int)RefreshRateTrayValue.Value; ts.UseSSL = UseSSLCheckBox.Checked; ts.Username = UserField.Text; ts.Password = !ClearPasswordCheckBox.Checked ? PassField.Text : null; ts.Proxy.ProxyMode = (ProxyMode)EnableProxyCombo.SelectedIndex; ts.Proxy.Host = ProxyHostField.Text; ts.Proxy.Port = (int)ProxyPortField.Value; ts.Proxy.Username = ProxyUserField.Text; ts.Proxy.Password = !ClearProxyPasswordCheckBox.Checked ? ProxyPassField.Text : null; ts.RetryLimit = (int)RetryLimitValue.Value; ts.PlinkEnable = PlinkEnableCheckBox.Checked; ts.PlinkCmd = PlinkCmdTextBox.Text; ts.DownLimit = downloadLimitItems.Text; ts.UpLimit = uploadLimitItems.Text; ts.CustomPath = customPathTextBox.Text.Length > 0 ? customPathTextBox.Text : null; ts.SambaShareMappings.Clear(); foreach (SambaShareMappings s in listSambaShareMappings.Items) { ts.AddSambaMapping(s.UnixPathPrefix, s.SambaShare); } serversettingschanged = false; }
private void SaveSettings() { LocalSettings sett = Program.Settings; sett.MinToTray = MinToTrayCheckBox.Checked; sett.StartedBalloon = notificationOnAdditionCheckBox.Checked; sett.CompletedBaloon = notificationOnCompletionCheckBox.Checked; sett.ColorTray = ColorTrayIconCheckBox.Checked; sett.MinOnClose = minimizeOnCloseCheckBox.Checked; sett.UploadPrompt = UploadPromptCheckBox.Checked; sett.UseLocalCookies = useLocalCookiesCheckBox.Checked; sett.AutoCheckupdate = AutoCheckUpdateCheckBox.Checked; sett.UpdateToBeta = UpdateToBetaCheckBox.Checked; sett.AutoUpdateGeoip = AutoUpdateGeoipCheckBox.Checked; sett.DeleteTorrentWhenAdding = DeleteTorrentCheckBox.Checked; sett.DefaultDoubleClickAction = defaultActionComboBox.SelectedIndex; sett.PlinkPath = PlinkPathTextBox.Text; sett.StateImagePath = stateImageBrowse.FileName; sett.InfopanelImagePath = infopanelImageBrowse.FileName; sett.ToolbarImagePath = toolbarImageBrowse.FileName; sett.TrayImagePath = trayImageBrowse.FileName; sett.Servers.Clear(); foreach (ListViewItem lvi in listServers.Items) { TransmissionServer ts = lvi.Tag as TransmissionServer; sett.Servers.Add(lvi.Name, lvi.Tag as TransmissionServer); } if (AutoConnectComboBox.SelectedItem != null && sett.Servers.ContainsKey(AutoConnectComboBox.SelectedItem as string)) { sett.AutoConnect = AutoConnectComboBox.SelectedItem as string; } else { sett.AutoConnect = ""; } if (CurrentProfileComboBox.SelectedItem != null && sett.Servers.ContainsKey(CurrentProfileComboBox.SelectedItem as string)) { sett.CurrentProfile = CurrentProfileComboBox.SelectedItem as string; } else { sett.CurrentProfile = ""; } sett.DontSavePasswords = DontSavePasswordsCheckBox.Checked; sett.RssFeeds.Clear(); foreach (ListViewItem lvi in listRssFeeds.Items) { sett.RssFeeds.Add(lvi.Name, lvi.SubItems[1].Text); } sett.Commit(); if (StartOnSystemCheckBox.Checked) { Util.SetAutoStart(AboutDialog.AssemblyTitle, Toolbox.GetExecuteLocation()); } else { Util.UnSetAutoStart(AboutDialog.AssemblyTitle); } }
private ListViewItem CreateServerItem(string name, TransmissionServer ts) { ListViewItem lv = new ListViewItem(); lv.Name = lv.Text = name; lv.SubItems.Add(ts.Host); lv.SubItems.Add(ts.Port.ToString()); lv.Tag = ts; return(lv); }
private void addServerToolStripMenuItem_Click(object sender, EventArgs e) { TransmissionServer ts = new TransmissionServer(); string name; int counter = 0; do { name = "Server " + (counter++); } while (listServers.Items.ContainsKey(name)); listServers.Items.Add(CreateServerItem(name, ts)); CurrentProfileComboBox.Items.Add(name); AutoConnectComboBox.Items.Add(name); }
private void listServers_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (e.IsSelected) { current = e.Item; TransmissionServer ts = current.Tag as TransmissionServer; StartPausedCheckBox.Checked = ts.StartPaused; HostField.Text = ts.Host; PortField.Value = ts.Port; RefreshRateValue.Value = ts.RefreshRate; RefreshRateTrayValue.Value = ts.RefreshRateTray; UseSSLCheckBox.Checked = ts.UseSSL; PassField.Enabled = UserField.Enabled = EnableAuthCheckBox.Checked = ts.AuthEnabled; UserField.Text = ts.Username; PassField.Text = ts.Password; EnableProxyCombo.SelectedIndex = (int)ts.Proxy.ProxyMode; ProxyPortField.Enabled = ProxyHostField.Enabled = ts.Proxy.ProxyMode == ProxyMode.Enabled; ProxyHostField.Text = ts.Proxy.Host; ProxyPortField.Value = ts.Proxy.Port; ProxyAuthEnableCheckBox.Checked = ts.Proxy.AuthEnabled; ProxyUserField.Enabled = ProxyPassField.Enabled = (ts.Proxy.AuthEnabled && ts.Proxy.ProxyMode == ProxyMode.Enabled); ProxyUserField.Text = ts.Proxy.Username; ProxyPassField.Text = ts.Proxy.Password; RetryLimitValue.Value = ts.RetryLimit; PlinkEnableCheckBox.Checked = ts.PlinkEnable; PlinkCmdTextBox.Text = ts.PlinkCmd; downloadLimitItems.Text = ts.DownLimit; uploadLimitItems.Text = ts.UpLimit; customPathTextBox.Text = ts.CustomPath != null ? ts.CustomPath : ""; listSambaShareMappings.Items.Clear(); foreach (KeyValuePair <string, string> s in ts.SambaShareMappings) { listSambaShareMappings.Items.Add(new SambaShareMappings(s.Key, s.Value)); } } else { AskToSaveServerIfNeed(); } serversettingschanged = false; removeServerToolStripMenuItem.Enabled = removeServerButton.Enabled = tabServerSettings.Enabled = (listServers.SelectedItems.Count > 0); }
public static void SetupWebRequest(HttpWebRequest request, bool rpc, bool authenticate) { request.KeepAlive = false; request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate"); request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; request.UserAgent = $"{AboutDialog.AssemblyProduct}/{AboutDialog.AssemblyVersion}"; if (XTransmissionSessionId != null && authenticate && rpc) { request.Headers["X-Transmission-Session-Id"] = XTransmissionSessionId; } if (!rpc) { request.CookieContainer = PersistentCookies.GetCookieContainerForUrl(request.RequestUri); } TransmissionServer settings = Program.Settings.Current; if (settings.AuthEnabled && authenticate) { request.Credentials = new NetworkCredential(settings.Username, settings.ValidPassword); request.PreAuthenticate = Program.DaemonDescriptor.Version < 1.40 || Program.DaemonDescriptor.Version >= 1.6; } if (settings.Proxy.ProxyMode == ProxyMode.Enabled) { request.Proxy = new WebProxy(settings.Proxy.Host, settings.Proxy.Port); if (settings.Proxy.AuthEnabled) { string[] user = settings.Proxy.Username.Split("\\".ToCharArray(), 2); if (user.Length > 1) { request.Proxy.Credentials = new NetworkCredential(user[1], settings.Proxy.ValidPassword, user[0]); } else { request.Proxy.Credentials = new NetworkCredential(settings.Proxy.Username, settings.Proxy.ValidPassword); } } } else if (settings.Proxy.ProxyMode == ProxyMode.Disabled) { request.Proxy = null; } }
private void ClearDestPathHistoryButton_Click(object sender, EventArgs e) { TransmissionServer ts = current.Tag as TransmissionServer; ts.ClearDestPathHistory(); }