diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-29 01:40:15 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-29 01:40:15 -0400 |
| commit | 2729301bffb8b4a15c2228fee39717d80b123e60 (patch) | |
| tree | 783fb50681cdf085ea6ea550e52d2ee970d198ea /MediaBrowser.Server.Startup.Common | |
| parent | ce38e987910b4badb4c40844786449458b2d3229 (diff) | |
move common dependencies
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
4 files changed, 60 insertions, 46 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 3ef63fd941..b26edb8953 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -104,6 +104,8 @@ using MediaBrowser.Common.Implementations.Serialization; using MediaBrowser.Common.Implementations.Updates; using MediaBrowser.Common.IO; using MediaBrowser.Common.Plugins; +using MediaBrowser.Common.Security; +using MediaBrowser.Common.Updates; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; @@ -120,6 +122,7 @@ using MediaBrowser.Model.Xml; using MediaBrowser.Server.Implementations.Archiving; using MediaBrowser.Server.Implementations.Reflection; using MediaBrowser.Server.Implementations.Serialization; +using MediaBrowser.Server.Implementations.Updates; using MediaBrowser.Server.Implementations.Xml; using OpenSubtitlesHandler; using ServiceStack; @@ -227,6 +230,17 @@ namespace MediaBrowser.Server.Startup.Common private IPlaylistManager PlaylistManager { get; set; } /// <summary> + /// Gets or sets the installation manager. + /// </summary> + /// <value>The installation manager.</value> + protected IInstallationManager InstallationManager { get; private set; } + /// <summary> + /// Gets the security manager. + /// </summary> + /// <value>The security manager.</value> + protected ISecurityManager SecurityManager { get; private set; } + + /// <summary> /// Gets or sets the zip client. /// </summary> /// <value>The zip client.</value> @@ -405,6 +419,11 @@ namespace MediaBrowser.Server.Startup.Common return new MemoryStreamProvider(); } + protected override ISystemEvents CreateSystemEvents() + { + return new SystemEvents(LogManager.GetLogger("SystemEvents")); + } + protected override IJsonSerializer CreateJsonSerializer() { try @@ -636,7 +655,6 @@ namespace MediaBrowser.Server.Startup.Common { var migrations = new List<IVersionMigration> { - new MovieDbEpisodeProviderMigration(ServerConfigurationManager), new DbMigration(ServerConfigurationManager, TaskManager) }; @@ -660,6 +678,12 @@ namespace MediaBrowser.Server.Startup.Common { await base.RegisterResources(progress).ConfigureAwait(false); + SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager, FileSystemManager); + RegisterSingleInstance(SecurityManager); + + InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager); + RegisterSingleInstance(InstallationManager); + ZipClient = new ZipClient(FileSystemManager); RegisterSingleInstance(ZipClient); diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index c0ef484c97..53dbac53f1 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -77,11 +77,11 @@ <Compile Include="MbLinkShortcutHandler.cs" /> <Compile Include="Migrations\IVersionMigration.cs" /> <Compile Include="Migrations\DbMigration.cs" /> - <Compile Include="Migrations\MovieDbEpisodeProviderMigration.cs" /> <Compile Include="Migrations\UpdateLevelMigration.cs" /> <Compile Include="NativeEnvironment.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="StartupOptions.cs" /> + <Compile Include="SystemEvents.cs" /> <Compile Include="UnhandledExceptionWriter.cs" /> </ItemGroup> <ItemGroup> diff --git a/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs deleted file mode 100644 index cd2122e57b..0000000000 --- a/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs +++ /dev/null @@ -1,44 +0,0 @@ -using MediaBrowser.Controller.Configuration; -using System.Linq; -using System.Threading.Tasks; - -namespace MediaBrowser.Server.Startup.Common.Migrations -{ - class MovieDbEpisodeProviderMigration : IVersionMigration - { - private readonly IServerConfigurationManager _config; - private const string _providerName = "TheMovieDb"; - - public MovieDbEpisodeProviderMigration(IServerConfigurationManager config) - { - _config = config; - } - - public async Task Run() - { - var migrationKey = this.GetType().FullName; - var migrationKeyList = _config.Configuration.Migrations.ToList(); - - if (!migrationKeyList.Contains(migrationKey)) - { - foreach (var metaDataOption in _config.Configuration.MetadataOptions) - { - if (metaDataOption.ItemType == "Episode") - { - var disabledFetchers = metaDataOption.DisabledMetadataFetchers.ToList(); - if (!disabledFetchers.Contains(_providerName)) - { - disabledFetchers.Add(_providerName); - metaDataOption.DisabledMetadataFetchers = disabledFetchers.ToArray(); - } - } - } - - migrationKeyList.Add(migrationKey); - _config.Configuration.Migrations = migrationKeyList.ToArray(); - _config.SaveConfiguration(); - } - - } - } -} diff --git a/MediaBrowser.Server.Startup.Common/SystemEvents.cs b/MediaBrowser.Server.Startup.Common/SystemEvents.cs new file mode 100644 index 0000000000..088d04a249 --- /dev/null +++ b/MediaBrowser.Server.Startup.Common/SystemEvents.cs @@ -0,0 +1,34 @@ +using System; +using MediaBrowser.Common.Events; +using MediaBrowser.Model.Logging; +using MediaBrowser.Model.System; + +namespace MediaBrowser.Server.Startup.Common +{ + public class SystemEvents : ISystemEvents + { + public event EventHandler Resume; + public event EventHandler Suspend; + + private readonly ILogger _logger; + + public SystemEvents(ILogger logger) + { + _logger = logger; + Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; + } + + private void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e) + { + switch (e.Mode) + { + case Microsoft.Win32.PowerModes.Resume: + EventHelper.FireEventIfNotNull(Resume, this, EventArgs.Empty, _logger); + break; + case Microsoft.Win32.PowerModes.Suspend: + EventHelper.FireEventIfNotNull(Suspend, this, EventArgs.Empty, _logger); + break; + } + } + } +} |
