mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
Created IConfigurationManager
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Implementations.Configuration;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ServerConfigurationManager
|
||||
/// </summary>
|
||||
public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ServerConfigurationManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="applicationPaths">The application paths.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
||||
public ServerConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer)
|
||||
: base(applicationPaths, logManager, xmlSerializer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the configuration.
|
||||
/// </summary>
|
||||
/// <value>The type of the configuration.</value>
|
||||
protected override Type ConfigurationType
|
||||
{
|
||||
get { return typeof(ServerConfiguration); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application paths.
|
||||
/// </summary>
|
||||
/// <value>The application paths.</value>
|
||||
public IServerApplicationPaths ApplicationPaths
|
||||
{
|
||||
get { return (IServerApplicationPaths)CommonApplicationPaths; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configuration.
|
||||
/// </summary>
|
||||
/// <value>The configuration.</value>
|
||||
public ServerConfiguration Configuration
|
||||
{
|
||||
get { return (ServerConfiguration)CommonConfiguration; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -90,6 +91,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <value>The kernel.</value>
|
||||
private Kernel Kernel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration manager.
|
||||
/// </summary>
|
||||
/// <value>The configuration manager.</value>
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryManager" /> class.
|
||||
/// </summary>
|
||||
@@ -97,14 +104,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
public LibraryManager(Kernel kernel, ILogger logger, ITaskManager taskManager, IUserManager userManager)
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public LibraryManager(Kernel kernel, ILogger logger, ITaskManager taskManager, IUserManager userManager, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
Kernel = kernel;
|
||||
_logger = logger;
|
||||
_taskManager = taskManager;
|
||||
_userManager = userManager;
|
||||
ConfigurationManager = configurationManager;
|
||||
|
||||
kernel.ConfigurationUpdated += kernel_ConfigurationUpdated;
|
||||
ConfigurationManager.ConfigurationUpdated += kernel_ConfigurationUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -222,7 +231,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return null;
|
||||
}
|
||||
|
||||
var args = new ItemResolveArgs
|
||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
|
||||
{
|
||||
Parent = parent,
|
||||
Path = path,
|
||||
@@ -306,7 +315,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <exception cref="System.InvalidOperationException">Cannot create the root folder until plugins have loaded</exception>
|
||||
public AggregateFolder CreateRootFolder()
|
||||
{
|
||||
var rootFolderPath = Kernel.ApplicationPaths.RootFolderPath;
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath;
|
||||
var rootFolder = Kernel.ItemRepository.RetrieveItem(rootFolderPath.GetMBId(typeof(AggregateFolder))) as AggregateFolder ?? (AggregateFolder)ResolvePath(rootFolderPath);
|
||||
|
||||
// Add in the plug-in folders
|
||||
@@ -338,7 +347,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Person}.</returns>
|
||||
private Task<Person> GetPerson(string name, CancellationToken cancellationToken, bool allowSlowProviders = false)
|
||||
{
|
||||
return GetImagesByNameItem<Person>(Kernel.ApplicationPaths.PeoplePath, name, cancellationToken, allowSlowProviders);
|
||||
return GetImagesByNameItem<Person>(ConfigurationManager.ApplicationPaths.PeoplePath, name, cancellationToken, allowSlowProviders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -349,7 +358,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Studio}.</returns>
|
||||
public Task<Studio> GetStudio(string name, bool allowSlowProviders = false)
|
||||
{
|
||||
return GetImagesByNameItem<Studio>(Kernel.ApplicationPaths.StudioPath, name, CancellationToken.None, allowSlowProviders);
|
||||
return GetImagesByNameItem<Studio>(ConfigurationManager.ApplicationPaths.StudioPath, name, CancellationToken.None, allowSlowProviders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -360,7 +369,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Genre}.</returns>
|
||||
public Task<Genre> GetGenre(string name, bool allowSlowProviders = false)
|
||||
{
|
||||
return GetImagesByNameItem<Genre>(Kernel.ApplicationPaths.GenrePath, name, CancellationToken.None, allowSlowProviders);
|
||||
return GetImagesByNameItem<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name, CancellationToken.None, allowSlowProviders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -382,7 +391,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return GetImagesByNameItem<Year>(Kernel.ApplicationPaths.YearPath, value.ToString(UsCulture), CancellationToken.None, allowSlowProviders);
|
||||
return GetImagesByNameItem<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture), CancellationToken.None, allowSlowProviders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -612,7 +621,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>IEnumerable{VirtualFolderInfo}.</returns>
|
||||
public IEnumerable<VirtualFolderInfo> GetDefaultVirtualFolders()
|
||||
{
|
||||
return GetView(Kernel.ApplicationPaths.DefaultUserViewsPath);
|
||||
return GetView(ConfigurationManager.ApplicationPaths.DefaultUserViewsPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -16,6 +17,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
/// </summary>
|
||||
public class MovieResolver : BaseVideoResolver<Movie>
|
||||
{
|
||||
private IServerApplicationPaths ApplicationPaths { get; set; }
|
||||
|
||||
public MovieResolver(IServerApplicationPaths appPaths)
|
||||
{
|
||||
ApplicationPaths = appPaths;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@@ -149,7 +157,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
continue;
|
||||
}
|
||||
|
||||
var childArgs = new ItemResolveArgs
|
||||
var childArgs = new ItemResolveArgs(ApplicationPaths)
|
||||
{
|
||||
FileInfo = child,
|
||||
Path = child.Path
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Connectivity;
|
||||
@@ -89,15 +90,23 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <value>The kernel.</value>
|
||||
private Kernel Kernel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration manager.
|
||||
/// </summary>
|
||||
/// <value>The configuration manager.</value>
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public UserManager(Kernel kernel, ILogger logger)
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public UserManager(Kernel kernel, ILogger logger, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
_logger = logger;
|
||||
Kernel = kernel;
|
||||
ConfigurationManager = configurationManager;
|
||||
}
|
||||
|
||||
#region Events
|
||||
@@ -596,14 +605,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
var pctIn = Decimal.Divide(positionTicks, item.RunTimeTicks.Value) * 100;
|
||||
|
||||
// Don't track in very beginning
|
||||
if (pctIn < Kernel.Configuration.MinResumePct)
|
||||
if (pctIn < ConfigurationManager.Configuration.MinResumePct)
|
||||
{
|
||||
positionTicks = 0;
|
||||
incrementPlayCount = false;
|
||||
}
|
||||
|
||||
// If we're at the end, assume completed
|
||||
else if (pctIn > Kernel.Configuration.MaxResumePct || positionTicks >= item.RunTimeTicks.Value)
|
||||
else if (pctIn > ConfigurationManager.Configuration.MaxResumePct || positionTicks >= item.RunTimeTicks.Value)
|
||||
{
|
||||
positionTicks = 0;
|
||||
data.Played = true;
|
||||
@@ -614,7 +623,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
// Enforce MinResumeDuration
|
||||
var durationSeconds = TimeSpan.FromTicks(item.RunTimeTicks.Value).TotalSeconds;
|
||||
|
||||
if (durationSeconds < Kernel.Configuration.MinResumeDurationSeconds)
|
||||
if (durationSeconds < ConfigurationManager.Configuration.MinResumeDurationSeconds)
|
||||
{
|
||||
positionTicks = 0;
|
||||
data.Played = true;
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<Link>Properties\SharedVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="BdInfo\BdInfoExaminer.cs" />
|
||||
<Compile Include="Configuration\ServerConfigurationManager.cs" />
|
||||
<Compile Include="Library\CoreResolutionIgnoreRule.cs" />
|
||||
<Compile Include="Library\LibraryManager.cs" />
|
||||
<Compile Include="Library\ResolverHelper.cs" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Weather;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
Reference in New Issue
Block a user