removed dead code

pull/702/head
Luke Pulverenti 8 years ago
parent 32b442d8c9
commit 42d67db1b8

@ -266,7 +266,6 @@
<Compile Include="Playlists\IPlaylistManager.cs" /> <Compile Include="Playlists\IPlaylistManager.cs" />
<Compile Include="Playlists\Playlist.cs" /> <Compile Include="Playlists\Playlist.cs" />
<Compile Include="Plugins\ILocalizablePlugin.cs" /> <Compile Include="Plugins\ILocalizablePlugin.cs" />
<Compile Include="Power\IPowerManagement.cs" />
<Compile Include="Providers\AlbumInfo.cs" /> <Compile Include="Providers\AlbumInfo.cs" />
<Compile Include="Providers\ArtistInfo.cs" /> <Compile Include="Providers\ArtistInfo.cs" />
<Compile Include="Providers\BookInfo.cs" /> <Compile Include="Providers\BookInfo.cs" />

@ -1,13 +0,0 @@
using System;
namespace MediaBrowser.Controller.Power
{
public interface IPowerManagement
{
/// <summary>
/// Schedules the wake.
/// </summary>
/// <param name="utcTime">The UTC time.</param>
void ScheduleWake(DateTime utcTime);
}
}

@ -27,7 +27,6 @@ using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Power;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using Microsoft.Win32; using Microsoft.Win32;
@ -61,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings = private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings =
new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase); new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase);
public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IFileOrganizationService organizationService, IMediaEncoder mediaEncoder, IPowerManagement powerManagement) public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IFileOrganizationService organizationService, IMediaEncoder mediaEncoder)
{ {
Current = this; Current = this;
@ -79,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers")); _seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));
_timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), powerManagement, _logger); _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger);
_timerProvider.TimerFired += _timerProvider_TimerFired; _timerProvider.TimerFired += _timerProvider_TimerFired;
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated; _config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;

@ -9,7 +9,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Power;
using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.LiveTv;
namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
@ -17,15 +16,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
public class TimerManager : ItemDataProvider<TimerInfo> public class TimerManager : ItemDataProvider<TimerInfo>
{ {
private readonly ConcurrentDictionary<string, Timer> _timers = new ConcurrentDictionary<string, Timer>(StringComparer.OrdinalIgnoreCase); private readonly ConcurrentDictionary<string, Timer> _timers = new ConcurrentDictionary<string, Timer>(StringComparer.OrdinalIgnoreCase);
private readonly IPowerManagement _powerManagement;
private readonly ILogger _logger; private readonly ILogger _logger;
public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired; public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;
public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, IPowerManagement powerManagement, ILogger logger1) public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1)
: base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase)) : base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase))
{ {
_powerManagement = powerManagement;
_logger = logger1; _logger = logger1;
} }
@ -64,7 +61,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
{ {
var timespan = RecordingHelper.GetStartTime(item) - DateTime.UtcNow; var timespan = RecordingHelper.GetStartTime(item) - DateTime.UtcNow;
timer.Change(timespan, TimeSpan.Zero); timer.Change(timespan, TimeSpan.Zero);
ScheduleWake(item);
} }
else else
{ {
@ -101,7 +97,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
base.Add(item); base.Add(item);
AddTimer(item); AddTimer(item);
ScheduleWake(item);
} }
private void AddTimer(TimerInfo item) private void AddTimer(TimerInfo item)
@ -124,25 +119,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
StartTimer(item, timerLength); StartTimer(item, timerLength);
} }
private void ScheduleWake(TimerInfo info)
{
var startDate = RecordingHelper.GetStartTime(info).AddMinutes(-5);
try
{
_powerManagement.ScheduleWake(startDate);
_logger.Info("Scheduled system wake timer at {0} (UTC)", startDate);
}
catch (NotImplementedException)
{
}
catch (Exception ex)
{
_logger.ErrorException("Error scheduling wake timer", ex);
}
}
public void StartTimer(TimerInfo item, TimeSpan dueTime) public void StartTimer(TimerInfo item, TimeSpan dueTime)
{ {
StopTimer(item); StopTimer(item);

@ -8,7 +8,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using MediaBrowser.Controller.Power;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using MediaBrowser.Server.Implementations.Persistence; using MediaBrowser.Server.Implementations.Persistence;
using MediaBrowser.Server.Startup.Common.FFMpeg; using MediaBrowser.Server.Startup.Common.FFMpeg;
@ -232,11 +231,6 @@ namespace MediaBrowser.Server.Mono.Native
public string machine = string.Empty; public string machine = string.Empty;
} }
public IPowerManagement GetPowerManagement()
{
return new NullPowerManagement();
}
public FFMpegInstallInfo GetFfmpegInstallInfo() public FFMpegInstallInfo GetFfmpegInstallInfo()
{ {
return GetInfo(Environment); return GetInfo(Environment);
@ -289,12 +283,4 @@ namespace MediaBrowser.Server.Mono.Native
return false; return false;
} }
} }
public class NullPowerManagement : IPowerManagement
{
public void ScheduleWake(DateTime utcTime)
{
throw new NotImplementedException();
}
}
} }

