|
@@ -114,6 +114,11 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
private static readonly string[] _relevantEnvVarPrefixes = { "JELLYFIN_", "DOTNET_", "ASPNETCORE_" };
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// The disposable parts.
|
|
|
+ /// </summary>
|
|
|
+ private readonly List<IDisposable> _disposableParts = new List<IDisposable>();
|
|
|
+
|
|
|
private readonly IFileSystem _fileSystemManager;
|
|
|
private readonly IConfiguration _startupConfig;
|
|
|
private readonly IXmlSerializer _xmlSerializer;
|
|
@@ -125,6 +130,62 @@ namespace Emby.Server.Implementations
|
|
|
private ISessionManager _sessionManager;
|
|
|
private string[] _urlPrefixes;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Gets or sets all concrete types.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>All concrete types.</value>
|
|
|
+ private Type[] _allConcreteTypes;
|
|
|
+
|
|
|
+ private DeviceId _deviceId;
|
|
|
+
|
|
|
+ private bool _disposed = false;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of the <see cref="ApplicationHost"/> class.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
|
|
|
+ /// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
|
|
|
+ /// <param name="options">Instance of the <see cref="IStartupOptions"/> interface.</param>
|
|
|
+ /// <param name="startupConfig">The <see cref="IConfiguration" /> interface.</param>
|
|
|
+ /// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
|
|
+ /// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
|
|
|
+ public ApplicationHost(
|
|
|
+ IServerApplicationPaths applicationPaths,
|
|
|
+ ILoggerFactory loggerFactory,
|
|
|
+ IStartupOptions options,
|
|
|
+ IConfiguration startupConfig,
|
|
|
+ IFileSystem fileSystem,
|
|
|
+ IServiceCollection serviceCollection)
|
|
|
+ {
|
|
|
+ ApplicationPaths = applicationPaths;
|
|
|
+ LoggerFactory = loggerFactory;
|
|
|
+ _startupOptions = options;
|
|
|
+ _startupConfig = startupConfig;
|
|
|
+ _fileSystemManager = fileSystem;
|
|
|
+ ServiceCollection = serviceCollection;
|
|
|
+
|
|
|
+ Logger = LoggerFactory.CreateLogger<ApplicationHost>();
|
|
|
+ fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
|
|
+
|
|
|
+ ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
|
|
|
+ ApplicationVersionString = ApplicationVersion.ToString(3);
|
|
|
+ ApplicationUserAgent = Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
|
|
+
|
|
|
+ _xmlSerializer = new MyXmlSerializer();
|
|
|
+ ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, _xmlSerializer, _fileSystemManager);
|
|
|
+ _pluginManager = new PluginManager(
|
|
|
+ LoggerFactory.CreateLogger<PluginManager>(),
|
|
|
+ this,
|
|
|
+ ConfigurationManager.Configuration,
|
|
|
+ ApplicationPaths.PluginsPath,
|
|
|
+ ApplicationVersion);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Occurs when [has pending restart changed].
|
|
|
+ /// </summary>
|
|
|
+ public event EventHandler HasPendingRestartChanged;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Gets a value indicating whether this instance can self restart.
|
|
|
/// </summary>
|
|
@@ -155,11 +216,6 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
public INetworkManager NetManager { get; internal set; }
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Occurs when [has pending restart changed].
|
|
|
- /// </summary>
|
|
|
- public event EventHandler HasPendingRestartChanged;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Gets a value indicating whether this instance has changes that require the entire application to restart.
|
|
|
/// </summary>
|
|
@@ -187,17 +243,6 @@ namespace Emby.Server.Implementations
|
|
|
/// <value>The application paths.</value>
|
|
|
protected IServerApplicationPaths ApplicationPaths { get; set; }
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Gets or sets all concrete types.
|
|
|
- /// </summary>
|
|
|
- /// <value>All concrete types.</value>
|
|
|
- private Type[] _allConcreteTypes;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// The disposable parts.
|
|
|
- /// </summary>
|
|
|
- private readonly List<IDisposable> _disposableParts = new List<IDisposable>();
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Gets or sets the configuration manager.
|
|
|
/// </summary>
|
|
@@ -224,47 +269,55 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
public string PublishedServerUrl => _startupOptions.PublishedServerUrl ?? _startupConfig[UdpServer.AddressOverrideConfigKey];
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
+ public Version ApplicationVersion { get; }
|
|
|
+
|
|
|
+ /// <inheritdoc />
|
|
|
+ public string ApplicationVersionString { get; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// Initializes a new instance of the <see cref="ApplicationHost"/> class.
|
|
|
+ /// Gets the current application user agent.
|
|
|
/// </summary>
|
|
|
- /// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
|
|
|
- /// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
|
|
|
- /// <param name="options">Instance of the <see cref="IStartupOptions"/> interface.</param>
|
|
|
- /// <param name="startupConfig">The <see cref="IConfiguration" /> interface.</param>
|
|
|
- /// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
|
|
- /// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
|
|
|
- public ApplicationHost(
|
|
|
- IServerApplicationPaths applicationPaths,
|
|
|
- ILoggerFactory loggerFactory,
|
|
|
- IStartupOptions options,
|
|
|
- IConfiguration startupConfig,
|
|
|
- IFileSystem fileSystem,
|
|
|
- IServiceCollection serviceCollection)
|
|
|
- {
|
|
|
- ApplicationPaths = applicationPaths;
|
|
|
- LoggerFactory = loggerFactory;
|
|
|
- _startupOptions = options;
|
|
|
- _startupConfig = startupConfig;
|
|
|
- _fileSystemManager = fileSystem;
|
|
|
- ServiceCollection = serviceCollection;
|
|
|
+ /// <value>The application user agent.</value>
|
|
|
+ public string ApplicationUserAgent { get; }
|
|
|
|
|
|
- Logger = LoggerFactory.CreateLogger<ApplicationHost>();
|
|
|
- fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
|
|
|
+ /// <summary>
|
|
|
+ /// Gets the email address for use within a comment section of a user agent field.
|
|
|
+ /// Presently used to provide contact information to MusicBrainz service.
|
|
|
+ /// </summary>
|
|
|
+ public string ApplicationUserAgentAddress => "team@jellyfin.org";
|
|
|
|
|
|
- ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;
|
|
|
- ApplicationVersionString = ApplicationVersion.ToString(3);
|
|
|
- ApplicationUserAgent = Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
|
|
+ /// <summary>
|
|
|
+ /// Gets the current application name.
|
|
|
+ /// </summary>
|
|
|
+ /// <value>The application name.</value>
|
|
|
+ public string ApplicationProductName { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName;
|
|
|
|
|
|
- _xmlSerializer = new MyXmlSerializer();
|
|
|
- ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, _xmlSerializer, _fileSystemManager);
|
|
|
- _pluginManager = new PluginManager(
|
|
|
- LoggerFactory.CreateLogger<PluginManager>(),
|
|
|
- this,
|
|
|
- ConfigurationManager.Configuration,
|
|
|
- ApplicationPaths.PluginsPath,
|
|
|
- ApplicationVersion);
|
|
|
+ public string SystemId
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ _deviceId ??= new DeviceId(ApplicationPaths, LoggerFactory);
|
|
|
+
|
|
|
+ return _deviceId.Value;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
+ public string Name => ApplicationProductName;
|
|
|
+
|
|
|
+ private CertificateInfo CertificateInfo { get; set; }
|
|
|
+
|
|
|
+ public X509Certificate2 Certificate { get; private set; }
|
|
|
+
|
|
|
+ /// <inheritdoc/>
|
|
|
+ public bool ListenWithHttps => Certificate != null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
|
|
|
+
|
|
|
+ public string FriendlyName =>
|
|
|
+ string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName)
|
|
|
+ ? Environment.MachineName
|
|
|
+ : ConfigurationManager.Configuration.ServerName;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Temporary function to migration network settings out of system.xml and into network.xml.
|
|
|
/// TODO: remove at the point when a fixed migration path has been decided upon.
|
|
@@ -297,45 +350,6 @@ namespace Emby.Server.Implementations
|
|
|
.Replace(appPaths.InternalMetadataPath, appPaths.VirtualInternalMetadataPath, StringComparison.OrdinalIgnoreCase);
|
|
|
}
|
|
|
|
|
|
- /// <inheritdoc />
|
|
|
- public Version ApplicationVersion { get; }
|
|
|
-
|
|
|
- /// <inheritdoc />
|
|
|
- public string ApplicationVersionString { get; }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Gets the current application user agent.
|
|
|
- /// </summary>
|
|
|
- /// <value>The application user agent.</value>
|
|
|
- public string ApplicationUserAgent { get; }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Gets the email address for use within a comment section of a user agent field.
|
|
|
- /// Presently used to provide contact information to MusicBrainz service.
|
|
|
- /// </summary>
|
|
|
- public string ApplicationUserAgentAddress => "team@jellyfin.org";
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Gets the current application name.
|
|
|
- /// </summary>
|
|
|
- /// <value>The application name.</value>
|
|
|
- public string ApplicationProductName { get; } = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName;
|
|
|
-
|
|
|
- private DeviceId _deviceId;
|
|
|
-
|
|
|
- public string SystemId
|
|
|
- {
|
|
|
- get
|
|
|
- {
|
|
|
- _deviceId ??= new DeviceId(ApplicationPaths, LoggerFactory);
|
|
|
-
|
|
|
- return _deviceId.Value;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <inheritdoc/>
|
|
|
- public string Name => ApplicationProductName;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Creates an instance of type and resolves all constructor dependencies.
|
|
|
/// </summary>
|
|
@@ -857,10 +871,6 @@ namespace Emby.Server.Implementations
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private CertificateInfo CertificateInfo { get; set; }
|
|
|
-
|
|
|
- public X509Certificate2 Certificate { get; private set; }
|
|
|
-
|
|
|
private IEnumerable<string> GetUrlPrefixes()
|
|
|
{
|
|
|
var hosts = new[] { "+" };
|
|
@@ -1114,9 +1124,6 @@ namespace Emby.Server.Implementations
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- /// <inheritdoc/>
|
|
|
- public bool ListenWithHttps => Certificate != null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
|
|
|
-
|
|
|
/// <inheritdoc/>
|
|
|
public string GetSmartApiUrl(IPAddress remoteAddr, int? port = null)
|
|
|
{
|
|
@@ -1203,14 +1210,7 @@ namespace Emby.Server.Implementations
|
|
|
}.ToString().TrimEnd('/');
|
|
|
}
|
|
|
|
|
|
- public string FriendlyName =>
|
|
|
- string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName)
|
|
|
- ? Environment.MachineName
|
|
|
- : ConfigurationManager.Configuration.ServerName;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Shuts down.
|
|
|
- /// </summary>
|
|
|
+ /// <inheritdoc />
|
|
|
public async Task Shutdown()
|
|
|
{
|
|
|
if (IsShuttingDown)
|
|
@@ -1248,41 +1248,7 @@ namespace Emby.Server.Implementations
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public virtual void LaunchUrl(string url)
|
|
|
- {
|
|
|
- if (!CanLaunchWebBrowser)
|
|
|
- {
|
|
|
- throw new NotSupportedException();
|
|
|
- }
|
|
|
-
|
|
|
- var process = new Process
|
|
|
- {
|
|
|
- StartInfo = new ProcessStartInfo
|
|
|
- {
|
|
|
- FileName = url,
|
|
|
- UseShellExecute = true,
|
|
|
- ErrorDialog = false
|
|
|
- },
|
|
|
- EnableRaisingEvents = true
|
|
|
- };
|
|
|
- process.Exited += (sender, args) => ((Process)sender).Dispose();
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- process.Start();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- Logger.LogError(ex, "Error launching url: {url}", url);
|
|
|
- throw;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private bool _disposed = false;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
|
- /// </summary>
|
|
|
+ /// <inheritdoc />
|
|
|
public void Dispose()
|
|
|
{
|
|
|
Dispose(true);
|