aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication/Native')
-rw-r--r--MediaBrowser.ServerApplication/Native/DbConnector.cs22
-rw-r--r--MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs4
-rw-r--r--MediaBrowser.ServerApplication/Native/PowerManagement.cs17
-rw-r--r--MediaBrowser.ServerApplication/Native/RegisterServer.bat3
-rw-r--r--MediaBrowser.ServerApplication/Native/WindowsApp.cs262
5 files changed, 22 insertions, 286 deletions
diff --git a/MediaBrowser.ServerApplication/Native/DbConnector.cs b/MediaBrowser.ServerApplication/Native/DbConnector.cs
deleted file mode 100644
index f403ce2ce..000000000
--- a/MediaBrowser.ServerApplication/Native/DbConnector.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Data;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Implementations.Persistence;
-
-namespace MediaBrowser.ServerApplication.Native
-{
- public class DbConnector : IDbConnector
- {
- private readonly ILogger _logger;
-
- public DbConnector(ILogger logger)
- {
- _logger = logger;
- }
-
- public Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null)
- {
- return SqliteExtensions.ConnectToDb(dbPath, isReadOnly, enablePooling, cacheSize, _logger);
- }
- }
-} \ No newline at end of file
diff --git a/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs
index dc1e3c79b..91ff7033e 100644
--- a/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs
+++ b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs
@@ -3,11 +3,11 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
-using CommonIO;
+using MediaBrowser.Model.IO;
namespace MediaBrowser.ServerApplication.Native
{
- public class LnkShortcutHandler : IShortcutHandler
+ public class LnkShortcutHandler :IShortcutHandler
{
public string Extension
{
diff --git a/MediaBrowser.ServerApplication/Native/PowerManagement.cs b/MediaBrowser.ServerApplication/Native/PowerManagement.cs
new file mode 100644
index 000000000..0bd3db1da
--- /dev/null
+++ b/MediaBrowser.ServerApplication/Native/PowerManagement.cs
@@ -0,0 +1,17 @@
+using MediaBrowser.Model.System;
+
+namespace MediaBrowser.ServerApplication.Native
+{
+ public class PowerManagement : IPowerManagement
+ {
+ public void PreventSystemStandby()
+ {
+ MainStartup.Invoke(Standby.PreventSleep);
+ }
+
+ public void AllowSystemStandby()
+ {
+ MainStartup.Invoke(Standby.AllowSleep);
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/Native/RegisterServer.bat b/MediaBrowser.ServerApplication/Native/RegisterServer.bat
index 85baa0d03..504df2199 100644
--- a/MediaBrowser.ServerApplication/Native/RegisterServer.bat
+++ b/MediaBrowser.ServerApplication/Native/RegisterServer.bat
@@ -26,6 +26,9 @@ netsh advfirewall firewall delete rule name="Emby Server"
netsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=TCP program=%4 enable=yes
netsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=UDP program=%4 enable=yes
+netsh advfirewall firewall add rule name="mediabrowser.serverapplication.exe" dir=in action=allow protocol=TCP program=%4 enable=yes
+netsh advfirewall firewall add rule name="mediabrowser.serverapplication.exe" dir=in action=allow protocol=UDP program=%4 enable=yes
+
:DONE
Exit \ No newline at end of file
diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
deleted file mode 100644
index 7ebede40c..000000000
--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs
+++ /dev/null
@@ -1,262 +0,0 @@
-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.Model.System;
-using MediaBrowser.Server.Implementations.Persistence;
-using MediaBrowser.Server.Startup.Common.FFMpeg;
-using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;
-
-namespace MediaBrowser.ServerApplication.Native
-{
- public class WindowsApp : INativeApp
- {
- private readonly IFileSystem _fileSystem;
- private readonly ILogger _logger;
-
- public WindowsApp(IFileSystem fileSystem, ILogger logger)
- {
- _fileSystem = fileSystem;
- _logger = logger;
- }
-
- public List<Assembly> GetAssembliesWithParts()
- {
- var list = new List<Assembly>();
-
- if (!System.Environment.Is64BitProcess)
- {
- //list.Add(typeof(PismoIsoManager).Assembly);
- }
-
- list.Add(GetType().Assembly);
-
- return list;
- }
-
- public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, string tempDirectory)
- {
- ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, applicationPath, tempDirectory);
- }
-
- public NativeEnvironment Environment
- {
- get
- {
- return new NativeEnvironment
- {
- OperatingSystem = OperatingSystem.Windows,
- SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86,
- OperatingSystemVersionString = System.Environment.OSVersion.VersionString
- };
- }
- }
-
- public bool SupportsLibraryMonitor
- {
- get { return true; }
- }
-
- public bool SupportsRunningAsService
- {
- get
- {
- return true;
- }
- }
-
- public bool IsRunningAsService
- {
- get;
- set;
- }
-
- public bool CanSelfRestart
- {
- get
- {
- return MainStartup.CanSelfRestart;
- }
- }
-
- public bool SupportsAutoRunAtStartup
- {
- get
- {
- return true;
- }
- }
-
- public bool CanSelfUpdate
- {
- get
- {
- return MainStartup.CanSelfUpdate;
- }
- }
-
- public void Shutdown()
- {
- MainStartup.Shutdown();
- }
-
- public void Restart(StartupOptions startupOptions)
- {
- MainStartup.Restart();
- }
-
- public void ConfigureAutoRun(bool autorun)
- {
- 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)
- {
- return new NetworkManager(logger);
- }
-
- public void PreventSystemStandby()
- {
- MainStartup.Invoke(Standby.PreventSleep);
- }
-
- public void AllowSystemStandby()
- {
- MainStartup.Invoke(Standby.AllowSleep);
- }
-
- 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();
- }
-
- public void EnableLoopback(string appName)
- {
- LoopUtil.Run(appName);
- }
-
- public bool PortsRequireAuthorization(string applicationPath)
- {
- var appNameSrch = Path.GetFileName(applicationPath);
-
- var startInfo = new ProcessStartInfo
- {
- FileName = "netsh",
-
- Arguments = "advfirewall firewall show rule \"" + appNameSrch + "\"",
-
- CreateNoWindow = true,
- UseShellExecute = false,
- WindowStyle = ProcessWindowStyle.Hidden,
- ErrorDialog = false,
- RedirectStandardOutput = true
- };
-
- using (var process = Process.Start(startInfo))
- {
- process.Start();
-
- try
- {
- var data = process.StandardOutput.ReadToEnd() ?? string.Empty;
-
- if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)
- {
- _logger.Info("Found potential windows firewall rule blocking Emby Server: " + data);
- }
-
- //var parts = data.Split('\n');
-
- //return parts.Length > 4;
- //return Confirm();
- return false;
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error querying windows firewall", ex);
-
- // Hate having to do this
- try
- {
- process.Kill();
- }
- catch (Exception ex1)
- {
- _logger.ErrorException("Error killing process", ex1);
- }
-
- throw;
- }
- }
- }
- }
-} \ No newline at end of file