private void ApplicationSetup_Load(object sender, EventArgs e) { try { this.Text = string.Format(Strings.ApplicationSetup.DialogTitle, License.VersionNumbers.Version); m_isUpdating = true; m_connection = new DataFetcherNested(Program.DataConnection); m_settings = new ApplicationSettings(m_connection); RecentDuration.Value = m_settings.RecentBackupDuration; TempPath.Text = m_settings.TempPath; UseCommonPassword.Checked = m_settings.UseCommonPassword; CommonPassword.Text = CommonPassword.InitialPassword = m_settings.CommonPassword; CommonPassword.AskToEnterNewPassword = !string.IsNullOrEmpty(CommonPassword.Text); if (EncryptionModule.Items.Count > 0) { bool foundEncryption = false; int defaultIndex = 0; for (int i = 0; i < EncryptionModule.Items.Count; i++) if (((ComboBoxItemPair<Library.Interface.IEncryption>)EncryptionModule.Items[i]).Value.FilenameExtension == m_settings.CommonPasswordEncryptionModule) { foundEncryption = true; EncryptionModule.SelectedIndex = i; break; } else if (((ComboBoxItemPair<Library.Interface.IEncryption>)EncryptionModule.Items[i]).Value.FilenameExtension == "aes") defaultIndex = i; if (!foundEncryption) EncryptionModule.SelectedIndex = defaultIndex; } else { PasswordDefaultsGroup.Enabled = false; } SignatureCacheEnabled.Checked = m_settings.SignatureCacheEnabled; SignatureCachePath.Text = m_settings.SignatureCachePath; CalculateSignatureCacheSize(); StartupDelayDuration.Value = m_settings.StartupDelayDuration; ThreadPriorityPicker.SelectedPriority = m_settings.ThreadPriorityOverride; Bandwidth.UploadLimit = m_settings.UploadSpeedLimit; Bandwidth.DownloadLimit = m_settings.DownloadSpeedLimit; HideDonateButton.Checked = m_settings.HideDonateButton; BalloonNotificationLevel.SelectedItem = null; foreach(ComboBoxItemPair<ApplicationSettings.NotificationLevel> p in BalloonNotificationLevel.Items) if (p.Value == m_settings.BallonNotificationLevel) { BalloonNotificationLevel.SelectedItem = p; break; } if (string.IsNullOrEmpty(m_settings.DisplayLanguage)) LanguageSelection.SelectedIndex = 0; else { try { LanguageSelection.SelectedIndex = -1; System.Globalization.CultureInfo cci = System.Globalization.CultureInfo.GetCultureInfo(m_settings.DisplayLanguage); for(int i = 0; i < LanguageSelection.Items.Count; i++) if (((ComboBoxItemPair<CultureInfo>)LanguageSelection.Items[i]).Value == cci) { LanguageSelection.SelectedIndex = i; break; } } catch { LanguageSelection.SelectedIndex = -1; } } try { foreach (Library.Interface.ISettingsControl ic in Library.DynamicLoader.SettingsControlLoader.Modules) { Control c = ic.GetControl(m_settings.CreateDetachedCopy(), Datamodel.SettingExtension.GetExtensions(m_connection, ic.Key)); c.Dock = DockStyle.Fill; TabPage tab = new TabPage(); tab.Text = ic.PageTitle; tab.ToolTipText = ic.PageDescription; tab.Controls.Add(c); tab.Tag = ic; TabContainer.TabPages.Add(tab); } } catch (Exception ex) { MessageBox.Show(this, string.Format(Strings.ApplicationSetup.SettingControlsLoadError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } //Place the license page last TabContainer.TabPages.Remove(LicenseTab); TabContainer.TabPages.Insert(TabContainer.TabPages.Count, LicenseTab); string licensePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "licenses"); List<Duplicati.License.LicenseEntry> licenses = Duplicati.License.LicenseReader.ReadLicenses(licensePath); licenses.Insert(0, new Duplicati.License.LicenseEntry("Duplicati", System.IO.Path.Combine(licensePath, "duplicati-url.txt"), System.IO.Path.Combine(licensePath, "license.txt"))); licenses.Insert(0, new Duplicati.License.LicenseEntry("Acknowledgements", System.IO.Path.Combine(licensePath, "duplicati-url.txt"), System.IO.Path.Combine(licensePath, "acknowledgements.txt"))); LicenseSections.Items.Clear(); LicenseSections.Items.AddRange(licenses.ToArray()); LicenseSections.SelectedIndex = -1; LicenseSections.SelectedIndex = 0; } finally { m_isUpdating = false; } }
public virtual string GetConfiguration(Dictionary<string, string> options) { //Schedule settings have lowest priority, because there is currently no setup SetupSchedule(options); //Now setup the environment ApplicationSettings appSet = new ApplicationSettings(this.Task.DataParent); if (this.Task.ExistsInDb && appSet.SignatureCacheEnabled && !string.IsNullOrEmpty(appSet.SignatureCachePath)) options["signature-cache-path"] = System.IO.Path.Combine(System.Environment.ExpandEnvironmentVariables(appSet.SignatureCachePath), this.Task.Schedule.ID.ToString()); if (!string.IsNullOrEmpty(appSet.TempPath)) { string tempdir = System.Environment.ExpandEnvironmentVariables(appSet.TempPath); if (!System.IO.Directory.Exists(tempdir)) System.IO.Directory.CreateDirectory(tempdir); options["tempdir"] = tempdir; } Dictionary<string, string> env = appSet.CreateDetachedCopy(); //Inject the encryption, backend and compression module names into the environment env["encryption-module"] = this.Task.EncryptionModule; env["compression-module"] = this.Task.CompressionModule; env["backend-module"] = this.Task.Service; //If there are any control extensions, let them modify the environment foreach (Library.Interface.ISettingsControl ic in Library.DynamicLoader.SettingsControlLoader.Modules) ic.GetConfiguration(env, SettingExtension.GetExtensions(this.Task.Schedule.DataParent, ic.Key), options); //Setup encryption module SetupEncryptionModule(env, this.Task.EncryptionSettingsLookup, options); //Setup compression module SetupCompressionModule(env, this.Task.CompressionSettingsLookup, options); //Next is the actual backend setup string destination = SetupBackend(env, options); //Setup any task options SetupTask(options); //Setup any task extension options SetupTaskExtensions(options); //Override everything set in the overrides, this is placed last so it cannot be overriden elsewhere foreach (TaskOverride ov in this.Task.TaskOverrides) options[ov.Name] = ov.Value; return destination; }