diff options
| author | 7illusions <z@7illusions.com> | 2014-05-12 16:55:07 +0200 |
|---|---|---|
| committer | 7illusions <z@7illusions.com> | 2014-05-12 16:55:07 +0200 |
| commit | baf5cf2544fcaad2246923f60caaf3fed4a94aaf (patch) | |
| tree | a808b700095f876e437b95c432c0220e241f9fda /MediaBrowser.ServerApplication | |
| parent | 8f3a6279e173dcbaaa05a56556afb410ee12dd4d (diff) | |
| parent | b9b568de13d81f9db1a8502d50940475c1d79c72 (diff) | |
Merge pull request #3 from MediaBrowser/master
Sync with Master
Diffstat (limited to 'MediaBrowser.ServerApplication')
9 files changed, 232 insertions, 105 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 0740feece..2bae497ff 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -29,13 +29,14 @@ using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Resolvers; +using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Sorting; +using MediaBrowser.Controller.Subtitles; using MediaBrowser.Controller.Themes; using MediaBrowser.Dlna; using MediaBrowser.Dlna.Eventing; using MediaBrowser.Dlna.Main; -using MediaBrowser.Dlna.PlayTo; using MediaBrowser.Dlna.Server; using MediaBrowser.MediaEncoding.BdInfo; using MediaBrowser.MediaEncoding.Encoder; @@ -44,6 +45,7 @@ using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.System; using MediaBrowser.Model.Updates; using MediaBrowser.Providers.Manager; +using MediaBrowser.Providers.Subtitles; using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Implementations.Channels; using MediaBrowser.Server.Implementations.Collections; @@ -60,6 +62,7 @@ using MediaBrowser.Server.Implementations.Localization; using MediaBrowser.Server.Implementations.MediaEncoder; using MediaBrowser.Server.Implementations.Notifications; using MediaBrowser.Server.Implementations.Persistence; +using MediaBrowser.Server.Implementations.Security; using MediaBrowser.Server.Implementations.ServerManager; using MediaBrowser.Server.Implementations.Session; using MediaBrowser.Server.Implementations.Themes; @@ -193,6 +196,7 @@ namespace MediaBrowser.ServerApplication private IProviderRepository ProviderRepository { get; set; } private INotificationManager NotificationManager { get; set; } + private ISubtitleManager SubtitleManager { get; set; } /// <summary> /// Initializes a new instance of the <see cref="ApplicationHost"/> class. @@ -492,7 +496,7 @@ namespace MediaBrowser.ServerApplication DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager); RegisterSingleInstance(DtoService); - SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor); + SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository); RegisterSingleInstance(SessionManager); var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer); @@ -507,7 +511,7 @@ namespace MediaBrowser.ServerApplication MediaEncoder); RegisterSingleInstance(EncodingManager); - ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, Logger, ServerConfigurationManager, FileSystemManager, UserDataManager); + ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, Logger, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer); RegisterSingleInstance(ChannelManager); var appThemeManager = new AppThemeManager(ApplicationPaths, FileSystemManager, JsonSerializer, Logger); @@ -531,6 +535,11 @@ namespace MediaBrowser.ServerApplication NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager); RegisterSingleInstance(NotificationManager); + RegisterSingleInstance<IEncryptionManager>(new EncryptionManager()); + + SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor); + RegisterSingleInstance(SubtitleManager); + var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false)); var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false)); var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false)); @@ -566,7 +575,7 @@ namespace MediaBrowser.ServerApplication { var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager).GetFFMpegInfo(progress).ConfigureAwait(false); - MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ApplicationPaths, JsonSerializer, info.Path, info.ProbePath, info.Version, FileSystemManager); + MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ApplicationPaths, JsonSerializer, info.EncoderPath, info.ProbePath, info.Version, FileSystemManager); RegisterSingleInstance(MediaEncoder); } @@ -710,9 +719,11 @@ namespace MediaBrowser.ServerApplication LiveTvManager.AddParts(GetExports<ILiveTvService>()); + SubtitleManager.AddParts(GetExports<ISubtitleProvider>()); + SessionManager.AddParts(GetExports<ISessionControllerFactory>()); - ChannelManager.AddParts(GetExports<IChannel>()); + ChannelManager.AddParts(GetExports<IChannel>(), GetExports<IChannelFactory>()); NotificationManager.AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>()); } @@ -1026,16 +1037,12 @@ namespace MediaBrowser.ServerApplication /// <returns>Task{CheckForUpdateResult}.</returns> public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress) { -#if DEBUG - return new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false }; -#endif - var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion, ConfigurationManager.CommonConfiguration.SystemUpdateLevel); - HasUpdateAvailable = version != null; + HasUpdateAvailable = version != null && version.version >= ApplicationVersion; return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } : new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false }; diff --git a/MediaBrowser.ServerApplication/EntryPoints/KeepServerAwake.cs b/MediaBrowser.ServerApplication/EntryPoints/KeepServerAwake.cs new file mode 100644 index 000000000..9881bdf18 --- /dev/null +++ b/MediaBrowser.ServerApplication/EntryPoints/KeepServerAwake.cs @@ -0,0 +1,57 @@ +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Logging; +using MediaBrowser.ServerApplication.Native; +using System; +using System.Linq; +using System.Threading; + +namespace MediaBrowser.ServerApplication.EntryPoints +{ + public class KeepServerAwake : IServerEntryPoint + { + private readonly ISessionManager _sessionManager; + private readonly ILogger _logger; + private Timer _timer; + + public KeepServerAwake(ISessionManager sessionManager, ILogger logger) + { + _sessionManager = sessionManager; + _logger = logger; + } + + public void Run() + { + _timer = new Timer(obj => + { + var now = DateTime.UtcNow; + if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 5)) + { + KeepAlive(); + } + + }, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); + } + + private void KeepAlive() + { + try + { + NativeApp.PreventSystemStandby(); + } + catch (Exception ex) + { + _logger.ErrorException("Error resetting system standby timer", ex); + } + } + + public void Dispose() + { + if (_timer != null) + { + _timer.Dispose(); + _timer = null; + } + } + } +} diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloadInfo.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloadInfo.cs index c4f529754..b4fc47d02 100644 --- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloadInfo.cs +++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloadInfo.cs @@ -4,6 +4,8 @@ using Mono.Unix.Native; using System.Text.RegularExpressions; using System.IO; #endif +using System.IO; +using System.Text.RegularExpressions; namespace MediaBrowser.ServerApplication.FFMpeg { @@ -32,7 +34,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg switch (arg) { case "Version": - return "20140304"; + return "20140506"; case "FFMpegFilename": return "ffmpeg.exe"; case "FFProbeFilename": @@ -42,7 +44,6 @@ namespace MediaBrowser.ServerApplication.FFMpeg } break; - #if __MonoCS__ case PlatformID.Unix: if (PlatformDetection.IsMac) { @@ -69,7 +70,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg switch (arg) { case "Version": - return "20140304"; + return "20140506"; case "FFMpegFilename": return "ffmpeg"; case "FFProbeFilename": @@ -85,7 +86,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg switch (arg) { case "Version": - return "20140304"; + return "20140505"; case "FFMpegFilename": return "ffmpeg"; case "FFProbeFilename": @@ -98,7 +99,6 @@ namespace MediaBrowser.ServerApplication.FFMpeg } // Unsupported Unix platform return ""; -#endif } return ""; } @@ -106,18 +106,17 @@ namespace MediaBrowser.ServerApplication.FFMpeg private static string[] GetDownloadUrls() { var pid = Environment.OSVersion.Platform; - + switch (pid) { case PlatformID.Win32NT: return new[] { - "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20140304-git-f34cceb-win32-static.7z", - "https://www.dropbox.com/s/6brdetuzbld93jk/ffmpeg-20140304-git-f34cceb-win32-static.7z?dl=1" + "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20140506-git-2baf1c8-win32-static.7z", + "https://www.dropbox.com/s/lxlzxs0r83iatsv/ffmpeg-20140506-git-2baf1c8-win32-static.7z?dl=1" }; - - #if __MonoCS__ - case PlatformID.Unix: + + case PlatformID.Unix: if (PlatformDetection.IsMac && PlatformDetection.IsX86_64) { return new[] @@ -132,8 +131,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg { return new[] { - "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.2014-03-04.tar.gz", - "https://www.dropbox.com/s/0l76mcauqqkta31/ffmpeg.static.32bit.2014-03-04.tar.gz?dl=1" + "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.latest.tar.gz", + "https://www.dropbox.com/s/k9s02pv5to6slfb/ffmpeg.static.32bit.2014-05-06.tar.gz?dl=1" }; } @@ -141,22 +140,20 @@ namespace MediaBrowser.ServerApplication.FFMpeg { return new[] { - "http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.2014-03-04.tar.gz", - "https://www.dropbox.com/s/9wlxz440mdejuqe/ffmpeg.static.64bit.2014-03-04.tar.gz?dl=1" + "http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz", + "https://www.dropbox.com/s/onuregwghywnzjo/ffmpeg.static.64bit.2014-05-05.tar.gz?dl=1" }; } } //No Unix version available - return new string[] {}; -#endif + return new string[] { }; } - return new string[] {}; + return new string[] { }; } } - #if __MonoCS__ public static class PlatformDetection { public readonly static bool IsWindows; @@ -166,34 +163,52 @@ namespace MediaBrowser.ServerApplication.FFMpeg public readonly static bool IsX86_64; public readonly static bool IsArm; - static PlatformDetection () + static PlatformDetection() { IsWindows = Path.DirectorySeparatorChar == '\\'; //Don't call uname on windows if (!IsWindows) { - Utsname uname; - var callResult = Syscall.uname(out uname); - if (callResult == 0) - { - IsMac = uname.sysname == "Darwin"; - IsLinux = !IsMac && uname.sysname == "Linux"; + var uname = GetUnixName(); - Regex archX86 = new Regex("(i|I)[3-6]86"); - IsX86 = archX86.IsMatch(uname.machine); - IsX86_64 = !IsX86 && uname.machine == "x86_64"; - IsArm = !IsX86 && !IsX86 && uname.machine.StartsWith("arm"); - } + IsMac = uname.sysname == "Darwin"; + IsLinux = uname.sysname == "Linux"; + + var archX86 = new Regex("(i|I)[3-6]86"); + IsX86 = archX86.IsMatch(uname.machine); + IsX86_64 = !IsX86 && uname.machine == "x86_64"; + IsArm = !IsX86 && !IsX86_64 && uname.machine.StartsWith("arm"); } else { - if (System.Environment.Is64BitOperatingSystem) + if (Environment.Is64BitOperatingSystem) IsX86_64 = true; else IsX86 = true; } } + + private static Uname GetUnixName() + { + var uname = new Uname(); + +#if __MonoCS__ + Utsname utsname; + var callResult = Syscall.uname(out utsname); + if (callResult == 0) + { + uname.sysname= utsname.sysname; + uname.machine= utsname.machine; + } +#endif + return uname; + } + } + + public class Uname + { + public string sysname = string.Empty; + public string machine = string.Empty; } - #endif } diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs index b9c45e0d9..c550cb27f 100644 --- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs +++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs @@ -42,63 +42,86 @@ namespace MediaBrowser.ServerApplication.FFMpeg public async Task<FFMpegInfo> GetFFMpegInfo(IProgress<double> progress) { - var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true), FFMpegDownloadInfo.Version); + var rootEncoderPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); + var versionedDirectoryPath = Path.Combine(rootEncoderPath, FFMpegDownloadInfo.Version); var info = new FFMpegInfo { ProbePath = Path.Combine(versionedDirectoryPath, FFMpegDownloadInfo.FFProbeFilename), - Path = Path.Combine(versionedDirectoryPath, FFMpegDownloadInfo.FFMpegFilename), + EncoderPath = Path.Combine(versionedDirectoryPath, FFMpegDownloadInfo.FFMpegFilename), Version = FFMpegDownloadInfo.Version }; Directory.CreateDirectory(versionedDirectoryPath); - var tasks = new List<Task>(); - - double ffmpegPercent = 0; - double fontPercent = 0; - var syncLock = new object(); - - if (!File.Exists(info.ProbePath) || !File.Exists(info.Path)) + if (!File.Exists(info.ProbePath) || !File.Exists(info.EncoderPath)) { - var ffmpegProgress = new ActionableProgress<double>(); - ffmpegProgress.RegisterAction(p => - { - ffmpegPercent = p; + // ffmpeg not present. See if there's an older version we can start with + var existingVersion = GetExistingVersion(info, rootEncoderPath); - lock (syncLock) - { - progress.Report((ffmpegPercent / 2) + (fontPercent / 2)); - } - }); + // No older version. Need to download and block until complete + if (existingVersion == null) + { + await DownloadFFMpeg(versionedDirectoryPath, progress).ConfigureAwait(false); + } + else + { + // Older version found. + // Start with that. Download new version in the background. + var newPath = versionedDirectoryPath; + Task.Run(() => DownloadFFMpegInBackground(newPath)); - tasks.Add(DownloadFFMpeg(info, ffmpegProgress)); - } - else - { - ffmpegPercent = 100; - progress.Report(50); + info = existingVersion; + versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath); + } } - var fontProgress = new ActionableProgress<double>(); - fontProgress.RegisterAction(p => + await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false); + + return info; + } + + private FFMpegInfo GetExistingVersion(FFMpegInfo info, string rootEncoderPath) + { + var encoderFilename = Path.GetFileName(info.EncoderPath); + var probeFilename = Path.GetFileName(info.ProbePath); + + foreach (var directory in Directory.EnumerateDirectories(rootEncoderPath, "*", SearchOption.TopDirectoryOnly) + .ToList()) { - fontPercent = p; + var allFiles = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories).ToList(); - lock (syncLock) + var encoder = allFiles.FirstOrDefault(i => string.Equals(Path.GetFileName(i), encoderFilename, StringComparison.OrdinalIgnoreCase)); + var probe = allFiles.FirstOrDefault(i => string.Equals(Path.GetFileName(i), probeFilename, StringComparison.OrdinalIgnoreCase)); + + if (!string.IsNullOrWhiteSpace(encoder) && + !string.IsNullOrWhiteSpace(probe)) { - progress.Report((ffmpegPercent / 2) + (fontPercent / 2)); + return new FFMpegInfo + { + EncoderPath = encoder, + ProbePath = probe, + Version = Path.GetFileNameWithoutExtension(Path.GetDirectoryName(probe)) + }; } - }); - - tasks.Add(DownloadFonts(versionedDirectoryPath, fontProgress)); + } - await Task.WhenAll(tasks).ConfigureAwait(false); + return null; + } - return info; + private async void DownloadFFMpegInBackground(string directory) + { + try + { + await DownloadFFMpeg(directory, new Progress<double>()).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error downloading ffmpeg", ex); + } } - private async Task DownloadFFMpeg(FFMpegInfo info, IProgress<double> progress) + private async Task DownloadFFMpeg(string directory, IProgress<double> progress) { foreach (var url in FFMpegDownloadInfo.FfMpegUrls) { @@ -114,7 +137,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg }).ConfigureAwait(false); - ExtractFFMpeg(tempFile, Path.GetDirectoryName(info.Path)); + ExtractFFMpeg(tempFile, directory); return; } catch (HttpException ex) @@ -132,7 +155,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg private void ExtractFFMpeg(string tempFile, string targetFolder) { - _logger.Debug("Extracting ffmpeg from {0}", tempFile); + _logger.Info("Extracting ffmpeg from {0}", tempFile); var tempFolder = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString()); @@ -171,6 +194,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg private void ExtractArchive(string archivePath, string targetPath) { + _logger.Info("Extracting {0} to {1}", archivePath, targetPath); + if (string.Equals(FFMpegDownloadInfo.ArchiveType, "7z", StringComparison.OrdinalIgnoreCase)) { _zipClient.ExtractAllFrom7z(archivePath, targetPath, true); @@ -182,6 +207,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg } private void Extract7zArchive(string archivePath, string targetPath) { + _logger.Info("Extracting {0} to {1}", archivePath, targetPath); + _zipClient.ExtractAllFrom7z(archivePath, targetPath, true); } @@ -201,7 +228,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg /// Extracts the fonts. /// </summary> /// <param name="targetPath">The target path.</param> - private async Task DownloadFonts(string targetPath, IProgress<double> progress) + /// <returns>Task.</returns> + private async Task DownloadFonts(string targetPath) { try { @@ -213,12 +241,19 @@ namespace MediaBrowser.ServerApplication.FFMpeg var fontFile = Path.Combine(fontsDirectory, fontFilename); - if (!File.Exists(fontFile)) + if (File.Exists(fontFile)) { - await DownloadFontFile(fontsDirectory, fontFilename, progress).ConfigureAwait(false); + await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); + } + else + { + // Kick this off, but no need to wait on it + Task.Run(async () => + { + await DownloadFontFile(fontsDirectory, fontFilename, new Progress<double>()).ConfigureAwait(false); + await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); + }); } - - await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); } catch (HttpException ex) { @@ -230,8 +265,6 @@ namespace MediaBrowser.ServerApplication.FFMpeg // Don't let the server crash because of this _logger.ErrorException("Error writing ffmpeg font files", ex); } - - progress.Report(100); } /// <summary> @@ -325,19 +358,5 @@ namespace MediaBrowser.ServerApplication.FFMpeg } } } - - /// <summary> - /// Gets the media tools path. - /// </summary> - /// <param name="create">if set to <c>true</c> [create].</param> - /// <returns>System.String.</returns> - private string GetMediaToolsPath(bool create) - { - var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); - - Directory.CreateDirectory(path); - - return path; - } } } diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegInfo.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegInfo.cs index 147a9f771..1361277aa 100644 --- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegInfo.cs +++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegInfo.cs @@ -9,7 +9,7 @@ /// Gets or sets the path. /// </summary> /// <value>The path.</value> - public string Path { get; set; } + public string EncoderPath { get; set; } /// <summary> /// Gets or sets the probe path. /// </summary> diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index d8bd3938e..6dcbf00e3 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -111,6 +111,7 @@ namespace MediaBrowser.ServerApplication /// <summary> /// Determines whether [is already running] [the specified current process]. /// </summary> + /// <param name="applicationPath">The application path.</param> /// <param name="currentProcess">The current process.</param> /// <returns><c>true</c> if [is already running] [the specified current process]; otherwise, <c>false</c>.</returns> private static bool IsAlreadyRunning(string applicationPath, Process currentProcess) @@ -131,7 +132,7 @@ namespace MediaBrowser.ServerApplication { _logger.Info("Found a duplicate process. Giving it time to exit."); - if (!duplicate.WaitForExit(5000)) + if (!duplicate.WaitForExit(10000)) { _logger.Info("The duplicate process did not exit."); return true; diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index b49e100ab..7fdea66f6 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -96,6 +96,7 @@ <Compile Include="BackgroundServiceInstaller.cs"> <SubType>Component</SubType> </Compile> + <Compile Include="EntryPoints\KeepServerAwake.cs" /> <Compile Include="EntryPoints\ResourceEntryPoint.cs" /> <Compile Include="EntryPoints\StartupWizard.cs" /> <Compile Include="EntryPoints\WanAddressEntryPoint.cs" /> diff --git a/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs b/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs index 39beee563..77a543ad7 100644 --- a/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs +++ b/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs @@ -45,7 +45,7 @@ namespace MediaBrowser.ServerApplication.Native /// <param name="logger">The logger.</param> public static void OpenCommunity(ILogger logger) { - OpenUrl("http://mediabrowser3.com/community", logger); + OpenUrl("http://mediabrowser.tv/community", logger); } /// <summary> diff --git a/MediaBrowser.ServerApplication/Native/NativeApp.cs b/MediaBrowser.ServerApplication/Native/NativeApp.cs index 646a7bc98..2388b610b 100644 --- a/MediaBrowser.ServerApplication/Native/NativeApp.cs +++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs @@ -1,4 +1,5 @@ - +using System.Runtime.InteropServices; + namespace MediaBrowser.ServerApplication.Native { /// <summary> @@ -57,5 +58,31 @@ namespace MediaBrowser.ServerApplication.Native return MainStartup.CanSelfUpdate; } } + + public static void PreventSystemStandby() + { + SystemHelper.ResetStandbyTimer(); + } + + internal enum EXECUTION_STATE : uint + { + ES_NONE = 0, + ES_SYSTEM_REQUIRED = 0x00000001, + ES_DISPLAY_REQUIRED = 0x00000002, + ES_USER_PRESENT = 0x00000004, + ES_AWAYMODE_REQUIRED = 0x00000040, + ES_CONTINUOUS = 0x80000000 + } + + public class SystemHelper + { + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags); + + public static void ResetStandbyTimer() + { + EXECUTION_STATE es = SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED); + } + } } } |
