The Free Software Media System - Server Backend & API
Remove unused PowerManagement
Bond_009c07d5a696354
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 9b9c6146fa..950ae10c7d 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -369,7 +369,6 @@ namespace Emby.Server.Implementationspublic StartupOptions StartupOptions { get; private set; }- internal IPowerManagement PowerManagement { get; private set; }internal IImageEncoder ImageEncoder { get; private set; }protected IProcessFactory ProcessFactory { get; private set; }@@ -391,7 +390,6 @@ namespace Emby.Server.ImplementationsILoggerFactory loggerFactory,StartupOptions options,IFileSystem fileSystem,- IPowerManagement powerManagement,IEnvironmentInfo environmentInfo,IImageEncoder imageEncoder,ISystemEvents systemEvents,@@ -417,7 +415,6 @@ namespace Emby.Server.ImplementationsLogger = LoggerFactory.CreateLogger("App");StartupOptions = options;- PowerManagement = powerManagement;ImageEncoder = imageEncoder;@@ -857,8 +854,6 @@ namespace Emby.Server.ImplementationsSocketFactory = new SocketFactory(LoggerFactory.CreateLogger("SocketFactory"));RegisterSingleInstance(SocketFactory);- RegisterSingleInstance(PowerManagement);-SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LoggerFactory, FileSystemManager, CryptographyProvider);RegisterSingleInstance(SecurityManager);diff --git a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs b/Emby.Server.Implementations/EntryPoints/KeepServerAwake.csdeleted file mode 100644index a6dadcef0c..0000000000--- a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs+++ /dev/null@@ -1,65 +0,0 @@-using MediaBrowser.Controller;-using MediaBrowser.Controller.Plugins;-using MediaBrowser.Controller.Session;-using Microsoft.Extensions.Logging;-using System;-using System.Linq;-using MediaBrowser.Model.System;-using MediaBrowser.Model.Threading;--namespace Emby.Server.Implementations.EntryPoints-{- public class KeepServerAwake : IServerEntryPoint- {- private readonly ISessionManager _sessionManager;- private readonly ILogger _logger;- private ITimer _timer;- private readonly IServerApplicationHost _appHost;- private readonly ITimerFactory _timerFactory;- private readonly IPowerManagement _powerManagement;-- public KeepServerAwake(ISessionManager sessionManager, ILogger logger, IServerApplicationHost appHost, ITimerFactory timerFactory, IPowerManagement powerManagement)- {- _sessionManager = sessionManager;- _logger = logger;- _appHost = appHost;- _timerFactory = timerFactory;- _powerManagement = powerManagement;- }-- public void Run()- {- _timer = _timerFactory.Create(OnTimerCallback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));- }-- private void OnTimerCallback(object state)- {- var now = DateTime.UtcNow;-- try- {- if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15))- {- _powerManagement.PreventSystemStandby();- }- else- {- _powerManagement.AllowSystemStandby();- }- }- catch (Exception ex)- {- _logger.LogError(ex, "Error resetting system standby timer");- }- }-- public void Dispose()- {- if (_timer != null)- {- _timer.Dispose();- _timer = null;- }- }- }-}diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 59f9fe86f8..81a47bfea1 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -75,7 +75,23 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate readonly IStreamHelper _streamHelper;- public EmbyTV(IServerApplicationHost appHost, IStreamHelper streamHelper, IMediaSourceManager mediaSourceManager, IAssemblyInfo assemblyInfo, ILogger logger, IJsonSerializer jsonSerializer, IPowerManagement powerManagement, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IMediaEncoder mediaEncoder, ITimerFactory timerFactory, IProcessFactory processFactory, ISystemEvents systemEvents)+ public EmbyTV(IServerApplicationHost appHost,+ IStreamHelper streamHelper,+ IMediaSourceManager mediaSourceManager,+ IAssemblyInfo assemblyInfo,+ ILogger logger,+ IJsonSerializer jsonSerializer,+ IHttpClient httpClient,+ IServerConfigurationManager config,+ ILiveTvManager liveTvManager,+ IFileSystem fileSystem,+ ILibraryManager libraryManager,+ ILibraryMonitor libraryMonitor,+ IProviderManager providerManager,+ IMediaEncoder mediaEncoder,+ ITimerFactory timerFactory,+ IProcessFactory processFactory,+ ISystemEvents systemEvents){Current = this;@@ -97,7 +113,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_streamHelper = streamHelper;_seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));- _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory, powerManagement);+ _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory);_timerProvider.TimerFired += _timerProvider_TimerFired;_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.csindex 76a044c023..e4ab347704 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs@@ -9,7 +9,6 @@ using MediaBrowser.Model.Serialization;using MediaBrowser.Model.IO;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Threading;-using MediaBrowser.Model.System;namespace Emby.Server.Implementations.LiveTv.EmbyTV{@@ -20,14 +19,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVpublic event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;private readonly ITimerFactory _timerFactory;- private readonly IPowerManagement _powerManagement;- public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory, IPowerManagement powerManagement)+ public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory): base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase)){_logger = logger1;_timerFactory = timerFactory;- _powerManagement = powerManagement;}public void RestartTimers()@@ -36,7 +33,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVforeach (var item in GetAll().ToList()){- AddOrUpdateSystemTimer(item, false);+ AddOrUpdateSystemTimer(item);}}@@ -59,7 +56,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVpublic override void Update(TimerInfo item){base.Update(item);- AddOrUpdateSystemTimer(item, false);+ AddOrUpdateSystemTimer(item);}public void AddOrUpdate(TimerInfo item, bool resetTimer)@@ -90,7 +87,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}base.Add(item);- AddOrUpdateSystemTimer(item, true);+ AddOrUpdateSystemTimer(item);}private bool ShouldStartTimer(TimerInfo item)@@ -104,7 +101,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVreturn true;}- private void AddOrUpdateSystemTimer(TimerInfo item, bool scheduleSystemWakeTimer)+ private void AddOrUpdateSystemTimer(TimerInfo item){StopTimer(item);@@ -124,23 +121,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVvar dueTime = startDate - now;StartTimer(item, dueTime);-- if (scheduleSystemWakeTimer && dueTime >= TimeSpan.FromMinutes(15))- {- ScheduleSystemWakeTimer(startDate, item.Name);- }- }-- private void ScheduleSystemWakeTimer(DateTime startDate, string displayName)- {- try- {- _powerManagement.ScheduleWake(startDate.AddMinutes(-5), displayName);- }- catch (Exception ex)- {- _logger.LogError(ex, "Error scheduling wake timer");- }}private void StartTimer(TimerInfo item, TimeSpan dueTime)diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.csindex b546343871..64e03f22ea 100644--- a/Jellyfin.Server/CoreAppHost.cs+++ b/Jellyfin.Server/CoreAppHost.cs@@ -11,8 +11,8 @@ namespace Jellyfin.Server{public class CoreAppHost : ApplicationHost{- public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager)- : base(applicationPaths, loggerFactory, options, fileSystem, powerManagement, environmentInfo, imageEncoder, systemEvents, networkManager)+ public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager)+ : base(applicationPaths, loggerFactory, options, fileSystem, environmentInfo, imageEncoder, systemEvents, networkManager){}diff --git a/Jellyfin.Server/PowerManagement.cs b/Jellyfin.Server/PowerManagement.csdeleted file mode 100644index c27c518937..0000000000--- a/Jellyfin.Server/PowerManagement.cs+++ /dev/null@@ -1,23 +0,0 @@-using System;-using MediaBrowser.Model.System;--namespace Jellyfin.Server.Native-{- public class PowerManagement : IPowerManagement- {- public void PreventSystemStandby()- {-- }-- public void AllowSystemStandby()- {-- }-- public void ScheduleWake(DateTime wakeTimeUtc, string displayName)- {-- }- }-}diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.csindex 03fdacb26f..e9f4708c8b 100644--- a/Jellyfin.Server/Program.cs+++ b/Jellyfin.Server/Program.cs@@ -13,7 +13,6 @@ using Emby.Server.Implementations;using Emby.Server.Implementations.EnvironmentInfo;using Emby.Server.Implementations.IO;using Emby.Server.Implementations.Networking;-using Jellyfin.Server.Native;using MediaBrowser.Common.Configuration;using MediaBrowser.Common.Net;using MediaBrowser.Controller.Drawing;@@ -71,7 +70,6 @@ namespace Jellyfin.Server_loggerFactory,options,fileSystem,- new PowerManagement(),environmentInfo,new NullImageEncoder(),new SystemEvents(_loggerFactory.CreateLogger("SystemEvents")),@@ -274,7 +272,7 @@ namespace Jellyfin.Server}}- public static void Shutdown()+ public static void Shutdown(){ApplicationTaskCompletionSource.SetResult(true);}diff --git a/MediaBrowser.Model/System/IPowerManagement.cs b/MediaBrowser.Model/System/IPowerManagement.csdeleted file mode 100644index 03907568cf..0000000000--- a/MediaBrowser.Model/System/IPowerManagement.cs+++ /dev/null@@ -1,11 +0,0 @@-using System;--namespace MediaBrowser.Model.System-{- public interface IPowerManagement- {- void PreventSystemStandby();- void AllowSystemStandby();- void ScheduleWake(DateTime wakeTimeUtc, string displayName);- }-}