Ejemplo n.º 1
0
        private void MigrateModularConfigurations()
        {
            var saveConfig = false;

            if (ServerConfigurationManager.Configuration.DlnaOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("dlna", ServerConfigurationManager.Configuration.DlnaOptions);
                ServerConfigurationManager.Configuration.DlnaOptions = null;
                saveConfig = true;
            }

            if (ServerConfigurationManager.Configuration.ChapterOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("chapters", ServerConfigurationManager.Configuration.ChapterOptions);
                ServerConfigurationManager.Configuration.ChapterOptions = null;
                saveConfig = true;
            }

            if (ServerConfigurationManager.Configuration.ChannelOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("channels", ServerConfigurationManager.Configuration.ChannelOptions);
                ServerConfigurationManager.Configuration.ChannelOptions = null;
                saveConfig = true;
            }

            if (ServerConfigurationManager.Configuration.NotificationOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("notifications", ServerConfigurationManager.Configuration.NotificationOptions);
                ServerConfigurationManager.Configuration.NotificationOptions = null;
                saveConfig = true;
            }

            if (ServerConfigurationManager.Configuration.LiveTvOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("livetv", ServerConfigurationManager.Configuration.LiveTvOptions);
                ServerConfigurationManager.Configuration.LiveTvOptions = null;
                saveConfig = true;
            }

            if (ServerConfigurationManager.Configuration.TvFileOrganizationOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("autoorganize", new AutoOrganizeOptions {
                    TvOptions = ServerConfigurationManager.Configuration.TvFileOrganizationOptions
                });
                ServerConfigurationManager.Configuration.TvFileOrganizationOptions = null;
                saveConfig = true;
            }

            if (ServerConfigurationManager.Configuration.SubtitleOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("subtitles", ServerConfigurationManager.Configuration.SubtitleOptions);
                ServerConfigurationManager.Configuration.SubtitleOptions = null;
                saveConfig = true;
            }

            if (saveConfig)
            {
                ServerConfigurationManager.SaveConfiguration();
            }
        }
Ejemplo n.º 2
0
        private void MigrateModularConfigurations()
        {
            var saveConfig = false;

            if (saveConfig)
            {
                ServerConfigurationManager.SaveConfiguration();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when [configuration updated].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected override void OnConfigurationUpdated(object sender, EventArgs e)
        {
            base.OnConfigurationUpdated(sender, e);

            if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase))
            {
                ServerConfigurationManager.Configuration.IsPortAuthorized = false;
                ServerConfigurationManager.SaveConfiguration();

                NotifyPendingRestart();
            }
        }
Ejemplo n.º 4
0
        private void MigrateModularConfigurations()
        {
            var saveConfig = false;

            if (ServerConfigurationManager.Configuration.TvFileOrganizationOptions != null)
            {
                ServerConfigurationManager.SaveConfiguration("autoorganize", new AutoOrganizeOptions {
                    TvOptions = ServerConfigurationManager.Configuration.TvFileOrganizationOptions
                });
                ServerConfigurationManager.Configuration.TvFileOrganizationOptions = null;
                saveConfig = true;
            }

            if (saveConfig)
            {
                ServerConfigurationManager.SaveConfiguration();
            }
        }
