diff --git a/Duplicati/Datamodel/Backends/FTP.cs b/Duplicati/Datamodel/Backends/FTP.cs index 71e158889..adff5c2f1 100644 --- a/Duplicati/Datamodel/Backends/FTP.cs +++ b/Duplicati/Datamodel/Backends/FTP.cs @@ -69,6 +69,10 @@ namespace Duplicati.Datamodel.Backends env["FTP_PASSWORD"] = this.Password; } + public string FriendlyName { get { return "FTP host"; } } + public string SystemName { get { return "ftp"; } } + public void SetService() { m_owner.Service = this.SystemName; } + #endregion } } diff --git a/Duplicati/Datamodel/Backends/File.cs b/Duplicati/Datamodel/Backends/File.cs index c25d95e7d..dc618b431 100644 --- a/Duplicati/Datamodel/Backends/File.cs +++ b/Duplicati/Datamodel/Backends/File.cs @@ -79,6 +79,10 @@ namespace Duplicati.Datamodel.Backends args.Add(this.TimeSeparator); } + public string FriendlyName { get { return "External drive or folder"; } } + public string SystemName { get { return "file"; } } + public void SetService() { m_owner.Service = this.SystemName; } + #endregion } } diff --git a/Duplicati/Datamodel/Backends/IBackend.cs b/Duplicati/Datamodel/Backends/IBackend.cs index 8d73a6565..75d561d4a 100644 --- a/Duplicati/Datamodel/Backends/IBackend.cs +++ b/Duplicati/Datamodel/Backends/IBackend.cs @@ -28,5 +28,9 @@ namespace Duplicati.Datamodel.Backends { string GetDestinationPath(); void GetExtraSettings(List args, StringDictionary env); + string FriendlyName { get; } + string SystemName { get; } + void SetService(); + } } diff --git a/Duplicati/Datamodel/Backends/S3.cs b/Duplicati/Datamodel/Backends/S3.cs index 3af21509f..badc299ef 100644 --- a/Duplicati/Datamodel/Backends/S3.cs +++ b/Duplicati/Datamodel/Backends/S3.cs @@ -103,6 +103,10 @@ namespace Duplicati.Datamodel.Backends env["AWS_ACCESS_KEY"] = this.AccessKey; } + public string FriendlyName { get { return "Amazon S3"; } } + public string SystemName { get { return "s3"; } } + public void SetService() { m_owner.Service = this.SystemName; } + #endregion } } diff --git a/Duplicati/Datamodel/Backends/SSH.cs b/Duplicati/Datamodel/Backends/SSH.cs index 34dc1f042..b70d18e85 100644 --- a/Duplicati/Datamodel/Backends/SSH.cs +++ b/Duplicati/Datamodel/Backends/SSH.cs @@ -106,6 +106,10 @@ namespace Duplicati.Datamodel.Backends env["FTP_PASSWORD"] = this.Password; } + public string FriendlyName { get { return "SSH host"; } } + public string SystemName { get { return "ssh"; } } + public void SetService() { m_owner.Service = this.SystemName; } + #endregion } } diff --git a/Duplicati/Datamodel/Task.Extension.cs b/Duplicati/Datamodel/Task.Extension.cs index 728978908..5af494daa 100644 --- a/Duplicati/Datamodel/Task.Extension.cs +++ b/Duplicati/Datamodel/Task.Extension.cs @@ -53,6 +53,8 @@ namespace Duplicati.Datamodel return new Backends.S3(this); case "file": return new Backends.File(this); + case "ftp": + return new Backends.FTP(this); } return null; diff --git a/Duplicati/Duplicati.csproj b/Duplicati/Duplicati.csproj index 05e4f0709..917e89210 100644 --- a/Duplicati/Duplicati.csproj +++ b/Duplicati/Duplicati.csproj @@ -169,6 +169,12 @@ SelectFiles.cs + + UserControl + + + SelectName.cs + UserControl @@ -323,6 +329,10 @@ Designer SelectFiles.cs + + Designer + SelectName.cs + Designer SelectWhen.cs diff --git a/Duplicati/HelperControls/BackupTreeView.cs b/Duplicati/HelperControls/BackupTreeView.cs index a6e8a055e..d3b908eb8 100644 --- a/Duplicati/HelperControls/BackupTreeView.cs +++ b/Duplicati/HelperControls/BackupTreeView.cs @@ -39,7 +39,35 @@ namespace Duplicati.HelperControls InitializeComponent(); } - public void Setup(IDataFetcher connection, bool allowEdit) + public string SelectedFolder + { + get + { + if (treeView.SelectedNode == null) + return ""; + else + { + string s = treeView.SelectedNode.FullPath; + if (s == treeView.SelectedNode.Text) + return ""; + else + return s.Substring(0, s.Length - treeView.SelectedNode.Text.Length - treeView.PathSeparator.Length); + } + } + + set + { + TreeNode match; + FindNode(value, false, out match); + if (match != null) + match.TreeView.SelectedNode = match; + else + treeView.SelectedNode = null; + } + } + + + public void Setup(IDataFetcher connection, bool allowEdit, bool onlyFolders) { m_connection = connection; m_allowEdit = allowEdit; @@ -54,19 +82,32 @@ namespace Duplicati.HelperControls t.ImageIndex = t.SelectedImageIndex = imageList.Images.IndexOfKey("Backup"); t.Tag = s; + TreeNodeCollection col; + if (string.IsNullOrEmpty(s.Path)) - treeView.Nodes.Add(t); + col = treeView.Nodes; else - FindNode(s.Path, true).Add(t); + col = FindNode(s.Path, true); + + if (!onlyFolders) + col.Add(t); } treeView.LabelEdit = m_allowEdit; } private TreeNodeCollection FindNode(string path, bool allowCreate) + { + TreeNode dummy; + return FindNode(path, allowCreate, out dummy); + } + + private TreeNodeCollection FindNode(string path, bool allowCreate, out TreeNode match) { TreeNodeCollection col = treeView.Nodes; - TreeNode match = null; + match = null; + if (string.IsNullOrEmpty(path)) + return col; foreach (string p in path.Split(treeView.PathSeparator[0])) { diff --git a/Duplicati/Program.cs b/Duplicati/Program.cs index 1369e88ba..520a51cbe 100644 --- a/Duplicati/Program.cs +++ b/Duplicati/Program.cs @@ -55,6 +55,7 @@ namespace Duplicati public static ServiceStatus StatusDialog; public static ServiceSetup SetupDialog; + public static WizardHandler Wizard; public static ApplicationSettings ApplicationSettings; @@ -106,11 +107,11 @@ namespace Duplicati TrayIcon.ContextMenuStrip.Items.Add("Status", new Bitmap(asm.GetManifestResourceStream(typeof(Program), "Icons.Status.ico")), new EventHandler(Status_Clicked)); - TrayIcon.ContextMenuStrip.Items.Add("Setup", new Bitmap(asm.GetManifestResourceStream(typeof(Program), "Icons.Time.ico")), new EventHandler(Settings_Clicked)); + TrayIcon.ContextMenuStrip.Items.Add("Setup", new Bitmap(asm.GetManifestResourceStream(typeof(Program), "Icons.Time.ico")), new EventHandler(Setup_Clicked)); TrayIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator()); - TrayIcon.ContextMenuStrip.Items.Add("Settings", new Bitmap(asm.GetManifestResourceStream(typeof(Program), "Icons.Settings.ico")), new EventHandler(Setup_Clicked)); + TrayIcon.ContextMenuStrip.Items.Add("Settings", new Bitmap(asm.GetManifestResourceStream(typeof(Program), "Icons.Settings.ico")), new EventHandler(Settings_Clicked)); TrayIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator()); @@ -176,13 +177,12 @@ namespace Duplicati private static void Setup_Clicked(object sender, EventArgs e) { - ShowSetup(); + ShowWizard(); } private static void TrayIcon_DoubleClick(object sender, EventArgs e) { - //ShowStatus(); - ShowWizard(); + ShowStatus(); } public static void ShowStatus() @@ -194,7 +194,15 @@ namespace Duplicati StatusDialog.Activate(); } - public static void ShowSettings() + public static void ShowWizard() + { + if (Wizard == null || Wizard.Visible) + Wizard = new WizardHandler(); + + Wizard.Show(); + } + + public static void ShowSetup() { if (SetupDialog == null || !SetupDialog.Visible) SetupDialog = new ServiceSetup(); @@ -203,7 +211,7 @@ namespace Duplicati SetupDialog.Activate(); } - public static void ShowSetup() + public static void ShowSettings() { lock (MainLock) { @@ -212,10 +220,5 @@ namespace Duplicati } } - public static void ShowWizard() - { - new WizardHandler().Show(); - } - } } \ No newline at end of file diff --git a/Duplicati/Scheduler.cs b/Duplicati/Scheduler.cs index b9610f043..586132f1b 100644 --- a/Duplicati/Scheduler.cs +++ b/Duplicati/Scheduler.cs @@ -100,7 +100,14 @@ namespace Duplicati int i = 0; while (start <= DateTime.Now && i++ < 50000) - start = Timeparser.ParseTimeInterval(sc.Repeat, start); + try + { + start = Timeparser.ParseTimeInterval(sc.Repeat, start); + } + catch + { + continue; + } if (start < DateTime.Now) continue; diff --git a/Duplicati/ServiceSetup.cs b/Duplicati/ServiceSetup.cs index 9e807d833..1fa49a615 100644 --- a/Duplicati/ServiceSetup.cs +++ b/Duplicati/ServiceSetup.cs @@ -37,7 +37,7 @@ namespace Duplicati InitializeComponent(); m_connection = new DataFetcherNested(Program.DataConnection); - backupTreeView.Setup(m_connection, true); + backupTreeView.Setup(m_connection, true, false); backupTreeView.treeView.AfterSelect += new TreeViewEventHandler(treeView_AfterSelect); backupTreeView.treeView.ContextMenuStrip = TreeMenuStrip; } diff --git a/Duplicati/ServiceStatus.cs b/Duplicati/ServiceStatus.cs index fb41a8863..62efc79f8 100644 --- a/Duplicati/ServiceStatus.cs +++ b/Duplicati/ServiceStatus.cs @@ -157,7 +157,7 @@ namespace Duplicati recentBackups.Items.Clear(); foreach (Log l in logs) { - ListViewItem lvi = new ListViewItem(new string[] { l.EndTime.ToString("g", System.Globalization.CultureInfo.CurrentUICulture), l.OwnerTask.Schedule.Name, l.TransferSizeString }); + ListViewItem lvi = new ListViewItem(new string[] { l.EndTime.ToString("g", System.Globalization.CultureInfo.CurrentUICulture), l.OwnerTask == null ? "" : l.OwnerTask.Schedule.Name, l.TransferSizeString }); lvi.Tag = l; lvi.ImageIndex = imageList.Images.ContainsKey(l.ParsedStatus) ? imageList.Images.IndexOfKey(l.ParsedStatus) : imageList.Images.IndexOfKey("Warning"); diff --git a/Duplicati/Wizard pages/Add backup/FinishedAdd.Designer.cs b/Duplicati/Wizard pages/Add backup/FinishedAdd.Designer.cs index a565c3558..562572940 100644 --- a/Duplicati/Wizard pages/Add backup/FinishedAdd.Designer.cs +++ b/Duplicati/Wizard pages/Add backup/FinishedAdd.Designer.cs @@ -44,6 +44,7 @@ namespace Duplicati.Wizard_pages.Add_backup // // Summary // + this.Summary.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Summary.Location = new System.Drawing.Point(24, 40); this.Summary.Multiline = true; this.Summary.Name = "Summary"; diff --git a/Duplicati/Wizard pages/Add backup/FinishedAdd.cs b/Duplicati/Wizard pages/Add backup/FinishedAdd.cs index bbba657bc..6044ab47c 100644 --- a/Duplicati/Wizard pages/Add backup/FinishedAdd.cs +++ b/Duplicati/Wizard pages/Add backup/FinishedAdd.cs @@ -48,9 +48,39 @@ namespace Duplicati.Wizard_pages.Add_backup void IWizardControl.Enter(IWizardForm owner) { - Summary.Text = - "Action: Add new backup\r\n" + - "When: " + m_schedule.When.ToString() + "\r\n"; + List> strings = new List>(); + strings.Add(new KeyValuePair("Action", "Add new backup")); + strings.Add(new KeyValuePair("Source folder", m_schedule.Tasks[0].SourcePath)); + strings.Add(new KeyValuePair("When", m_schedule.When.ToString())); + if (!string.IsNullOrEmpty(m_schedule.Repeat)) + strings.Add(new KeyValuePair("Repeat", m_schedule.Repeat)); + if (!string.IsNullOrEmpty(m_schedule.FullAfter)) + strings.Add(new KeyValuePair("Full backup each", m_schedule.FullAfter)); + if (m_schedule.KeepFull > 0) + strings.Add(new KeyValuePair("Keep full backups", m_schedule.KeepFull.ToString())); + + if (m_schedule.Tasks != null && m_schedule.Tasks.Count == 1) + { + Duplicati.Datamodel.Backends.IBackend backend = m_schedule.Tasks[0].Backend; + strings.Add(new KeyValuePair(null, null)); + strings.Add(new KeyValuePair("Destination", backend.FriendlyName)); + strings.Add(new KeyValuePair("Destination path", backend.GetDestinationPath())); + } + + int maxlen = 0; + foreach(KeyValuePair i in strings) + if (i.Key != null) + maxlen = Math.Max(maxlen, i.Key.Length); + + System.Text.StringBuilder sb = new StringBuilder(); + foreach (KeyValuePair i in strings) + if (i.Key == null) + sb.Append("\r\n"); + else + sb.Append(i.Key + ": " + new String(' ', maxlen - i.Key.Length) + i.Value + "\r\n"); + + Summary.Text = sb.ToString(); + } void IWizardControl.Leave(IWizardForm owner, ref bool cancel) @@ -67,5 +97,6 @@ namespace Duplicati.Wizard_pages.Add_backup } #endregion + } } diff --git a/Duplicati/Wizard pages/Add backup/IncrementalSettings.cs b/Duplicati/Wizard pages/Add backup/IncrementalSettings.cs index a33cdbc58..fddbce8b9 100644 --- a/Duplicati/Wizard pages/Add backup/IncrementalSettings.cs +++ b/Duplicati/Wizard pages/Add backup/IncrementalSettings.cs @@ -155,7 +155,7 @@ namespace Duplicati.Wizard_pages.Add_backup if (m_schedule != null) { if (FullBackups.Checked) - m_schedule.Repeat = FullBackups.Text; + m_schedule.Repeat = FullDuration.Text; else m_schedule.Repeat = null; diff --git a/Duplicati/Wizard pages/Add backup/SelectFiles.cs b/Duplicati/Wizard pages/Add backup/SelectFiles.cs index 314c58bb9..dea64fe70 100644 --- a/Duplicati/Wizard pages/Add backup/SelectFiles.cs +++ b/Duplicati/Wizard pages/Add backup/SelectFiles.cs @@ -124,7 +124,7 @@ namespace Duplicati.Wizard_pages.Add_backup { m_owner = owner; if (m_schedule != null) - TargetFolder.Text = m_schedule.Path; + TargetFolder.Text = m_schedule.Tasks[0].SourcePath; Rescan(); } @@ -229,7 +229,7 @@ namespace Duplicati.Wizard_pages.Add_backup m_calculator.AddTask(TargetFolder.Text); } - m_schedule.Path = TargetFolder.Text; + m_schedule.Tasks[0].SourcePath = TargetFolder.Text; } #region IScheduleBased Members diff --git a/Duplicati/Wizard pages/Add backup/SelectName.Designer.cs b/Duplicati/Wizard pages/Add backup/SelectName.Designer.cs new file mode 100644 index 000000000..3caa44fb9 --- /dev/null +++ b/Duplicati/Wizard pages/Add backup/SelectName.Designer.cs @@ -0,0 +1,104 @@ +namespace Duplicati.Wizard_pages.Add_backup +{ + partial class SelectName + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.BackupFolder = new Duplicati.HelperControls.BackupTreeView(); + this.label1 = new System.Windows.Forms.Label(); + this.BackupName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // BackupFolder + // + this.BackupFolder.Location = new System.Drawing.Point(24, 80); + this.BackupFolder.Name = "BackupFolder"; + this.BackupFolder.Size = new System.Drawing.Size(440, 120); + this.BackupFolder.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(24, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(73, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Backup name"; + // + // BackupName + // + this.BackupName.Location = new System.Drawing.Point(120, 16); + this.BackupName.Name = "BackupName"; + this.BackupName.Size = new System.Drawing.Size(344, 20); + this.BackupName.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(24, 64); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(187, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Place the backup in a group (optional)"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(344, 200); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(120, 24); + this.button1.TabIndex = 4; + this.button1.Text = "Add a group"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // SelectName + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.button1); + this.Controls.Add(this.label2); + this.Controls.Add(this.BackupName); + this.Controls.Add(this.label1); + this.Controls.Add(this.BackupFolder); + this.Name = "SelectName"; + this.Size = new System.Drawing.Size(506, 242); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Duplicati.HelperControls.BackupTreeView BackupFolder; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox BackupName; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + } +} diff --git a/Duplicati/Wizard pages/Add backup/SelectName.cs b/Duplicati/Wizard pages/Add backup/SelectName.cs new file mode 100644 index 000000000..6cdb65c63 --- /dev/null +++ b/Duplicati/Wizard pages/Add backup/SelectName.cs @@ -0,0 +1,108 @@ +#region Disclaimer / License +// Copyright (C) 2008, Kenneth Skovhede +// http://www.hexad.dk, opensource@hexad.dk +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +#endregion +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using System.Windows.Forms.Wizard; +using Duplicati.Datamodel; + +namespace Duplicati.Wizard_pages.Add_backup +{ + public partial class SelectName : UserControl, IWizardControl, Interfaces.IScheduleBased + { + private Schedule m_schedule; + + public SelectName() + { + InitializeComponent(); + BackupFolder.treeView.HideSelection = false; + } + + #region IWizardControl Members + + Control IWizardControl.Control + { + get { return this; } + } + + string IWizardControl.Title + { + get { return "Enter a name for the backup"; } + } + + string IWizardControl.HelpText + { + get { return "On this page you can enter a name for the backup, so you can find and modify it later"; } + } + + Image IWizardControl.Image + { + get { return null; } + } + + bool IWizardControl.FullSize + { + get { return false; } + } + + void IWizardControl.Enter(IWizardForm owner) + { + BackupName.Text = m_schedule.Name; + BackupFolder.SelectedFolder = (string.IsNullOrEmpty(m_schedule.Path) ? "" : m_schedule.Path + BackupFolder.treeView.PathSeparator) + m_schedule.Name; + } + + void IWizardControl.Leave(IWizardForm owner, ref bool cancel) + { + if (BackupName.Text.Trim().Length <= 0) + { + MessageBox.Show(this, "You must enter a name for the backup", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); + cancel = true; + return; + } + m_schedule.Name = BackupName.Text; + if (BackupFolder.treeView.SelectedNode != null) + m_schedule.Path = BackupFolder.SelectedFolder; + else + m_schedule.Path = ""; + } + + #endregion + + #region IScheduleBased Members + + public void Setup(Schedule schedule) + { + m_schedule = schedule; + BackupFolder.Setup(schedule.DataParent, true, true); + } + + #endregion + + private void button1_Click(object sender, EventArgs e) + { + BackupFolder.SelectedFolder = null; + BackupFolder.AddFolder(null); + } + } +} diff --git a/Duplicati/Wizard pages/Add backup/SelectName.resx b/Duplicati/Wizard pages/Add backup/SelectName.resx new file mode 100644 index 000000000..ff31a6db5 --- /dev/null +++ b/Duplicati/Wizard pages/Add backup/SelectName.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Duplicati/Wizard pages/Backends/FTP/FTPOptions.cs b/Duplicati/Wizard pages/Backends/FTP/FTPOptions.cs index 37bb43a5b..7ecedb57f 100644 --- a/Duplicati/Wizard pages/Backends/FTP/FTPOptions.cs +++ b/Duplicati/Wizard pages/Backends/FTP/FTPOptions.cs @@ -99,6 +99,7 @@ namespace Duplicati.Wizard_pages.Backends.FTP m_ftp.Username = Username.Text; m_ftp.Password = Password.Text; m_ftp.Port = (int)Port.Value; + m_ftp.SetService(); } #endregion diff --git a/Duplicati/Wizard pages/Backends/File/FileOptions.cs b/Duplicati/Wizard pages/Backends/File/FileOptions.cs index 28985787b..31497bb3d 100644 --- a/Duplicati/Wizard pages/Backends/File/FileOptions.cs +++ b/Duplicati/Wizard pages/Backends/File/FileOptions.cs @@ -123,6 +123,7 @@ namespace Duplicati.Wizard_pages.Backends.File } m_file.DestinationFolder = TargetFolder.Text; + if (UseCredentials.Checked) { m_file.Username = Username.Text; @@ -133,6 +134,8 @@ namespace Duplicati.Wizard_pages.Backends.File m_file.Username = null; m_file.Password = null; } + + m_file.SetService(); } #endregion diff --git a/Duplicati/Wizard pages/Backends/S3/S3Options.cs b/Duplicati/Wizard pages/Backends/S3/S3Options.cs index 8913354cf..fd1506e3f 100644 --- a/Duplicati/Wizard pages/Backends/S3/S3Options.cs +++ b/Duplicati/Wizard pages/Backends/S3/S3Options.cs @@ -84,6 +84,7 @@ namespace Duplicati.Wizard_pages.Backends.S3 m_s3.ServerUrl = null; m_s3.Prefix = null; m_s3.UseEuroBucket = UseEuroBuckets.Checked; + m_s3.SetService(); } diff --git a/Duplicati/Wizard pages/Backends/SSH/SSHOptions.cs b/Duplicati/Wizard pages/Backends/SSH/SSHOptions.cs index d9619ca57..7a74dc92f 100644 --- a/Duplicati/Wizard pages/Backends/SSH/SSHOptions.cs +++ b/Duplicati/Wizard pages/Backends/SSH/SSHOptions.cs @@ -108,6 +108,7 @@ namespace Duplicati.Wizard_pages.Backends.SSH } m_ssh.Port = (int)Port.Value; + m_ssh.SetService(); } diff --git a/Duplicati/Wizard pages/MainPage.Designer.cs b/Duplicati/Wizard pages/MainPage.Designer.cs index 1b7072cdb..85680a7ba 100644 --- a/Duplicati/Wizard pages/MainPage.Designer.cs +++ b/Duplicati/Wizard pages/MainPage.Designer.cs @@ -30,9 +30,10 @@ namespace Duplicati.Wizard_pages { this.label1 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); - this.CreateNew = new System.Windows.Forms.RadioButton(); - this.Edit = new System.Windows.Forms.RadioButton(); this.Restore = new System.Windows.Forms.RadioButton(); + this.Edit = new System.Windows.Forms.RadioButton(); + this.CreateNew = new System.Windows.Forms.RadioButton(); + this.ShowAdvanced = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.SuspendLayout(); // @@ -52,33 +53,9 @@ namespace Duplicati.Wizard_pages this.panel1.Controls.Add(this.CreateNew); this.panel1.Location = new System.Drawing.Point(32, 32); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(440, 184); + this.panel1.Size = new System.Drawing.Size(440, 104); this.panel1.TabIndex = 1; // - // CreateNew - // - this.CreateNew.AutoSize = true; - this.CreateNew.Location = new System.Drawing.Point(0, 8); - this.CreateNew.Name = "CreateNew"; - this.CreateNew.Size = new System.Drawing.Size(141, 17); - this.CreateNew.TabIndex = 0; - this.CreateNew.TabStop = true; - this.CreateNew.Text = "Schedule a new backup"; - this.CreateNew.UseVisualStyleBackColor = true; - this.CreateNew.CheckedChanged += new System.EventHandler(this.Radio_CheckedChanged); - // - // Edit - // - this.Edit.AutoSize = true; - this.Edit.Location = new System.Drawing.Point(0, 40); - this.Edit.Name = "Edit"; - this.Edit.Size = new System.Drawing.Size(185, 17); - this.Edit.TabIndex = 1; - this.Edit.TabStop = true; - this.Edit.Text = "Edit or remove an existing backup"; - this.Edit.UseVisualStyleBackColor = true; - this.Edit.CheckedChanged += new System.EventHandler(this.Radio_CheckedChanged); - // // Restore // this.Restore.AutoSize = true; @@ -91,10 +68,45 @@ namespace Duplicati.Wizard_pages this.Restore.UseVisualStyleBackColor = true; this.Restore.CheckedChanged += new System.EventHandler(this.Radio_CheckedChanged); // + // Edit + // + this.Edit.AutoSize = true; + this.Edit.Location = new System.Drawing.Point(0, 40); + this.Edit.Name = "Edit"; + this.Edit.Size = new System.Drawing.Size(185, 17); + this.Edit.TabIndex = 1; + this.Edit.TabStop = true; + this.Edit.Text = "Edit or remove an existing backup"; + this.Edit.UseVisualStyleBackColor = true; + this.Edit.CheckedChanged += new System.EventHandler(this.Radio_CheckedChanged); + // + // CreateNew + // + this.CreateNew.AutoSize = true; + this.CreateNew.Location = new System.Drawing.Point(0, 8); + this.CreateNew.Name = "CreateNew"; + this.CreateNew.Size = new System.Drawing.Size(141, 17); + this.CreateNew.TabIndex = 0; + this.CreateNew.TabStop = true; + this.CreateNew.Text = "Schedule a new backup"; + this.CreateNew.UseVisualStyleBackColor = true; + this.CreateNew.CheckedChanged += new System.EventHandler(this.Radio_CheckedChanged); + // + // ShowAdvanced + // + this.ShowAdvanced.Location = new System.Drawing.Point(32, 184); + this.ShowAdvanced.Name = "ShowAdvanced"; + this.ShowAdvanced.Size = new System.Drawing.Size(104, 24); + this.ShowAdvanced.TabIndex = 2; + this.ShowAdvanced.Text = "Advanced setup"; + this.ShowAdvanced.UseVisualStyleBackColor = true; + this.ShowAdvanced.Click += new System.EventHandler(this.ShowAdvanced_Click); + // // MainPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.ShowAdvanced); this.Controls.Add(this.panel1); this.Controls.Add(this.label1); this.Name = "MainPage"; @@ -113,5 +125,6 @@ namespace Duplicati.Wizard_pages private System.Windows.Forms.RadioButton Restore; private System.Windows.Forms.RadioButton Edit; private System.Windows.Forms.RadioButton CreateNew; + private System.Windows.Forms.Button ShowAdvanced; } } diff --git a/Duplicati/Wizard pages/MainPage.cs b/Duplicati/Wizard pages/MainPage.cs index d4e2d4aab..554cee73c 100644 --- a/Duplicati/Wizard pages/MainPage.cs +++ b/Duplicati/Wizard pages/MainPage.cs @@ -76,10 +76,19 @@ namespace Duplicati.Wizard_pages { m_owner = owner; UpdateButtonState(); + + this.Controls.Remove(ShowAdvanced); + m_owner.ButtonPanel.Controls.Add(ShowAdvanced); + ShowAdvanced.Top = m_owner.CancelButton.Top; + ShowAdvanced.Left = m_owner.ButtonPanel.Width - m_owner.CancelButton.Right; + ShowAdvanced.Visible = true; } void IWizardControl.Leave(IWizardForm owner, ref bool cancel) { + m_owner.ButtonPanel.Controls.Remove(ShowAdvanced); + this.Controls.Add(ShowAdvanced); + ShowAdvanced.Visible = false; } #endregion @@ -110,5 +119,12 @@ namespace Duplicati.Wizard_pages } } + + private void ShowAdvanced_Click(object sender, EventArgs e) + { + Program.ShowSetup(); + m_owner.Dialog.DialogResult = DialogResult.Cancel; + m_owner.Dialog.Close(); + } } } diff --git a/Duplicati/WizardHandler.cs b/Duplicati/WizardHandler.cs index 655f3b144..1a5520c7f 100644 --- a/Duplicati/WizardHandler.cs +++ b/Duplicati/WizardHandler.cs @@ -16,6 +16,7 @@ namespace Duplicati public enum Pages { MainAction, + Add_SelectName, Add_SelectFiles, Add_SelectWhen, Add_Incremental, @@ -29,11 +30,31 @@ namespace Duplicati Add_Finished, } + /// + /// The main wizard form + /// IWizardForm m_form; + + /// + /// The connection on which changes are made + /// IDataFetcher m_connection; + + /// + /// The item to be commited, for the add procedure + /// Schedule m_addedItem; + + /// + /// The item to be committed, for the edit procedure + /// Schedule m_editItem; + /// + /// The page that produced the finish page, used to go back to it + /// + IWizardControl m_addFinishedPage = null; + public WizardHandler() { @@ -43,6 +64,7 @@ namespace Duplicati m_form.Pages.Clear(); m_form.Pages.AddRange(new IWizardControl[] { new Wizard_pages.MainPage(), + new Wizard_pages.Add_backup.SelectName(), new Wizard_pages.Add_backup.SelectFiles(), new Wizard_pages.Add_backup.SelectWhen(), new Wizard_pages.Add_backup.IncrementalSettings(), @@ -59,8 +81,21 @@ namespace Duplicati m_form.DefaultImage = Program.NeutralIcon.ToBitmap(); m_form.BackPressed += new PageChangeHandler(m_form_BackPressed); m_form.NextPressed += new PageChangeHandler(m_form_NextPressed); + m_form.Finished += new System.ComponentModel.CancelEventHandler(m_form_Finished); } + void m_form_Finished(object sender, System.ComponentModel.CancelEventArgs e) + { + //TODO: Implement CommitRecursive + m_connection.CommitAll(); + Program.DataConnection.CommitAll(); + + if ((m_form.CurrentPage as Duplicati.Wizard_pages.Add_backup.FinishedAdd).RunNow.Checked) + Program.WorkThread.AddTask(new FullBackupTask(m_addedItem)); + } + + public bool Visible { get { return m_form.Dialog.Visible; } } + void m_form_NextPressed(object sender, PageChangedArgs args) { switch ((Pages)m_form.Pages.IndexOf(m_form.CurrentPage)) @@ -69,7 +104,7 @@ namespace Duplicati switch (((Wizard_pages.MainPage)m_form.CurrentPage).SelectedAction) { case Duplicati.Wizard_pages.MainPage.Action.Add: - args.NextPage = m_form.Pages[(int)Pages.Add_SelectFiles]; + args.NextPage = m_form.Pages[(int)Pages.Add_SelectName]; if (m_addedItem == null || m_editItem != null) { @@ -127,11 +162,12 @@ namespace Duplicati case Pages.Add_SSHOptions: case Pages.Add_WebDAVOptions: case Pages.Add_S3Options: + m_addFinishedPage = m_form.CurrentPage; args.NextPage = m_form.Pages[(int)Pages.Add_Finished]; + args.TreatAsLast = true; break; case Pages.Add_Finished: - SetupFinishPage(m_form.Pages[(int)Pages.Add_Finished] as Wizard_pages.Add_backup.FinishedAdd); break; @@ -152,6 +188,10 @@ namespace Duplicati case Pages.Add_SelectFiles: args.NextPage = m_form.Pages[(int)Pages.MainAction]; break; + case Pages.Add_Finished: + if (m_addFinishedPage != null) + args.NextPage = m_addFinishedPage; + break; } } @@ -160,9 +200,5 @@ namespace Duplicati (m_form as Form).ShowDialog(); } - private void SetupFinishPage(Wizard_pages.Add_backup.FinishedAdd page) - { - - } } } diff --git a/Duplicati/WorkerThread.cs b/Duplicati/WorkerThread.cs index b04001def..33ff096d5 100644 --- a/Duplicati/WorkerThread.cs +++ b/Duplicati/WorkerThread.cs @@ -143,7 +143,7 @@ namespace Duplicati if (m_tasks.Count > 0) m_currentTask = m_tasks.Dequeue(); - if (m_currentTask == null) + if (m_currentTask == null && !m_terminate) m_event.WaitOne(); if (m_terminate) diff --git a/WizardForm/Dialog.Designer.cs b/WizardForm/Dialog.Designer.cs index c44a8ad89..40c6bc40f 100644 --- a/WizardForm/Dialog.Designer.cs +++ b/WizardForm/Dialog.Designer.cs @@ -113,6 +113,7 @@ namespace System.Windows.Forms.Wizard // // _CancelButton // + this._CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; this._CancelButton.Location = new System.Drawing.Point(416, 16); this._CancelButton.Name = "_CancelButton"; this._CancelButton.Size = new System.Drawing.Size(80, 24); @@ -133,6 +134,7 @@ namespace System.Windows.Forms.Wizard // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this._CancelButton; this.ClientSize = new System.Drawing.Size(506, 354); this.Controls.Add(this._ButtonPanel); this.Controls.Add(this._InfoPanel); @@ -143,6 +145,7 @@ namespace System.Windows.Forms.Wizard this.Name = "Dialog"; this.Text = "Dialog"; this.Load += new System.EventHandler(this.Dialog_Load); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Dialog_KeyUp); this._InfoPanel.ResumeLayout(false); this._InfoPanel.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this._PageIcon)).EndInit(); diff --git a/WizardForm/Dialog.cs b/WizardForm/Dialog.cs index b5a44c04e..ae0ea3b5c 100644 --- a/WizardForm/Dialog.cs +++ b/WizardForm/Dialog.cs @@ -36,7 +36,7 @@ namespace System.Windows.Forms.Wizard private bool m_isLastPage = false; public event CancelEventHandler Finished; - public event EventHandler Cancelled; + public event CancelEventHandler Cancelled; public event PageChangeHandler NextPressed; public event PageChangeHandler BackPressed; @@ -202,7 +202,12 @@ namespace System.Windows.Forms.Wizard private void CancelBtn_Click(object sender, EventArgs e) { if (Cancelled != null) - Cancelled(this, null); + { + CancelEventArgs ce = new CancelEventArgs(false); + Cancelled(this, ce); + if (ce.Cancel) + return; + } this.DialogResult = DialogResult.Cancel; this.Close(); } @@ -267,5 +272,12 @@ namespace System.Windows.Forms.Wizard if (this.Pages.Count > 0) this.CurrentPage = Pages[0]; } + + private void Dialog_KeyUp(object sender, KeyEventArgs e) + { + //Setting the CancelButton property of the form does not allow canceling the event + if (e.KeyCode == Keys.Escape) + this.CancelBtn_Click(null, null); + } } } \ No newline at end of file diff --git a/WizardForm/IWizardForm.cs b/WizardForm/IWizardForm.cs index 50404823d..add714d2e 100644 --- a/WizardForm/IWizardForm.cs +++ b/WizardForm/IWizardForm.cs @@ -63,6 +63,6 @@ namespace System.Windows.Forms.Wizard event PageChangeHandler NextPressed; event PageChangeHandler BackPressed; event CancelEventHandler Finished; - event EventHandler Cancelled; + event CancelEventHandler Cancelled; } }