diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 20:54:51 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 20:54:51 -0400 |
| commit | fe5a9232c84cea113336005b3c7cbd7fe77a2d80 (patch) | |
| tree | 9fb1412f4a8ca4303ec276b6ab6e096f98eed58d /MediaBrowser.ServerApplication/Native/ServerAuthorization.cs | |
| parent | 0ab379e271afe69372806ab0e24a874d3f085456 (diff) | |
moved a few things for mono
Diffstat (limited to 'MediaBrowser.ServerApplication/Native/ServerAuthorization.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/Native/ServerAuthorization.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs new file mode 100644 index 000000000..91f0974eb --- /dev/null +++ b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs @@ -0,0 +1,56 @@ +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="httpServerPort">The HTTP server port.</param> + /// <param name="httpServerUrlPrefix">The HTTP server URL prefix.</param> + /// <param name="webSocketPort">The web socket port.</param> + /// <param name="udpPort">The UDP port.</param> + /// <param name="tempDirectory">The temp directory.</param> + public static void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int webSocketPort, int udpPort, string 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}", httpServerPort, + httpServerUrlPrefix, + udpPort, + webSocketPort), + + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden, + Verb = "runas", + ErrorDialog = false + }; + + using (var process = Process.Start(startInfo)) + { + process.WaitForExit(); + } + } + } +} |
