From f7a804aec7a7d6935e6bcb43763d05db94432140 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 13 Aug 2024 22:37:36 +0200 Subject: [PATCH] Removed unused files and methods --- .../Serializable/ServerStatus.cs | 127 ------------------ .../HttpServerConnection.cs | 10 +- .../Duplicati.GUI.TrayIcon}/IServerStatus.cs | 17 +-- .../Implementations/ServerStatus.cs | 43 ------ .../Interface/IServerSettings.cs | 56 -------- .../InterfaceResolver.cs | 8 -- .../Serializer.cs | 1 - .../WebserverCore/Dto/ServerStatusDto.cs | 3 +- 8 files changed, 4 insertions(+), 261 deletions(-) delete mode 100644 Duplicati.Library.RestAPI/Serializable/ServerStatus.cs rename Duplicati/{Server/Duplicati.Server.Serialization/Interface => GUI/Duplicati.GUI.TrayIcon}/IServerStatus.cs (69%) delete mode 100644 Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs delete mode 100644 Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs diff --git a/Duplicati.Library.RestAPI/Serializable/ServerStatus.cs b/Duplicati.Library.RestAPI/Serializable/ServerStatus.cs deleted file mode 100644 index 86e4a5ce7..000000000 --- a/Duplicati.Library.RestAPI/Serializable/ServerStatus.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2024, 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 System; -using System.Linq; -using System.Collections.Generic; -using Duplicati.Server.Serialization; -using Duplicati.Library.RestAPI; - -namespace Duplicati.Server.Serializable -{ - /// - /// This class collects all reportable status properties into a single class that can be exported as JSON - /// - public class ServerStatus(LiveControls liveControls) : Duplicati.Server.Serialization.Interface.IServerStatus - { - public LiveControlState ProgramState - { - get { return EnumConverter.Convert(liveControls.State); } - } - - public string UpdatedVersion - { - get - { - var u = FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion; - if (u == null) - return null; - - Version v; - if (!Version.TryParse(u.Version, out v)) - return null; - - if (v <= System.Reflection.Assembly.GetExecutingAssembly().GetName().Version) - return null; - - return u.Displayname; - } - } - - public string UpdateDownloadLink => FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion?.GetUpdateUrls()?.FirstOrDefault(); - - public UpdatePollerStates UpdaterState { get { return FIXMEGlobal.UpdatePoller.ThreadState; } } - - public double UpdateDownloadProgress { get { return FIXMEGlobal.UpdatePoller.DownloadProgess; } } - - - public Tuple ActiveTask - { - get - { - var t = FIXMEGlobal.WorkThread.CurrentTask; - if (t == null) - return null; - else - return new Tuple(t.TaskID, t.Backup == null ? null : t.Backup.ID); - } - } - - public bool HasWarning { get { return FIXMEGlobal.DataConnection.ApplicationSettings.UnackedWarning; } } - public bool HasError { get { return FIXMEGlobal.DataConnection.ApplicationSettings.UnackedError; } } - - public SuggestedStatusIcon SuggestedStatusIcon - { - get - { - if (this.ActiveTask == null) - { - if (this.ProgramState == LiveControlState.Paused) - return SuggestedStatusIcon.Paused; - - if (this.HasError) - return SuggestedStatusIcon.ReadyError; - if (this.HasWarning) - return SuggestedStatusIcon.ReadyWarning; - - return SuggestedStatusIcon.Ready; - } - else - { - if (this.ProgramState == LiveControlState.Running) - return SuggestedStatusIcon.Active; - else - return SuggestedStatusIcon.ActivePaused; - } - } - } - - public DateTime EstimatedPauseEnd - { - get - { - return liveControls.EstimatedPauseEnd; - } - } - - private long m_lastEventID = FIXMEGlobal.StatusEventNotifyer.EventNo; - - public long LastEventID - { - get { return m_lastEventID; } - set { m_lastEventID = value; } - } - - public long LastDataUpdateID => FIXMEGlobal.NotificationUpdateService.LastDataUpdateId; - - public long LastNotificationUpdateID => FIXMEGlobal.NotificationUpdateService.LastNotificationUpdateId; - } -} - diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs index ef1d0346b..51384c1b1 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs @@ -58,19 +58,11 @@ namespace Duplicati.GUI.TrayIcon }; private record ServerStatusImpl( - Tuple ActiveTask, LiveControlState ProgramState, - bool HasWarning, - bool HasError, SuggestedStatusIcon SuggestedStatusIcon, - DateTime EstimatedPauseEnd, long LastEventID, long LastDataUpdateID, - long LastNotificationUpdateID, - string UpdatedVersion, - string UpdateDownloadLink, - UpdatePollerStates UpdaterState, - double UpdateDownloadProgress + long LastNotificationUpdateID ) : IServerStatus; private record NotificationImpl( diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerStatus.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/IServerStatus.cs similarity index 69% rename from Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerStatus.cs rename to Duplicati/GUI/Duplicati.GUI.TrayIcon/IServerStatus.cs index 04c86fa42..84b82b62f 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerStatus.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/IServerStatus.cs @@ -18,29 +18,16 @@ // 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 System; +using Duplicati.Server.Serialization; -namespace Duplicati.Server.Serialization.Interface +namespace Duplicati.GUI.TrayIcon { - // TODO: This interface should be moved to the TrayIcon and mimic only the properties that are needed - // The source data for the interface is actually the in ServerStatusDto.cs - public interface IServerStatus { - Tuple ActiveTask { get; } LiveControlState ProgramState { get; } - bool HasWarning { get; } - bool HasError { get; } SuggestedStatusIcon SuggestedStatusIcon { get; } - DateTime EstimatedPauseEnd { get; } long LastEventID { get; } long LastDataUpdateID { get; } long LastNotificationUpdateID { get; } - - string UpdatedVersion { get; } - string UpdateDownloadLink { get; } - UpdatePollerStates UpdaterState { get; } - double UpdateDownloadProgress { get; } - } } diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs b/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs deleted file mode 100644 index 1f5d2c9b0..000000000 --- a/Duplicati/Server/Duplicati.Server.Serialization/Implementations/ServerStatus.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2024, 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 System; -using System.Collections.Generic; - -namespace Duplicati.Server.Serialization.Implementations -{ - internal class ServerStatus : Interface.IServerStatus - { - public Tuple ActiveTask { get; set; } - public LiveControlState ProgramState { 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; } - public long LastNotificationUpdateID { get; set; } - - public string UpdatedVersion { get; set; } - public string UpdateDownloadLink { get; set; } - public UpdatePollerStates UpdaterState { get; set; } - public double UpdateDownloadProgress { get; set; } - } -} diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs deleted file mode 100644 index 74bacb603..000000000 --- a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IServerSettings.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2024, 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. - -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/InterfaceResolver.cs b/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs index 9e6588f89..1f6f7f66a 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/InterfaceResolver.cs @@ -24,14 +24,6 @@ using Newtonsoft.Json; namespace Duplicati.Server.Serialization { - public class SerializableStatusCreator : CustomCreationConverter - { - public override Interface.IServerStatus Create(Type objectType) - { - return new Implementations.ServerStatus(); - } - } - public class SettingsCreator : CustomCreationConverter { public override Interface.ISetting Create(Type objectType) diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs b/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs index 2af57ca0a..7d8d36551 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Serializer.cs @@ -38,7 +38,6 @@ namespace Duplicati.Server.Serialization { new DayOfWeekConcerter(), new StringEnumConverter(), - new SerializableStatusCreator(), new SettingsCreator(), new FilterCreator(), new NotificationCreator(), diff --git a/Duplicati/WebserverCore/Dto/ServerStatusDto.cs b/Duplicati/WebserverCore/Dto/ServerStatusDto.cs index e19b3314e..70033d478 100644 --- a/Duplicati/WebserverCore/Dto/ServerStatusDto.cs +++ b/Duplicati/WebserverCore/Dto/ServerStatusDto.cs @@ -1,12 +1,11 @@ using Duplicati.Server.Serialization; -using Duplicati.Server.Serialization.Interface; namespace Duplicati.WebserverCore.Dto; /// /// Represents the server status DTO. /// -public sealed record ServerStatusDto : IServerStatus +public sealed record ServerStatusDto { /// /// Gets or sets the active task.