@ -561,8 +561,6 @@ namespace MediaBrowser.Server.Startup.Common
EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager); EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
RegisterSingleInstance(EncodingManager); RegisterSingleInstance(EncodingManager);
RegisterSingleInstance(NativeApp.GetPowerManagement());
var sharingRepo = new SharingRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector()); var sharingRepo = new SharingRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
await sharingRepo.Initialize().ConfigureAwait(false); await sharingRepo.Initialize().ConfigureAwait(false);
RegisterSingleInstance<ISharingManager>(new SharingManager(sharingRepo, ServerConfigurationManager, LibraryManager, this)); RegisterSingleInstance<ISharingManager>(new SharingManager(sharingRepo, ServerConfigurationManager, LibraryManager, this));

@ -2,7 +2,6 @@
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using MediaBrowser.Controller.Power;
using MediaBrowser.Server.Implementations.Persistence; using MediaBrowser.Server.Implementations.Persistence;
using MediaBrowser.Server.Startup.Common.FFMpeg; using MediaBrowser.Server.Startup.Common.FFMpeg;
@ -98,12 +97,6 @@ namespace MediaBrowser.Server.Startup.Common
void AllowSystemStandby(); void AllowSystemStandby();
/// <summary>
/// Gets the power management.
/// </summary>
/// <returns>IPowerManagement.</returns>
IPowerManagement GetPowerManagement();
FFMpegInstallInfo GetFfmpegInstallInfo(); FFMpegInstallInfo GetFfmpegInstallInfo();
void LaunchUrl(string url); void LaunchUrl(string url);

@ -123,7 +123,6 @@
<Compile Include="Native\Standby.cs" /> <Compile Include="Native\Standby.cs" />
<Compile Include="Native\ServerAuthorization.cs" /> <Compile Include="Native\ServerAuthorization.cs" />
<Compile Include="Native\WindowsApp.cs" /> <Compile Include="Native\WindowsApp.cs" />
<Compile Include="Native\WindowsPowerManagement.cs" />
<Compile Include="Networking\CertificateGenerator.cs" /> <Compile Include="Networking\CertificateGenerator.cs" />
<Compile Include="Networking\NativeMethods.cs" /> <Compile Include="Networking\NativeMethods.cs" />
<Compile Include="Networking\NetworkManager.cs" /> <Compile Include="Networking\NetworkManager.cs" />

@ -9,7 +9,6 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Power;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using MediaBrowser.Server.Implementations.Persistence; using MediaBrowser.Server.Implementations.Persistence;
using MediaBrowser.Server.Startup.Common.FFMpeg; using MediaBrowser.Server.Startup.Common.FFMpeg;
@ -148,11 +147,6 @@ namespace MediaBrowser.ServerApplication.Native
MainStartup.Invoke(Standby.AllowSleep); MainStartup.Invoke(Standby.AllowSleep);
} }
public IPowerManagement GetPowerManagement()
{
return new WindowsPowerManagement(_logger);
}
public FFMpegInstallInfo GetFfmpegInstallInfo() public FFMpegInstallInfo GetFfmpegInstallInfo()
{ {
var info = new FFMpegInstallInfo(); var info = new FFMpegInstallInfo();

@ -1,94 +0,0 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using MediaBrowser.Controller.Power;
using MediaBrowser.Model.Logging;
using Microsoft.Win32.SafeHandles;
namespace MediaBrowser.ServerApplication.Native
{
public class WindowsPowerManagement : IPowerManagement
{
[DllImport("kernel32.dll")]
public static extern SafeWaitHandle CreateWaitableTimer(IntPtr lpTimerAttributes,
bool bManualReset,
string lpTimerName);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWaitableTimer(SafeWaitHandle hTimer,
[In] ref long pDueTime,
int lPeriod,
IntPtr pfnCompletionRoutine,
IntPtr lpArgToCompletionRoutine,
bool fResume);
private BackgroundWorker _bgWorker;
private readonly ILogger _logger;
private readonly object _initLock = new object();
public WindowsPowerManagement(ILogger logger)
{
_logger = logger;
}
public void ScheduleWake(DateTime utcTime)
{
//Initialize();
//_bgWorker.RunWorkerAsync(utcTime.ToFileTime());
throw new NotImplementedException();
}
private void Initialize()
{
lock (_initLock)
{
if (_bgWorker == null)
{
_bgWorker = new BackgroundWorker();
_bgWorker.DoWork += bgWorker_DoWork;
_bgWorker.RunWorkerCompleted += bgWorker_RunWorkerCompleted;
}
}
}
void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//if (Woken != null)
//{
// Woken(this, new EventArgs());
//}
}
private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
try
{
long waketime = (long)e.Argument;
using (SafeWaitHandle handle = CreateWaitableTimer(IntPtr.Zero, true, GetType().Assembly.GetName().Name + "Timer"))
{
if (SetWaitableTimer(handle, ref waketime, 0, IntPtr.Zero, IntPtr.Zero, true))
{
using (EventWaitHandle wh = new EventWaitHandle(false,
EventResetMode.AutoReset))
{
wh.SafeWaitHandle = handle;
wh.WaitOne();
}
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
}
catch (Exception ex)
{
_logger.ErrorException("Error scheduling wake timer", ex);
}
}
}
}
Loading…
Cancel
Save