aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native/WindowsApp.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication/Native/WindowsApp.cs')
-rw-r--r--MediaBrowser.ServerApplication/Native/WindowsApp.cs92
1 files changed, 86 insertions, 6 deletions
diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
index 164037dc5..d8b2720c2 100644
--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs
+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
@@ -1,11 +1,19 @@
-using MediaBrowser.Common.Net;
+using System;
+using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Startup.Common;
using MediaBrowser.ServerApplication.Networking;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
using System.Reflection;
+using System.Windows.Forms;
using CommonIO;
using MediaBrowser.Controller.Power;
+using MediaBrowser.Model.System;
+using MediaBrowser.Server.Implementations.Persistence;
+using MediaBrowser.Server.Startup.Common.FFMpeg;
+using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;
namespace MediaBrowser.ServerApplication.Native
{
@@ -30,7 +38,7 @@ namespace MediaBrowser.ServerApplication.Native
}
list.Add(GetType().Assembly);
-
+
return list;
}
@@ -46,7 +54,7 @@ namespace MediaBrowser.ServerApplication.Native
return new NativeEnvironment
{
OperatingSystem = OperatingSystem.Windows,
- SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
+ SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86,
OperatingSystemVersionString = System.Environment.OSVersion.VersionString
};
}
@@ -107,7 +115,22 @@ namespace MediaBrowser.ServerApplication.Native
public void ConfigureAutoRun(bool autorun)
{
- Autorun.Configure(autorun, _fileSystem);
+ var shortcutPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
+
+ var startupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);
+
+ if (autorun)
+ {
+ //Copy our shortut into the startup folder for this user
+ var targetPath = Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk");
+ _fileSystem.CreateDirectory(Path.GetDirectoryName(targetPath));
+ File.Copy(shortcutPath, targetPath, true);
+ }
+ else
+ {
+ //Remove our shortcut from the startup folder for this user
+ _fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
+ }
}
public INetworkManager CreateNetworkManager(ILogger logger)
@@ -117,12 +140,69 @@ namespace MediaBrowser.ServerApplication.Native
public void PreventSystemStandby()
{
- Standby.PreventSystemStandby();
+ MainStartup.Invoke(Standby.PreventSleep);
+ }
+
+ public void AllowSystemStandby()
+ {
+ MainStartup.Invoke(Standby.AllowSleep);
}
public IPowerManagement GetPowerManagement()
{
return new WindowsPowerManagement(_logger);
}
+
+ public FFMpegInstallInfo GetFfmpegInstallInfo()
+ {
+ var info = new FFMpegInstallInfo();
+
+ info.FFMpegFilename = "ffmpeg.exe";
+ info.FFProbeFilename = "ffprobe.exe";
+ info.Version = "0";
+
+ return info;
+ }
+
+ public void LaunchUrl(string url)
+ {
+ var process = new Process
+ {
+ StartInfo = new ProcessStartInfo
+ {
+ FileName = url
+ },
+
+ EnableRaisingEvents = true,
+ };
+
+ process.Exited += ProcessExited;
+
+ try
+ {
+ process.Start();
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error launching url: {0}", ex, url);
+
+ throw;
+ }
+ }
+
+ public IDbConnector GetDbConnector()
+ {
+ return new DbConnector(_logger);
+ }
+
+ /// <summary>
+ /// Processes the exited.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
+ private static void ProcessExited(object sender, EventArgs e)
+ {
+ ((Process)sender).Dispose();
+ }
}
-}
+} \ No newline at end of file