// Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // // 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; using Duplicati.Library.RestAPI; using Duplicati.Server.Serialization.Interface; namespace Duplicati.Server.Serializable { /// /// The server config /// public static class ServerSettings { /// /// Shared implementation for reporting dynamic modules /// private class DynamicModule : IDynamicModule { /// /// Constructor for backend interface /// public DynamicModule(Duplicati.Library.Interface.IBackend backend) { this.Key = backend.ProtocolKey; this.Description = backend.Description; this.DisplayName = backend.DisplayName; if (backend.SupportedCommands != null) this.Options = backend.SupportedCommands.ToArray(); } /// /// Constructor for compression module interface /// public DynamicModule(Duplicati.Library.Interface.ICompression module) { this.Key = module.FilenameExtension; this.Description = module.Description; this.DisplayName = module.DisplayName; if (module.SupportedCommands != null) this.Options = module.SupportedCommands.ToArray(); } /// /// Constructor for encryption module interface /// public DynamicModule(Duplicati.Library.Interface.IEncryption module) { this.Key = module.FilenameExtension; this.Description = module.Description; this.DisplayName = module.DisplayName; if (module.SupportedCommands != null) this.Options = module.SupportedCommands.ToArray(); } /// /// Constructor for generic module interface /// public DynamicModule(Duplicati.Library.Interface.IGenericModule module) { this.Key = module.Key; this.Description = module.Description; this.DisplayName = module.DisplayName; if (module.SupportedCommands != null) this.Options = module.SupportedCommands.ToArray(); } /// /// Constructor for webmodule interface /// public DynamicModule(Duplicati.Library.Interface.IWebModule module) { this.Key = module.Key; this.Description = module.Description; this.DisplayName = module.DisplayName; if (module.SupportedCommands != null) this.Options = module.SupportedCommands.ToArray(); } /// /// The module key /// public string Key { get; private set; } /// /// The localized module description /// public string Description { get; private set; } /// /// Gets the localized display name /// /// The display name. public string DisplayName { get; private set; } /// /// The options supported by the module /// public Duplicati.Library.Interface.ICommandLineArgument[] Options { get; private set; } } /// /// Gets all supported options /// public static Duplicati.Library.Interface.ICommandLineArgument[] Options { get { return new Duplicati.Library.Main.Options(new System.Collections.Generic.Dictionary()).SupportedCommands.ToArray(); } } /// /// The backend modules known by the server /// public static IDynamicModule[] BackendModules { get { return (from n in Library.DynamicLoader.BackendLoader.Backends select new DynamicModule(n)) .ToArray(); } } /// /// The encryption modules known by the server /// public static IDynamicModule[] EncryptionModules { get { return (from n in Library.DynamicLoader.EncryptionLoader.Modules select new DynamicModule(n)) .ToArray(); } } /// /// The compression modules known by the server /// public static IDynamicModule[] CompressionModules { get { return (from n in Library.DynamicLoader.CompressionLoader.Modules select new DynamicModule(n)) .ToArray(); } } /// /// The generic modules known by the server /// public static IDynamicModule[] GenericModules { get { return (from n in Library.DynamicLoader.GenericLoader.Modules select new DynamicModule(n)) .ToArray(); } } /// /// The web modules known by the server /// public static IDynamicModule[] WebModules { get { return (from n in Library.DynamicLoader.WebLoader.Modules select new DynamicModule(n)) .ToArray(); } } /// /// The web modules known by the server /// public static IDynamicModule[] ConnectionModules { get { return (from n in Library.DynamicLoader.GenericLoader.Modules where n is Library.Interface.IConnectionModule select new DynamicModule(n)) .ToArray(); } } /// /// The server modules known by the server /// public static object[] ServerModules { get { return (from n in Library.DynamicLoader.GenericLoader.Modules where n is Library.Interface.IGenericServerModule select n) .ToArray(); } } /// /// The filters that are applied to all backups /// public static IFilter[] Filters { get { return FIXMEGlobal.DataConnection.Filters; } } /// /// The settings applied to all backups by default /// public static ISetting[] Settings { get { return FIXMEGlobal.DataConnection.Settings; } } } }