// Copyright (C) 2025, The Duplicati Team // https://duplicati.com, hello@duplicati.com // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. using Duplicati.Server; using System; using System.Collections.Generic; using Duplicati.Library.RestAPI.Abstractions; using Duplicati.Library.Utility; using Duplicati.WebserverCore.Abstractions; using Microsoft.Extensions.DependencyInjection; using Duplicati.Library.Interface; namespace Duplicati.Library.RestAPI { /** * In the absense of dependancy injection, there is a significant amount of variables exposed through Program as globals. * This causes a problem decoupling classes and leads to circular dependancies. */ public static class FIXMEGlobal { /// /// The placeholder for passwords in the UI /// public const string PASSWORD_PLACEHOLDER = "**********"; public static IServiceProvider Provider { get; set; } /// /// This is the only access to the database /// public static Server.Database.Connection DataConnection; /// /// A delegate method for creating a copy of the current progress state /// public static Func GenerateProgressState; /// /// The status event signaler, used to control long polling of status updates /// public static EventPollNotify StatusEventNotifyer => Provider.GetRequiredService(); /// /// For keeping and incrementing last last events Ids of db save and last notification /// public static INotificationUpdateService NotificationUpdateService => Provider.GetRequiredService(); /// /// Checks if the server has started and is listening for events /// public static bool IsServerStarted => Provider != null; /// /// This is the working thread /// public static WorkerThread WorkThread => Provider.GetRequiredService().WorkerThread; public static IWorkerThreadsManager WorkerThreadsManager => Provider.GetRequiredService(); public static Action StartOrStopUsageReporter; /// /// Gets the folder where Duplicati data is stored /// public static string DataFolder; /// /// This is the scheduling thread /// public static IScheduler Scheduler => Provider.GetRequiredService(); /// /// The log redirect handler /// public static readonly LogWriteHandler LogHandler = new LogWriteHandler(); /// /// The update poll thread. /// public static UpdatePollThread UpdatePoller => Provider.GetRequiredService(); /// /// Used to check the origin of the web server (e.g. Tray icon or a stand alone Server) /// public static string Origin = "Server"; /// /// The application exit event /// public static System.Threading.ManualResetEvent ApplicationExitEvent; /// /// List of completed task results /// public static readonly List> TaskResultCache = new List>(); /// /// This is the lock to be used before manipulating the shared resources /// public static readonly object MainLock = new object(); /// /// The shared secret provider from the server invocation /// public static ISecretProvider SecretProvider { get; set; } /// /// Flag to indicate if the settings encryption key was provided externally /// public static bool SettingsEncryptionKeyProvidedExternally { get; set; } } }