From bc58e2862cefb8a7bfc4bed8198fde5c3aed1714 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 18 Dec 2016 00:43:11 -0500 Subject: fix merge conflicts --- .../ApplicationHost.cs | 1619 -------------------- 1 file changed, 1619 deletions(-) delete mode 100644 MediaBrowser.Server.Startup.Common/ApplicationHost.cs (limited to 'MediaBrowser.Server.Startup.Common/ApplicationHost.cs') diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs deleted file mode 100644 index 6e188fae81..0000000000 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ /dev/null @@ -1,1619 +0,0 @@ -using Emby.Drawing; -using Emby.Drawing.GDI; -using Emby.Drawing.ImageMagick; -using MediaBrowser.Api; -using MediaBrowser.Common; -using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Implementations; -using MediaBrowser.Common.Implementations.ScheduledTasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Common.Progress; -using MediaBrowser.Controller; -using MediaBrowser.Controller.Activity; -using MediaBrowser.Controller.Channels; -using MediaBrowser.Controller.Chapters; -using MediaBrowser.Controller.Collections; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Connect; -using MediaBrowser.Controller.Devices; -using MediaBrowser.Controller.Dlna; -using MediaBrowser.Controller.Drawing; -using MediaBrowser.Controller.Dto; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.FileOrganization; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Controller.Localization; -using MediaBrowser.Controller.MediaEncoding; -using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.News; -using MediaBrowser.Controller.Notifications; -using MediaBrowser.Controller.Persistence; -using MediaBrowser.Controller.Playlists; -using MediaBrowser.Controller.Plugins; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Controller.Resolvers; -using MediaBrowser.Controller.Security; -using MediaBrowser.Controller.Session; -using MediaBrowser.Controller.Social; -using MediaBrowser.Controller.Sorting; -using MediaBrowser.Controller.Subtitles; -using MediaBrowser.Controller.Sync; -using MediaBrowser.Controller.TV; -using MediaBrowser.Dlna; -using MediaBrowser.Dlna.ConnectionManager; -using MediaBrowser.Dlna.ContentDirectory; -using MediaBrowser.Dlna.Main; -using MediaBrowser.Dlna.MediaReceiverRegistrar; -using MediaBrowser.Dlna.Ssdp; -using MediaBrowser.LocalMetadata.Savers; -using MediaBrowser.MediaEncoding.BdInfo; -using MediaBrowser.MediaEncoding.Encoder; -using MediaBrowser.MediaEncoding.Subtitles; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.MediaInfo; -using MediaBrowser.Model.System; -using MediaBrowser.Model.Updates; -using MediaBrowser.Providers.Chapters; -using MediaBrowser.Providers.Manager; -using MediaBrowser.Providers.Subtitles; -using MediaBrowser.Server.Implementations; -using MediaBrowser.Server.Implementations.Activity; -using MediaBrowser.Server.Implementations.Channels; -using MediaBrowser.Server.Implementations.Collections; -using MediaBrowser.Server.Implementations.Configuration; -using MediaBrowser.Server.Implementations.Connect; -using MediaBrowser.Server.Implementations.Devices; -using MediaBrowser.Server.Implementations.Dto; -using MediaBrowser.Server.Implementations.EntryPoints; -using MediaBrowser.Server.Implementations.FileOrganization; -using MediaBrowser.Server.Implementations.HttpServer; -using MediaBrowser.Server.Implementations.HttpServer.Security; -using MediaBrowser.Server.Implementations.IO; -using MediaBrowser.Server.Implementations.Library; -using MediaBrowser.Server.Implementations.LiveTv; -using MediaBrowser.Server.Implementations.Localization; -using MediaBrowser.Server.Implementations.MediaEncoder; -using MediaBrowser.Server.Implementations.Notifications; -using MediaBrowser.Server.Implementations.Persistence; -using MediaBrowser.Server.Implementations.Playlists; -using MediaBrowser.Server.Implementations.Security; -using MediaBrowser.Server.Implementations.ServerManager; -using MediaBrowser.Server.Implementations.Session; -using MediaBrowser.Server.Implementations.Social; -using MediaBrowser.Server.Implementations.Sync; -using MediaBrowser.Server.Implementations.TV; -using MediaBrowser.Server.Startup.Common.FFMpeg; -using MediaBrowser.Server.Startup.Common.Migrations; -using MediaBrowser.WebDashboard.Api; -using MediaBrowser.XbmcMetadata.Providers; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using CommonIO; -using MediaBrowser.Api.Playback; -using MediaBrowser.Common.Implementations.Serialization; -using MediaBrowser.Common.Implementations.Updates; -using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Model.Serialization; - -namespace MediaBrowser.Server.Startup.Common -{ - /// - /// Class CompositionRoot - /// - public class ApplicationHost : BaseApplicationHost, IServerApplicationHost - { - /// - /// Gets the server configuration manager. - /// - /// The server configuration manager. - public IServerConfigurationManager ServerConfigurationManager - { - get { return (IServerConfigurationManager)ConfigurationManager; } - } - - /// - /// Gets the configuration manager. - /// - /// IConfigurationManager. - protected override IConfigurationManager GetConfigurationManager() - { - return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer, FileSystemManager); - } - - /// - /// Gets or sets the server manager. - /// - /// The server manager. - private IServerManager ServerManager { get; set; } - /// - /// Gets or sets the user manager. - /// - /// The user manager. - public IUserManager UserManager { get; set; } - /// - /// Gets or sets the library manager. - /// - /// The library manager. - internal ILibraryManager LibraryManager { get; set; } - /// - /// Gets or sets the directory watchers. - /// - /// The directory watchers. - private ILibraryMonitor LibraryMonitor { get; set; } - /// - /// Gets or sets the provider manager. - /// - /// The provider manager. - private IProviderManager ProviderManager { get; set; } - /// - /// Gets or sets the HTTP server. - /// - /// The HTTP server. - private IHttpServer HttpServer { get; set; } - private IDtoService DtoService { get; set; } - private IImageProcessor ImageProcessor { get; set; } - - /// - /// Gets or sets the media encoder. - /// - /// The media encoder. - private IMediaEncoder MediaEncoder { get; set; } - private ISubtitleEncoder SubtitleEncoder { get; set; } - - private IConnectManager ConnectManager { get; set; } - private ISessionManager SessionManager { get; set; } - - private ILiveTvManager LiveTvManager { get; set; } - - public ILocalizationManager LocalizationManager { get; set; } - - private IEncodingManager EncodingManager { get; set; } - private IChannelManager ChannelManager { get; set; } - private ISyncManager SyncManager { get; set; } - - /// - /// Gets or sets the user data repository. - /// - /// The user data repository. - private IUserDataManager UserDataManager { get; set; } - private IUserRepository UserRepository { get; set; } - internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; } - internal IItemRepository ItemRepository { get; set; } - private INotificationsRepository NotificationsRepository { get; set; } - private IFileOrganizationRepository FileOrganizationRepository { get; set; } - - private INotificationManager NotificationManager { get; set; } - private ISubtitleManager SubtitleManager { get; set; } - private IChapterManager ChapterManager { get; set; } - private IDeviceManager DeviceManager { get; set; } - - internal IUserViewManager UserViewManager { get; set; } - - private IAuthenticationRepository AuthenticationRepository { get; set; } - private ISyncRepository SyncRepository { get; set; } - private ITVSeriesManager TVSeriesManager { get; set; } - private ICollectionManager CollectionManager { get; set; } - private IMediaSourceManager MediaSourceManager { get; set; } - private IPlaylistManager PlaylistManager { get; set; } - - private readonly StartupOptions _startupOptions; - private readonly string _releaseAssetFilename; - - internal INativeApp NativeApp { get; set; } - - /// - /// Initializes a new instance of the class. - /// - /// The application paths. - /// The log manager. - /// The options. - /// The file system. - /// The release asset filename. - /// The native application. - public ApplicationHost(ServerApplicationPaths applicationPaths, - ILogManager logManager, - StartupOptions options, - IFileSystem fileSystem, - string releaseAssetFilename, - INativeApp nativeApp) - : base(applicationPaths, logManager, fileSystem) - { - _startupOptions = options; - _releaseAssetFilename = releaseAssetFilename; - NativeApp = nativeApp; - - SetBaseExceptionMessage(); - } - - private Version _version; - /// - /// Gets the current application version - /// - /// The application version. - public override Version ApplicationVersion - { - get - { - return _version ?? (_version = NativeApp.GetType().Assembly.GetName().Version); - } - } - - public override string OperatingSystemDisplayName - { - get { return NativeApp.Environment.OperatingSystemVersionString; } - } - - public override bool IsRunningAsService - { - get { return NativeApp.IsRunningAsService; } - } - - public bool SupportsRunningAsService - { - get { return NativeApp.SupportsRunningAsService; } - } - - public bool SupportsLibraryMonitor - { - get { return NativeApp.SupportsLibraryMonitor; } - } - - /// - /// Gets the name. - /// - /// The name. - public override string Name - { - get - { - return "Emby Server"; - } - } - - /// - /// Gets a value indicating whether this instance can self restart. - /// - /// true if this instance can self restart; otherwise, false. - public override bool CanSelfRestart - { - get { return NativeApp.CanSelfRestart; } - } - - public bool SupportsAutoRunAtStartup - { - get { return NativeApp.SupportsAutoRunAtStartup; } - } - - private void SetBaseExceptionMessage() - { - var builder = GetBaseExceptionMessage(ApplicationPaths); - - // Skip if plugins haven't been loaded yet - //if (Plugins != null) - //{ - // var pluginString = string.Join("|", Plugins.Select(i => i.Name + "-" + i.Version.ToString()).ToArray()); - // builder.Insert(0, string.Format("Plugins: {0}{1}", pluginString, Environment.NewLine)); - //} - - builder.Insert(0, string.Format("Version: {0}{1}", ApplicationVersion, Environment.NewLine)); - builder.Insert(0, "*** Error Report ***" + Environment.NewLine); - - LogManager.ExceptionMessagePrefix = builder.ToString(); - } - - /// - /// Runs the startup tasks. - /// - /// - /// Runs the startup tasks. - /// - public override async Task RunStartupTasks() - { - await PerformPreInitMigrations().ConfigureAwait(false); - - if (ServerConfigurationManager.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion && - ServerConfigurationManager.Configuration.IsStartupWizardCompleted) - { - TaskManager.SuspendTriggers = true; - } - - await base.RunStartupTasks().ConfigureAwait(false); - - await MediaEncoder.Init().ConfigureAwait(false); - - if (string.IsNullOrWhiteSpace(MediaEncoder.EncoderPath)) - { - if (ServerConfigurationManager.Configuration.IsStartupWizardCompleted) - { - ServerConfigurationManager.Configuration.IsStartupWizardCompleted = false; - ServerConfigurationManager.SaveConfiguration(); - } - } - - Logger.Info("ServerId: {0}", SystemId); - Logger.Info("Core startup complete"); - HttpServer.GlobalResponse = null; - - PerformPostInitMigrations(); - Logger.Info("Post-init migrations complete"); - - foreach (var entryPoint in GetExports().ToList()) - { - var name = entryPoint.GetType().FullName; - Logger.Info("Starting entry point {0}", name); - var now = DateTime.UtcNow; - try - { - entryPoint.Run(); - } - catch (Exception ex) - { - Logger.ErrorException("Error in {0}", ex, name); - } - Logger.Info("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture)); - } - Logger.Info("All entry points have started"); - - LogManager.RemoveConsoleOutput(); - } - - protected override IJsonSerializer CreateJsonSerializer() - { - var result = base.CreateJsonSerializer(); - - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ShortOverview" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "Taglines" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "Keywords" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ShortOverview" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ShortOverview" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "PlaceOfBirth" }; - - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds" }; - ServiceStack.Text.JsConfig