aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs7
-rw-r--r--MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs59
-rw-r--r--MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs31
-rw-r--r--MediaBrowser.Server.Startup.Common/EntryPoints/StartupWizard.cs2
-rw-r--r--MediaBrowser.Server.Startup.Common/INativeApp.cs4
5 files changed, 41 insertions, 62 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 93dbe2945..01575e71f 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -440,7 +440,7 @@ namespace MediaBrowser.Server.Startup.Common
LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, this);
RegisterSingleInstance(LibraryMonitor);
- ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager);
+ ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer);
RegisterSingleInstance(ProviderManager);
SeriesOrderManager = new SeriesOrderManager();
@@ -1404,5 +1404,10 @@ namespace MediaBrowser.Server.Startup.Common
return externalDns;
}
}
+
+ public void LaunchUrl(string url)
+ {
+ NativeApp.LaunchUrl(url);
+ }
}
}
diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
index a4504f25a..db48d1110 100644
--- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
+++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
@@ -15,87 +15,58 @@ namespace MediaBrowser.Server.Startup.Common.Browser
/// </summary>
/// <param name="page">The page.</param>
/// <param name="appHost">The app host.</param>
- /// <param name="logger">The logger.</param>
- public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger)
+ public static void OpenDashboardPage(string page, IServerApplicationHost appHost)
{
var url = appHost.GetLocalApiUrl("localhost") + "/web/" + page;
- OpenUrl(url, logger);
+ OpenUrl(appHost, url);
}
/// <summary>
/// Opens the community.
/// </summary>
- /// <param name="logger">The logger.</param>
- public static void OpenCommunity(ILogger logger)
+ public static void OpenCommunity(IServerApplicationHost appHost)
{
- OpenUrl("http://emby.media/community", logger);
+ OpenUrl(appHost, "http://emby.media/community");
}
/// <summary>
/// Opens the web client.
/// </summary>
/// <param name="appHost">The app host.</param>
- /// <param name="logger">The logger.</param>
- public static void OpenWebClient(IServerApplicationHost appHost, ILogger logger)
+ public static void OpenWebClient(IServerApplicationHost appHost)
{
- OpenDashboardPage("index.html", appHost, logger);
+ OpenDashboardPage("index.html", appHost);
}
/// <summary>
/// Opens the dashboard.
/// </summary>
/// <param name="appHost">The app host.</param>
- /// <param name="logger">The logger.</param>
- public static void OpenDashboard(IServerApplicationHost appHost, ILogger logger)
+ public static void OpenDashboard(IServerApplicationHost appHost)
{
- OpenDashboardPage("dashboard.html", appHost, logger);
+ OpenDashboardPage("dashboard.html", appHost);
}
/// <summary>
/// Opens the URL.
/// </summary>
/// <param name="url">The URL.</param>
- /// <param name="logger">The logger.</param>
- private static void OpenUrl(string url, ILogger logger)
+ private static void OpenUrl(IServerApplicationHost appHost, string url)
{
- var process = new Process
- {
- StartInfo = new ProcessStartInfo
- {
- FileName = url
- },
-
- EnableRaisingEvents = true,
- };
-
- process.Exited += ProcessExited;
-
try
{
- process.Start();
+ appHost.LaunchUrl(url);
+ }
+ catch (NotImplementedException)
+ {
+
}
catch (Exception ex)
{
- logger.ErrorException("Error launching url: {0}", ex, url);
-
- Console.WriteLine("Error launching url: {0}", ex.Message);
+ Console.WriteLine("Error launching url: " + url);
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();
- }
}
}
diff --git a/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs b/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs
index 20d4c6b2a..dbfd6f4e8 100644
--- a/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs
+++ b/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs
@@ -27,28 +27,27 @@ namespace MediaBrowser.Server.Startup.Common.EntryPoints
_timer = new PeriodicTimer(obj =>
{
var now = DateTime.UtcNow;
- if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15))
+ var nativeApp = ((ApplicationHost)_appHost).NativeApp;
+
+ try
+ {
+ if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15))
+ {
+ nativeApp.PreventSystemStandby();
+ }
+ else
+ {
+ nativeApp.AllowSystemStandby();
+ }
+ }
+ catch (Exception ex)
{
- KeepAlive();
+ _logger.ErrorException("Error resetting system standby timer", ex);
}
}, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));
}
- private void KeepAlive()
- {
- var nativeApp = ((ApplicationHost)_appHost).NativeApp;
-
- try
- {
- nativeApp.PreventSystemStandby();
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error resetting system standby timer", ex);
- }
- }
-
public void Dispose()
{
if (_timer != null)
diff --git a/MediaBrowser.Server.Startup.Common/EntryPoints/StartupWizard.cs b/MediaBrowser.Server.Startup.Common/EntryPoints/StartupWizard.cs
index 854fa44c1..f9d173c59 100644
--- a/MediaBrowser.Server.Startup.Common/EntryPoints/StartupWizard.cs
+++ b/MediaBrowser.Server.Startup.Common/EntryPoints/StartupWizard.cs
@@ -46,7 +46,7 @@ namespace MediaBrowser.Server.Startup.Common.EntryPoints
/// </summary>
private void LaunchStartupWizard()
{
- BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost, _logger);
+ BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost);
}
/// <summary>
diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.cs
index 121d4192e..c0758b47f 100644
--- a/MediaBrowser.Server.Startup.Common/INativeApp.cs
+++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs
@@ -93,6 +93,8 @@ namespace MediaBrowser.Server.Startup.Common
/// </summary>
void PreventSystemStandby();
+ void AllowSystemStandby();
+
/// <summary>
/// Gets the power management.
/// </summary>
@@ -100,5 +102,7 @@ namespace MediaBrowser.Server.Startup.Common
IPowerManagement GetPowerManagement();
FFMpegInstallInfo GetFfmpegInstallInfo();
+
+ void LaunchUrl(string url);
}
}