aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication/Native')
-rw-r--r--MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs332
-rw-r--r--MediaBrowser.ServerApplication/Native/LoopUtil.cs293
-rw-r--r--MediaBrowser.ServerApplication/Native/PowerManagement.cs17
-rw-r--r--MediaBrowser.ServerApplication/Native/RegisterServer.bat34
-rw-r--r--MediaBrowser.ServerApplication/Native/ServerAuthorization.cs54
-rw-r--r--MediaBrowser.ServerApplication/Native/Standby.cs48
6 files changed, 0 insertions, 778 deletions
diff --git a/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs
deleted file mode 100644
index e53a79670..000000000
--- a/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs
+++ /dev/null
@@ -1,332 +0,0 @@
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.ComTypes;
-using System.Text;
-using MediaBrowser.Model.IO;
-
-namespace MediaBrowser.ServerApplication.Native
-{
- public class LnkShortcutHandler :IShortcutHandler
- {
- public string Extension
- {
- get { return ".lnk"; }
- }
-
- public string Resolve(string shortcutPath)
- {
- var link = new ShellLink();
- ((IPersistFile)link).Load(shortcutPath, NativeMethods.STGM_READ);
- // ((IShellLinkW)link).Resolve(hwnd, 0)
- var sb = new StringBuilder(NativeMethods.MAX_PATH);
- WIN32_FIND_DATA data;
- ((IShellLinkW)link).GetPath(sb, sb.Capacity, out data, 0);
- return sb.ToString();
- }
-
- public void Create(string shortcutPath, string targetPath)
- {
- throw new NotImplementedException();
- }
- }
-
- /// <summary>
- /// Class NativeMethods
- /// </summary>
- public static class NativeMethods
- {
- /// <summary>
- /// The MA x_ PATH
- /// </summary>
- public const int MAX_PATH = 260;
- /// <summary>
- /// The MA x_ ALTERNATE
- /// </summary>
- public const int MAX_ALTERNATE = 14;
- /// <summary>
- /// The INVALI d_ HANDL e_ VALUE
- /// </summary>
- public static IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
- /// <summary>
- /// The STG m_ READ
- /// </summary>
- public const int STGM_READ = 0;
- }
-
- /// <summary>
- /// Struct FILETIME
- /// </summary>
- [StructLayout(LayoutKind.Sequential)]
- public struct FILETIME
- {
- /// <summary>
- /// The dw low date time
- /// </summary>
- public uint dwLowDateTime;
- /// <summary>
- /// The dw high date time
- /// </summary>
- public uint dwHighDateTime;
- }
-
- /// <summary>
- /// Struct WIN32_FIND_DATA
- /// </summary>
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- public struct WIN32_FIND_DATA
- {
- /// <summary>
- /// The dw file attributes
- /// </summary>
- public FileAttributes dwFileAttributes;
- /// <summary>
- /// The ft creation time
- /// </summary>
- public FILETIME ftCreationTime;
- /// <summary>
- /// The ft last access time
- /// </summary>
- public FILETIME ftLastAccessTime;
- /// <summary>
- /// The ft last write time
- /// </summary>
- public FILETIME ftLastWriteTime;
- /// <summary>
- /// The n file size high
- /// </summary>
- public int nFileSizeHigh;
- /// <summary>
- /// The n file size low
- /// </summary>
- public int nFileSizeLow;
- /// <summary>
- /// The dw reserved0
- /// </summary>
- public int dwReserved0;
- /// <summary>
- /// The dw reserved1
- /// </summary>
- public int dwReserved1;
-
- /// <summary>
- /// The c file name
- /// </summary>
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeMethods.MAX_PATH)]
- public string cFileName;
-
- /// <summary>
- /// This will always be null when FINDEX_INFO_LEVELS = basic
- /// </summary>
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeMethods.MAX_ALTERNATE)]
- public string cAlternate;
-
- /// <summary>
- /// Gets or sets the path.
- /// </summary>
- /// <value>The path.</value>
- public string Path { get; set; }
-
- /// <summary>
- /// Returns a <see cref="System.String" /> that represents this instance.
- /// </summary>
- /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
- public override string ToString()
- {
- return Path ?? string.Empty;
- }
- }
-
- /// <summary>
- /// Enum SLGP_FLAGS
- /// </summary>
- [Flags]
- public enum SLGP_FLAGS
- {
- /// <summary>
- /// Retrieves the standard short (8.3 format) file name
- /// </summary>
- SLGP_SHORTPATH = 0x1,
- /// <summary>
- /// Retrieves the Universal Naming Convention (UNC) path name of the file
- /// </summary>
- SLGP_UNCPRIORITY = 0x2,
- /// <summary>
- /// Retrieves the raw path name. A raw path is something that might not exist and may include environment variables that need to be expanded
- /// </summary>
- SLGP_RAWPATH = 0x4
- }
- /// <summary>
- /// Enum SLR_FLAGS
- /// </summary>
- [Flags]
- public enum SLR_FLAGS
- {
- /// <summary>
- /// Do not display a dialog box if the link cannot be resolved. When SLR_NO_UI is set,
- /// the high-order word of fFlags can be set to a time-out value that specifies the
- /// maximum amount of time to be spent resolving the link. The function returns if the
- /// link cannot be resolved within the time-out duration. If the high-order word is set
- /// to zero, the time-out duration will be set to the default value of 3,000 milliseconds
- /// (3 seconds). To specify a value, set the high word of fFlags to the desired time-out
- /// duration, in milliseconds.
- /// </summary>
- SLR_NO_UI = 0x1,
- /// <summary>
- /// Obsolete and no longer used
- /// </summary>
- SLR_ANY_MATCH = 0x2,
- /// <summary>
- /// If the link object has changed, update its path and list of identifiers.
- /// If SLR_UPDATE is set, you do not need to call IPersistFile::IsDirty to determine
- /// whether or not the link object has changed.
- /// </summary>
- SLR_UPDATE = 0x4,
- /// <summary>
- /// Do not update the link information
- /// </summary>
- SLR_NOUPDATE = 0x8,
- /// <summary>
- /// Do not execute the search heuristics
- /// </summary>
- SLR_NOSEARCH = 0x10,
- /// <summary>
- /// Do not use distributed link tracking
- /// </summary>
- SLR_NOTRACK = 0x20,
- /// <summary>
- /// Disable distributed link tracking. By default, distributed link tracking tracks
- /// removable media across multiple devices based on the volume name. It also uses the
- /// Universal Naming Convention (UNC) path to track remote file systems whose drive letter
- /// has changed. Setting SLR_NOLINKINFO disables both types of tracking.
- /// </summary>
- SLR_NOLINKINFO = 0x40,
- /// <summary>
- /// Call the Microsoft Windows Installer
- /// </summary>
- SLR_INVOKE_MSI = 0x80
- }
-
- /// <summary>
- /// The IShellLink interface allows Shell links to be created, modified, and resolved
- /// </summary>
- [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F9-0000-0000-C000-000000000046")]
- public interface IShellLinkW
- {
- /// <summary>
- /// Retrieves the path and file name of a Shell link object
- /// </summary>
- /// <param name="pszFile">The PSZ file.</param>
- /// <param name="cchMaxPath">The CCH max path.</param>
- /// <param name="pfd">The PFD.</param>
- /// <param name="fFlags">The f flags.</param>
- void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out WIN32_FIND_DATA pfd, SLGP_FLAGS fFlags);
- /// <summary>
- /// Retrieves the list of item identifiers for a Shell link object
- /// </summary>
- /// <param name="ppidl">The ppidl.</param>
- void GetIDList(out IntPtr ppidl);
- /// <summary>
- /// Sets the pointer to an item identifier list (PIDL) for a Shell link object.
- /// </summary>
- /// <param name="pidl">The pidl.</param>
- void SetIDList(IntPtr pidl);
- /// <summary>
- /// Retrieves the description string for a Shell link object
- /// </summary>
- /// <param name="pszName">Name of the PSZ.</param>
- /// <param name="cchMaxName">Name of the CCH max.</param>
- void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
- /// <summary>
- /// Sets the description for a Shell link object. The description can be any application-defined string
- /// </summary>
- /// <param name="pszName">Name of the PSZ.</param>
- void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
- /// <summary>
- /// Retrieves the name of the working directory for a Shell link object
- /// </summary>
- /// <param name="pszDir">The PSZ dir.</param>
- /// <param name="cchMaxPath">The CCH max path.</param>
- void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
- /// <summary>
- /// Sets the name of the working directory for a Shell link object
- /// </summary>
- /// <param name="pszDir">The PSZ dir.</param>
- void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
- /// <summary>
- /// Retrieves the command-line arguments associated with a Shell link object
- /// </summary>
- /// <param name="pszArgs">The PSZ args.</param>
- /// <param name="cchMaxPath">The CCH max path.</param>
- void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
- /// <summary>
- /// Sets the command-line arguments for a Shell link object
- /// </summary>
- /// <param name="pszArgs">The PSZ args.</param>
- void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
- /// <summary>
- /// Retrieves the hot key for a Shell link object
- /// </summary>
- /// <param name="pwHotkey">The pw hotkey.</param>
- void GetHotkey(out short pwHotkey);
- /// <summary>
- /// Sets a hot key for a Shell link object
- /// </summary>
- /// <param name="wHotkey">The w hotkey.</param>
- void SetHotkey(short wHotkey);
- /// <summary>
- /// Retrieves the show command for a Shell link object
- /// </summary>
- /// <param name="piShowCmd">The pi show CMD.</param>
- void GetShowCmd(out int piShowCmd);
- /// <summary>
- /// Sets the show command for a Shell link object. The show command sets the initial show state of the window.
- /// </summary>
- /// <param name="iShowCmd">The i show CMD.</param>
- void SetShowCmd(int iShowCmd);
- /// <summary>
- /// Retrieves the location (path and index) of the icon for a Shell link object
- /// </summary>
- /// <param name="pszIconPath">The PSZ icon path.</param>
- /// <param name="cchIconPath">The CCH icon path.</param>
- /// <param name="piIcon">The pi icon.</param>
- void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath,
- int cchIconPath, out int piIcon);
- /// <summary>
- /// Sets the location (path and index) of the icon for a Shell link object
- /// </summary>
- /// <param name="pszIconPath">The PSZ icon path.</param>
- /// <param name="iIcon">The i icon.</param>
- void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
- /// <summary>
- /// Sets the relative path to the Shell link object
- /// </summary>
- /// <param name="pszPathRel">The PSZ path rel.</param>
- /// <param name="dwReserved">The dw reserved.</param>
- void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
- /// <summary>
- /// Attempts to find the target of a Shell link, even if it has been moved or renamed
- /// </summary>
- /// <param name="hwnd">The HWND.</param>
- /// <param name="fFlags">The f flags.</param>
- void Resolve(IntPtr hwnd, SLR_FLAGS fFlags);
- /// <summary>
- /// Sets the path and file name of a Shell link object
- /// </summary>
- /// <param name="pszFile">The PSZ file.</param>
- void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
-
- }
-
- // CLSID_ShellLink from ShlGuid.h
- /// <summary>
- /// Class ShellLink
- /// </summary>
- [
- ComImport,
- Guid("00021401-0000-0000-C000-000000000046")
- ]
- public class ShellLink
- {
- }
-}
diff --git a/MediaBrowser.ServerApplication/Native/LoopUtil.cs b/MediaBrowser.ServerApplication/Native/LoopUtil.cs
deleted file mode 100644
index 0efdba389..000000000
--- a/MediaBrowser.ServerApplication/Native/LoopUtil.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-/*
- * Important - Even though this will compile in the shared projects, it will cause build failures within the mono runtime
- */
-namespace MediaBrowser.ServerApplication.Native
-{
- /// <summary>
- /// http://blogs.msdn.com/b/fiddler/archive/2011/12/10/fiddler-windows-8-apps-enable-LoopUtil-network-isolation-exemption.aspx
- /// </summary>
- public class LoopUtil
- {
- //http://msdn.microsoft.com/en-us/library/windows/desktop/aa379595(v=vs.85).aspx
- [StructLayout(LayoutKind.Sequential)]
- internal struct SID_AND_ATTRIBUTES
- {
- public IntPtr Sid;
- public uint Attributes;
- }
-
- [StructLayoutAttribute(LayoutKind.Sequential)]
- internal struct INET_FIREWALL_AC_CAPABILITIES
- {
- public uint count;
- public IntPtr capabilities; //SID_AND_ATTRIBUTES
- }
-
- [StructLayoutAttribute(LayoutKind.Sequential)]
- internal struct INET_FIREWALL_AC_BINARIES
- {
- public uint count;
- public IntPtr binaries;
- }
-
- [StructLayoutAttribute(LayoutKind.Sequential)]
- internal struct INET_FIREWALL_APP_CONTAINER
- {
- internal IntPtr appContainerSid;
- internal IntPtr userSid;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string appContainerName;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string displayName;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string description;
- internal INET_FIREWALL_AC_CAPABILITIES capabilities;
- internal INET_FIREWALL_AC_BINARIES binaries;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string workingDirectory;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string packageFullName;
- }
-
-
- // Call this API to load the current list of LoopUtil-enabled AppContainers
- [DllImport("FirewallAPI.dll")]
- internal static extern uint NetworkIsolationGetAppContainerConfig(out uint pdwCntACs, out IntPtr appContainerSids);
-
- // Call this API to set the LoopUtil-exemption list
- [DllImport("FirewallAPI.dll")]
- private static extern uint NetworkIsolationSetAppContainerConfig(uint pdwCntACs, SID_AND_ATTRIBUTES[] appContainerSids);
-
- // Use this API to convert a string SID into an actual SID
- [DllImport("advapi32.dll", SetLastError = true)]
- internal static extern bool ConvertStringSidToSid(string strSid, out IntPtr pSid);
-
- [DllImport("advapi32", /*CharSet = CharSet.Auto,*/ SetLastError = true)]
- static extern bool ConvertSidToStringSid(IntPtr pSid, out string strSid);
-
- // Call this API to enumerate all of the AppContainers on the system
- [DllImport("FirewallAPI.dll")]
- internal static extern uint NetworkIsolationEnumAppContainers(uint Flags, out uint pdwCntPublicACs, out IntPtr ppACs);
- // DWORD NetworkIsolationEnumAppContainers(
- // _In_ DWORD Flags,
- // _Out_ DWORD *pdwNumPublicAppCs,
- // _Out_ PINET_FIREWALL_APP_CONTAINER *ppPublicAppCs
- //);
-
- //http://msdn.microsoft.com/en-gb/library/windows/desktop/hh968116.aspx
- enum NETISO_FLAG
- {
- NETISO_FLAG_FORCE_COMPUTE_BINARIES = 0x1,
- NETISO_FLAG_MAX = 0x2
- }
-
-
- public class AppContainer
- {
- public String appContainerName { get; set; }
- public String displayName { get; set; }
- public String workingDirectory { get; set; }
- public String StringSid { get; set; }
- public List<uint> capabilities { get; set; }
- public bool LoopUtil { get; set; }
-
- public AppContainer(String _appContainerName, String _displayName, String _workingDirectory, IntPtr _sid)
- {
- this.appContainerName = _appContainerName;
- this.displayName = _displayName;
- this.workingDirectory = _workingDirectory;
- String tempSid;
- ConvertSidToStringSid(_sid, out tempSid);
- this.StringSid = tempSid;
- }
- }
-
- internal List<LoopUtil.INET_FIREWALL_APP_CONTAINER> _AppList;
- internal List<LoopUtil.SID_AND_ATTRIBUTES> _AppListConfig;
- public List<AppContainer> Apps = new List<AppContainer>();
- internal IntPtr _pACs;
-
- public LoopUtil()
- {
- LoadApps();
- }
-
- public void LoadApps()
- {
- Apps.Clear();
- _pACs = IntPtr.Zero;
- //Full List of Apps
- _AppList = PI_NetworkIsolationEnumAppContainers();
- //List of Apps that have LoopUtil enabled.
- _AppListConfig = PI_NetworkIsolationGetAppContainerConfig();
- foreach (var PI_app in _AppList)
- {
- AppContainer app = new AppContainer(PI_app.appContainerName, PI_app.displayName, PI_app.workingDirectory, PI_app.appContainerSid);
-
- app.LoopUtil = CheckLoopback(PI_app.appContainerSid);
- Apps.Add(app);
- }
- }
- private bool CheckLoopback(IntPtr intPtr)
- {
- foreach (SID_AND_ATTRIBUTES item in _AppListConfig)
- {
- string left, right;
- ConvertSidToStringSid(item.Sid, out left);
- ConvertSidToStringSid(intPtr, out right);
-
- if (left == right)
- {
- return true;
- }
- }
- return false;
- }
-
- private bool CreateExcemptions(string appName)
- {
- var hasChanges = false;
-
- foreach (var app in Apps)
- {
- if ((app.appContainerName ?? string.Empty).IndexOf(appName, StringComparison.OrdinalIgnoreCase) != -1 ||
- (app.displayName ?? string.Empty).IndexOf(appName, StringComparison.OrdinalIgnoreCase) != -1)
- {
- if (!app.LoopUtil)
- {
- app.LoopUtil = true;
- hasChanges = true;
- }
- }
- }
-
- return hasChanges;
- }
-
- public static void Run(string appName)
- {
- var util = new LoopUtil();
- util.LoadApps();
-
- var hasChanges = util.CreateExcemptions(appName);
-
- if (hasChanges)
- {
- util.SaveLoopbackState();
- }
- }
-
- private static List<SID_AND_ATTRIBUTES> PI_NetworkIsolationGetAppContainerConfig()
- {
-
- IntPtr arrayValue = IntPtr.Zero;
- uint size = 0;
- var list = new List<SID_AND_ATTRIBUTES>();
-
- // Pin down variables
- GCHandle handle_pdwCntPublicACs = GCHandle.Alloc(size, GCHandleType.Pinned);
- GCHandle handle_ppACs = GCHandle.Alloc(arrayValue, GCHandleType.Pinned);
-
- uint retval = NetworkIsolationGetAppContainerConfig(out size, out arrayValue);
-
- var structSize = Marshal.SizeOf(typeof(SID_AND_ATTRIBUTES));
- for (var i = 0; i < size; i++)
- {
- var cur = (SID_AND_ATTRIBUTES)Marshal.PtrToStructure(arrayValue, typeof(SID_AND_ATTRIBUTES));
- list.Add(cur);
- arrayValue = new IntPtr((long)(arrayValue) + (long)(structSize));
- }
-
- //release pinned variables.
- handle_pdwCntPublicACs.Free();
- handle_ppACs.Free();
-
- return list;
-
-
- }
-
- private List<INET_FIREWALL_APP_CONTAINER> PI_NetworkIsolationEnumAppContainers()
- {
-
- IntPtr arrayValue = IntPtr.Zero;
- uint size = 0;
- var list = new List<INET_FIREWALL_APP_CONTAINER>();
-
- // Pin down variables
- GCHandle handle_pdwCntPublicACs = GCHandle.Alloc(size, GCHandleType.Pinned);
- GCHandle handle_ppACs = GCHandle.Alloc(arrayValue, GCHandleType.Pinned);
-
- //uint retval2 = NetworkIsolationGetAppContainerConfig( out size, out arrayValue);
-
- uint retval = NetworkIsolationEnumAppContainers((Int32)NETISO_FLAG.NETISO_FLAG_MAX, out size, out arrayValue);
- _pACs = arrayValue; //store the pointer so it can be freed when we close the form
-
- var structSize = Marshal.SizeOf(typeof(INET_FIREWALL_APP_CONTAINER));
- for (var i = 0; i < size; i++)
- {
- var cur = (INET_FIREWALL_APP_CONTAINER)Marshal.PtrToStructure(arrayValue, typeof(INET_FIREWALL_APP_CONTAINER));
- list.Add(cur);
- arrayValue = new IntPtr((long)(arrayValue) + (long)(structSize));
- }
-
- //release pinned variables.
- handle_pdwCntPublicACs.Free();
- handle_ppACs.Free();
-
- return list;
-
-
- }
-
- public bool SaveLoopbackState()
- {
- var countEnabled = CountEnabledLoopUtil();
- SID_AND_ATTRIBUTES[] arr = new SID_AND_ATTRIBUTES[countEnabled];
- int count = 0;
-
- for (int i = 0; i < Apps.Count; i++)
- {
- if (Apps[i].LoopUtil)
- {
- arr[count].Attributes = 0;
- //TO DO:
- IntPtr ptr;
- ConvertStringSidToSid(Apps[i].StringSid, out ptr);
- arr[count].Sid = ptr;
- count++;
- }
-
- }
-
-
- if (NetworkIsolationSetAppContainerConfig((uint)countEnabled, arr) == 0)
- {
- return true;
- }
- else
- { return false; }
-
- }
-
- private int CountEnabledLoopUtil()
- {
- var count = 0;
- for (int i = 0; i < Apps.Count; i++)
- {
- if (Apps[i].LoopUtil)
- {
- count++;
- }
-
- }
- return count;
- }
- }
-}
diff --git a/MediaBrowser.ServerApplication/Native/PowerManagement.cs b/MediaBrowser.ServerApplication/Native/PowerManagement.cs
deleted file mode 100644
index 0bd3db1da..000000000
--- a/MediaBrowser.ServerApplication/Native/PowerManagement.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-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
deleted file mode 100644
index 504df2199..000000000
--- a/MediaBrowser.ServerApplication/Native/RegisterServer.bat
+++ /dev/null
@@ -1,34 +0,0 @@
-rem %1 = udp server port
-rem %2 = http server port
-rem %3 = https server port
-rem %4 = exe path
-
-if [%1]==[] GOTO DONE
-
-netsh advfirewall firewall delete rule name="Port %1" protocol=UDP localport=%1
-netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=UDP localport=%1
-
-if [%2]==[] GOTO DONE
-
-netsh advfirewall firewall delete rule name="Port %2" protocol=TCP localport=%2
-netsh advfirewall firewall add rule name="Port %2" dir=in action=allow protocol=TCP localport=%2
-
-if [%3]==[] GOTO DONE
-
-netsh advfirewall firewall delete rule name="Port %3" protocol=TCP localport=%3
-netsh advfirewall firewall add rule name="Port %3" dir=in action=allow protocol=TCP localport=%3
-
-if [%4]==[] GOTO DONE
-
-netsh advfirewall firewall delete rule name="mediabrowser.serverapplication.exe"
-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/ServerAuthorization.cs b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs
deleted file mode 100644
index 70444ad9f..000000000
--- a/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-
-namespace MediaBrowser.ServerApplication.Native
-{
- /// <summary>
- /// Class Authorization
- /// </summary>
- public static class ServerAuthorization
- {
- /// <summary>
- /// Authorizes the server.
- /// </summary>
- /// <param name="udpPort">The UDP port.</param>
- /// <param name="httpServerPort">The HTTP server port.</param>
- /// <param name="httpsServerPort">The HTTPS server port.</param>
- /// <param name="tempDirectory">The temp directory.</param>
- public static void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory)
- {
- Directory.CreateDirectory(tempDirectory);
-
- // Create a temp file path to extract the bat file to
- var tmpFile = Path.Combine(tempDirectory, Guid.NewGuid() + ".bat");
-
- // Extract the bat file
- using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(ServerAuthorization).Namespace + ".RegisterServer.bat"))
- {
- using (var fileStream = File.Create(tmpFile))
- {
- stream.CopyTo(fileStream);
- }
- }
-
- var startInfo = new ProcessStartInfo
- {
- FileName = tmpFile,
-
- Arguments = string.Format("{0} {1} {2} \"{3}\"", udpPort, httpServerPort, httpsServerPort, applicationPath),
-
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden,
- Verb = "runas",
- ErrorDialog = false
- };
-
- using (var process = Process.Start(startInfo))
- {
- process.WaitForExit();
- }
- }
- }
-}
diff --git a/MediaBrowser.ServerApplication/Native/Standby.cs b/MediaBrowser.ServerApplication/Native/Standby.cs
deleted file mode 100644
index 919709538..000000000
--- a/MediaBrowser.ServerApplication/Native/Standby.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-namespace MediaBrowser.ServerApplication.Native
-{
- /// <summary>
- /// Class NativeApp
- /// </summary>
- public static class Standby
- {
- public static void PreventSleepAndMonitorOff()
- {
- NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED | NativeMethods.ES_DISPLAY_REQUIRED);
- }
-
- public static void PreventSleep()
- {
- NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
- }
-
- // Clear EXECUTION_STATE flags to allow the system to sleep and turn off monitor normally
- public static void AllowSleep()
- {
- NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS);
- }
-
- internal static class NativeMethods
- {
- // Import SetThreadExecutionState Win32 API and necessary flags
- [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- public static extern uint SetThreadExecutionState(uint esFlags);
- public const uint ES_CONTINUOUS = 0x80000000;
- public const uint ES_SYSTEM_REQUIRED = 0x00000001;
- public const uint ES_DISPLAY_REQUIRED = 0x00000002;
- }
-
- [Flags]
- 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
- }
- }
-}