aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-10-12 15:43:28 -0400
committerGitHub <noreply@github.com>2016-10-12 15:43:28 -0400
commit25ef9777cafee83c46ff53ede2caa04e3295e98a (patch)
tree5f1e6045d0b4d4d5b7d8dcaadf035b326f36e672 /MediaBrowser.ServerApplication/Native
parent0677d4ec990aee9a3bf7bda39dda01eb6fa66281 (diff)
parent5be6cf05e34459a046aceaa16c891f3034859476 (diff)
Merge pull request #2224 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.ServerApplication/Native')
-rw-r--r--MediaBrowser.ServerApplication/Native/WindowsApp.cs17
-rw-r--r--MediaBrowser.ServerApplication/Native/WindowsPowerManagement.cs94
2 files changed, 0 insertions, 111 deletions
diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
index b08b82de5..7ebede40c 100644
--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs
+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
@@ -9,7 +9,6 @@ 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;
@@ -148,11 +147,6 @@ namespace MediaBrowser.ServerApplication.Native
MainStartup.Invoke(Standby.AllowSleep);
}
- public IPowerManagement GetPowerManagement()
- {
- return new WindowsPowerManagement(_logger);
- }
-
public FFMpegInstallInfo GetFfmpegInstallInfo()
{
var info = new FFMpegInstallInfo();
@@ -210,16 +204,6 @@ namespace MediaBrowser.ServerApplication.Native
LoopUtil.Run(appName);
}
- private bool Confirm()
- {
- if (MainStartup._splash == null)
- {
- return false;
- }
-
- return MessageBox.Show(MainStartup._splash, "Emby has detected that a rule has been added to Windows Firewall that may prevent your other devices from accessing Emby Server. Click OK to remove this rule, or cancel to proceed anyway.", "Windows Firewall", MessageBoxButtons.OKCancel) == DialogResult.OK;
- }
-
public bool PortsRequireAuthorization(string applicationPath)
{
var appNameSrch = Path.GetFileName(applicationPath);
@@ -248,7 +232,6 @@ namespace MediaBrowser.ServerApplication.Native
if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)
{
_logger.Info("Found potential windows firewall rule blocking Emby Server: " + data);
- return Confirm();
}
//var parts = data.Split('\n');
diff --git a/MediaBrowser.ServerApplication/Native/WindowsPowerManagement.cs b/MediaBrowser.ServerApplication/Native/WindowsPowerManagement.cs
deleted file mode 100644
index 866272639..000000000
--- a/MediaBrowser.ServerApplication/Native/WindowsPowerManagement.cs
+++ /dev/null
@@ -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);
- }
- }
- }
-}