Merge pull request #365 from Bond-009/power

Remove unused PowerManagement
pull/1154/head
Anthony Lavado 6 years ago committed by GitHub
commit e9b44a3d6e

@ -369,7 +369,6 @@ namespace Emby.Server.Implementations
public 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.Implementations
ILoggerFactory loggerFactory,
StartupOptions options,
IFileSystem fileSystem,
IPowerManagement powerManagement,
IEnvironmentInfo environmentInfo,
IImageEncoder imageEncoder,
ISystemEvents systemEvents,
@ -417,7 +415,6 @@ namespace Emby.Server.Implementations
Logger = LoggerFactory.CreateLogger("App");
StartupOptions = options;
PowerManagement = powerManagement;
ImageEncoder = imageEncoder;
@ -857,8 +854,6 @@ namespace Emby.Server.Implementations
SocketFactory = new SocketFactory(LoggerFactory.CreateLogger("SocketFactory"));
RegisterSingleInstance(SocketFactory);
RegisterSingleInstance(PowerManagement);
SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LoggerFactory, FileSystemManager, CryptographyProvider);
RegisterSingleInstance(SecurityManager);

@ -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;
}
}
}
}

@ -75,7 +75,23 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private 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;

@ -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.EmbyTV
public 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.EmbyTV
foreach (var item in GetAll().ToList())
{
AddOrUpdateSystemTimer(item, false);
AddOrUpdateSystemTimer(item);
}
}
@ -59,7 +56,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public 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.EmbyTV
return true;
}
private void AddOrUpdateSystemTimer(TimerInfo item, bool scheduleSystemWakeTimer)
private void AddOrUpdateSystemTimer(TimerInfo item)
{
StopTimer(item);
@ -124,23 +121,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var 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)

@ -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)
{
}

@ -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)
{
}
}
}

@ -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);
}

@ -1,11 +0,0 @@
using System;
namespace MediaBrowser.Model.System
{
public interface IPowerManagement
{
void PreventSystemStandby();
void AllowSystemStandby();
void ScheduleWake(DateTime wakeTimeUtc, string displayName);
}
}
Loading…
Cancel
Save