update browser launcher
This commit is contained in:
parent
75fcde417a
commit
ebf0eeb3bd
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Controller
|
||||||
public interface IServerApplicationHost : IApplicationHost
|
public interface IServerApplicationHost : IApplicationHost
|
||||||
{
|
{
|
||||||
event EventHandler HasUpdateAvailableChanged;
|
event EventHandler HasUpdateAvailableChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the system info.
|
/// Gets the system info.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -86,5 +86,7 @@ namespace MediaBrowser.Controller
|
||||||
/// <param name="ipAddress">The ip address.</param>
|
/// <param name="ipAddress">The ip address.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
string GetLocalApiUrl(IPAddress ipAddress);
|
string GetLocalApiUrl(IPAddress ipAddress);
|
||||||
|
|
||||||
|
void LaunchUrl(string url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,11 @@ namespace MediaBrowser.Server.Mono.Native
|
||||||
return GetInfo(Environment);
|
return GetInfo(Environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LaunchUrl(string url)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
|
public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
|
||||||
{
|
{
|
||||||
var info = new FFMpegInstallInfo();
|
var info = new FFMpegInstallInfo();
|
||||||
|
|
|
@ -1404,5 +1404,10 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
return externalDns;
|
return externalDns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LaunchUrl(string url)
|
||||||
|
{
|
||||||
|
NativeApp.LaunchUrl(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,87 +15,58 @@ namespace MediaBrowser.Server.Startup.Common.Browser
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="page">The page.</param>
|
/// <param name="page">The page.</param>
|
||||||
/// <param name="appHost">The app host.</param>
|
/// <param name="appHost">The app host.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
public static void OpenDashboardPage(string page, IServerApplicationHost appHost)
|
||||||
public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger)
|
|
||||||
{
|
{
|
||||||
var url = appHost.GetLocalApiUrl("localhost") + "/web/" + page;
|
var url = appHost.GetLocalApiUrl("localhost") + "/web/" + page;
|
||||||
|
|
||||||
OpenUrl(url, logger);
|
OpenUrl(appHost, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the community.
|
/// Opens the community.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger">The logger.</param>
|
public static void OpenCommunity(IServerApplicationHost appHost)
|
||||||
public static void OpenCommunity(ILogger logger)
|
|
||||||
{
|
{
|
||||||
OpenUrl("http://emby.media/community", logger);
|
OpenUrl(appHost, "http://emby.media/community");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the web client.
|
/// Opens the web client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appHost">The app host.</param>
|
/// <param name="appHost">The app host.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
public static void OpenWebClient(IServerApplicationHost appHost)
|
||||||
public static void OpenWebClient(IServerApplicationHost appHost, ILogger logger)
|
|
||||||
{
|
{
|
||||||
OpenDashboardPage("index.html", appHost, logger);
|
OpenDashboardPage("index.html", appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the dashboard.
|
/// Opens the dashboard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appHost">The app host.</param>
|
/// <param name="appHost">The app host.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
public static void OpenDashboard(IServerApplicationHost appHost)
|
||||||
public static void OpenDashboard(IServerApplicationHost appHost, ILogger logger)
|
|
||||||
{
|
{
|
||||||
OpenDashboardPage("dashboard.html", appHost, logger);
|
OpenDashboardPage("dashboard.html", appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the URL.
|
/// Opens the URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url">The URL.</param>
|
/// <param name="url">The URL.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
private static void OpenUrl(IServerApplicationHost appHost, string url)
|
||||||
private static void OpenUrl(string url, ILogger logger)
|
|
||||||
{
|
{
|
||||||
var process = new Process
|
|
||||||
{
|
|
||||||
StartInfo = new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = url
|
|
||||||
},
|
|
||||||
|
|
||||||
EnableRaisingEvents = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
process.Exited += ProcessExited;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
process.Start();
|
appHost.LaunchUrl(url);
|
||||||
|
}
|
||||||
|
catch (NotImplementedException)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.ErrorException("Error launching url: {0}", ex, url);
|
Console.WriteLine("Error launching url: " + url);
|
||||||
|
|
||||||
Console.WriteLine("Error launching url: {0}", ex.Message);
|
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
|
|
||||||
//#if !__MonoCS__
|
|
||||||
// System.Windows.Forms.MessageBox.Show("There was an error launching your web browser. Please check your default browser settings.");
|
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Server.Startup.Common.EntryPoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void LaunchStartupWizard()
|
private void LaunchStartupWizard()
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost, _logger);
|
BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -102,5 +102,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
IPowerManagement GetPowerManagement();
|
IPowerManagement GetPowerManagement();
|
||||||
|
|
||||||
FFMpegInstallInfo GetFfmpegInstallInfo();
|
FFMpegInstallInfo GetFfmpegInstallInfo();
|
||||||
|
|
||||||
|
void LaunchUrl(string url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ namespace MediaBrowser.ServerApplication
|
||||||
{
|
{
|
||||||
if (e.Reason == SessionSwitchReason.SessionLogon)
|
if (e.Reason == SessionSwitchReason.SessionLogon)
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenDashboard(_appHost, _logger);
|
BrowserLauncher.OpenDashboard(_appHost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
using MediaBrowser.Common.Net;
|
using System;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Server.Startup.Common;
|
using MediaBrowser.Server.Startup.Common;
|
||||||
using MediaBrowser.ServerApplication.Networking;
|
using MediaBrowser.ServerApplication.Networking;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
using MediaBrowser.Controller.Power;
|
using MediaBrowser.Controller.Power;
|
||||||
using MediaBrowser.Server.Startup.Common.FFMpeg;
|
using MediaBrowser.Server.Startup.Common.FFMpeg;
|
||||||
|
using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication.Native
|
namespace MediaBrowser.ServerApplication.Native
|
||||||
{
|
{
|
||||||
|
@ -162,6 +165,42 @@ namespace MediaBrowser.ServerApplication.Native
|
||||||
return info;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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();
|
||||||
|
}
|
||||||
|
|
||||||
private string[] GetDownloadUrls()
|
private string[] GetDownloadUrls()
|
||||||
{
|
{
|
||||||
switch (Environment.SystemArchitecture)
|
switch (Environment.SystemArchitecture)
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace MediaBrowser.ServerApplication
|
||||||
|
|
||||||
void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenDashboard(_appHost, _logger);
|
BrowserLauncher.OpenDashboard(_appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LocalizeText()
|
private void LocalizeText()
|
||||||
|
@ -199,17 +199,17 @@ namespace MediaBrowser.ServerApplication
|
||||||
|
|
||||||
void cmdBrowse_Click(object sender, EventArgs e)
|
void cmdBrowse_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenWebClient(_appHost, _logger);
|
BrowserLauncher.OpenWebClient(_appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdCommunity_Click(object sender, EventArgs e)
|
void cmdCommunity_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenCommunity(_logger);
|
BrowserLauncher.OpenCommunity(_appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdConfigure_Click(object sender, EventArgs e)
|
void cmdConfigure_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BrowserLauncher.OpenDashboard(_appHost, _logger);
|
BrowserLauncher.OpenDashboard(_appHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdRestart_Click(object sender, EventArgs e)
|
void cmdRestart_Click(object sender, EventArgs e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user