Ejemplo n.º 5
0
        public void Post(UpdateItemContentType request)
        {
            var item = _libraryManager.GetItemById(request.ItemId);
            var path = item.ContainingFolderPath;

            var types = ServerConfigurationManager.Configuration.ContentTypes
                        .Where(i => !string.IsNullOrWhiteSpace(i.Name))
                        .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase))
                        .ToList();

            if (!string.IsNullOrWhiteSpace(request.ContentType))
            {
                types.Add(new NameValuePair
                {
                    Name  = path,
                    Value = request.ContentType
                });
            }

            ServerConfigurationManager.Configuration.ContentTypes = types.ToArray();
            ServerConfigurationManager.SaveConfiguration();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Registers resources that classes will depend on
        /// </summary>
        /// <returns>Task.</returns>
        protected override async Task RegisterResources(IProgress <double> progress)
        {
            await base.RegisterResources(progress).ConfigureAwait(false);

            RegisterSingleInstance <IHttpResultFactory>(new HttpResultFactory(LogManager, FileSystemManager, JsonSerializer));

            RegisterSingleInstance <IServerApplicationHost>(this);
            RegisterSingleInstance <IServerApplicationPaths>(ApplicationPaths);

            RegisterSingleInstance(ServerConfigurationManager);

            LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer);
            RegisterSingleInstance(LocalizationManager);

            RegisterSingleInstance <IBlurayExaminer>(() => new BdInfoExaminer());

            UserDataManager = new UserDataManager(LogManager, ServerConfigurationManager);
            RegisterSingleInstance(UserDataManager);

            UserRepository = await GetUserRepository().ConfigureAwait(false);

            RegisterSingleInstance(UserRepository);

            DisplayPreferencesRepository = new SqliteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
            RegisterSingleInstance(DisplayPreferencesRepository);

            ItemRepository = new SqliteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
            RegisterSingleInstance(ItemRepository);

            ProviderRepository = new SqliteProviderInfoRepository(ApplicationPaths, LogManager);
            RegisterSingleInstance(ProviderRepository);

            FileOrganizationRepository = await GetFileOrganizationRepository().ConfigureAwait(false);

            RegisterSingleInstance(FileOrganizationRepository);

            AuthenticationRepository = await GetAuthenticationRepository().ConfigureAwait(false);

            RegisterSingleInstance(AuthenticationRepository);

            SyncRepository = await GetSyncRepository().ConfigureAwait(false);

            RegisterSingleInstance(SyncRepository);

            UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer);
            RegisterSingleInstance(UserManager);

            LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);
            RegisterSingleInstance(LibraryManager);

            var musicManager = new MusicManager(LibraryManager);

            RegisterSingleInstance <IMusicManager>(new MusicManager(LibraryManager));

            LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager);
            RegisterSingleInstance(LibraryMonitor);

            ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager);
            RegisterSingleInstance(ProviderManager);

            SeriesOrderManager = new SeriesOrderManager();
            RegisterSingleInstance(SeriesOrderManager);

            RegisterSingleInstance <ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));

            if (IsFirstRun)
            {
                ServerConfigurationManager.Configuration.EnableWin8HttpListener = false;
                ServerConfigurationManager.SaveConfiguration();
                _supportsNativeWebSocket = false;
            }

            if (!ServerConfigurationManager.Configuration.EnableWin8HttpListener)
            {
                _supportsNativeWebSocket = false;
            }

            HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket);
            RegisterSingleInstance(HttpServer, false);
            progress.Report(10);

            ServerManager = new ServerManager(this, JsonSerializer, LogManager.GetLogger("ServerManager"), ServerConfigurationManager);
            RegisterSingleInstance(ServerManager);

            var innerProgress = new ActionableProgress <double>();

            innerProgress.RegisterAction(p => progress.Report((.75 * p) + 15));

            ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
            RegisterSingleInstance(ImageProcessor);

            TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);
            RegisterSingleInstance(TVSeriesManager);

            SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder);
            RegisterSingleInstance(SyncManager);

            DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this);
            RegisterSingleInstance(DtoService);

            var encryptionManager = new EncryptionManager();

            RegisterSingleInstance <IEncryptionManager>(encryptionManager);

            ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager);
            RegisterSingleInstance(ConnectManager);

            DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));
            RegisterSingleInstance(DeviceManager);

            SessionManager = new SessionManager(UserDataManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);
            RegisterSingleInstance(SessionManager);

            var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);

            RegisterSingleInstance <INewsService>(newsService);

            var fileOrganizationService = new FileOrganizationService(TaskManager, FileOrganizationRepository, LogManager.GetLogger("FileOrganizationService"), LibraryMonitor, LibraryManager, ServerConfigurationManager, FileSystemManager, ProviderManager);

            RegisterSingleInstance <IFileOrganizationService>(fileOrganizationService);

            progress.Report(15);

            ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, Logger, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient);
            RegisterSingleInstance(ChannelManager);

            var appThemeManager = new AppThemeManager(ApplicationPaths, FileSystemManager, JsonSerializer, Logger);

            RegisterSingleInstance <IAppThemeManager>(appThemeManager);

            var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer);

            RegisterSingleInstance <IDlnaManager>(dlnaManager);

            var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient);

            RegisterSingleInstance <IConnectionManager>(connectionManager);

            CollectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("CollectionManager"));
            RegisterSingleInstance(CollectionManager);

            var playlistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager);

            RegisterSingleInstance <IPlaylistManager>(playlistManager);

            LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer);
            RegisterSingleInstance(LiveTvManager);

            UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, FileSystemManager, UserManager, ChannelManager, LiveTvManager, ApplicationPaths, playlistManager);
            RegisterSingleInstance(UserViewManager);

            var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager);

            RegisterSingleInstance <IContentDirectory>(contentDirectory);

            NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);
            RegisterSingleInstance(NotificationManager);

            SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, ItemRepository);
            RegisterSingleInstance(SubtitleManager);

            ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
            RegisterSingleInstance(ChapterManager);

            await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);

            progress.Report(90);

            EncodingManager = new EncodingManager(FileSystemManager, Logger,
                                                  MediaEncoder, ChapterManager);
            RegisterSingleInstance(EncodingManager);

            var activityLogRepo = await GetActivityLogRepository().ConfigureAwait(false);

            RegisterSingleInstance(activityLogRepo);
            RegisterSingleInstance <IActivityManager>(new ActivityManager(LogManager.GetLogger("ActivityManager"), activityLogRepo, UserManager));

            var authContext = new AuthorizationContext(AuthenticationRepository);

            RegisterSingleInstance <IAuthorizationContext>(authContext);
            RegisterSingleInstance <ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
            RegisterSingleInstance <IAuthService>(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager, DeviceManager));

            SubtitleEncoder = new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer);
            RegisterSingleInstance(SubtitleEncoder);

            await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false);
            await ConfigureItemRepositories().ConfigureAwait(false);
            await ConfigureUserDataRepositories().ConfigureAwait(false);
            await ConfigureNotificationsRepository().ConfigureAwait(false);

            progress.Report(100);

            SetStaticProperties();

            await((UserManager)UserManager).Initialize().ConfigureAwait(false);

            SetKernelProperties();
        }