Pārlūkot izejas kodu

Add setting to auto-run web app when server starts

Luke Pulverenti 7 gadi atpakaļ
vecāks
revīzija
8717f81bf4

+ 30 - 7
Emby.Server.Implementations/ApplicationHost.cs

@@ -148,6 +148,34 @@ namespace Emby.Server.Implementations
             }
         }
 
+        public virtual bool CanLaunchWebBrowser
+        {
+            get
+            {
+                if (!Environment.UserInteractive)
+                {
+                    return false;
+                }
+
+                if (StartupOptions.ContainsOption("-service"))
+                {
+                    return false;
+                }
+
+                if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
+                {
+                    return true;
+                }
+
+                if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX)
+                {
+                    return true;
+                }
+
+                return false;
+            }
+        }
+
         /// <summary>
         /// Occurs when [has pending restart changed].
         /// </summary>
@@ -1936,6 +1964,7 @@ namespace Emby.Server.Implementations
                 OperatingSystemDisplayName = OperatingSystemDisplayName,
                 CanSelfRestart = CanSelfRestart,
                 CanSelfUpdate = CanSelfUpdate,
+                CanLaunchWebBrowser = CanLaunchWebBrowser,
                 WanAddress = ConnectManager.WanApiAddress,
                 HasUpdateAvailable = HasUpdateAvailable,
                 SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
@@ -2358,13 +2387,7 @@ namespace Emby.Server.Implementations
 
         public virtual void LaunchUrl(string url)
         {
-            if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows &&
-                EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.OSX)
-            {
-                throw new NotSupportedException();
-            }
-
-            if (!Environment.UserInteractive)
+            if (!CanLaunchWebBrowser)
             {
                 throw new NotSupportedException();
             }

+ 7 - 2
Emby.Server.Implementations/EntryPoints/StartupWizard.cs

@@ -35,15 +35,20 @@ namespace Emby.Server.Implementations.EntryPoints
         /// </summary>
         public void Run()
         {
+            if (!_appHost.CanLaunchWebBrowser)
+            {
+                return;
+            }
+
             if (_appHost.IsFirstRun)
             {
                 BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost);
             }
-            else if (_config.Configuration.IsStartupWizardCompleted)
+            else if (_config.Configuration.IsStartupWizardCompleted && _config.Configuration.AutoRunWebApp)
             {
                 var options = ((ApplicationHost)_appHost).StartupOptions;
 
-                if (!options.ContainsOption("-service") && !options.ContainsOption("-nobrowser"))
+                if (!options.ContainsOption("-noautorunwebapp"))
                 {
                     BrowserLauncher.OpenDashboardPage("index.html", _appHost);
                 }

+ 1 - 0
MediaBrowser.Api/StartupWizardService.cs

@@ -67,6 +67,7 @@ namespace MediaBrowser.Api
         public void Post(ReportStartupWizardComplete request)
         {
             _config.Configuration.IsStartupWizardCompleted = true;
+            _config.Configuration.AutoRunWebApp = true;
             _config.SetOptimalValues();
             _config.SaveConfiguration();
 

+ 3 - 1
MediaBrowser.Controller/IServerApplicationHost.cs

@@ -29,7 +29,9 @@ namespace MediaBrowser.Controller
         /// </summary>
         /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
         bool SupportsAutoRunAtStartup { get; }
-        
+
+        bool CanLaunchWebBrowser { get; }
+
         /// <summary>
         /// Gets the HTTP server port.
         /// </summary>

+ 2 - 0
MediaBrowser.Model/Configuration/ServerConfiguration.cs

@@ -61,6 +61,8 @@ namespace MediaBrowser.Model.Configuration
         /// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
         public bool IsPortAuthorized { get; set; }
 
+        public bool AutoRunWebApp { get; set; }
+
         /// <summary>
         /// Gets or sets a value indicating whether [enable case sensitive item ids].
         /// </summary>

+ 2 - 0
MediaBrowser.Model/System/SystemInfo.cs

@@ -68,6 +68,8 @@ namespace MediaBrowser.Model.System
         /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
         public bool CanSelfUpdate { get; set; }
 
+        public bool CanLaunchWebBrowser { get; set; }
+
         /// <summary>
         /// Gets or sets plugin assemblies that failed to load.
         /// </summary>