diff --git a/Duplicati.sln b/Duplicati.sln index 6256d580b..04f9609e3 100644 --- a/Duplicati.sln +++ b/Duplicati.sln @@ -25,8 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.Backend.W EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.Backend.CloudFiles", "Duplicati\Library\Backend\CloudFiles\Duplicati.Library.Backend.CloudFiles.csproj", "{1BFAE226-8364-4086-825C-BB83F6F3EE4C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Datamodel", "Duplicati\GUI\Datamodel\Datamodel.csproj", "{B60D0993-B0C5-457A-90D9-DB6EEB33CE47}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.CommandLine.BackendTester", "Duplicati\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj", "{E7280DCA-7776-4A73-B9B5-41FD77FC8799}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.Interface", "Duplicati\Library\Interface\Duplicati.Library.Interface.csproj", "{C5899F45-B0FF-483C-9D38-24A9FCAAB237}" @@ -119,10 +117,6 @@ Global {9E9675C7-1198-44CD-85E0-FD582E9EEAFF}.Debug|Any CPU.Build.0 = Debug|Any CPU {9E9675C7-1198-44CD-85E0-FD582E9EEAFF}.Release|Any CPU.ActiveCfg = Release|Any CPU {9E9675C7-1198-44CD-85E0-FD582E9EEAFF}.Release|Any CPU.Build.0 = Release|Any CPU - {B60D0993-B0C5-457A-90D9-DB6EEB33CE47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B60D0993-B0C5-457A-90D9-DB6EEB33CE47}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B60D0993-B0C5-457A-90D9-DB6EEB33CE47}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B60D0993-B0C5-457A-90D9-DB6EEB33CE47}.Release|Any CPU.Build.0 = Release|Any CPU {BAE27510-8B5D-44B2-B33E-372A98908041}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BAE27510-8B5D-44B2-B33E-372A98908041}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAE27510-8B5D-44B2-B33E-372A98908041}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -177,7 +171,7 @@ Global {FF2BF37C-E502-4C98-BEA0-701671DDFA08}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Duplicati\CommandLine\Duplicati.CommandLine.csproj + StartupItem = Duplicati\GUI\Duplicati.GUI.MacTrayIcon\Duplicati.GUI.MacTrayIcon.csproj Policies = $0 $0.StandardHeader = $1 $1.Text = @ Copyright (C) 2011, Kenneth Skovhede\r\n http://www.hexad.dk, opensource@hexad.dk\n \n This library is free software; you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation; either version 2.1 of the\n License, or (at your option) any later version.\n\n This library is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this library; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -199,7 +193,6 @@ Global $4.EventRemoveBraceStyle = NextLine $4.StatementBraceStyle = NextLine $4.ElseNewLinePlacement = NewLine - $4.ElseIfNewLinePlacement = SameLine $4.CatchNewLinePlacement = NewLine $4.FinallyNewLinePlacement = NewLine $4.BeforeMethodDeclarationParentheses = False diff --git a/Duplicati/GUI/Datamodel/ApplicationSetting.cs b/Duplicati/GUI/Datamodel/ApplicationSetting.cs deleted file mode 100644 index 12a0646f8..000000000 --- a/Duplicati/GUI/Datamodel/ApplicationSetting.cs +++ /dev/null @@ -1,77 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// ApplicationSetting -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("ApplicationSetting")] - public partial class ApplicationSetting : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/ApplicationSettings.cs b/Duplicati/GUI/Datamodel/ApplicationSettings.cs deleted file mode 100644 index f47fb92d7..000000000 --- a/Duplicati/GUI/Datamodel/ApplicationSettings.cs +++ /dev/null @@ -1,321 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; -using System.Data.LightDatamodel; - -namespace Duplicati.Datamodel -{ - public class ApplicationSettings - { - public enum NotificationLevel - { - Off, - Start, - StartAndStop, - Continous, - Warnings, - Errors - } - - private SettingsHelper m_appset; - - private const string RECENT_DURATION = "Recent duration"; - private const string TEMP_PATH = "Temp Path"; - - private const string USE_COMMON_PASSWORD = "Use common password"; - private const string COMMON_PASSWORD_ENCRYPTION_MODULE = "Encryption module used with common password"; - private const string COMMON_PASSWORD = "Common password"; - - private const string SIGNATURE_CACHE_PATH = "Signature Cache Path"; - private const string SIGNATURE_CACHE_ENABLED = "Signature Cache Enabled"; - - private const string DISPLAY_LANGUAGE = "Display Language"; - - private const string STARTUP_DELAY_DURATION = "Startup delay duration"; - private const string THREAD_PRIORITY_OVERRIDE = "Thread priority override"; - private const string UPLOAD_SPEED_LIMIT = "Upload speed limit"; - private const string DOWNLOAD_SPEED_LIMIT = "Download speed limit"; - - private const string HIDE_DONATE_BUTTON = "Hide donate button"; - - private const string BALLON_NOTIFICATION_LEVEL = "Balloon notification level"; - - public ApplicationSettings(IDataFetcher dataparent) - { - m_appset = new SettingsHelper(dataparent, new List(dataparent.GetObjects()), "Name", "Value"); - } - - /// - /// Creates a detached copy of all the application settings - /// - /// A dictionary with application settings - public Dictionary CreateDetachedCopy() - { - //We need to read/write all values to make sure they have the propper defaults - foreach (System.Reflection.PropertyInfo pi in this.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly)) - if (pi.CanRead && pi.CanWrite) - pi.SetValue(this, pi.GetValue(this, null), null); - - //After that, simply copy the values over - Dictionary res = new Dictionary(); - foreach (KeyValuePair k in m_appset) - res[k.Key] = k.Value; - return res; - } - - /// - /// Gets a reference to the internal options - /// - public IDictionary RawOptions { get { return m_appset; } } - - /// - /// Gets or sets the amount of time a log entry will be visible in the list of recent backups - /// - public string RecentBackupDuration - { - get { return string.IsNullOrEmpty(m_appset[RECENT_DURATION]) ? "2W" : m_appset[RECENT_DURATION]; } - set { m_appset[RECENT_DURATION] = value; } - } - - /// - /// Returns the default Duplicati temp path - /// - public static string DefaultTempPath - { - get - { -#if DEBUG - return System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "TEMP"); -#else - return System.IO.Path.GetTempPath(); -#endif - } - } - - /// - /// Gets or sets the path to store temporary files. May contain environment variables - /// - public string TempPath - { - get - { - if (string.IsNullOrEmpty(m_appset[TEMP_PATH])) - { - return DefaultTempPath; - } - else - return m_appset[TEMP_PATH]; - } - set { m_appset[TEMP_PATH] = value; } - } - - /// - /// Gets or sets a value indicating if Duplicati should apply a common password to backups - /// - public bool UseCommonPassword - { - get - { - bool res; - string tmp; - m_appset.TryGetValue(USE_COMMON_PASSWORD, out tmp); - - if (bool.TryParse(tmp, out res)) - return res; - else - return false; - } - set { m_appset[USE_COMMON_PASSWORD] = value.ToString(); } - } - - /// - /// Gets or sets the encryption module used as default - /// - public string CommonPasswordEncryptionModule - { - get - { - string res; - m_appset.TryGetValue(COMMON_PASSWORD_ENCRYPTION_MODULE, out res); - return string.IsNullOrEmpty(res) ? "aes" : res; - } - set { m_appset[COMMON_PASSWORD_ENCRYPTION_MODULE] = value; } - } - - /// - /// Gets or sets the common password applied to encrypt files. - /// - public string CommonPassword - { - get - { - string res; - m_appset.TryGetValue(COMMON_PASSWORD, out res); - return string.IsNullOrEmpty(res) ? "" : res; - } - set { m_appset[COMMON_PASSWORD] = value; } - } - - /// - /// Returns the default Duplicati signature cache path - /// - public static string DefaultSignatureCachePath - { - get - { - if (Duplicati.Library.Utility.Utility.IsClientLinux) - return System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%DUPLICATI_HOME%").TrimStart('"').TrimEnd('"'), "Signature Cache"); - else - return System.IO.Path.Combine(System.IO.Path.Combine(Environment.ExpandEnvironmentVariables(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)), "Duplicati"), "Signature Cache"); - } - } - - /// - /// Gets or sets the path to store signature cache files. May contain environment variables - /// - public string SignatureCachePath - { - get - { - if (string.IsNullOrEmpty(m_appset[SIGNATURE_CACHE_PATH])) - { - return DefaultSignatureCachePath; - } - else - return m_appset[SIGNATURE_CACHE_PATH]; - } - set { m_appset[SIGNATURE_CACHE_PATH] = value; } - } - - /// - /// Gets or sets a value indicating if the signature cache should be used. - /// - public bool SignatureCacheEnabled - { - get - { - bool res; - if (bool.TryParse(m_appset[SIGNATURE_CACHE_ENABLED], out res)) - return res; - else - return true; - } - set { m_appset[SIGNATURE_CACHE_ENABLED] = value.ToString(); } - } - - /// - /// Gets or sets the language used in the user interface - /// - public string DisplayLanguage - { - get - { - if (string.IsNullOrEmpty(m_appset[DISPLAY_LANGUAGE])) - return ""; - else - return m_appset[DISPLAY_LANGUAGE]; - } - set { m_appset[DISPLAY_LANGUAGE] = value; } - } - - /// - /// Gets or sets the amount of time Duplicati will be paused after startup - /// - public string StartupDelayDuration - { - get { return string.IsNullOrEmpty(m_appset[STARTUP_DELAY_DURATION]) ? "5m" : m_appset[STARTUP_DELAY_DURATION]; } - set { m_appset[STARTUP_DELAY_DURATION] = value; } - } - - /// - /// Gets or sets the thread priority used for the backup thread - /// - public System.Threading.ThreadPriority? ThreadPriorityOverride - { - get - { - if (string.IsNullOrEmpty(m_appset[THREAD_PRIORITY_OVERRIDE])) - return null; - else - return Library.Utility.Utility.ParsePriority(m_appset[THREAD_PRIORITY_OVERRIDE]); - } - set - { - if (value == null) - m_appset[THREAD_PRIORITY_OVERRIDE] = ""; - else - m_appset[THREAD_PRIORITY_OVERRIDE] = value.Value.ToString(); - } - } - - /// - /// Gets or sets the upper limit for download speeds - /// - public string DownloadSpeedLimit - { - get { return m_appset[DOWNLOAD_SPEED_LIMIT]; } - set { m_appset[DOWNLOAD_SPEED_LIMIT] = value == null ? "" : value; } - } - - /// - /// Gets or sets the upper limit for upload speeds - /// - public string UploadSpeedLimit - { - get { return m_appset[UPLOAD_SPEED_LIMIT]; } - set { m_appset[UPLOAD_SPEED_LIMIT] = value == null ? "" : value; } - } - - /// - /// Gets or sets a value indicating if the donate button in Duplicati should be hidden - /// - public bool HideDonateButton - { - get - { - string tmp; - m_appset.TryGetValue(HIDE_DONATE_BUTTON, out tmp); - - return Duplicati.Library.Utility.Utility.ParseBool(tmp, false); - } - set { m_appset[HIDE_DONATE_BUTTON] = value.ToString(); } - } - - /// - /// Gets or sets the balloon notification level - /// - public NotificationLevel BallonNotificationLevel - { - get - { - string v; - m_appset.TryGetValue(BALLON_NOTIFICATION_LEVEL, out v); - if (!string.IsNullOrEmpty(v)) - try { return (NotificationLevel)Enum.Parse(typeof(NotificationLevel), v); } - catch { } - - return NotificationLevel.Warnings; - } - set { m_appset[BALLON_NOTIFICATION_LEVEL] = value.ToString(); } - } - } -} diff --git a/Duplicati/GUI/Datamodel/AssemblyInfo.cs b/Duplicati/GUI/Datamodel/AssemblyInfo.cs deleted file mode 100644 index 5dbb9bd91..000000000 --- a/Duplicati/GUI/Datamodel/AssemblyInfo.cs +++ /dev/null @@ -1,78 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("Dulicati.Datamodel")] -[assembly: AssemblyDescription("The datamodel for Duplicati")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("HexaD")] -[assembly: AssemblyProduct("Duplicati")] -[assembly: AssemblyCopyright("LGPL, Copyright © HexaD 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.0.0")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: ComVisibleAttribute(false)] -[assembly: AssemblyFileVersionAttribute("1.0.0.0")] diff --git a/Duplicati/GUI/Datamodel/BackendSetting.cs b/Duplicati/GUI/Datamodel/BackendSetting.cs deleted file mode 100644 index f95a77614..000000000 --- a/Duplicati/GUI/Datamodel/BackendSetting.cs +++ /dev/null @@ -1,92 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// BackendSetting -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("BackendSetting")] - public partial class BackendSetting : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("BackendSettingTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("BackendSettingTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("BackendSettingTask", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/CommandQueue.cs b/Duplicati/GUI/Datamodel/CommandQueue.cs deleted file mode 100644 index 3ab53454c..000000000 --- a/Duplicati/GUI/Datamodel/CommandQueue.cs +++ /dev/null @@ -1,85 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// CommandQueue -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("CommandQueue")] - public partial class CommandQueue : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("Command")] - private System.String m_Command = ""; - [DatabaseField("Argument")] - private System.String m_Argument = ""; - [DatabaseField("Completed")] - private System.Boolean m_Completed = false; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.String Command - { - get{return m_Command;} - set{object oldvalue = m_Command;OnBeforeDataChange(this, "Command", oldvalue, value);m_Command = value;OnAfterDataChange(this, "Command", oldvalue, value);} - } - - public System.String Argument - { - get{return m_Argument;} - set{object oldvalue = m_Argument;OnBeforeDataChange(this, "Argument", oldvalue, value);m_Argument = value;OnAfterDataChange(this, "Argument", oldvalue, value);} - } - - public System.Boolean Completed - { - get{return m_Completed;} - set{object oldvalue = m_Completed;OnBeforeDataChange(this, "Completed", oldvalue, value);m_Completed = value;OnAfterDataChange(this, "Completed", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/CompressionSetting.cs b/Duplicati/GUI/Datamodel/CompressionSetting.cs deleted file mode 100644 index 9240a5a76..000000000 --- a/Duplicati/GUI/Datamodel/CompressionSetting.cs +++ /dev/null @@ -1,92 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// CompressionSetting -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("CompressionSetting")] - public partial class CompressionSetting : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("CompressionSettingTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("CompressionSettingTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("CompressionSettingTask", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/1. Support timestamp flag.sql b/Duplicati/GUI/Datamodel/Database schema/1. Support timestamp flag.sql deleted file mode 100644 index 2d58d1a78..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/1. Support timestamp flag.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "Task" ADD COLUMN "IgnoreTimestamps" BOOLEAN NULL; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/2. Refactor for easier extensions.sql b/Duplicati/GUI/Datamodel/Database schema/2. Refactor for easier extensions.sql deleted file mode 100644 index 01f595336..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/2. Refactor for easier extensions.sql +++ /dev/null @@ -1,57 +0,0 @@ --- TaskSettings becomes BackendSetting -ALTER TABLE TaskSetting RENAME TO BackendSetting; - --- TaskSetting is now extensions -CREATE TABLE "TaskExtension" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - --- Copy values from the Task table -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Max Upload Size', [MaxUploadSize] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Upload bandwidth', [UploadBandwidth] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Download Bandwidth', [DownloadBandwidth] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Volume Size', [VolumeSize] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Thread Priority', [ThreadPriority] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Async Transfer', [AsyncTransfer] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Include Setup', [IncludeSetup] FROM Task; -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [ID], 'Ignore Timestamps', [IgnoreTimestamps] FROM Task; - --- Move FileTimeSeparator into extensions -INSERT INTO TaskExtension ([TaskID], [Name], [Value]) SELECT [TaskID], 'File Time Seperator', Value FROM BackendSetting WHERE [Name] = 'TimeSeparator'; -DELETE FROM BackendSetting WHERE [Name] = 'TimeSeparator'; - --- Create a reduced Task table -CREATE TABLE "TempTask" ( - "ID" INTEGER PRIMARY KEY, - "ScheduleID" INTEGER NULL, - "Service" TEXT NULL, - "Encryptionkey" TEXT NULL, - "Signaturekey" TEXT NULL, - "SourcePath" TEXT NULL, - "KeepFull" INTEGER NULL, - "KeepTime" TEXT NULL, - "FullAfter" TEXT NULL, - "GPGEncryption" BOOLEAN NULL, - "IncludeSetup" BOOLEAN NULL -); - --- Copy values -INSERT INTO TempTask ([ID], [ScheduleID], [Service], [EncryptionKey], [SignatureKey], [SourcePath], [KeepFull], [KeepTime], [FullAfter], [GPGEncryption], [IncludeSetup]) SELECT [ID], [ScheduleID], [Service], [EncryptionKey], [SignatureKey], [SourcePath], [KeepFull], [KeepTime], [FullAfter], [GPGEncryption], [IncludeSetup] FROM Task; -DROP TABLE Task; - --- Use the new reduced table -ALTER TABLE "TempTask" RENAME TO "Task"; - --- Add the override table -CREATE TABLE "TaskOverride" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - --- Reduce database size -VACUUM; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/3. Default managed SSH.sql b/Duplicati/GUI/Datamodel/Database schema/3. Default managed SSH.sql deleted file mode 100644 index 683e76889..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/3. Default managed SSH.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Set existing SSH connections to be unmanaged -INSERT INTO "BackendSetting" ("TaskID", "Name", "Value") SELECT [ID], 'Use Unmanaged SSH', 'True' FROM Task WHERE "Service" LIKE 'ssh'; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/4. Support for setting controls.sql b/Duplicati/GUI/Datamodel/Database schema/4. Support for setting controls.sql deleted file mode 100644 index 9dac62752..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/4. Support for setting controls.sql +++ /dev/null @@ -1,66 +0,0 @@ --- Refactor the GPGEncryption column to now use EncryptionModule instead -ALTER TABLE "Task" ADD COLUMN "EncryptionModule" TEXT NULL; -ALTER TABLE "Task" ADD COLUMN "CompressionModule" TEXT NULL; - -UPDATE "Task" SET "EncryptionModule"="aes"; -UPDATE "Task" SET "EncryptionModule"="gpg" WHERE "GPGEncryption" = 1; - --- Create a reduced Task table -CREATE TABLE "TempTask" ( - "ID" INTEGER PRIMARY KEY, - "ScheduleID" INTEGER NULL, - "Service" TEXT NULL, - "Encryptionkey" TEXT NULL, - "Signaturekey" TEXT NULL, - "SourcePath" TEXT NULL, - "KeepFull" INTEGER NULL, - "KeepTime" TEXT NULL, - "FullAfter" TEXT NULL, - "EncryptionModule" TEXT NULL, - "CompressionModule" TEXT NULL, - "IncludeSetup" BOOLEAN NULL -); - -INSERT INTO TempTask ([ID], [ScheduleID], [Service], [EncryptionKey], [SignatureKey], [SourcePath], [KeepFull], [KeepTime], [FullAfter], [EncryptionModule], [CompressionModule], [IncludeSetup]) SELECT [ID], [ScheduleID], [Service], [EncryptionKey], [SignatureKey], [SourcePath], [KeepFull], [KeepTime], [FullAfter], [EncryptionModule], [CompressionModule], [IncludeSetup] FROM Task; - -DROP TABLE "Task"; -ALTER TABLE "TempTask" RENAME TO "Task"; - --- SettingExtension is now supported -CREATE TABLE "SettingExtension" ( - "ID" INTEGER PRIMARY KEY, - "SettingKey" TEXT NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - --- Add the compression setting table -CREATE TABLE "CompressionSetting" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - --- Add the encryption setting table -CREATE TABLE "EncryptionSetting" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - --- Use the GPG indicator to set the compression module value -UPDATE "ApplicationSetting" SET [Name] = "Encryption module used with common password" WHERE [Name] LIKE "Use PGP with common password"; -UPDATE "ApplicationSetting" SET [Value] = "aes" WHERE [Name] LIKE "Encryption module used with common password" AND [Value] LIKE "False"; -UPDATE "ApplicationSetting" SET [Value] = "gpg" WHERE [Name] LIKE "Encryption module used with common password" AND [Value] LIKE "True"; - --- Move the SFTP path into the controls settings, instead of the application settings -INSERT INTO "SettingExtension" ([SettingKey], [Name], [Value]) SELECT "ssh-settings", [Name], [Value] FROM "ApplicationSetting" WHERE [Name] LIKE "SFTP Path"; -DELETE FROM "ApplicationSetting" WHERE [Name] LIKE "SFTP Path"; - --- Move the GPG path into the controls settings, instead of the application settings, fixing the PGP -> GPG mistake on the way -INSERT INTO "SettingExtension" ([SettingKey], [Name], [Value]) SELECT "gpg-settings", "GPG Path", [Value] FROM "ApplicationSetting" WHERE [Name] LIKE "PGP Path"; -DELETE FROM "ApplicationSetting" WHERE [Name] LIKE "PGP Path"; - -VACUUM; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/5. Remove signaturekey.sql b/Duplicati/GUI/Datamodel/Database schema/5. Remove signaturekey.sql deleted file mode 100644 index e3788ba9e..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/5. Remove signaturekey.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "TempTask" ( - "ID" INTEGER PRIMARY KEY, - "ScheduleID" INTEGER NULL, - "Service" TEXT NULL, - "Encryptionkey" TEXT NULL, - "SourcePath" TEXT NULL, - "KeepFull" INTEGER NULL, - "KeepTime" TEXT NULL, - "FullAfter" TEXT NULL, - "EncryptionModule" TEXT NULL, - "CompressionModule" TEXT NULL, - "IncludeSetup" BOOLEAN NULL -); - -INSERT INTO TempTask ([ID], [ScheduleID], [Service], [EncryptionKey], [SourcePath], [KeepFull], [KeepTime], [FullAfter], [EncryptionModule], [CompressionModule], [IncludeSetup]) SELECT [ID], [ScheduleID], [Service], [EncryptionKey], [SourcePath], [KeepFull], [KeepTime], [FullAfter], [EncryptionModule], [CompressionModule], [IncludeSetup] FROM Task; - -DROP TABLE "Task"; -ALTER TABLE "TempTask" RENAME TO "Task"; - -VACUUM; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/6. Remove TimeSeparator and UseShortFilenames.sql b/Duplicati/GUI/Datamodel/Database schema/6. Remove TimeSeparator and UseShortFilenames.sql deleted file mode 100644 index b0de9c408..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/6. Remove TimeSeparator and UseShortFilenames.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Remove unused options -DELETE FROM TaskExtension WHERE [Name] LIKE 'File Time Seperator'; -DELETE FROM TaskExtension WHERE [Name] LIKE 'Short Filenames'; - --- Remove any empty filename prefixes which should be most common -DELETE FROM TaskExtension WHERE [Name] LIKE 'Filename Prefix' AND ([Value] LIKE '' OR [Value] IS NULL); - --- Move any non-empty filename prefixes into the manual settings override -INSERT INTO TaskOverride ([TaskID], [Name], [Value]) SELECT [TaskID], 'filename-prefix', [Value] FROM TaskExtension WHERE [Name] LIKE 'Filename Prefix'; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/7. Add error message field to log.sql b/Duplicati/GUI/Datamodel/Database schema/7. Add error message field to log.sql deleted file mode 100644 index 13bf0d2f0..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/7. Add error message field to log.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "Log" ADD COLUMN "ParsedMessage" TEXT NULL; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/8. Add filter fields.sql b/Duplicati/GUI/Datamodel/Database schema/8. Add filter fields.sql deleted file mode 100644 index d384b024e..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/8. Add filter fields.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "TaskFilter" ADD COLUMN "GlobbingFilter" TEXT NULL; \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Database schema/9. Add Schedule Metadata table.sql b/Duplicati/GUI/Datamodel/Database schema/9. Add Schedule Metadata table.sql deleted file mode 100644 index 450975f09..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/9. Add Schedule Metadata table.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "ScheduleMetadata" ( - "ID" INTEGER PRIMARY KEY, - "ScheduleID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); diff --git a/Duplicati/GUI/Datamodel/Database schema/Schema.sql b/Duplicati/GUI/Datamodel/Database schema/Schema.sql deleted file mode 100644 index 83f082032..000000000 --- a/Duplicati/GUI/Datamodel/Database schema/Schema.sql +++ /dev/null @@ -1,118 +0,0 @@ -CREATE TABLE "Task" ( - "ID" INTEGER PRIMARY KEY, - "ScheduleID" INTEGER NULL, - "Service" TEXT NULL, - "Encryptionkey" TEXT NULL, - "SourcePath" TEXT NULL, - "KeepFull" INTEGER NULL, - "KeepTime" TEXT NULL, - "FullAfter" TEXT NULL, - "EncryptionModule" TEXT NULL, - "CompressionModule" TEXT NULL, - "IncludeSetup" BOOLEAN NULL -); - -CREATE TABLE "Schedule" ( - "ID" INTEGER PRIMARY KEY, - "Name" TEXT NULL, - "Path" TEXT NULL, - "When" DATETIME NULL, - "Repeat" TEXT NULL, - "Weekdays" TEXT NULL -); - -CREATE TABLE "BackendSetting" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "TaskExtension" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "TaskOverride" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "CommandQueue" ( - "ID" INTEGER PRIMARY KEY, - "Command" TEXT NULL, - "Argument" TEXT NULL, - "Completed" BOOLEAN NULL -); - -CREATE TABLE "Log" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "EndTime" DATETIME NULL, - "BeginTime" DATETIME NULL, - "Action" TEXT NULL, - "SubAction" TEXT NULL, - "Transfersize" INTEGER NULL, - "ParsedStatus" TEXT NULL, - "ParsedMessage" TEXT NULL, - "LogBlobID" INTEGER NULL -); - -CREATE TABLE "LogBlob" ( - "ID" INTEGER PRIMARY KEY, - "Data" BLOB NULL -); - -CREATE TABLE "Version" ( - "ID" INTEGER PRIMARY KEY, - "Version" INTEGER -); - -CREATE TABLE "ApplicationSetting" ( - "ID" INTEGER PRIMARY KEY, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "TaskFilter" ( - "ID" INTEGER PRIMARY KEY, - "SortOrder" INTEGER NULL, - "Include" BOOLEAN NULL, - "Filter" TEXT NULL, - "TaskID" INTEGER NULL, - "GlobbingFilter" TEXT NULL -); - -CREATE TABLE "SettingExtension" ( - "ID" INTEGER PRIMARY KEY, - "SettingKey" TEXT NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "CompressionSetting" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "EncryptionSetting" ( - "ID" INTEGER PRIMARY KEY, - "TaskID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -CREATE TABLE "ScheduleMetadata" ( - "ID" INTEGER PRIMARY KEY, - "ScheduleID" INTEGER NULL, - "Name" TEXT NULL, - "Value" TEXT NULL -); - -INSERT INTO "Version" ("Version") VALUES (9); \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/DatabaseUpgrader.cs b/Duplicati/GUI/Datamodel/DatabaseUpgrader.cs deleted file mode 100644 index 137e0db75..000000000 --- a/Duplicati/GUI/Datamodel/DatabaseUpgrader.cs +++ /dev/null @@ -1,185 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; -using System.Data; - -namespace Duplicati.Datamodel -{ - /// - /// This class will read embedded files from the given folder. - /// Updates should have the form "1.Sample upgrade.sql". - /// When the database schema changes, simply put a new file into the folder. - /// Each upgrade file should ONLY upgrade from the previous version. - /// If done correctly, a user may be upgrade from the very first version - /// to the very latest. - /// - /// The Schema.sql file should ALWAYS have the latests schema, as that will - /// ensure that new installs do not run upgrades after installation. - /// Also remember to update the last line in Schema.sql to insert the - /// current version number in the version table. - /// - /// Currently no upgrades may contain semicolons, except as the SQL statement - /// delimiter. - /// - public static class DatabaseUpgrader - { - //This is the "folder" where the embedded resources can be found - private const string FOLDER_NAME = "Database_schema"; - - //This is the name of the schema sql - private const string SCHEMA_NAME = "Schema.sql"; - - /// - /// Ensures that the database is up to date - /// - /// The database connection to use - /// The file the database is placed in - public static void UpgradeDatabase(IDbConnection connection, string sourcefile) - { - //Shorthand for current assembly - System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); - - if (connection.State != ConnectionState.Open) - { - if (string.IsNullOrEmpty(connection.ConnectionString)) - connection.ConnectionString = "Data Source=" + sourcefile; - - connection.Open(); - } - - - int dbversion = 0; - IDbCommand cmd = connection.CreateCommand(); - try - { - //See if the version table is present, - cmd.CommandText = "SELECT COUNT(*) FROM SQLITE_MASTER WHERE Name LIKE 'Version'"; - - int count = Convert.ToInt32(cmd.ExecuteScalar()); - - if (count == 0) - dbversion = -1; //Empty - else if (count == 1) - { - cmd.CommandText = "SELECT max(Version) FROM Version"; - dbversion = Convert.ToInt32(cmd.ExecuteScalar()); - } - else - throw new Exception(Strings.DatabaseUpgrader.TableLayoutError); - - } - catch(Exception ex) - { - //Hopefully a more explanatory error message - throw new Exception(string.Format(Strings.DatabaseUpgrader.DatabaseFormatError, ex.Message), ex); - } - - - //On a new database, we just load the most current schema, and upgrade from there - //This avoids potentitally lenghty upgrades - if (dbversion == -1) - { - cmd.CommandText = new System.IO.StreamReader(asm.GetManifestResourceStream(typeof(DatabaseUpgrader), FOLDER_NAME + "." + SCHEMA_NAME)).ReadToEnd(); - cmd.ExecuteNonQuery(); - UpgradeDatabase(connection, sourcefile); - return; - } - - //Get updates, and sort them according to version - //This enables upgrading through several versions - //ea, from 1 to 8, by stepping 2->3->4->5->6->7->8 - SortedDictionary upgrades = new SortedDictionary(); - string prefix = typeof(DatabaseUpgrader).Namespace + "." + FOLDER_NAME + "."; - int maxversion = -1; - foreach (string s in asm.GetManifestResourceNames()) - { - //The resource name will be "Duplicati.GUI.Database_schema.1.Sample upgrade.sql" - //The number indicates the version that will be upgraded to - if (s.StartsWith(prefix) && !s.Equals(prefix + SCHEMA_NAME)) - { - try - { - string version = s.Substring(prefix.Length, s.IndexOf(".", prefix.Length + 1) - prefix.Length); - int fileversion = int.Parse(version); - maxversion = Math.Max(maxversion, fileversion); - if (fileversion > dbversion) - { - if (!upgrades.ContainsKey(fileversion)) - upgrades.Add(fileversion, ""); - upgrades[fileversion] += new System.IO.StreamReader(asm.GetManifestResourceStream(s)).ReadToEnd(); - } - } - catch - { - } - } - } - - if (dbversion > maxversion) - throw new Exception(string.Format(Strings.DatabaseUpgrader.InvalidVersionError, dbversion, maxversion, System.IO.Path.GetDirectoryName(sourcefile))); - - if (upgrades.Count > 0) - { - string backupfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(sourcefile), Strings.DatabaseUpgrader.BackupFilenamePrefix + " " + DateTime.Now.ToString("yyyyMMddhhmmss") + ".sqlite"); - - try - { - if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(backupfile))) - System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(backupfile)); - - //Keep a backup - System.IO.File.Copy(sourcefile, backupfile, false); - - int newversion = dbversion; - foreach (int key in upgrades.Keys) - { - //TODO: Find a better way to split SQL statements, as there may be embedded semicolons - //in the SQL, like "UPDATE x WHERE y = ';';" - - //We split them to get a better error message - foreach(string c in upgrades[key].Split(';')) - if (c.Trim().Length > 0) - { - cmd.CommandText = c; - cmd.ExecuteNonQuery(); - } - - newversion = Math.Max(newversion, key); - } - - //Update databaseversion, so we don't run the scripts again - cmd.CommandText = "Update version SET Version = " + newversion.ToString(); - cmd.ExecuteNonQuery(); - } - catch (Exception ex) - { - connection.Close(); - //Restore the database - System.IO.File.Copy(backupfile, sourcefile, true); - throw new Exception(string.Format(Strings.DatabaseUpgrader.UpgradeFailure, cmd.CommandText, ex.Message), ex); - } - } - - - } - } -} diff --git a/Duplicati/GUI/Datamodel/Datamodel.csproj b/Duplicati/GUI/Datamodel/Datamodel.csproj deleted file mode 100644 index 47deee1cd..000000000 --- a/Duplicati/GUI/Datamodel/Datamodel.csproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - Local - 9.0.30729 - 2.0 - {B60D0993-B0C5-457A-90D9-DB6EEB33CE47} - Debug - AnyCPU - - Datamodel - Duplicati.snk - JScript - Grid - IE50 - false - Library - Duplicati.Datamodel - OnBuildSuccess - - - - true - 3.5 - - - bin\Debug\ - 285212672 - - - DEBUG;TRACE - - - true - 4096 - false - false - false - 4 - full - prompt - - - bin\Release\ - 285212672 - - - TRACE - - - 4096 - true - false - false - 4 - none - prompt - - - - System - - - System.Data - - - ..\..\..\thirdparty\LightDataModel\LightDatamodel.dll - - - - - - - - - DatabaseUpgrader.resx - True - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65} - Duplicati.Library.Utility - - - - - - ResXFileCodeGenerator - DatabaseUpgrader.Designer.cs - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Duplicati.snk b/Duplicati/GUI/Datamodel/Duplicati.snk deleted file mode 100644 index e0c1e2dd8..000000000 Binary files a/Duplicati/GUI/Datamodel/Duplicati.snk and /dev/null differ diff --git a/Duplicati/GUI/Datamodel/Duplicati.sqlite b/Duplicati/GUI/Datamodel/Duplicati.sqlite deleted file mode 100644 index 13e9107da..000000000 Binary files a/Duplicati/GUI/Datamodel/Duplicati.sqlite and /dev/null differ diff --git a/Duplicati/GUI/Datamodel/EncryptionSetting.cs b/Duplicati/GUI/Datamodel/EncryptionSetting.cs deleted file mode 100644 index 52100a216..000000000 --- a/Duplicati/GUI/Datamodel/EncryptionSetting.cs +++ /dev/null @@ -1,92 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// EncryptionSetting -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("EncryptionSetting")] - public partial class EncryptionSetting : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("EncryptionSettingTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("EncryptionSettingTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("EncryptionSettingTask", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/LightDataModel.Mapping.xml b/Duplicati/GUI/Datamodel/LightDataModel.Mapping.xml deleted file mode 100644 index 0ef874945..000000000 --- a/Duplicati/GUI/Datamodel/LightDataModel.Mapping.xml +++ /dev/null @@ -1,1019 +0,0 @@ - - - - - Task - Task - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.String - Service - Service - false - false - false - false - false - false - - - System.String - Encryptionkey - Encryptionkey - false - false - false - false - false - false - - - System.String - SourcePath - SourcePath - false - false - false - false - false - false - - - System.Int64 - ScheduleID - ScheduleID - false - false - false - false - false - false - - - System.Int64 - KeepFull - KeepFull - false - false - false - false - false - false - - - System.String - KeepTime - KeepTime - false - false - false - false - false - false - - - System.String - FullAfter - FullAfter - false - false - false - false - false - false - - - System.Boolean - IncludeSetup - IncludeSetup - false - false - false - false - false - false - - - System.String - EncryptionModule - EncryptionModule - false - false - false - false - false - false - - - System.String - CompressionModule - CompressionModule - false - false - false - false - false - false - - - false - - - TaskSchedule - ScheduleID - Schedule - OneToOne - Schedule - ID - Task - Task - - -
- - Schedule - Schedule - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Path - Path - false - false - false - false - false - false - - - System.DateTime - When - When - false - false - false - false - false - false - - - System.String - Repeat - Repeat - false - false - false - false - false - false - - - System.String - Weekdays - Weekdays - false - false - false - false - false - false - - - false - -
- - CommandQueue - CommandQueue - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.String - Command - Command - false - false - false - false - false - false - - - System.String - Argument - Argument - false - false - false - false - false - false - - - System.Boolean - Completed - Completed - false - false - false - false - false - false - - - false - -
- - Log - Log - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - System.DateTime - EndTime - EndTime - false - false - false - false - false - false - - - System.DateTime - BeginTime - BeginTime - false - false - false - false - false - false - - - System.String - Action - Action - false - false - false - false - false - false - - - System.String - SubAction - SubAction - false - false - false - false - false - false - - - System.Int64 - Transfersize - Transfersize - false - false - false - false - false - false - - - System.String - ParsedStatus - ParsedStatus - false - false - false - false - false - false - - - System.Int64 - LogBlobID - LogBlobID - false - false - false - false - false - false - - - false - - - LogTask - TaskID - OwnerTask - OneToMany - Task - ID - Logs - Log - - - LogBlob - LogBlobID - Blob - OneToOne - LogBlob - ID - Log - Log - - -
- - LogBlob - LogBlob - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Byte[] - Data - Data - false - false - false - false - false - false - - - false - -
- - Version - Version - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - Version - Version - false - false - false - false - false - false - - - true - -
- - ApplicationSetting - ApplicationSetting - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - -
- - TaskFilter - TaskFilter - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - SortOrder - SortOrder - false - false - false - false - false - false - - - System.Boolean - Include - Include - false - false - false - false - false - false - - - System.String - Filter - Filter - false - false - false - false - false - false - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - false - - - TaskFilterTask - TaskID - Task - OneToMany - Task - ID - Filters - TaskFilter - - -
- - BackendSetting - BackendSetting - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - - - BackendSettingTask - TaskID - Task - OneToMany - Task - ID - BackendSettings - BackendSetting - - -
- - TaskExtension - TaskExtension - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - - - TaskExtensionTask - TaskID - Task - OneToMany - Task - ID - TaskExtensions - TaskExtension - - -
- - TaskOverride - TaskOverride - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - - - TaskOverrideTask - TaskID - Task - OneToMany - Task - ID - TaskOverrides - TaskOverride - - -
- - SettingExtension - SettingExtension - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.String - SettingKey - SettingKey - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - -
- - CompressionSetting - CompressionSetting - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - - - CompressionSettingTask - TaskID - Task - OneToMany - Task - ID - CompressionSettings - CompressionSetting - - -
- - EncryptionSetting - EncryptionSetting - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - TaskID - TaskID - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - - - EncryptionSettingTask - TaskID - Task - OneToMany - Task - ID - EncryptionSettings - EncryptionSetting - - -
- - ScheduleMetadata - ScheduleMetadata - ID - - - System.Int64 - ID - ID - true - true - false - false - false - true - - - System.Int64 - ScheduleID - ScheduleID - false - false - false - false - false - false - - - System.String - Name - Name - false - false - false - false - false - false - - - System.String - Value - Value - false - false - false - false - false - false - - - false - - - ScheduleMetadataSchedule - ScheduleID - Schedule - OneToMany - Schedule - ID - Metadata - ScheduleMetadata - - -
-
-
\ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Log.Extension.cs b/Duplicati/GUI/Datamodel/Log.Extension.cs deleted file mode 100644 index bd2624436..000000000 --- a/Duplicati/GUI/Datamodel/Log.Extension.cs +++ /dev/null @@ -1,36 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; - -namespace Duplicati.Datamodel -{ - public partial class Log - { - public string TransferSizeString - { - get - { - return Library.Utility.Utility.FormatSizeString(this.Transfersize); - } - } - } -} diff --git a/Duplicati/GUI/Datamodel/Log.cs b/Duplicati/GUI/Datamodel/Log.cs deleted file mode 100644 index d704dae60..000000000 --- a/Duplicati/GUI/Datamodel/Log.cs +++ /dev/null @@ -1,147 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// Log -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("Log")] - public partial class Log : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("LogTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("EndTime")] - private System.DateTime m_EndTime = new System.DateTime(1, 1, 1); - [DatabaseField("BeginTime")] - private System.DateTime m_BeginTime = new System.DateTime(1, 1, 1); - [DatabaseField("Action")] - private System.String m_Action = ""; - [DatabaseField("SubAction")] - private System.String m_SubAction = ""; - [DatabaseField("Transfersize")] - private System.Int64 m_Transfersize = long.MinValue; - [DatabaseField("ParsedStatus")] - private System.String m_ParsedStatus = ""; - [DatabaseField("ParsedMessage")] - private System.String m_ParsedMessage = ""; - [Relation("LogBlob", typeof(LogBlob), "ID"), DatabaseField("LogBlobID")] - private System.Int64 m_LogBlobID = long.MinValue; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.DateTime EndTime - { - get{return m_EndTime;} - set{object oldvalue = m_EndTime;OnBeforeDataChange(this, "EndTime", oldvalue, value);m_EndTime = value;OnAfterDataChange(this, "EndTime", oldvalue, value);} - } - - public System.DateTime BeginTime - { - get{return m_BeginTime;} - set{object oldvalue = m_BeginTime;OnBeforeDataChange(this, "BeginTime", oldvalue, value);m_BeginTime = value;OnAfterDataChange(this, "BeginTime", oldvalue, value);} - } - - public System.String Action - { - get{return m_Action;} - set{object oldvalue = m_Action;OnBeforeDataChange(this, "Action", oldvalue, value);m_Action = value;OnAfterDataChange(this, "Action", oldvalue, value);} - } - - public System.String SubAction - { - get{return m_SubAction;} - set{object oldvalue = m_SubAction;OnBeforeDataChange(this, "SubAction", oldvalue, value);m_SubAction = value;OnAfterDataChange(this, "SubAction", oldvalue, value);} - } - - public System.Int64 Transfersize - { - get{return m_Transfersize;} - set{object oldvalue = m_Transfersize;OnBeforeDataChange(this, "Transfersize", oldvalue, value);m_Transfersize = value;OnAfterDataChange(this, "Transfersize", oldvalue, value);} - } - - public System.String ParsedStatus - { - get{return m_ParsedStatus;} - set{object oldvalue = m_ParsedStatus;OnBeforeDataChange(this, "ParsedStatus", oldvalue, value);m_ParsedStatus = value;OnAfterDataChange(this, "ParsedStatus", oldvalue, value);} - } - - public System.String ParsedMessage - { - get { return m_ParsedMessage; } - set { object oldvalue = m_ParsedMessage; OnBeforeDataChange(this, "ParsedMessage", oldvalue, value); m_ParsedMessage = value; OnAfterDataChange(this, "ParsedMessage", oldvalue, value); } - } - - public System.Int64 LogBlobID - { - get{return m_LogBlobID;} - set{object oldvalue = m_LogBlobID;OnBeforeDataChange(this, "LogBlobID", oldvalue, value);m_LogBlobID = value;OnAfterDataChange(this, "LogBlobID", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task OwnerTask - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("LogTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("LogTask", this, value); } - } - - [Affects(typeof(LogBlob))] - public LogBlob Blob - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("LogBlob", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("LogBlob", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/LogBlob.Extension.cs b/Duplicati/GUI/Datamodel/LogBlob.Extension.cs deleted file mode 100644 index ffdb0ae72..000000000 --- a/Duplicati/GUI/Datamodel/LogBlob.Extension.cs +++ /dev/null @@ -1,40 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; - -namespace Duplicati.Datamodel -{ - public partial class LogBlob - { - public string StringData - { - get - { - return System.Text.Encoding.UTF8.GetString(this.Data); - } - set - { - this.Data = System.Text.Encoding.UTF8.GetBytes(value); - } - } - } -} diff --git a/Duplicati/GUI/Datamodel/LogBlob.cs b/Duplicati/GUI/Datamodel/LogBlob.cs deleted file mode 100644 index 27dd34412..000000000 --- a/Duplicati/GUI/Datamodel/LogBlob.cs +++ /dev/null @@ -1,76 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// LogBlob -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("LogBlob")] - public partial class LogBlob : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, Relation("LogBlob", typeof(Log), "LogBlobID", false), DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("Data")] - private System.Byte[] m_Data = null; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Byte[] Data - { - get{return m_Data;} - set{object oldvalue = m_Data;OnBeforeDataChange(this, "Data", oldvalue, value);m_Data = value;OnAfterDataChange(this, "Data", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Log))] - public Log Log - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("LogBlob", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("LogBlob", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Schedule.Extension.cs b/Duplicati/GUI/Datamodel/Schedule.Extension.cs deleted file mode 100644 index 064932b53..000000000 --- a/Duplicati/GUI/Datamodel/Schedule.Extension.cs +++ /dev/null @@ -1,157 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; - -namespace Duplicati.Datamodel -{ - public partial class Schedule - { - private DateTime m_nextSchedule = new DateTime(); - - public bool ExistsInDb - { - get { return this.ID > 0; } - } - - /// - /// Gets or sets the next scheduled time. - /// Note that this property is volatile, so - /// commiting the object will not persist this value. - /// Only a call to ScheduledRunCompleted will persist this value. - /// - public DateTime NextScheduledTime - { - get - { - if (m_nextSchedule.Ticks == 0) - return this.When; - else - return m_nextSchedule; - } - set - { - m_nextSchedule = value; - } - } - - /// - /// Signals that the a scheduled run has completed. - /// Will write a new scheduled time to the database - /// - public void ScheduledRunCompleted() - { - if (m_nextSchedule.Ticks != 0) - { - this.When = m_nextSchedule; - m_nextSchedule = new DateTime(); - ((System.Data.LightDatamodel.IDataFetcherWithRelations)this.DataParent).CommitRecursiveWithRelations(this); - } - } - - /// - /// Signals that the operation failed and that the backup - /// - public void ScheduledRunFailed() - { - m_nextSchedule = new DateTime(0); - } - - /// - /// Gets or sets the schedule allowed weekdays, - /// this is a parser/wrapper for the Weekdays string - /// - public DayOfWeek[] AllowedWeekdays - { - get - { - if (string.IsNullOrEmpty(this.Weekdays)) - return null; - else - { - string[] names = System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.AbbreviatedDayNames; - List l = new List(); - foreach(string s in this.Weekdays.Split(',')) - { - int x = -1; - for(int i = 0; i < names.Length; i++) - if (s.Trim().Equals(names[i], StringComparison.InvariantCultureIgnoreCase)) - { - x = i; - break; - } - - if (x >= 0 && !l.Contains((DayOfWeek)x)) - l.Add((DayOfWeek)x); - } - - l.Sort(); - return l.ToArray(); - } - } - set - { - if (value == null || value.Length == 0) - this.Weekdays = null; - else - { - //Filter duplicates - List l = new List(); - foreach (DayOfWeek d in value) - if (!l.Contains(d)) - l.Add(d); - - //If all is selected, don't store - if (l.Count == 7) - this.Weekdays = null; - else - { - l.Sort(); - - StringBuilder sb = new StringBuilder(); - foreach (DayOfWeek d in l) - { - if (sb.Length != 0) - sb.Append(","); - sb.Append(System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.AbbreviatedDayNames[(int)d]); - } - - this.Weekdays = sb.ToString(); - } - } - } - } - - private SettingsHelper m_metadataLookup; - - public IDictionary MetadataLookup - { - get - { - //Extra check because the datamodel copies the collection between contexts... not nice - if (m_metadataLookup == null || m_metadataLookup.DataParent != this.DataParent || m_metadataLookup.Collection != this.Metadata) - m_metadataLookup = new SettingsHelper(this.DataParent, this.Metadata, "Name", "Value"); - - return m_metadataLookup; - } - } - } -} diff --git a/Duplicati/GUI/Datamodel/Schedule.cs b/Duplicati/GUI/Datamodel/Schedule.cs deleted file mode 100644 index 5e384936d..000000000 --- a/Duplicati/GUI/Datamodel/Schedule.cs +++ /dev/null @@ -1,117 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// Schedule -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("Schedule")] - public partial class Schedule : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, Relation("TaskSchedule", typeof(Task), "ScheduleID", false), Relation("ScheduleMetadataSchedule", typeof(ScheduleMetadata), "ScheduleID", false), DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Path")] - private System.String m_Path = ""; - [DatabaseField("When")] - private System.DateTime m_When = new System.DateTime(1, 1, 1); - [DatabaseField("Repeat")] - private System.String m_Repeat = ""; - [DatabaseField("Weekdays")] - private System.String m_Weekdays = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Path - { - get{return m_Path;} - set{object oldvalue = m_Path;OnBeforeDataChange(this, "Path", oldvalue, value);m_Path = value;OnAfterDataChange(this, "Path", oldvalue, value);} - } - - public System.DateTime When - { - get{return m_When;} - set{object oldvalue = m_When;OnBeforeDataChange(this, "When", oldvalue, value);m_When = value;OnAfterDataChange(this, "When", oldvalue, value);} - } - - public System.String Repeat - { - get{return m_Repeat;} - set{object oldvalue = m_Repeat;OnBeforeDataChange(this, "Repeat", oldvalue, value);m_Repeat = value;OnAfterDataChange(this, "Repeat", oldvalue, value);} - } - - public System.String Weekdays - { - get{return m_Weekdays;} - set{object oldvalue = m_Weekdays;OnBeforeDataChange(this, "Weekdays", oldvalue, value);m_Weekdays = value;OnAfterDataChange(this, "Weekdays", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("TaskSchedule", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("TaskSchedule", this, value); } - } - - [Affects(typeof(ScheduleMetadata))] - public System.Collections.Generic.IList Metadata - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("ScheduleMetadataSchedule", this); - } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/ScheduleMetadata.cs b/Duplicati/GUI/Datamodel/ScheduleMetadata.cs deleted file mode 100644 index 88785ceaa..000000000 --- a/Duplicati/GUI/Datamodel/ScheduleMetadata.cs +++ /dev/null @@ -1,92 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// ScheduleMetadata -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("ScheduleMetadata")] - public partial class ScheduleMetadata : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("ScheduleMetadataSchedule", typeof(Schedule), "ID"), DatabaseField("ScheduleID")] - private System.Int64 m_ScheduleID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 ScheduleID - { - get{return m_ScheduleID;} - set{object oldvalue = m_ScheduleID;OnBeforeDataChange(this, "ScheduleID", oldvalue, value);m_ScheduleID = value;OnAfterDataChange(this, "ScheduleID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Schedule))] - public Schedule Schedule - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("ScheduleMetadataSchedule", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("ScheduleMetadataSchedule", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/SettingExtension.Extension.cs b/Duplicati/GUI/Datamodel/SettingExtension.Extension.cs deleted file mode 100644 index e0cc3f1a4..000000000 --- a/Duplicati/GUI/Datamodel/SettingExtension.Extension.cs +++ /dev/null @@ -1,49 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; - -namespace Duplicati.Datamodel -{ - public partial class SettingExtension - { - public static IDictionary GetExtensions(System.Data.LightDatamodel.IDataFetcher fetcher, string key) - { - return new ExtDict(fetcher, key); - } - - private class ExtDict : SettingsHelper - { - private string m_key; - public ExtDict(System.Data.LightDatamodel.IDataFetcher fetcher, string key) - : base(fetcher, new List(fetcher.GetObjects("SettingKey LIKE ?", key)), "Name", "Value") - { - m_key = key; - } - - public override void Add(string key, string value) - { - base.Add(key, value); - base.InternalSettings[key].SettingKey = m_key; - } - } - } -} diff --git a/Duplicati/GUI/Datamodel/SettingExtension.cs b/Duplicati/GUI/Datamodel/SettingExtension.cs deleted file mode 100644 index db909b293..000000000 --- a/Duplicati/GUI/Datamodel/SettingExtension.cs +++ /dev/null @@ -1,85 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// SettingExtension -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("SettingExtension")] - public partial class SettingExtension : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("SettingKey")] - private System.String m_SettingKey = ""; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.String SettingKey - { - get{return m_SettingKey;} - set{object oldvalue = m_SettingKey;OnBeforeDataChange(this, "SettingKey", oldvalue, value);m_SettingKey = value;OnAfterDataChange(this, "SettingKey", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/SettingsHelper.cs b/Duplicati/GUI/Datamodel/SettingsHelper.cs deleted file mode 100644 index 3f64329cf..000000000 --- a/Duplicati/GUI/Datamodel/SettingsHelper.cs +++ /dev/null @@ -1,321 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Text; -using System.Data.LightDatamodel; -using System.Reflection; - -namespace Duplicati.Datamodel -{ - public class SettingsHelper - : IDictionary - where TBase : IDataClass - { - private Dictionary m_settings; - private IList m_col; - private IDataFetcher m_parent; - - private PropertyInfo m_keyfield; - private PropertyInfo m_valuefield; - - public SettingsHelper(IDataFetcher parent, IList col, string keyfield, string valuefield) - : this(parent, col, typeof(TBase).GetProperty(keyfield), typeof(TBase).GetProperty(valuefield)) - - { - } - - public SettingsHelper(IDataFetcher parent, IList col, PropertyInfo keyfield, PropertyInfo valuefield) - { - m_parent = parent; - m_col = col; - m_keyfield = keyfield; - m_valuefield = valuefield; - - if (m_parent == null) - throw new ArgumentNullException("parent"); - if (m_col == null) - throw new ArgumentNullException("col"); - if (m_keyfield == null) - throw new ArgumentNullException("keyfield"); - if (m_valuefield == null) - throw new ArgumentNullException("valuefield"); - - parent.AfterDataConnection += new DataConnectionEventHandler(parent_AfterDataConnection); - } - - void parent_AfterDataConnection(object sender, DataActions action) - { - if (action != DataActions.Fetch) - m_settings = null; - - } - - public PropertyInfo KeyField { get { return m_keyfield; } } - public PropertyInfo ValueField { get { return m_valuefield; } } - - protected Dictionary InternalSettings - { - get - { - if (m_settings == null) - { - m_settings = new Dictionary(); - - foreach (TBase item in m_col) - if (!m_settings.ContainsKey((TKey)m_keyfield.GetValue(item, null))) - m_settings.Add((TKey)m_keyfield.GetValue(item, null), item); - } - - return m_settings; - } - } - - #region IDictionary Members - - public virtual void Add(TKey key, TValue value) - { - TBase item = Activator.CreateInstance(); - m_keyfield.SetValue(item, key, null); - m_valuefield.SetValue(item, value, null); - - InternalSettings.Add(key, item); - m_parent.Add(item); - m_col.Add(item); - } - - public bool ContainsKey(TKey key) - { - return InternalSettings.ContainsKey(key); - } - - public ICollection Keys - { - get { return InternalSettings.Keys; } - } - - public bool Remove(TKey key) - { - if (InternalSettings.ContainsKey(key)) - { - m_col.Remove(InternalSettings[key]); - m_parent.DeleteObject(InternalSettings[key]); - } - - return InternalSettings.Remove(key); - } - - public bool TryGetValue(TKey key, out TValue value) - { - TBase item; - if (InternalSettings.TryGetValue(key, out item)) - { - value = (TValue)m_valuefield.GetValue(item, null); - return true; - } - else - { - value = default(TValue); - return false; - } - - } - - public ICollection Values - { - get - { - List lst = new List(); - foreach (TBase item in InternalSettings.Values) - lst.Add((TValue)m_valuefield.GetValue(item, null)); - return lst; - } - } - - public TValue this[TKey key] - { - get - { - TBase tmp; - if (InternalSettings.TryGetValue(key, out tmp)) - return (TValue)m_valuefield.GetValue(tmp, null); - else - return default(TValue); - } - set - { - bool exists = InternalSettings.ContainsKey(key); - - if (value == null && exists) - { - //Remove - this.Remove(key); - } - else if (value != null && !exists) - { - //Add - this.Add(key, value); - } - else if (value != null && exists) - { - //Update - m_valuefield.SetValue(InternalSettings[key], value, null); - } - //else: It should be removed, but does not exist - - } - } - - #endregion - - #region ICollection> Members - - public void Add(KeyValuePair item) - { - this.Add(item.Key, item.Value); - } - - public void Clear() - { - while (m_col.Count > 0) - { - TBase item = m_col[0]; - m_col.Remove(item); - m_parent.DeleteObject(item); - } - - InternalSettings.Clear(); - } - - public bool Contains(KeyValuePair item) - { - if (!InternalSettings.ContainsKey(item.Key)) - return false; - - TValue v = this[item.Key]; - if (v == null && item.Value == null) - return true; - else if (v == null) - return false; - else - return v.Equals(item.Value); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - ((ICollection>)(InternalSettings)).CopyTo(array, arrayIndex); - } - - public int Count - { - get { return InternalSettings.Count; } - } - - public bool IsReadOnly - { - get { return false; } - } - - public bool Remove(KeyValuePair item) - { - if (!this.Contains(item)) - return false; - - return this.Remove(item.Key); - } - - #endregion - - #region IEnumerable> Members - - public IEnumerator> GetEnumerator() - { - return new TranslatoryEnumerator(this, InternalSettings.GetEnumerator()); - } - - #endregion - - #region IEnumerable Members - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return ((System.Collections.IEnumerable)InternalSettings).GetEnumerator(); - } - - #endregion - - - private class TranslatoryEnumerator : IEnumerator> - { - private SettingsHelper m_parent; - private IEnumerator> m_base; - - public TranslatoryEnumerator(SettingsHelper parent, IEnumerator> en) - { - m_parent = parent; - m_base = en; - } - - #region IEnumerator> Members - - public KeyValuePair Current - { - get - { - return new KeyValuePair(m_base.Current.Key, (TValue)m_parent.ValueField.GetValue(m_base.Current.Value, null)); - } - } - - #endregion - - #region IDisposable Members - - public void Dispose() - { - m_parent = null; - m_base = null; - } - - #endregion - - #region IEnumerator Members - - object System.Collections.IEnumerator.Current - { - get { return new System.Collections.DictionaryEntry(m_base.Current.Key, (TValue)m_parent.KeyField.GetValue(m_base.Current.Value, null)); } - } - - public bool MoveNext() - { - return m_base.MoveNext(); - } - - public void Reset() - { - m_base.Reset(); - } - - #endregion - } - - public IDataFetcher DataParent { get { return m_parent; } } - public IList Collection { get { return m_col; } } - } -} diff --git a/Duplicati/GUI/Datamodel/Strings/DatabaseUpgrader.Designer.cs b/Duplicati/GUI/Datamodel/Strings/DatabaseUpgrader.Designer.cs deleted file mode 100644 index f0c5e484f..000000000 --- a/Duplicati/GUI/Datamodel/Strings/DatabaseUpgrader.Designer.cs +++ /dev/null @@ -1,114 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.269 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Duplicati.Datamodel.Strings { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class DatabaseUpgrader { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal DatabaseUpgrader() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Duplicati.Datamodel.Strings.DatabaseUpgrader", typeof(DatabaseUpgrader).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to backup. - /// - internal static string BackupFilenamePrefix { - get { - return ResourceManager.GetString("BackupFilenamePrefix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to determine database format: {0}. - /// - internal static string DatabaseFormatError { - get { - return ResourceManager.GetString("DatabaseFormatError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to - ///The database has version {0} but the largest supported version is {1}. - /// - ///This is likely caused by upgrading to a newer version and then downgrading. - ///If this is the case, there is likely a backup file of the previous database version in the folder {2}.. - /// - internal static string InvalidVersionError { - get { - return ResourceManager.GetString("InvalidVersionError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unknown table layout detected. - /// - internal static string TableLayoutError { - get { - return ResourceManager.GetString("TableLayoutError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Failed to execute SQL: {0} - ///Error: {1} - ///Database is NOT upgraded.. - /// - internal static string UpgradeFailure { - get { - return ResourceManager.GetString("UpgradeFailure", resourceCulture); - } - } - } -} diff --git a/Duplicati/GUI/Datamodel/Strings/DatabaseUpgrader.resx b/Duplicati/GUI/Datamodel/Strings/DatabaseUpgrader.resx deleted file mode 100644 index 9a48a0514..000000000 --- a/Duplicati/GUI/Datamodel/Strings/DatabaseUpgrader.resx +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - backup - A string prefixed to the name of the database when making a backup - - - Unable to determine database format: {0} - An error message that is displayed if an error occurs while determining database layout - - - -The database has version {0} but the largest supported version is {1}. - -This is likely caused by upgrading to a newer version and then downgrading. -If this is the case, there is likely a backup file of the previous database version in the folder {2}. - An error message that is displayed if the database version number does not match - - - Unknown table layout detected - An error message that is displayed when the layout of the database is unexpected - - - Failed to execute SQL: {0} -Error: {1} -Database is NOT upgraded. - An error message displayed if one of the upgrade SQL statements fail - - \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/Task.Extension.cs b/Duplicati/GUI/Datamodel/Task.Extension.cs deleted file mode 100644 index 5bd2a2531..000000000 --- a/Duplicati/GUI/Datamodel/Task.Extension.cs +++ /dev/null @@ -1,355 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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.Collections.Specialized; -using System.Text; - - -namespace Duplicati.Datamodel -{ - public partial class Task - { - public Task() - { - this.AfterDataCommit += new System.Data.LightDatamodel.DataConnectionEventHandler(Task_AfterDataCommit); - } - - void Task_AfterDataCommit(object sender, System.Data.LightDatamodel.DataActions action) - { - if (action != System.Data.LightDatamodel.DataActions.Fetch) - { - m_backendSettings = null; - m_extensionSettings = null; - } - } - - private SettingsHelper m_backendSettings; - private SettingsHelper m_extensionSettings; - - private SettingsHelper m_taskOverrides; - - private SettingsHelper m_encryptionSettings; - private SettingsHelper m_compressionSettings; - - public IDictionary BackendSettingsLookup - { - get - { - //Extra check because the datamodel copies the collection between contexts... not nice - if (m_backendSettings == null || m_backendSettings.DataParent != this.DataParent || m_backendSettings.Collection != this.BackendSettings) - m_backendSettings = new SettingsHelper(this.DataParent, this.BackendSettings, "Name", "Value"); - - return m_backendSettings; - } - } - - public IDictionary TaskExtensionsLookup - { - get - { - //Extra check because the datamodel copies the collection between contexts... not nice - if (m_extensionSettings == null || m_extensionSettings.DataParent != this.DataParent || m_extensionSettings.Collection != this.TaskExtensions) - m_extensionSettings = new SettingsHelper(this.DataParent, this.TaskExtensions, "Name", "Value"); - - return m_extensionSettings; - } - } - - public IDictionary TaskOverridesLookup - { - get - { - //Extra check because the datamodel copies the collection between contexts... not nice - if (m_taskOverrides == null || m_taskOverrides.DataParent != this.DataParent || m_taskOverrides.Collection != this.TaskOverrides) - m_taskOverrides = new SettingsHelper(this.DataParent, this.TaskOverrides, "Name", "Value"); - - return m_taskOverrides; - } - } - - public IDictionary EncryptionSettingsLookup - { - get - { - //Extra check because the datamodel copies the collection between contexts... not nice - if (m_encryptionSettings == null || m_encryptionSettings.DataParent != this.DataParent || m_encryptionSettings.Collection != this.EncryptionSettings) - m_encryptionSettings = new SettingsHelper(this.DataParent, this.EncryptionSettings, "Name", "Value"); - - return m_encryptionSettings; - } - } - - public IDictionary CompressionSettingsLookup - { - get - { - //Extra check because the datamodel copies the collection between contexts... not nice - if (m_compressionSettings == null || m_compressionSettings.DataParent != this.DataParent || m_compressionSettings.Collection != this.CompressionSettings) - m_compressionSettings = new SettingsHelper(this.DataParent, this.CompressionSettings, "Name", "Value"); - - return m_compressionSettings; - } - } - - public TaskExtensionWrapper Extensions - { - get { return new TaskExtensionWrapper(this); } - } - - public string FilterXml - { - get - { - if (this.Filters.Count <= 0) - return ""; - - System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); - System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("root")); - - foreach (TaskFilter f in this.SortedFilters) - { - System.Xml.XmlNode e = root.AppendChild(doc.CreateElement("filter")); - e.Attributes.Append(doc.CreateAttribute("include")).Value = f.Include.ToString(); - e.Attributes.Append(doc.CreateAttribute("filter")).Value = f.Filter ?? ""; - e.Attributes.Append(doc.CreateAttribute("globbing")).Value = f.GlobbingFilter ?? ""; - } - - return doc.OuterXml; - } - set - { - //Delete previous ones - this.SortedFilters = new TaskFilter[0]; - - if (string.IsNullOrEmpty(value)) - return; - - System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); - doc.LoadXml(value); - - List filters = new List(); - foreach(System.Xml.XmlNode n in doc.SelectNodes("root/filter")) - { - TaskFilter tf = this.DataParent.Add(); - tf.Include = bool.Parse(n.Attributes["include"].Value); - tf.GlobbingFilter = n.Attributes["globbing"].Value; - tf.Filter = n.Attributes["filter"].Value; - filters.Add(tf); - } - - this.SortedFilters = filters.ToArray(); - } - } - - public bool ExistsInDb - { - get { return this.ID > 0; } - } - - - public TaskFilter[] SortedFilters - { - get - { - return System.Data.LightDatamodel.Query.Parse("ORDER BY SortOrder").EvaluateList(this.Filters).ToArray(); - } - set - { - foreach (TaskFilter t in this.SortedFilters) - if (Array.IndexOf(value, t) >= 0) - this.Filters.Remove(t); - else - t.DataParent.DeleteObject(t); - - int index = 0; - foreach (TaskFilter t in value) - { - t.SortOrder = index++; - this.Filters.Add(t); - } - } - } - - - public class TaskExtensionWrapper - { - private const string MAX_UPLOAD_SIZE = "Max Upload Size"; - private const string UPLOAD_BANDWIDTH = "Upload Bandwidth"; - private const string DOWNLOAD_BANDWIDTH = "Download Bandwidth"; - private const string VOLUME_SIZE = "Volume Size"; - private const string THREAD_PRIORITY = "Thread Priority"; - private const string ASYNC_TRANSFER = "Async Transfer"; - private const string INCLUDE_SETUP = "Include Setup"; - private const string IGNORE_TIMESTAMPS = "Ignore Timestamps"; - private const string FILE_SIZE_LIMIT = "File Size Limit"; - - private const string SELECTFILES_VERSION = "Select Files - Version"; - private const string SELECTFILES_USESIMPLEMODE = "Select Files - Use Simple Mode"; - private const string SELECTFILES_INCLUDEDOCUMENTS = "Select Files - Include Documents"; - private const string SELECTFILES_INCLUDEDESKTOP = "Select Files - Include Desktop"; - private const string SELECTFILES_INCLUDEMUSIC = "Select Files - Include Music"; - private const string SELECTFILES_INCLUDEIMAGES = "Select Files - Include Images"; - private const string SELECTFILES_INCLUDEAPPDATA = "Select Files - Include AppData"; - - private const string SELECTWHEN_WARNEDNOSCHEDULE = "Select When - Warned No Schedule"; - private const string SELECTWHEN_WARNEDTOOMANYINCREMENTALS = "Select When - Warned Too Many Incrementals"; - private const string SELECTWHEN_WARNEDNOINCREMENTALS = "Select When - Warned No Incrementals"; - - private const string PASSWORDSETTINGS_WARNEDNOPASSWORD = "Password Settings - Warned No Password"; - private const string CLEANUPSETTINGS_WARNEDNOCLEANUP = "Cleanup Settings - Warned No Cleanup"; - - private const string DISABLE_AES_FALLBACK_DECRYPTION = "Disable AES fallback encryption"; - - private Task m_owner; - - public TaskExtensionWrapper(Task owner) - { - m_owner = owner; - } - - public string MaxUploadSize - { - get { return m_owner.TaskExtensionsLookup[MAX_UPLOAD_SIZE]; } - set { m_owner.TaskExtensionsLookup[MAX_UPLOAD_SIZE] = value; } - } - - public string UploadBandwidth - { - get { return m_owner.TaskExtensionsLookup[UPLOAD_BANDWIDTH]; } - set { m_owner.TaskExtensionsLookup[UPLOAD_BANDWIDTH] = value; } - } - - public string DownloadBandwidth - { - get { return m_owner.TaskExtensionsLookup[DOWNLOAD_BANDWIDTH]; } - set { m_owner.TaskExtensionsLookup[DOWNLOAD_BANDWIDTH] = value; } - } - - public string VolumeSize - { - get { return m_owner.TaskExtensionsLookup[VOLUME_SIZE]; } - set { m_owner.TaskExtensionsLookup[VOLUME_SIZE] = value; } - } - - public string ThreadPriority - { - get { return m_owner.TaskExtensionsLookup[THREAD_PRIORITY]; } - set { m_owner.TaskExtensionsLookup[THREAD_PRIORITY] = value; } - } - - public bool AsyncTransfer - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[ASYNC_TRANSFER], true); } - set { m_owner.TaskExtensionsLookup[ASYNC_TRANSFER] = value.ToString(); } - } - - public bool IgnoreTimestamps - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[IGNORE_TIMESTAMPS], false); } - set { m_owner.TaskExtensionsLookup[IGNORE_TIMESTAMPS] = value.ToString(); } - } - - public string FileSizeLimit - { - get { return m_owner.TaskExtensionsLookup[FILE_SIZE_LIMIT]; } - set { m_owner.TaskExtensionsLookup[FILE_SIZE_LIMIT] = value; } - } - - public int SelectFiles_Version - { - get { return string.IsNullOrEmpty(m_owner.TaskExtensionsLookup[SELECTFILES_VERSION]) ? 1 : int.Parse(m_owner.TaskExtensionsLookup[SELECTFILES_VERSION]); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_VERSION] = value.ToString(); } - } - - public bool SelectFiles_UseSimpleMode - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTFILES_USESIMPLEMODE], false); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_USESIMPLEMODE] = value.ToString(); } - } - - public bool SelectFiles_IncludeDocuments - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEDOCUMENTS], false); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEDOCUMENTS] = value.ToString(); } - } - - public bool SelectFiles_IncludeDesktop - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEDESKTOP], false); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEDESKTOP] = value.ToString(); } - } - - public bool SelectFiles_IncludeMusic - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEMUSIC], false); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEMUSIC] = value.ToString(); } - } - - public bool SelectFiles_IncludeImages - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEIMAGES], false); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEIMAGES] = value.ToString(); } - } - - public bool SelectFiles_IncludeAppData - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEAPPDATA], false); } - set { m_owner.TaskExtensionsLookup[SELECTFILES_INCLUDEAPPDATA] = value.ToString(); } - } - - public bool SelectWhen_WarnedNoSchedule - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTWHEN_WARNEDNOSCHEDULE], false); } - set { m_owner.TaskExtensionsLookup[SELECTWHEN_WARNEDNOSCHEDULE] = value.ToString(); } - } - - public bool SelectWhen_WarnedNoIncrementals - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTWHEN_WARNEDNOINCREMENTALS], false); } - set { m_owner.TaskExtensionsLookup[SELECTWHEN_WARNEDNOINCREMENTALS] = value.ToString(); } - } - - public bool SelectWhen_WarnedTooManyIncrementals - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[SELECTWHEN_WARNEDTOOMANYINCREMENTALS], false); } - set { m_owner.TaskExtensionsLookup[SELECTWHEN_WARNEDTOOMANYINCREMENTALS] = value.ToString(); } - } - - public bool PasswordSettings_WarnedNoPassword - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[PASSWORDSETTINGS_WARNEDNOPASSWORD], false); } - set { m_owner.TaskExtensionsLookup[PASSWORDSETTINGS_WARNEDNOPASSWORD] = value.ToString(); } - } - - public bool CleanupSettings_WarnedNoCleanup - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[CLEANUPSETTINGS_WARNEDNOCLEANUP], false); } - set { m_owner.TaskExtensionsLookup[CLEANUPSETTINGS_WARNEDNOCLEANUP] = value.ToString(); } - } - - public bool DisableAESFallbackDecryption - { - get { return Duplicati.Library.Utility.Utility.ParseBool(m_owner.TaskExtensionsLookup[DISABLE_AES_FALLBACK_DECRYPTION], false); } - set { m_owner.TaskExtensionsLookup[DISABLE_AES_FALLBACK_DECRYPTION] = value.ToString(); } - } - } - } -} diff --git a/Duplicati/GUI/Datamodel/Task.cs b/Duplicati/GUI/Datamodel/Task.cs deleted file mode 100644 index dbdf2829b..000000000 --- a/Duplicati/GUI/Datamodel/Task.cs +++ /dev/null @@ -1,211 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// Task -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("Task")] - public partial class Task : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, Relation("LogTask", typeof(Log), "TaskID", false), Relation("TaskFilterTask", typeof(TaskFilter), "TaskID", false), Relation("BackendSettingTask", typeof(BackendSetting), "TaskID", false), Relation("TaskExtensionTask", typeof(TaskExtension), "TaskID", false), Relation("TaskOverrideTask", typeof(TaskOverride), "TaskID", false), Relation("CompressionSettingTask", typeof(CompressionSetting), "TaskID", false), Relation("EncryptionSettingTask", typeof(EncryptionSetting), "TaskID", false), DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("Service")] - private System.String m_Service = ""; - [DatabaseField("Encryptionkey")] - private System.String m_Encryptionkey = ""; - [DatabaseField("SourcePath")] - private System.String m_SourcePath = ""; - [Relation("TaskSchedule", typeof(Schedule), "ID"), DatabaseField("ScheduleID")] - private System.Int64 m_ScheduleID = long.MinValue; - [DatabaseField("KeepFull")] - private System.Int64 m_KeepFull = long.MinValue; - [DatabaseField("KeepTime")] - private System.String m_KeepTime = ""; - [DatabaseField("FullAfter")] - private System.String m_FullAfter = ""; - [DatabaseField("IncludeSetup")] - private System.Boolean m_IncludeSetup = false; - [DatabaseField("EncryptionModule")] - private System.String m_EncryptionModule = ""; - [DatabaseField("CompressionModule")] - private System.String m_CompressionModule = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.String Service - { - get{return m_Service;} - set{object oldvalue = m_Service;OnBeforeDataChange(this, "Service", oldvalue, value);m_Service = value;OnAfterDataChange(this, "Service", oldvalue, value);} - } - - public System.String Encryptionkey - { - get{return m_Encryptionkey;} - set{object oldvalue = m_Encryptionkey;OnBeforeDataChange(this, "Encryptionkey", oldvalue, value);m_Encryptionkey = value;OnAfterDataChange(this, "Encryptionkey", oldvalue, value);} - } - - public System.String SourcePath - { - get{return m_SourcePath;} - set{object oldvalue = m_SourcePath;OnBeforeDataChange(this, "SourcePath", oldvalue, value);m_SourcePath = value;OnAfterDataChange(this, "SourcePath", oldvalue, value);} - } - - public System.Int64 ScheduleID - { - get{return m_ScheduleID;} - set{object oldvalue = m_ScheduleID;OnBeforeDataChange(this, "ScheduleID", oldvalue, value);m_ScheduleID = value;OnAfterDataChange(this, "ScheduleID", oldvalue, value);} - } - - public System.Int64 KeepFull - { - get{return m_KeepFull;} - set{object oldvalue = m_KeepFull;OnBeforeDataChange(this, "KeepFull", oldvalue, value);m_KeepFull = value;OnAfterDataChange(this, "KeepFull", oldvalue, value);} - } - - public System.String KeepTime - { - get{return m_KeepTime;} - set{object oldvalue = m_KeepTime;OnBeforeDataChange(this, "KeepTime", oldvalue, value);m_KeepTime = value;OnAfterDataChange(this, "KeepTime", oldvalue, value);} - } - - public System.String FullAfter - { - get{return m_FullAfter;} - set{object oldvalue = m_FullAfter;OnBeforeDataChange(this, "FullAfter", oldvalue, value);m_FullAfter = value;OnAfterDataChange(this, "FullAfter", oldvalue, value);} - } - - public System.Boolean IncludeSetup - { - get{return m_IncludeSetup;} - set{object oldvalue = m_IncludeSetup;OnBeforeDataChange(this, "IncludeSetup", oldvalue, value);m_IncludeSetup = value;OnAfterDataChange(this, "IncludeSetup", oldvalue, value);} - } - - public System.String EncryptionModule - { - get{return m_EncryptionModule;} - set{object oldvalue = m_EncryptionModule;OnBeforeDataChange(this, "EncryptionModule", oldvalue, value);m_EncryptionModule = value;OnAfterDataChange(this, "EncryptionModule", oldvalue, value);} - } - - public System.String CompressionModule - { - get{return m_CompressionModule;} - set{object oldvalue = m_CompressionModule;OnBeforeDataChange(this, "CompressionModule", oldvalue, value);m_CompressionModule = value;OnAfterDataChange(this, "CompressionModule", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Schedule))] - public Schedule Schedule - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("TaskSchedule", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("TaskSchedule", this, value); } - } - - [Affects(typeof(Log))] - public System.Collections.Generic.IList Logs - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("LogTask", this); - } - } - - [Affects(typeof(TaskFilter))] - public System.Collections.Generic.IList Filters - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("TaskFilterTask", this); - } - } - - [Affects(typeof(BackendSetting))] - public System.Collections.Generic.IList BackendSettings - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("BackendSettingTask", this); - } - } - - [Affects(typeof(TaskExtension))] - public System.Collections.Generic.IList TaskExtensions - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("TaskExtensionTask", this); - } - } - - [Affects(typeof(TaskOverride))] - public System.Collections.Generic.IList TaskOverrides - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("TaskOverrideTask", this); - } - } - - [Affects(typeof(CompressionSetting))] - public System.Collections.Generic.IList CompressionSettings - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("CompressionSettingTask", this); - } - } - - [Affects(typeof(EncryptionSetting))] - public System.Collections.Generic.IList EncryptionSettings - { - get - { - return ((DataFetcherWithRelations)m_dataparent).GetRelatedObjects("EncryptionSettingTask", this); - } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/TaskExtension.cs b/Duplicati/GUI/Datamodel/TaskExtension.cs deleted file mode 100644 index 5ce7ea544..000000000 --- a/Duplicati/GUI/Datamodel/TaskExtension.cs +++ /dev/null @@ -1,92 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// TaskExtension -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("TaskExtension")] - public partial class TaskExtension : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("TaskExtensionTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("TaskExtensionTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("TaskExtensionTask", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/TaskFilter.cs b/Duplicati/GUI/Datamodel/TaskFilter.cs deleted file mode 100644 index a20ff1b67..000000000 --- a/Duplicati/GUI/Datamodel/TaskFilter.cs +++ /dev/null @@ -1,109 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// TaskFilter -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("TaskFilter")] - public partial class TaskFilter : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [DatabaseField("SortOrder")] - private System.Int64 m_SortOrder = long.MinValue; - [DatabaseField("Include")] - private System.Boolean m_Include = false; - [DatabaseField("Filter")] - private System.String m_Filter = ""; - [Relation("TaskFilterTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("GlobbingFilter")] - private System.String m_GlobbingFilter = ""; - -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 SortOrder - { - get{return m_SortOrder;} - set{object oldvalue = m_SortOrder;OnBeforeDataChange(this, "SortOrder", oldvalue, value);m_SortOrder = value;OnAfterDataChange(this, "SortOrder", oldvalue, value);} - } - - public System.Boolean Include - { - get{return m_Include;} - set{object oldvalue = m_Include;OnBeforeDataChange(this, "Include", oldvalue, value);m_Include = value;OnAfterDataChange(this, "Include", oldvalue, value);} - } - - public System.String Filter - { - get{return m_Filter;} - set{object oldvalue = m_Filter;OnBeforeDataChange(this, "Filter", oldvalue, value);m_Filter = value;OnAfterDataChange(this, "Filter", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.String GlobbingFilter - { - get { return m_GlobbingFilter; } - set { object oldvalue = m_GlobbingFilter; OnBeforeDataChange(this, "GlobbingFilter", oldvalue, value); m_GlobbingFilter = value; OnAfterDataChange(this, "GlobbingFilter", oldvalue, value); } - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("TaskFilterTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("TaskFilterTask", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/TaskOverride.cs b/Duplicati/GUI/Datamodel/TaskOverride.cs deleted file mode 100644 index 203ecf208..000000000 --- a/Duplicati/GUI/Datamodel/TaskOverride.cs +++ /dev/null @@ -1,92 +0,0 @@ -#region Disclaimer / License -// Copyright (C) 2011, 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 -/// -/// This class was created by DataClassFileBuilder (LightDatamodel) -/// -/// Table -/// Duplicati.Datamodel -/// TaskOverride -/// -/// - -using System.Data.LightDatamodel; -using System.Data.LightDatamodel.DataClassAttributes; - -namespace Duplicati.Datamodel -{ - - [DatabaseTable("TaskOverride")] - public partial class TaskOverride : DataClassBase - { - -#region " private members " - - [AutoIncrement, PrimaryKey, DatabaseField("ID")] - private System.Int64 m_ID = long.MinValue; - [Relation("TaskOverrideTask", typeof(Task), "ID"), DatabaseField("TaskID")] - private System.Int64 m_TaskID = long.MinValue; - [DatabaseField("Name")] - private System.String m_Name = ""; - [DatabaseField("Value")] - private System.String m_Value = ""; -#endregion - -#region " properties " - - public System.Int64 ID - { - get{return m_ID;} - set{object oldvalue = m_ID;OnBeforeDataChange(this, "ID", oldvalue, value);m_ID = value;OnAfterDataChange(this, "ID", oldvalue, value);} - } - - public System.Int64 TaskID - { - get{return m_TaskID;} - set{object oldvalue = m_TaskID;OnBeforeDataChange(this, "TaskID", oldvalue, value);m_TaskID = value;OnAfterDataChange(this, "TaskID", oldvalue, value);} - } - - public System.String Name - { - get{return m_Name;} - set{object oldvalue = m_Name;OnBeforeDataChange(this, "Name", oldvalue, value);m_Name = value;OnAfterDataChange(this, "Name", oldvalue, value);} - } - - public System.String Value - { - get{return m_Value;} - set{object oldvalue = m_Value;OnBeforeDataChange(this, "Value", oldvalue, value);m_Value = value;OnAfterDataChange(this, "Value", oldvalue, value);} - } - -#endregion - -#region " referenced properties " - - [Affects(typeof(Task))] - public Task Task - { - get{ return ((DataFetcherWithRelations)m_dataparent).GetRelatedObject("TaskOverrideTask", this); } - set{ ((DataFetcherWithRelations)m_dataparent).SetRelatedObject("TaskOverrideTask", this, value); } - } - -#endregion - - } - -} \ No newline at end of file diff --git a/Duplicati/GUI/Datamodel/app.config b/Duplicati/GUI/Datamodel/app.config deleted file mode 100644 index 89dc7d426..000000000 --- a/Duplicati/GUI/Datamodel/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs index 37e0d1539..a8a03e454 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs @@ -33,8 +33,8 @@ namespace Duplicati.GUI.TrayIcon private class StatusEventArgs : EventArgs { - public readonly Duplicati.Server.Serialization.IServerStatus Status; - public StatusEventArgs(Duplicati.Server.Serialization.IServerStatus args) { this.Status = args; } + public readonly Duplicati.Server.Serialization.Interface.IServerStatus Status; + public StatusEventArgs(Duplicati.Server.Serialization.Interface.IServerStatus args) { this.Status = args; } } private class MenuItemWrapper : IMenuItem @@ -262,7 +262,7 @@ namespace Duplicati.GUI.TrayIcon protected override void RegisterStatusUpdateCallback () { - Program.Connection.StatusUpdated += delegate(Duplicati.Server.Serialization.IServerStatus status) { + Program.Connection.StatusUpdated += delegate(Duplicati.Server.Serialization.Interface.IServerStatus status) { Gtk.Application.Invoke(this, new StatusEventArgs(status), StatusUpdateEvent); }; } diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs index 7bc4b7083..53065cea1 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Duplicati.Server.Serialization; +using Duplicati.Server.Serialization.Interface; namespace Duplicati.GUI.TrayIcon { diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs index 7e8cd4c71..de1c35759 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/TrayIconBase.cs @@ -16,6 +16,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using Duplicati.Server.Serialization; +using Duplicati.Server.Serialization.Interface; using System.Collections.Generic; namespace Duplicati.GUI.TrayIcon diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/WindowsImplementation/WinFormsRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/WindowsImplementation/WinFormsRunner.cs index 0bbdc694b..8ed0a1257 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/WindowsImplementation/WinFormsRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/WindowsImplementation/WinFormsRunner.cs @@ -1,233 +1,234 @@ -// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using Duplicati.Server.Serialization; - -namespace Duplicati.GUI.TrayIcon.Windows -{ - //We use a separate class to start the runner to avoid attempts to load WinForms from Program.cs - public class WinFormsRunner : TrayIconBase - { - private class MenuItemWrapper : IMenuItem - { - private ToolStripItem m_menu; - private Action m_callback; - - public ToolStripItem MenuItem { get { return m_menu; } } - - public MenuItemWrapper(string text, MenuIcons icon, Action callback, IList subitems) - { - if (text == "-") - m_menu = new ToolStripSeparator(); - else - { - m_menu = new ToolStripMenuItem(text); - if (icon != MenuIcons.None) - m_menu.Image = GetIcon(icon); - - if (callback != null) - { - m_callback = callback; - m_menu.Click += OnMenuClick; - } - - if (subitems != null && subitems.Count > 0) - foreach(var itm in subitems) - ((ToolStripMenuItem)m_menu).DropDownItems.Add(((MenuItemWrapper)itm).MenuItem); - } - } - - private void OnMenuClick (object sender, EventArgs e) - { - m_callback(); - } - - private System.Drawing.Image GetIcon(MenuIcons icon) - { - switch(icon) - { - case MenuIcons.Pause: - return Properties.Resources.Pause; - case MenuIcons.Quit: - return Properties.Resources.CloseMenuIcon; - case MenuIcons.Resume: - return Properties.Resources.Play; - case MenuIcons.Status: - return Properties.Resources.StatusMenuIcon; - case MenuIcons.None: - default: - return null; - } - } - - #region IMenuItem implementation - public string Text { - set { - m_menu.Text = value; - } - } - - public MenuIcons Icon { - set { - m_menu.Image = GetIcon(value); - } - } - - public bool Enabled { - set { - m_menu.Enabled = value; - } - } - - public bool Default { - set { - m_menu.Font = new System.Drawing.Font(m_menu.Font, System.Drawing.FontStyle.Bold); - } - } - #endregion - } - - private Form m_handleProvider; - private NotifyIcon m_trayIcon; - - public static WinFormsRunner Instance = null; - - public override void Init (string[] args) - { - if (WinFormsRunner.Instance != null) - throw new Exception("Multiple trayicon instances not allowed!"); - - WinFormsRunner.Instance = this; - - //We need this ugly hack to get a handle that we can call Invoke on, - // and sadly the TrayIcon does not expose one, and forcing the context menu - // to create one causes weird "lost clicks" - m_handleProvider = new Form() - { - FormBorderStyle = FormBorderStyle.None, - Width = 10, - Height = 10, - Top = 0, - Left = 0 - }; - m_handleProvider.Show(); - m_handleProvider.Hide(); - - m_trayIcon = new NotifyIcon(); - m_trayIcon.DoubleClick += new EventHandler(m_trayIcon_DoubleClick); - m_trayIcon.Click += new EventHandler(m_trayIcon_Click); - base.Init(args); - } - - private void m_trayIcon_Click(object sender, EventArgs e) - { - if (m_onSingleClick != null) - m_onSingleClick(); - } - - private void m_trayIcon_DoubleClick(object sender, EventArgs e) - { - if (m_onDoubleClick != null) - m_onDoubleClick(); - } - - protected override void RegisterStatusUpdateCallback () - { - Program.Connection.StatusUpdated += delegate(IServerStatus status) { - m_handleProvider.Invoke(new Action(OnStatusUpdated), status); - }; - } - - #region implemented abstract members of Duplicati.GUI.TrayIcon.TrayIconBase - protected override void Run (string[] args) - { - m_trayIcon.Visible = true; - Application.Run(); - } - - protected override TrayIcons Icon { - set { - switch (value) - { - case TrayIcons.IdleError: - m_trayIcon.Icon = Properties.Resources.TrayNormalError; - break; - case TrayIcons.Paused: - m_trayIcon.Icon = Properties.Resources.TrayNormalPause; - break; - case TrayIcons.PausedError: - m_trayIcon.Icon = Properties.Resources.TrayNormalPause; - break; - case TrayIcons.Running: - m_trayIcon.Icon = Properties.Resources.TrayWorking; - break; - case TrayIcons.RunningError: - m_trayIcon.Icon = Properties.Resources.TrayWorking; - break; - case TrayIcons.Idle: - default: - m_trayIcon.Icon = Properties.Resources.TrayNormal; - break; - } - } - } - - protected override IMenuItem CreateMenuItem (string text, MenuIcons icon, Action callback, IList subitems) - { - return new MenuItemWrapper(text, icon, callback, subitems); - } - - protected override void Exit () - { - Application.Exit(); - } - - protected override void SetMenu (System.Collections.Generic.IEnumerable items) - { - m_trayIcon.ContextMenuStrip = new ContextMenuStrip(); - foreach(var itm in items) - m_trayIcon.ContextMenuStrip.Items.Add(((MenuItemWrapper)itm).MenuItem); - } - - public override void Dispose () - { - if (m_handleProvider != null) - { - m_handleProvider.Dispose(); - m_handleProvider = null; - } - - if (m_trayIcon != null) - { - m_trayIcon.Visible = false; - m_trayIcon.Dispose(); - m_trayIcon = null; - } - } - #endregion - - /*public override IBrowserWindow ShowUrlInWindow(string url) - { - var v = new WindowsBrowser(url); - v.Show(); - return v; - }*/ - } -} - +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Duplicati.Server.Serialization; +using Duplicati.Server.Serialization.Interface; + +namespace Duplicati.GUI.TrayIcon.Windows +{ + //We use a separate class to start the runner to avoid attempts to load WinForms from Program.cs + public class WinFormsRunner : TrayIconBase + { + private class MenuItemWrapper : IMenuItem + { + private ToolStripItem m_menu; + private Action m_callback; + + public ToolStripItem MenuItem { get { return m_menu; } } + + public MenuItemWrapper(string text, MenuIcons icon, Action callback, IList subitems) + { + if (text == "-") + m_menu = new ToolStripSeparator(); + else + { + m_menu = new ToolStripMenuItem(text); + if (icon != MenuIcons.None) + m_menu.Image = GetIcon(icon); + + if (callback != null) + { + m_callback = callback; + m_menu.Click += OnMenuClick; + } + + if (subitems != null && subitems.Count > 0) + foreach(var itm in subitems) + ((ToolStripMenuItem)m_menu).DropDownItems.Add(((MenuItemWrapper)itm).MenuItem); + } + } + + private void OnMenuClick (object sender, EventArgs e) + { + m_callback(); + } + + private System.Drawing.Image GetIcon(MenuIcons icon) + { + switch(icon) + { + case MenuIcons.Pause: + return Properties.Resources.Pause; + case MenuIcons.Quit: + return Properties.Resources.CloseMenuIcon; + case MenuIcons.Resume: + return Properties.Resources.Play; + case MenuIcons.Status: + return Properties.Resources.StatusMenuIcon; + case MenuIcons.None: + default: + return null; + } + } + + #region IMenuItem implementation + public string Text { + set { + m_menu.Text = value; + } + } + + public MenuIcons Icon { + set { + m_menu.Image = GetIcon(value); + } + } + + public bool Enabled { + set { + m_menu.Enabled = value; + } + } + + public bool Default { + set { + m_menu.Font = new System.Drawing.Font(m_menu.Font, System.Drawing.FontStyle.Bold); + } + } + #endregion + } + + private Form m_handleProvider; + private NotifyIcon m_trayIcon; + + public static WinFormsRunner Instance = null; + + public override void Init (string[] args) + { + if (WinFormsRunner.Instance != null) + throw new Exception("Multiple trayicon instances not allowed!"); + + WinFormsRunner.Instance = this; + + //We need this ugly hack to get a handle that we can call Invoke on, + // and sadly the TrayIcon does not expose one, and forcing the context menu + // to create one causes weird "lost clicks" + m_handleProvider = new Form() + { + FormBorderStyle = FormBorderStyle.None, + Width = 10, + Height = 10, + Top = 0, + Left = 0 + }; + m_handleProvider.Show(); + m_handleProvider.Hide(); + + m_trayIcon = new NotifyIcon(); + m_trayIcon.DoubleClick += new EventHandler(m_trayIcon_DoubleClick); + m_trayIcon.Click += new EventHandler(m_trayIcon_Click); + base.Init(args); + } + + private void m_trayIcon_Click(object sender, EventArgs e) + { + if (m_onSingleClick != null) + m_onSingleClick(); + } + + private void m_trayIcon_DoubleClick(object sender, EventArgs e) + { + if (m_onDoubleClick != null) + m_onDoubleClick(); + } + + protected override void RegisterStatusUpdateCallback () + { + Program.Connection.StatusUpdated += delegate(IServerStatus status) { + m_handleProvider.Invoke(new Action(OnStatusUpdated), status); + }; + } + + #region implemented abstract members of Duplicati.GUI.TrayIcon.TrayIconBase + protected override void Run (string[] args) + { + m_trayIcon.Visible = true; + Application.Run(); + } + + protected override TrayIcons Icon { + set { + switch (value) + { + case TrayIcons.IdleError: + m_trayIcon.Icon = Properties.Resources.TrayNormalError; + break; + case TrayIcons.Paused: + m_trayIcon.Icon = Properties.Resources.TrayNormalPause; + break; + case TrayIcons.PausedError: + m_trayIcon.Icon = Properties.Resources.TrayNormalPause; + break; + case TrayIcons.Running: + m_trayIcon.Icon = Properties.Resources.TrayWorking; + break; + case TrayIcons.RunningError: + m_trayIcon.Icon = Properties.Resources.TrayWorking; + break; + case TrayIcons.Idle: + default: + m_trayIcon.Icon = Properties.Resources.TrayNormal; + break; + } + } + } + + protected override IMenuItem CreateMenuItem (string text, MenuIcons icon, Action callback, IList subitems) + { + return new MenuItemWrapper(text, icon, callback, subitems); + } + + protected override void Exit () + { + Application.Exit(); + } + + protected override void SetMenu (System.Collections.Generic.IEnumerable items) + { + m_trayIcon.ContextMenuStrip = new ContextMenuStrip(); + foreach(var itm in items) + m_trayIcon.ContextMenuStrip.Items.Add(((MenuItemWrapper)itm).MenuItem); + } + + public override void Dispose () + { + if (m_handleProvider != null) + { + m_handleProvider.Dispose(); + m_handleProvider = null; + } + + if (m_trayIcon != null) + { + m_trayIcon.Visible = false; + m_trayIcon.Dispose(); + m_trayIcon = null; + } + } + #endregion + + /*public override IBrowserWindow ShowUrlInWindow(string url) + { + var v = new WindowsBrowser(url); + v.Show(); + return v; + }*/ + } +} + diff --git a/Duplicati/Library/Utility/WorkerThread.cs b/Duplicati/Library/Utility/WorkerThread.cs index 2134d04a4..87856e1b7 100644 --- a/Duplicati/Library/Utility/WorkerThread.cs +++ b/Duplicati/Library/Utility/WorkerThread.cs @@ -63,19 +63,12 @@ namespace Duplicati.Library.Utility /// /// A callback that performs the actual work on the item /// - private ProcessItemDelegate m_delegate; - - /// - /// A delegate used to signal a changed state - /// - /// The sender of the event - /// The new state - public delegate void WorkerStateChangedDelegate(WorkerThread sender, RunState state); + private Action m_delegate; /// /// An event that is raised when the runner state changes /// - public event WorkerStateChangedDelegate WorkerStateChanged; + public event Action, RunState> WorkerStateChanged; /// /// Event that occurs when a new operation is being processed @@ -90,8 +83,6 @@ namespace Duplicati.Library.Utility /// public event EventHandler WorkQueueChanged; - public delegate void ProcessItemDelegate(Tx item); - /// /// The internal state /// @@ -116,7 +107,7 @@ namespace Duplicati.Library.Utility /// Constructs a new WorkerThread /// /// The callback that performs the work - public WorkerThread(ProcessItemDelegate item, bool paused) + public WorkerThread(Action item, bool paused) { m_delegate = item; m_event = new AutoResetEvent(paused); diff --git a/Duplicati/License/Duplicati.License.csproj b/Duplicati/License/Duplicati.License.csproj index 5ad3dabfc..ef7b016e7 100644 --- a/Duplicati/License/Duplicati.License.csproj +++ b/Duplicati/License/Duplicati.License.csproj @@ -60,14 +60,6 @@ licenses\gpg\License.txt PreserveNewest - - licenses\LightDataModel\Homepage.txt - PreserveNewest - - - licenses\LightDataModel\license.txt - PreserveNewest - licenses\LitJSON\download.txt PreserveNewest diff --git a/Duplicati/Server/Database/ApplicationSettings.cs b/Duplicati/Server/Database/ApplicationSettings.cs new file mode 100644 index 000000000..466f43578 --- /dev/null +++ b/Duplicati/Server/Database/ApplicationSettings.cs @@ -0,0 +1,56 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Database +{ + public class ApplicationSettings + { + internal ApplicationSettings(Connection con) + { + var settings = con.GetSettings(Connection.APP_SETTINGS_ID); + // TODO: Map options to settings + + } + + public string StartupDelayDuration + { + get ; + set ; + } + + public System.Threading.ThreadPriority? ThreadPriorityOverride + { + get; + set; + } + + public string DownloadSpeedLimit + { + get; + set; + } + + public string UploadSpeedLimit + { + get; + set; + } + } +} + diff --git a/Duplicati/Server/Database/Backup.cs b/Duplicati/Server/Database/Backup.cs new file mode 100644 index 000000000..4f932fcb1 --- /dev/null +++ b/Duplicati/Server/Database/Backup.cs @@ -0,0 +1,92 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; +using Duplicati.Server.Serialization.Interface; +using System.Collections.Generic; + +namespace Duplicati.Server.Database +{ + public class Backup : IBackup + { + + public Backup() + { + this.ID = -2; + } + + internal void LoadChildren(Connection con) + { + if (this.ID < 0) + { + this.Sources = new string[0]; + this.Settings = new ISetting[0]; + this.Filters = new IFilter[0]; + this.Metadata = new Dictionary(); + } + else + { + this.Sources = con.GetSources(this.ID); + this.Settings = con.GetSettings(this.ID); + this.Filters = con.GetFilters(this.ID); + this.Metadata = con.GetMetadata(this.ID); + } + } + + /// + /// The backup ID + /// + public long ID { get; set; } + /// + /// The backup name + /// + public string Name { get; set; } + /// + /// The backup tags + /// + public string[] Tags { get; set; } + /// + /// The backup target url, excluding username/password + /// + public string TargetURL { get; set; } + /// + /// The path to the local database + /// + public string DBPath { get; internal set; } + + /// + /// The backup source folders and files + /// + public string[] Sources { get; set; } + + /// + /// The backup settings + /// + public ISetting[] Settings { get; set; } + + /// + /// The filters applied to the source files + /// + public IFilter[] Filters { get; set; } + + /// + /// The backup metadata + /// + public IDictionary Metadata { get; set; } + } +} + diff --git a/Duplicati/Server/Database/Connection.cs b/Duplicati/Server/Database/Connection.cs new file mode 100644 index 000000000..b82d0901b --- /dev/null +++ b/Duplicati/Server/Database/Connection.cs @@ -0,0 +1,431 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; +using System.Collections.Generic; +using System.Linq; +using Duplicati.Server.Serialization.Interface; +using System.Text; + +namespace Duplicati.Server.Database +{ + public class Connection : IDisposable + { + private System.Data.IDbConnection m_connection; + public readonly object m_lock = new object(); + public const int ANY_BACKUP_ID = -1; + public const int APP_SETTINGS_ID = -2; + + public event EventHandler DataChanged; + + public Connection(System.Data.IDbConnection connection) + { + m_connection = connection; + this.ApplicationSettings = new ApplicationSettings(this); + } + + public ApplicationSettings ApplicationSettings { get; private set; } + + internal IDictionary GetMetadata(long id) + { + lock(m_lock) + return ReadFromDb( + (rd) => new KeyValuePair( + ConvertToString(rd.GetValue(0)), + ConvertToString(rd.GetValue(1)) + ), + @"SELECT ""Name"", ""Value"" FROM ""Metadata"" WHERE ""BackupID"" = ? ", id) + .ToDictionary((k) => k.Key, (k) => k.Value); + } + + internal void SetMetadata(IDictionary values, long id, System.Data.IDbTransaction transaction) + { + lock(m_lock) + using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + { + OverwriteAndUpdateDb( + tr, + @"DELETE FROM ""Metadata"" WHERE ""BackupID"" = ?", new object[] { id }, + values, + @"INSERT INTO ""Metadata"" (""BackupID"", ""Name"", ""Value"") VALUES (?, ?, ?)", + (f) => new object[] { id, f.Key, f.Value } + ); + + if (tr != null) + tr.Commit(); + } + } + + internal IFilter[] GetFilters(long id) + { + lock(m_lock) + return ReadFromDb( + (rd) => (IFilter)new Filter() { + Order = ConvertToInt64(rd.GetValue(0)), + Include = ConvertToBoolean(rd.GetValue(1)), + Expression = ConvertToString(rd.GetValue(2)) ?? "" + }, + @"SELECT ""Order"", ""Include"", ""Expression"" FROM ""Filter"" WHERE ""BackupID"" = ? ORDER BY ""Order"" ", id) + .ToArray(); + } + + internal void SetFilters(IEnumerable values, long id, System.Data.IDbTransaction transaction = null) + { + lock(m_lock) + using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + { + OverwriteAndUpdateDb( + tr, + @"DELETE FROM ""Filter"" WHERE ""BackupID"" = ?", new object[] { id }, + values, + @"INSERT INTO ""Filter"" (""BackupID"", ""Order"", ""Include"", ""Expression"") VALUES (?, ?, ?, ?)", + (f) => new object[] { id, f.Order, f.Include, f.Expression } + ); + + if (tr != null) + tr.Commit(); + } + } + + internal ISetting[] GetSettings(long id) + { + lock(m_lock) + return ReadFromDb( + (rd) => (ISetting)new Setting() { + Filter = ConvertToString(rd.GetValue(0)) ?? "", + Name = ConvertToString(rd.GetValue(1)) ?? "", + Value = ConvertToString(rd.GetValue(2)) ?? "" + //TODO: Attach the argument information + }, + @"SELECT ""Filter"", ""Name"", ""Value"" FROM ""Option"" WHERE ""BackupID"" = ?", id) + .ToArray(); + } + + internal void SetSettings(IEnumerable values, long id, System.Data.IDbTransaction transaction = null) + { + lock(m_lock) + using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + { + OverwriteAndUpdateDb( + tr, + @"DELETE FROM ""Option"" WHERE ""BackupID"" = ?", new object[] { id }, + values, + @"INSERT INTO ""Option"" (""BackupID"", ""Filter"", ""Name"", ""Value"") VALUES (?, ?, ?, ?)", + (f) => new object[] { id, f.Filter, f.Name, f.Value } + ); + + if (tr != null) + tr.Commit(); + } + } + + internal string[] GetSources(long id) + { + lock(m_lock) + return ReadFromDb( + (rd) => ConvertToString(rd.GetValue(0)), + @"SELECT ""Path"" FROM ""Source"" WHERE ""BackupID"" = ?", id) + .ToArray(); + } + + internal void SetSources(IEnumerable values, long id, System.Data.IDbTransaction transaction) + { + lock(m_lock) + using(var tr = transaction == null ? m_connection.BeginTransaction() : null) + { + OverwriteAndUpdateDb( + tr, + @"DELETE FROM ""Source"" WHERE ""BackupID"" = ?", new object[] { id }, + values, + @"INSERT INTO ""Source"" (""BackupID"", ""Path"") VALUES (?, ?)", + (f) => new object[] { id, f } + ); + + if (tr != null) + tr.Commit(); + } + } + + internal long[] GetBackupIDsForTags(string[] tags) + { + if (tags == null || tags.Length == 0) + return new long[0]; + + if (tags.Length == 1 && tags[0].StartsWith("ID=")) + return new long[] { long.Parse(tags[0].Substring("ID=".Length)) }; + + lock(m_lock) + using(var cmd = m_connection.CreateCommand()) + { + var sb = new StringBuilder(); + + foreach(var t in tags) + { + if (sb.Length != 0) + sb.Append(" OR "); + sb.Append(@" ("","" || ""Tag"" || "","" LIKE ""%,"" || ? || "",%"") "); + + cmd.Parameters.Add(t); + } + + cmd.CommandText = @"SELECT ""ID"" FROM ""Backup"" WHERE " + sb.ToString(); + + return Read(cmd, (rd) => ConvertToInt64(rd.GetValue(0))).ToArray(); + } + } + + internal IBackup GetBackup(long id) + { + lock(m_lock) + { + var bk = ReadFromDb( + (rd) => new Backup() { + ID = ConvertToInt64(rd.GetValue(0)), + Name = ConvertToString(rd.GetValue(1)), + Tags = (ConvertToString(rd.GetValue(2)) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), + TargetURL = ConvertToString(rd.GetValue(3)), + DBPath = ConvertToString(rd.GetValue(4)), + }, + @"SELECT ""ID"", ""Name"", ""Tag"", ""TargetURL"", ""DBPath"" FROM ""Backup"" WHERE ID = ?", id) + .FirstOrDefault(); + + if (bk != null) + bk.LoadChildren(this); + + return bk; + } + } + + internal void AddOrUpdateBackup(IBackup item) + { + lock(m_lock) + using(var tr = m_connection.BeginTransaction()) + { + bool update = item.ID >= 0; + OverwriteAndUpdateDb( + tr, + update ? @"DELETE FROM ""Backup"" WHERE ""ID"" = ?" : null, + new object[] { item.ID }, + new IBackup[] { item }, + update ? + @"UPDATE ""Backup"" SET ""Name""=?, ""Tag""=?, ""TargetURL""=? WHERE ""ID""=?" : + @"INSERT INTO ""Backup"" (""Name"", ""Tag"", ""TargetURL"", ""DBPath"") VALUES (?,?,?,?)", + (n) => new object[] { + n.Name, + string.Join(",", n.Tags), + n.TargetURL, + update ? (object)item.ID : (object)n.DBPath + }); + + if (!update) + using(var cmd = m_connection.CreateCommand()) + { + cmd.Transaction = tr; + cmd.CommandText = @"SELECT last_insert_rowid;"; + item.ID = ConvertToInt64(cmd.ExecuteScalar()); + } + + SetSources(item.Sources, item.ID, tr); + SetSettings(item.Settings, item.ID, tr); + SetFilters(item.Filters, item.ID, tr); + SetMetadata(item.Metadata, item.ID, tr); + + tr.Commit(); + } + } + + public IBackup[] Backups + { + get + { + lock(m_lock) + { + var lst = ReadFromDb( + (rd) => (IBackup)new Backup() { + ID = ConvertToInt64(rd.GetValue(0)), + Name = ConvertToString(rd.GetValue(1)), + Tags = (ConvertToString(rd.GetValue(2)) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), + TargetURL = ConvertToString(rd.GetValue(3)), + DBPath = ConvertToString(rd.GetValue(4)), + }, + @"SELECT ""ID"", ""Name"", ""Tag"", ""TargetURL"", ""DBPath"" FROM ""Backup"" ") + .ToArray(); + + foreach(var n in lst) + n.Metadata = GetMetadata(n.ID); + + return lst; + } + } + } + + public ISchedule[] Schedules + { + get + { + lock(m_lock) + return ReadFromDb( + (rd) => (ISchedule)new Schedule() { + ID = ConvertToInt64(rd.GetValue(0)), + Tags = (ConvertToString(rd.GetValue(1)) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), + Time = ConvertToDateTime(rd.GetValue(2)), + Repeat = ConvertToString(rd.GetValue(3)), + LastRun = ConvertToDateTime(rd.GetValue(4)), + Rule = ConvertToString(rd.GetValue(5)), + }, + @"SELECT ""ID"", ""Tag"", ""Time"", ""Repeat"", ""LastRun"", ""Rule"" FROM ""Schedule"" ") + .ToArray(); + } + } + + + public IFilter[] Filters + { + get { return GetFilters(ANY_BACKUP_ID); } + set { SetFilters(value, ANY_BACKUP_ID); } + } + + public ISetting[] Settings + { + get { return GetSettings(ANY_BACKUP_ID); } + set { SetSettings(value, ANY_BACKUP_ID); } + } + + /// + /// Normalizes a DateTime instance floor'ed to seconds and in UTC + /// + /// The normalised date time + /// The input time + public static DateTime NormalizeDateTime(DateTime input) + { + var ticks = input.ToUniversalTime().Ticks; + ticks -= ticks % TimeSpan.TicksPerSecond; + return new DateTime(ticks, DateTimeKind.Utc); + } + + private static long NormalizeDateTimeToEpochSeconds(DateTime input) + { + return (long)Math.Floor((NormalizeDateTime(input) - Library.Utility.Utility.EPOCH).TotalSeconds); + } + + private static DateTime ConvertToDateTime(object r) + { + var unixTime = ConvertToInt64(r); + if (unixTime == 0) + return new DateTime(0); + + return Library.Utility.Utility.EPOCH.AddSeconds(unixTime); + } + + private static bool ConvertToBoolean(object r) + { + return ConvertToInt64(r) == 1; + } + + private static string ConvertToString(object r) + { + if (r == null || r == DBNull.Value) + return null; + else + return r.ToString(); + } + + private static long ConvertToInt64(object r, long @default = 0) + { + if (r == null || r == DBNull.Value) + return @default; + else + return Convert.ToInt64(r); + } + + private static IEnumerable Read(System.Data.IDbCommand cmd, Func f) + { + using(var rd = cmd.ExecuteReader()) + while(rd.Read()) + yield return f(rd); + } + + private static IEnumerable Read(System.Data.IDataReader rd, Func f) + { + while(rd.Read()) + yield return f(); + } + + private IEnumerable ReadFromDb(Func f, string sql, params object[] args) + { + using(var cmd = m_connection.CreateCommand()) + { + cmd.CommandText = sql; + if (args != null) + foreach(var a in args) + cmd.Parameters.Add(a); + + return Read(cmd, f); + } + } + + private void OverwriteAndUpdateDb(System.Data.IDbTransaction transaction, string deleteSql, object[] deleteArgs, IEnumerable values, string insertSql, Func f) + { + using(var cmd = m_connection.CreateCommand()) + { + cmd.Transaction = transaction; + + if (!string.IsNullOrEmpty(deleteSql)) + { + cmd.CommandText = deleteSql; + if (deleteArgs != null) + foreach(var a in deleteArgs) + cmd.Parameters.Add(a); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + + foreach(var n in values) + { + var r = f(n); + if (r == null) + continue; + + while (cmd.Parameters.Count < r.Length) + cmd.Parameters.Add(cmd.CreateParameter()); + + for(var i = 0; i < r.Length; i++) + cmd.Parameters[i] = r[i]; + + cmd.ExecuteNonQuery(); + } + } + } + + #region IDisposable implementation + public void Dispose() + { + try + { + if (m_connection != null) + m_connection.Dispose(); + } + catch + { + } + } + #endregion + } + +} + diff --git a/Duplicati/Server/Database/Database Schema/Schema.sql b/Duplicati/Server/Database/Database Schema/Schema.sql new file mode 100644 index 000000000..9d134a937 --- /dev/null +++ b/Duplicati/Server/Database/Database Schema/Schema.sql @@ -0,0 +1,102 @@ +/* + * The primary table that stores all backups. + * + * The name and tag are free form user strings. + * The tags are comma seperated + * the TargetURL is the url to remote storage, + * and the DBPath is the path to the local database + */ +CREATE TABLE "Backup" ( + "ID" INTEGER PRIMARY KEY, + "Name" TEXT NOT NULL, + "Tag" TEXT NOT NULL, + "TargetURL" TEXT NOT NULL, + "DBPath" TEXT NOT NULL +); + +/* + * The table that stores all schedules + * + * Tags is a comma separated parsed field that indicates + * which backups * to run when activated. + * special tags are ID:1 which means backup with ID = 1 + * + * Time is the scheduled time, and lastRun is the last time the backup was executed + * + * Rule is a special parsed field + */ +CREATE TABLE "Schedule" ( + "ID" INTEGER PRIMARY KEY, + "Tags" TEXT NOT NULL, + "Time" INTEGER NOT NULL, + "Repeat" INTEGER NOT NULL, + "LastRun" INTEGER NOT NULL, + "Rule" TEXT NOT NULL +); + +/* + * The source table is a list of source folders and files + */ +CREATE TABLE "Source" ( + "BackupID" INTEGER NOT NULL, + "Path" TEXT NOT NULL +); + +/* + * The filter table contains all filters associated with a backup. + * The special backupID -1 means "applied to all backups" + * The expression is the filter, if the filter is a regular + * expression, it is surrounded by hard brackets [ ] + */ +CREATE TABLE "Filter" ( + "BackupID" INTEGER NOT NULL, + "Order" INTEGER NOT NULL, + "Include" INTEGER NOT NULL, + "Expression" TEXT NOT NULL +); + +/* + * All options are stored in this table + * + * The special backupID -1 means "applied to all backups". + * + * The filter is used to indicate what the option applies to, + * for instance backend:s3 will only apply to backends of type S3 + * + * The name and value are the option name and value + */ +CREATE TABLE "Option" ( + "BackupID" INTEGER NOT NULL, + "Filter" TEXT NOT NULL, + "Name" TEXT NOT NULL, + "Value" TEXT NOT NULL +); + +/* + * Recorded metadata about a backup + * This table contains metadata, such as when the backup was last started, + * how long it took, how many files there were, how big the backup set was, + * how much data was uploaded, downloaded, how fast, how much space is left, + * and similar data. Programs can use this information to improve the display, + * but cannot count on these values being present + */ +CREATE TABLE "Metadata" ( + "BackupID" INTEGER NOT NULL, + "Name" TEXT NOT NULL, + "Value" TEXT NOT NULL +); + +/* + * The log of operations initiated by the scheduler/user + */ +CREATE TABLE "Log" ( + "BackupID" INTEGER NOT NULL, + "Description" TEXT NOT NULL, + "Start" INTEGER NOT NULL, + "Finish" INTEGER NOT NULL, + "Result" TEXT NOT NULL + "SuggestedIcon" TEXT NOT NULL +); + + + diff --git a/Duplicati/Server/Database/Filter.cs b/Duplicati/Server/Database/Filter.cs new file mode 100644 index 000000000..4127fccaa --- /dev/null +++ b/Duplicati/Server/Database/Filter.cs @@ -0,0 +1,31 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Database +{ + public class Filter : Duplicati.Server.Serialization.Interface.IFilter + { + public long Order { get; set; } + + public bool Include { get; set; } + + public string Expression { get; set; } + } +} + diff --git a/Duplicati/Server/Database/Schedule.cs b/Duplicati/Server/Database/Schedule.cs new file mode 100644 index 000000000..82a8b30e7 --- /dev/null +++ b/Duplicati/Server/Database/Schedule.cs @@ -0,0 +1,79 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; +using System.Linq; + +namespace Duplicati.Server.Database +{ + public class Schedule + { + public long ID { get; set; } + public string[] Tags { get; set; } + public DateTime Time { get; set; } + public string Repeat { get; set; } + public DateTime LastRun { get; set; } + public string Rule { get; set; } + + public DayOfWeek[] AllowedDays + { + get + { + if (string.IsNullOrEmpty(this.Rule)) + return null; + + var days = (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries) + where n.StartsWith("AllowedWeekDays=", StringComparison.InvariantCultureIgnoreCase) + select n.Substring("AllowedWeekDays=".Length).Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries)) + .FirstOrDefault(); + + + if (days == null) + return null; + + DayOfWeek dw = DayOfWeek.Monday; + return (from n in days + where Enum.TryParse(n, true, out dw) + select (DayOfWeek)Enum.Parse(typeof(DayOfWeek), n, true)) + .ToArray(); + } + set + { + + var parts = + string.IsNullOrEmpty(this.Rule) ? + new string[0] : + (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries) + where !n.StartsWith("AllowedWeekDays=", StringComparison.InvariantCultureIgnoreCase) + select n); + + if (value != null && value.Length != 0) + parts.Union(new string[] { + "AllowedWeekDays=" + + string.Join( + ",", + (from n in value + select Enum.GetName(typeof(DayOfWeek), n)) + .Distinct()) + }); + + this.Rule = string.Join(";", parts); + } + } + } +} + diff --git a/Duplicati/Server/Database/Setting.cs b/Duplicati/Server/Database/Setting.cs new file mode 100644 index 000000000..9103ce091 --- /dev/null +++ b/Duplicati/Server/Database/Setting.cs @@ -0,0 +1,40 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Database +{ + public class Setting + { + public string Filter { get; set; } + /// + /// The setting option + /// + public string Name { get; set; } + /// + /// The setting value + /// + public string Value { get; set; } + + /// + /// The actual option arguments + /// + public Duplicati.Library.Interface.ICommandLineArgument Argument { get; private set; } + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Duplicati.Server.Serialization.csproj b/Duplicati/Server/Duplicati.Server.Serialization/Duplicati.Server.Serialization.csproj index 94d99bb02..042eefa50 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Duplicati.Server.Serialization.csproj +++ b/Duplicati/Server/Duplicati.Server.Serialization/Duplicati.Server.Serialization.csproj @@ -36,9 +36,6 @@ Duplicati.snk - - ..\..\..\thirdparty\LightDataModel\LightDatamodel.dll - @@ -52,18 +49,20 @@ - - - - - - + + + + + + + + @@ -86,4 +85,7 @@ --> + + + \ No newline at end of file diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Enums.cs b/Duplicati/Server/Duplicati.Server.Serialization/Enums.cs index ffdef921e..b0a1ca331 100755 --- a/Duplicati/Server/Duplicati.Server.Serialization/Enums.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Enums.cs @@ -42,30 +42,10 @@ namespace Duplicati.Server.Serialization Backup, Restore, List, - Remove - } - - public enum DuplicatiOperationMode - { - Backup, - BackupFull, - BackupIncremental, - Restore, - RestoreControlfiles, - List, - GetBackupSets, - ListCurrentFiles, - ListSourceFolders, - ListActualSignatureFiles, - DeleteAllButNFull, - DeleteAllButN, - DeleteOlderThan, - CleanUp, - CreateFolder, - FindLastFileVersion, + Remove, Verify } - + public enum SuggestedStatusIcon { Ready, diff --git a/Duplicati/Server/Duplicati.Server.Serialization/IBackendSettings.cs b/Duplicati/Server/Duplicati.Server.Serialization/IBackendSettings.cs deleted file mode 100644 index a6794162d..000000000 --- a/Duplicati/Server/Duplicati.Server.Serialization/IBackendSettings.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Duplicati.Server.Serialization -{ - public interface IBackendSettings - { - /// - /// Gets or sets a string with all relevant properties encoded as a semi-valid URI - /// - string ConnectionURI { get; set; } - - /// - /// The username used to connect to the server - /// - string Username { get; set; } - - /// - /// The password used to connect to the server - /// - string Password { get; set; } - - /// - /// A lookup table with settings applied to the backend - /// - IDictionary Settings { get; set; } - } -} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/IFilterSet.cs b/Duplicati/Server/Duplicati.Server.Serialization/IFilterSet.cs deleted file mode 100644 index 5e2af774e..000000000 --- a/Duplicati/Server/Duplicati.Server.Serialization/IFilterSet.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Duplicati.Server.Serialization -{ - public enum FilterType - { - Include, - Exclude, - IncludeRegexp, - ExcludeRegexp, - ExcludeSize, - ExcludeOlderThan, - ExcludeNewerThan - } - - /// - /// Interface for a single filter set - /// - public interface IFilterSet - { - /// - /// Name of the filterset - /// - string Name { get; set; } - - /// - /// List of filters in this set - /// - IList> Filters { get; set; } - } -} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/BackendSettings.cs b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/BackendSettings.cs deleted file mode 100644 index 41734e526..000000000 --- a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/BackendSettings.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Duplicati.Server.Serialization.Implementations -{ - public class BackendSettings : IBackendSettings - { - public string ConnectionURI { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public IDictionary Settings { get; set; } - } -} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/FilterSet.cs b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/FilterSet.cs deleted file mode 100644 index 4c6e8150d..000000000 --- a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/FilterSet.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Duplicati.Server.Serialization.Implementations -{ - internal class FilterSet : IFilterSet - { - public string Name { get; set; } - public IList> Filters { get; set; } - } -} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ProgressEventData.cs b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ProgressEventData.cs index 2563473bb..0c1d7f2a7 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ProgressEventData.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ProgressEventData.cs @@ -5,12 +5,10 @@ using System.Text; namespace Duplicati.Server.Serialization.Implementations { - internal class ProgressEventData : IProgressEventData + internal class ProgressEventData : Interface.IProgressEventData { public DuplicatiOperation Operation { get; set; } - public DuplicatiOperationMode Mode { get; set; } - public string Message { get; set; } public string SubMessage { get; set; } @@ -21,7 +19,7 @@ namespace Duplicati.Server.Serialization.Implementations public long LastEventID { get; set; } - public IProgressEventData Clone() + public Interface.IProgressEventData Clone() { return (ProgressEventData)this.MemberwiseClone(); } diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs index 0319889c7..d9aea50d9 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs @@ -1,22 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Duplicati.Server.Serialization.Implementations -{ - internal class ServerStatus : IServerStatus - { - public RunnerState ActiveBackupState { get; set; } - public long ActiveScheduleId { get; set; } - public LiveControlState ProgramState { get; set; } - public IList SchedulerQueueIds { get; set; } - public bool HasError { get; set; } - public bool HasWarning { get; set; } - public SuggestedStatusIcon SuggestedStatusIcon { get; set; } - public DateTime LastLogUpdate { get; set; } - public DateTime EstimatedPauseEnd { get; set; } - public long LastEventID { get; set; } - public long LastDataUpdateID { get; set; } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Duplicati.Server.Serialization.Implementations +{ + internal class ServerStatus : Interface.IServerStatus + { + public RunnerState ActiveBackupState { get; set; } + public long ActiveScheduleId { get; set; } + public LiveControlState ProgramState { get; set; } + public IList SchedulerQueueIds { get; set; } + public bool HasError { get; set; } + public bool HasWarning { get; set; } + public SuggestedStatusIcon SuggestedStatusIcon { get; set; } + public DateTime EstimatedPauseEnd { get; set; } + public long LastEventID { get; set; } + public long LastDataUpdateID { get; set; } + } +} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs new file mode 100644 index 000000000..d7b482095 --- /dev/null +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs @@ -0,0 +1,70 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; +using System.Collections.Generic; + +namespace Duplicati.Server.Serialization.Interface +{ + /// + /// All settings for a single backup + /// + public interface IBackup + { + /// + /// The backup ID + /// + long ID { get; set; } + /// + /// The backup name + /// + string Name { get; set; } + /// + /// The backup tags + /// + string[] Tags { get; set; } + /// + /// The backup target url, excluding username/password + /// + string TargetURL { get; set; } + /// + /// The path to the local database + /// + string DBPath { get; } + + /// + /// The backup source folders and files + /// + string[] Sources { get; set; } + + /// + /// The backup settings + /// + ISetting[] Settings { get; set; } + + /// + /// The filters applied to the source files + /// + IFilter[] Filters { get; set; } + + /// + /// The backup metadata + /// + IDictionary Metadata { get; set; } + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IDynamicModule.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IDynamicModule.cs new file mode 100644 index 000000000..ed66a4b84 --- /dev/null +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IDynamicModule.cs @@ -0,0 +1,42 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; +using System.Collections.Generic; + +namespace Duplicati.Server.Serialization.Interface +{ + /// + /// The dynamic module + /// + public interface IDynamicModule + { + /// + /// The module key + /// + string Key { get; } + /// + /// The localized module description + /// + string Description { get; } + /// + /// The options supported by the module + /// + Duplicati.Library.Interface.ICommandLineArgument[] Options { get; } + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IFilter.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IFilter.cs new file mode 100644 index 000000000..3c68dfe01 --- /dev/null +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IFilter.cs @@ -0,0 +1,44 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Serialization.Interface +{ + /// + /// Represents a single filter + /// + public interface IFilter + { + /// + /// The sort order + /// + long Order { get; set; } + + /// + /// True if the filter includes the items, false if it excludes + /// + bool Include { get; set; } + + /// + /// The filter expression. + /// If the filter is a regular expression, it starts and ends with hard brackets [ ] + /// + string Expression { get; set; } + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/IProgressEventData.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IProgressEventData.cs similarity index 77% rename from Duplicati/Server/Duplicati.Server.Serialization/IProgressEventData.cs rename to Duplicati/Server/Duplicati.Server.Serialization/Interface/IProgressEventData.cs index 4da86651e..098bb2771 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/IProgressEventData.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IProgressEventData.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace Duplicati.Server.Serialization +namespace Duplicati.Server.Serialization.Interface { public interface IProgressEventData { DuplicatiOperation Operation { get; } - DuplicatiOperationMode Mode { get; } string Message { get; } string SubMessage { get; } int Progress { get; } diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/ISchedule.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/ISchedule.cs new file mode 100644 index 000000000..38fb4c204 --- /dev/null +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/ISchedule.cs @@ -0,0 +1,54 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Serialization.Interface +{ + /// + /// A single schedule + /// + public interface ISchedule + { + /// + /// The Schedule ID + /// + long ID { get; set; } + /// + /// The tags that this schedule affects + /// + string[] Tags { get; set; } + /// + /// The time this schedule is based on + /// + DateTime Time { get; set; } + /// + /// How often the backup is repeated + /// + string Repeat { get; set; } + /// + /// The time this schedule was last executed + /// + /// The last run. + DateTime LastRun { get; set; } + /// + /// The rule that is parsed to figure out when to run this backup next time + /// + DayOfWeek[] AllowedDays { get; set; } + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs new file mode 100644 index 000000000..d0d8fb26b --- /dev/null +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs @@ -0,0 +1,54 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Serialization.Interface +{ + /// + /// Gets all server settings + /// + public interface IServerSettings + { + /// + /// The backend modules known by the server + /// + IDynamicModule[] BackendModules { get; } + /// + /// The encryption modules known by the server + /// + IDynamicModule[] EncryptionModules { get; } + /// + /// The compression modules known by the server + /// + IDynamicModule[] CompressionModules { get; } + /// + /// The generic modules known by the server + /// + IDynamicModule[] GenericModules { get; } + + /// + /// The filters that are applied to all backups + /// + IFilter[] Filters { get; } + /// + /// The settings applied to all backups by default + /// + ISetting[] Settings { get; } + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/IServerStatus.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerStatus.cs similarity index 84% rename from Duplicati/Server/Duplicati.Server.Serialization/IServerStatus.cs rename to Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerStatus.cs index e2306e17b..fc30f2e6e 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/IServerStatus.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerStatus.cs @@ -1,20 +1,19 @@ -using System; -using System.Collections.Generic; - -namespace Duplicati.Server.Serialization -{ - public interface IServerStatus - { - RunnerState ActiveBackupState { get; } - long ActiveScheduleId { get; } - LiveControlState ProgramState { get; } - System.Collections.Generic.IList SchedulerQueueIds { get; } - bool HasWarning { get; } - bool HasError { get; } - SuggestedStatusIcon SuggestedStatusIcon { get; } - DateTime LastLogUpdate { get; } - DateTime EstimatedPauseEnd { get; } - long LastEventID { get; } - long LastDataUpdateID { get; } - } -} +using System; +using System.Collections.Generic; + +namespace Duplicati.Server.Serialization.Interface +{ + public interface IServerStatus + { + RunnerState ActiveBackupState { get; } + long ActiveScheduleId { get; } + LiveControlState ProgramState { get; } + System.Collections.Generic.IList SchedulerQueueIds { get; } + bool HasWarning { get; } + bool HasError { get; } + SuggestedStatusIcon SuggestedStatusIcon { get; } + DateTime EstimatedPauseEnd { get; } + long LastEventID { get; } + long LastDataUpdateID { get; } + } +} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/ISetting.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/ISetting.cs new file mode 100644 index 000000000..daad19397 --- /dev/null +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/ISetting.cs @@ -0,0 +1,47 @@ +// Copyright (C) 2011, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; + +namespace Duplicati.Server.Serialization.Interface +{ + /// + /// A single setting + /// + public interface ISetting + { + /// + /// The filter expression + /// + string Filter { get; } + /// + /// The setting option + /// + string Name { get; set; } + /// + /// The setting value + /// + string Value { get; set; } + + /// + /// The actual option arguments + /// + Duplicati.Library.Interface.ICommandLineArgument Argument { get; } + + } +} + diff --git a/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs b/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs index 774e06d47..c0c7fb35d 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs @@ -6,35 +6,19 @@ using Newtonsoft.Json.Converters; namespace Duplicati.Server.Serialization { - public class SerializableStatusCreator : CustomCreationConverter + public class SerializableStatusCreator : CustomCreationConverter { - public override IServerStatus Create(Type objectType) + public override Interface.IServerStatus Create(Type objectType) { return new Implementations.ServerStatus(); } } - public class ProgressEventDataCreator : CustomCreationConverter + public class ProgressEventDataCreator : CustomCreationConverter { - public override IProgressEventData Create(Type objectType) + public override Interface.IProgressEventData Create(Type objectType) { return new Implementations.ProgressEventData(); } } - - public class BackendSettingsCreator : CustomCreationConverter - { - public override IBackendSettings Create(Type objectType) - { - return new Implementations.BackendSettings(); - } - } - - public class FilterSetCreator : CustomCreationConverter - { - public override IFilterSet Create(Type objectType) - { - return new Implementations.FilterSet(); - } - } } diff --git a/Duplicati/Server/Duplicati.Server.Serialization/JsonSerializer.cs b/Duplicati/Server/Duplicati.Server.Serialization/JsonSerializer.cs index 0e3fee1c8..1cf393ad6 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/JsonSerializer.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/JsonSerializer.cs @@ -26,82 +26,29 @@ namespace Duplicati.Server.Serialization { internal class JsonSerializer : DefaultContractResolver { - private static readonly Dictionary m_ignoreList; - private static readonly Dictionary m_renameList; - static JsonSerializer() { - m_ignoreList = new Dictionary(); - m_ignoreList.Add("Duplicati.Datamodel.ApplicationSettings!RawOptions", null); - m_ignoreList.Add("Duplicati.Datamodel.Task!Extensions", null); - m_ignoreList.Add("Duplicati.Datamodel.Task!SortedFilters", null); - m_ignoreList.Add("Duplicati.Datamodel.Task!EncodedFilter", null); - m_ignoreList.Add("Duplicati.Datamodel.Task!ExistsInDb", null); - m_ignoreList.Add("Duplicati.Datamodel.Schedule!ExistsInDb", null); - - m_renameList = new Dictionary(); - m_renameList.Add("Duplicati.Datamodel.Schedule!MetadataLookup", "Metadata"); - m_renameList.Add("Duplicati.Datamodel.Task!BackendSettingsLookup", "BackendSettings"); - m_renameList.Add("Duplicati.Datamodel.Task!TaskExtensionsLookup", "Extensions"); - m_renameList.Add("Duplicati.Datamodel.Task!TaskOverridesLookup", "Overrides"); - m_renameList.Add("Duplicati.Datamodel.Task!EncryptionSettingsLookup", "EncryptionSettings"); - m_renameList.Add("Duplicati.Datamodel.Task!CompressionSettingsLookup", "CompressionSettings"); - m_renameList.Add("Duplicati.Datamodel.Task!FilterXml", "Filter"); } private static string MemberInfoAsKey(MemberInfo mi) { return mi.DeclaringType.FullName + "!" + mi.Name; } private static string ExposedNamed(MemberInfo mi) { - string newname; + /*string newname; if (!m_renameList.TryGetValue(MemberInfoAsKey(mi), out newname)) newname = mi.Name; - return newname; + return newname;*/ + return mi.Name; } protected override List GetSerializableMembers(Type objectType) { - return base.GetSerializableMembers(objectType).Where(x => !m_ignoreList.ContainsKey(MemberInfoAsKey(x))).ToList(); + //return base.GetSerializableMembers(objectType).Where(x => !m_ignoreList.ContainsKey(MemberInfoAsKey(x))).ToList(); + return base.GetSerializableMembers(objectType); } protected override JsonObjectContract CreateObjectContract (Type objectType) { - if (typeof(System.Data.LightDatamodel.IDataFetcher).IsAssignableFrom(objectType)) - { - //If this type was ever serialized, it would expose the entire internal object cache, and we do NOT want that :) - throw new Exception("Internal error, a non-serializable type was hit"); - } - else if (typeof(System.Data.LightDatamodel.IDataClass).IsAssignableFrom(objectType)) - { - JsonObjectContract joc = new JsonObjectContract(objectType); - joc.OverrideConstructor = objectType.GetConstructor(Type.EmptyTypes); - - foreach(var pi in objectType.GetProperties( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance )) - { - var customs = pi.GetCustomAttributes(false); - bool isRef = customs.Select(x => x.GetType()).Contains(typeof(System.Data.LightDatamodel.DataClassAttributes.Affects)); - bool isParent = typeof(System.Data.LightDatamodel.IDataFetcher).IsAssignableFrom(pi.PropertyType); - isRef |= typeof(System.Data.LightDatamodel.IDataClass).IsAssignableFrom(pi.PropertyType); - bool ignored = isRef || isParent || m_ignoreList.ContainsKey(MemberInfoAsKey(pi)); - - if (!ignored) - { - joc.Properties.Add(new JsonProperty() - { - PropertyName = ExposedNamed(pi), - PropertyType = pi.PropertyType, - Ignored = ignored, - UnderlyingName = pi.Name, - Readable = pi.CanRead, - Writable = pi.CanWrite & pi.Name != "ID", - ValueProvider = CreateMemberValueProvider(pi) - }); - } - } - - return joc; - } - else - return base.CreateObjectContract (objectType); + return base.CreateObjectContract (objectType); } protected override IValueProvider CreateMemberValueProvider(MemberInfo member) diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs b/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs index 1ce128bce..659dfaa38 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs @@ -19,9 +19,7 @@ namespace Duplicati.Server.Serialization m_jsonSettings.ContractResolver = new JsonSerializer(); m_jsonSettings.Converters = new JsonConverter[] { new SerializableStatusCreator(), - new ProgressEventDataCreator(), - new BackendSettingsCreator(), - new FilterSetCreator(), + new ProgressEventDataCreator() }.ToList(); } diff --git a/Duplicati/Server/Duplicati.Server.csproj b/Duplicati/Server/Duplicati.Server.csproj index ad186ae39..2f8a686c3 100644 --- a/Duplicati/Server/Duplicati.Server.csproj +++ b/Duplicati/Server/Duplicati.Server.csproj @@ -48,9 +48,6 @@ ..\..\thirdparty\HttpServer\HttpServer.MVC.dll - - ..\..\thirdparty\LightDataModel\LightDatamodel.dll - @@ -66,17 +63,12 @@ - - - - - DuplicatiRunner.resx @@ -103,14 +95,22 @@ True True - + + + + + + + + - + + @@ -125,18 +125,10 @@ {81765A64-3661-4E3E-B850-2F6F87A51F74} Duplicati.CommandLine - - {B60D0993-B0C5-457A-90D9-DB6EEB33CE47} - Datamodel - {FC9B7611-836F-4127-8B44-A7C31F506807} Duplicati.Library.Backend.File - - {42C91180-11EB-4590-82EA-80FE9D4DEBEC} - Duplicati.Library.Backend.GoogleDocs - {CCD76347-7DC7-4B42-B7E1-E500E624CAC3} Duplicati.Library.Backend.SkyDrive @@ -236,6 +228,8 @@ + + - - 1D - 13:00:00 - - - aes - zip - - - true - true - false - true - false - true - 50MB - - - true - 4 - 1M - - - *\Thumbs.db - - - - - \ No newline at end of file diff --git a/Duplicati/Server/newbackup.json b/Duplicati/Server/newbackup.json new file mode 100644 index 000000000..fcfaaf0a5 --- /dev/null +++ b/Duplicati/Server/newbackup.json @@ -0,0 +1,13 @@ +{ + Backup: { + Settings: { + "encryption-module": "aes", + "compression-module": "zip", + "dblock-size": "50mb" + } + }, + Schedule: { + Repeat: "1D" + Time: "13:00:00" + } +} \ No newline at end of file