aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Configuration
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/Configuration')
-rw-r--r--MediaBrowser.Common/Configuration/ConfigurationStore.cs22
-rw-r--r--MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs4
-rw-r--r--MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs43
-rw-r--r--MediaBrowser.Common/Configuration/IApplicationPaths.cs37
-rw-r--r--MediaBrowser.Common/Configuration/IConfigurationFactory.cs21
-rw-r--r--MediaBrowser.Common/Configuration/IConfigurationManager.cs11
-rw-r--r--MediaBrowser.Common/Configuration/IValidatingConfiguration.cs15
7 files changed, 127 insertions, 26 deletions
diff --git a/MediaBrowser.Common/Configuration/ConfigurationStore.cs b/MediaBrowser.Common/Configuration/ConfigurationStore.cs
new file mode 100644
index 0000000000..050ab1ab51
--- /dev/null
+++ b/MediaBrowser.Common/Configuration/ConfigurationStore.cs
@@ -0,0 +1,22 @@
+#nullable disable
+
+using System;
+
+namespace MediaBrowser.Common.Configuration
+{
+ /// <summary>
+ /// Describes a single entry in the application configuration.
+ /// </summary>
+ public class ConfigurationStore
+ {
+ /// <summary>
+ /// Gets or sets the unique identifier for the configuration.
+ /// </summary>
+ public string Key { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type used to store the data for this configuration entry.
+ /// </summary>
+ public Type ConfigurationType { get; set; }
+ }
+}
diff --git a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
index 0b59627cc8..2df87d8792 100644
--- a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
+++ b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
@@ -1,3 +1,6 @@
+#nullable disable
+#pragma warning disable CS1591
+
using System;
namespace MediaBrowser.Common.Configuration
@@ -9,6 +12,7 @@ namespace MediaBrowser.Common.Configuration
/// </summary>
/// <value>The key.</value>
public string Key { get; set; }
+
/// <summary>
/// Gets or sets the new configuration.
/// </summary>
diff --git a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
new file mode 100644
index 0000000000..89740ae084
--- /dev/null
+++ b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
@@ -0,0 +1,43 @@
+using System;
+using System.IO;
+using MediaBrowser.Model.Configuration;
+
+namespace MediaBrowser.Common.Configuration
+{
+ /// <summary>
+ /// Class containing extension methods for working with the encoding configuration.
+ /// </summary>
+ public static class EncodingConfigurationExtensions
+ {
+ /// <summary>
+ /// Gets the encoding options.
+ /// </summary>
+ /// <param name="configurationManager">The configuration manager.</param>
+ /// <returns>The encoding options.</returns>
+ public static EncodingOptions GetEncodingOptions(this IConfigurationManager configurationManager)
+ => configurationManager.GetConfiguration<EncodingOptions>("encoding");
+
+ /// <summary>
+ /// Retrieves the transcoding temp path from the encoding configuration, falling back to a default if no path
+ /// is specified in configuration. If the directory does not exist, it will be created.
+ /// </summary>
+ /// <param name="configurationManager">The configuration manager.</param>
+ /// <returns>The transcoding temp path.</returns>
+ /// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have the required permission to create it.</exception>
+ /// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is invalid.</exception>
+ /// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception>
+ public static string GetTranscodePath(this IConfigurationManager configurationManager)
+ {
+ // Get the configured path and fall back to a default
+ var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath;
+ if (string.IsNullOrEmpty(transcodingTempPath))
+ {
+ transcodingTempPath = Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes");
+ }
+
+ // Make sure the directory exists
+ Directory.CreateDirectory(transcodingTempPath);
+ return transcodingTempPath;
+ }
+ }
+}
diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
index cb4e8bf5f0..1370e6d79e 100644
--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs
+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
@@ -1,24 +1,34 @@
+#nullable disable
+
namespace MediaBrowser.Common.Configuration
{
/// <summary>
- /// Interface IApplicationPaths
+ /// Interface IApplicationPaths.
/// </summary>
public interface IApplicationPaths
{
/// <summary>
- /// Gets the path to the program data folder
+ /// Gets the path to the program data folder.
/// </summary>
/// <value>The program data path.</value>
string ProgramDataPath { get; }
/// <summary>
- /// Gets the path to the program system folder
+ /// Gets the path to the web UI resources folder.
+ /// </summary>
+ /// <remarks>
+ /// This value is not relevant if the server is configured to not host any static web content.
+ /// </remarks>
+ string WebPath { get; }
+
+ /// <summary>
+ /// Gets the path to the program system folder.
/// </summary>
/// <value>The program data path.</value>
string ProgramSystemPath { get; }
/// <summary>
- /// Gets the folder path to the data directory
+ /// Gets the folder path to the data directory.
/// </summary>
/// <value>The data directory.</value>
string DataPath { get; }
@@ -30,48 +40,51 @@ namespace MediaBrowser.Common.Configuration
string ImageCachePath { get; }
/// <summary>
- /// Gets the path to the plugin directory
+ /// Gets the path to the plugin directory.
/// </summary>
/// <value>The plugins path.</value>
string PluginsPath { get; }
/// <summary>
- /// Gets the path to the plugin configurations directory
+ /// Gets the path to the plugin configurations directory.
/// </summary>
/// <value>The plugin configurations path.</value>
string PluginConfigurationsPath { get; }
/// <summary>
- /// Gets the path to the log directory
+ /// Gets the path to the log directory.
/// </summary>
/// <value>The log directory path.</value>
string LogDirectoryPath { get; }
/// <summary>
- /// Gets the path to the application configuration root directory
+ /// Gets the path to the application configuration root directory.
/// </summary>
/// <value>The configuration directory path.</value>
string ConfigurationDirectoryPath { get; }
/// <summary>
- /// Gets the path to the system configuration file
+ /// Gets the path to the system configuration file.
/// </summary>
/// <value>The system configuration file path.</value>
string SystemConfigurationFilePath { get; }
/// <summary>
- /// Gets the folder path to the cache directory
+ /// Gets the folder path to the cache directory.
/// </summary>
/// <value>The cache directory.</value>
string CachePath { get; }
/// <summary>
- /// Gets the folder path to the temp directory within the cache folder
+ /// Gets the folder path to the temp directory within the cache folder.
/// </summary>
/// <value>The temp directory.</value>
string TempDirectory { get; }
+ /// <summary>
+ /// Gets the magic string used for virtual path manipulation.
+ /// </summary>
+ /// <value>The magic string used for virtual path manipulation.</value>
string VirtualDataPath { get; }
}
-
}
diff --git a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs
index 0fb2b83d1b..6db1f1364b 100644
--- a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs
+++ b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs
@@ -1,22 +1,17 @@
-using System;
using System.Collections.Generic;
namespace MediaBrowser.Common.Configuration
{
+ /// <summary>
+ /// Provides an interface to retrieve a configuration store. Classes with this interface are scanned for at
+ /// application start to dynamically register configuration for various modules/plugins.
+ /// </summary>
public interface IConfigurationFactory
{
+ /// <summary>
+ /// Get the configuration store for this module.
+ /// </summary>
+ /// <returns>The configuration store.</returns>
IEnumerable<ConfigurationStore> GetConfigurations();
}
-
- public class ConfigurationStore
- {
- public string Key { get; set; }
-
- public Type ConfigurationType { get; set; }
- }
-
- public interface IValidatingConfiguration
- {
- void Validate(object oldConfig, object newConfig);
- }
}
diff --git a/MediaBrowser.Common/Configuration/IConfigurationManager.cs b/MediaBrowser.Common/Configuration/IConfigurationManager.cs
index 8fed2dcdf4..fc63d93503 100644
--- a/MediaBrowser.Common/Configuration/IConfigurationManager.cs
+++ b/MediaBrowser.Common/Configuration/IConfigurationManager.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Configuration;
@@ -22,7 +24,7 @@ namespace MediaBrowser.Common.Configuration
event EventHandler<ConfigurationUpdateEventArgs> NamedConfigurationUpdated;
/// <summary>
- /// Gets or sets the application paths.
+ /// Gets the application paths.
/// </summary>
/// <value>The application paths.</value>
IApplicationPaths CommonApplicationPaths { get; }
@@ -45,6 +47,13 @@ namespace MediaBrowser.Common.Configuration
void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration);
/// <summary>
+ /// Manually pre-loads a factory so that it is available pre system initialisation.
+ /// </summary>
+ /// <typeparam name="T">Class to register.</typeparam>
+ void RegisterConfiguration<T>()
+ where T : IConfigurationFactory;
+
+ /// <summary>
/// Gets the configuration.
/// </summary>
/// <param name="key">The key.</param>
diff --git a/MediaBrowser.Common/Configuration/IValidatingConfiguration.cs b/MediaBrowser.Common/Configuration/IValidatingConfiguration.cs
new file mode 100644
index 0000000000..3b1d84f3c2
--- /dev/null
+++ b/MediaBrowser.Common/Configuration/IValidatingConfiguration.cs
@@ -0,0 +1,15 @@
+namespace MediaBrowser.Common.Configuration
+{
+ /// <summary>
+ /// A configuration store that can be validated.
+ /// </summary>
+ public interface IValidatingConfiguration
+ {
+ /// <summary>
+ /// Validation method to be invoked before saving the configuration.
+ /// </summary>
+ /// <param name="oldConfig">The old configuration.</param>
+ /// <param name="newConfig">The new configuration.</param>
+ void Validate(object oldConfig, object newConfig);
+ }
+}