aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs108
1 files changed, 16 insertions, 92 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index c71b917b8..365eb5856 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -110,9 +110,7 @@ using MediaBrowser.XbmcMetadata.Providers;
using Microsoft.Extensions.Logging;
using ServiceStack;
using ServiceStack.Text.Jsv;
-using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
-using UtfUnknown;
namespace Emby.Server.Implementations
{
@@ -142,7 +140,7 @@ namespace Emby.Server.Implementations
return false;
}
- if (StartupOptions.ContainsOption("-service"))
+ if (StartupOptions.IsService)
{
return false;
}
@@ -303,7 +301,7 @@ namespace Emby.Server.Implementations
private ILiveTvManager LiveTvManager { get; set; }
- public ILocalizationManager LocalizationManager { get; set; }
+ public LocalizationManager LocalizationManager { get; set; }
private IEncodingManager EncodingManager { get; set; }
private IChannelManager ChannelManager { get; set; }
@@ -344,7 +342,7 @@ namespace Emby.Server.Implementations
protected IHttpResultFactory HttpResultFactory { get; private set; }
protected IAuthService AuthService { get; private set; }
- public StartupOptions StartupOptions { get; private set; }
+ public IStartupOptions StartupOptions { get; private set; }
internal IImageEncoder ImageEncoder { get; private set; }
@@ -365,7 +363,7 @@ namespace Emby.Server.Implementations
/// </summary>
public ApplicationHost(ServerApplicationPaths applicationPaths,
ILoggerFactory loggerFactory,
- StartupOptions options,
+ IStartupOptions options,
IFileSystem fileSystem,
IEnvironmentInfo environmentInfo,
IImageEncoder imageEncoder,
@@ -697,7 +695,7 @@ namespace Emby.Server.Implementations
}
}
- public void Init()
+ public async Task Init()
{
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
@@ -727,7 +725,7 @@ namespace Emby.Server.Implementations
SetHttpLimit();
- RegisterResources();
+ await RegisterResources();
FindParts();
}
@@ -742,7 +740,7 @@ namespace Emby.Server.Implementations
/// <summary>
/// Registers resources that classes will depend on
/// </summary>
- protected void RegisterResources()
+ protected async Task RegisterResources()
{
RegisterSingleInstance(ConfigurationManager);
RegisterSingleInstance<IApplicationHost>(this);
@@ -803,9 +801,9 @@ namespace Emby.Server.Implementations
IAssemblyInfo assemblyInfo = new AssemblyInfo();
RegisterSingleInstance(assemblyInfo);
- LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory, assemblyInfo, new TextLocalizer());
- StringExtensions.LocalizationManager = LocalizationManager;
- RegisterSingleInstance(LocalizationManager);
+ LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory);
+ await LocalizationManager.LoadAll();
+ RegisterSingleInstance<ILocalizationManager>(LocalizationManager);
BlurayExaminer = new BdInfoExaminer(FileSystemManager);
RegisterSingleInstance(BlurayExaminer);
@@ -874,7 +872,7 @@ namespace Emby.Server.Implementations
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);
RegisterSingleInstance(MediaSourceManager);
- SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager);
+ SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager);
RegisterSingleInstance(SubtitleManager);
ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LoggerFactory, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer);
@@ -898,7 +896,7 @@ namespace Emby.Server.Implementations
PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory, UserManager, ProviderManager);
RegisterSingleInstance(PlaylistManager);
- LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, LoggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, () => ChannelManager);
+ LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, LoggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, FileSystemManager, () => ChannelManager);
RegisterSingleInstance(LiveTvManager);
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
@@ -1001,7 +999,7 @@ namespace Emby.Server.Implementations
try
{
- if (!FileSystemManager.FileExists(certificateLocation))
+ if (!File.Exists(certificateLocation))
{
return null;
}
@@ -1427,7 +1425,7 @@ namespace Emby.Server.Implementations
//if (generateCertificate)
//{
- // if (!FileSystemManager.FileExists(certPath))
+ // if (!File.Exists(certPath))
// {
// FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath));
@@ -1557,7 +1555,7 @@ namespace Emby.Server.Implementations
/// <returns>IEnumerable{Assembly}.</returns>
protected List<Tuple<Assembly, string>> GetComposablePartAssemblies()
{
- var list = GetPluginAssemblies();
+ var list = GetPluginAssemblies(ApplicationPaths.PluginsPath);
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
@@ -1608,79 +1606,6 @@ namespace Emby.Server.Implementations
protected abstract IEnumerable<Assembly> GetAssembliesWithPartsInternal();
- /// <summary>
- /// Gets the plugin assemblies.
- /// </summary>
- /// <returns>IEnumerable{Assembly}.</returns>
- private List<Tuple<Assembly, string>> GetPluginAssemblies()
- {
- // Copy pre-installed plugins
- var sourcePath = Path.Combine(ApplicationPaths.ApplicationResourcesPath, "plugins");
- CopyPlugins(sourcePath, ApplicationPaths.PluginsPath);
-
- return GetPluginAssemblies(ApplicationPaths.PluginsPath);
- }
-
- private void CopyPlugins(string source, string target)
- {
- List<string> files;
-
- try
- {
- files = Directory.EnumerateFiles(source, "*.dll", SearchOption.TopDirectoryOnly)
- .ToList();
-
- }
- catch (DirectoryNotFoundException)
- {
- return;
- }
-
- if (files.Count == 0)
- {
- return;
- }
-
- foreach (var sourceFile in files)
- {
- var filename = Path.GetFileName(sourceFile);
- var targetFile = Path.Combine(target, filename);
-
- var targetFileExists = File.Exists(targetFile);
-
- if (!targetFileExists && ServerConfigurationManager.Configuration.UninstalledPlugins.Contains(filename, StringComparer.OrdinalIgnoreCase))
- {
- continue;
- }
-
- if (targetFileExists && GetDllVersion(targetFile) >= GetDllVersion(sourceFile))
- {
- continue;
- }
-
- Directory.CreateDirectory(target);
- File.Copy(sourceFile, targetFile, true);
- }
- }
-
- private Version GetDllVersion(string path)
- {
- try
- {
- var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion);
-
- Logger.LogInformation("File {Path} has version {Version}", path, result);
-
- return result;
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error getting version number from {Path}", path);
-
- return new Version(1, 0);
- }
- }
-
private List<Tuple<Assembly, string>> GetPluginAssemblies(string path)
{
try
@@ -1738,7 +1663,6 @@ namespace Emby.Server.Implementations
var minRequiredVersions = new Dictionary<string, Version>(StringComparer.OrdinalIgnoreCase)
{
- { "GameBrowser.dll", new Version(3, 1) },
{ "moviethemesongs.dll", new Version(1, 6) },
{ "themesongs.dll", new Version(1, 2) }
};
@@ -1814,7 +1738,7 @@ namespace Emby.Server.Implementations
EncoderLocationType = MediaEncoder.EncoderLocationType,
SystemArchitecture = EnvironmentInfo.SystemArchitecture,
SystemUpdateLevel = SystemUpdateLevel,
- PackageName = StartupOptions.GetOption("-package")
+ PackageName = StartupOptions.PackageName
};
}