aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-24 20:54:51 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-24 20:54:51 -0400
commitfe5a9232c84cea113336005b3c7cbd7fe77a2d80 (patch)
tree9fb1412f4a8ca4303ec276b6ab6e096f98eed58d /MediaBrowser.ServerApplication/Native/BrowserLauncher.cs
parent0ab379e271afe69372806ab0e24a874d3f085456 (diff)
moved a few things for mono
Diffstat (limited to 'MediaBrowser.ServerApplication/Native/BrowserLauncher.cs')
-rw-r--r--MediaBrowser.ServerApplication/Native/BrowserLauncher.cs68
1 files changed, 68 insertions, 0 deletions
diff --git a/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs b/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs
new file mode 100644
index 000000000..e7d041d15
--- /dev/null
+++ b/MediaBrowser.ServerApplication/Native/BrowserLauncher.cs
@@ -0,0 +1,68 @@
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Logging;
+using System;
+using System.Diagnostics;
+using System.Windows.Forms;
+
+namespace MediaBrowser.ServerApplication.Native
+{
+ public static class BrowserLauncher
+ {
+ /// <summary>
+ /// Opens the dashboard page.
+ /// </summary>
+ /// <param name="page">The page.</param>
+ /// <param name="loggedInUser">The logged in user.</param>
+ /// <param name="configurationManager">The configuration manager.</param>
+ /// <param name="appHost">The app host.</param>
+ public static void OpenDashboardPage(string page, User loggedInUser, IServerConfigurationManager configurationManager, IServerApplicationHost appHost, ILogger logger)
+ {
+ var url = "http://localhost:" + configurationManager.Configuration.HttpServerPortNumber + "/" +
+ appHost.WebApplicationName + "/dashboard/" + page;
+
+ OpenUrl(url, logger);
+ }
+
+ /// <summary>
+ /// Opens the URL.
+ /// </summary>
+ /// <param name="url">The URL.</param>
+ public static void OpenUrl(string url, ILogger logger)
+ {
+ 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);
+
+ MessageBox.Show("There was an error launching your web browser. Please check your default browser settings.");
+ }
+ }
+
+ /// <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();
+ }
+ }
+}