aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-03-27 16:34:26 +0100
committerGitHub <noreply@github.com>2019-03-27 16:34:26 +0100
commitd0fbd260d5cc386119d96f53cdc1d164b80d02df (patch)
tree55d465b25aae29128b77d1867f0bfd9a1fc3708f /MediaBrowser.Common
parent7f42dcc60fd3aaf30f2408f6bddeb2b8bf921cdf (diff)
parent524357bfa845e1c01ef280b1d0fc3896b7b9dbaa (diff)
Merge branch 'master' into httpclient
Diffstat (limited to 'MediaBrowser.Common')
-rw-r--r--MediaBrowser.Common/Configuration/IApplicationPaths.cs6
-rw-r--r--MediaBrowser.Common/Extensions/BaseExtensions.cs10
-rw-r--r--MediaBrowser.Common/IApplicationHost.cs9
-rw-r--r--MediaBrowser.Common/Properties/AssemblyInfo.cs4
-rw-r--r--MediaBrowser.Common/Providers/SubtitleConfigurationFactory.cs18
-rw-r--r--MediaBrowser.Common/System/OperatingSystem.cs72
6 files changed, 111 insertions, 8 deletions
diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
index cb4e8bf5f..fd11bf904 100644
--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs
+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
@@ -12,6 +12,12 @@ namespace MediaBrowser.Common.Configuration
string ProgramDataPath { get; }
/// <summary>
+ /// Gets the path to the web UI resources folder
+ /// </summary>
+ /// <value>The web UI resources path.</value>
+ string WebPath { get; }
+
+ /// <summary>
/// Gets the path to the program system folder
/// </summary>
/// <value>The program data path.</value>
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs
index db0514bb1..40c16b957 100644
--- a/MediaBrowser.Common/Extensions/BaseExtensions.cs
+++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs
@@ -1,6 +1,7 @@
using System;
+using System.Text;
using System.Text.RegularExpressions;
-using MediaBrowser.Model.Cryptography;
+using System.Security.Cryptography;
namespace MediaBrowser.Common.Extensions
{
@@ -9,8 +10,6 @@ namespace MediaBrowser.Common.Extensions
/// </summary>
public static class BaseExtensions
{
- public static ICryptoProvider CryptographyProvider { get; set; }
-
/// <summary>
/// Strips the HTML.
/// </summary>
@@ -31,7 +30,10 @@ namespace MediaBrowser.Common.Extensions
/// <returns>Guid.</returns>
public static Guid GetMD5(this string str)
{
- return CryptographyProvider.GetMD5(str);
+ using (var provider = MD5.Create())
+ {
+ return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
+ }
}
}
}
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 3a4098612..2925a3efd 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Events;
@@ -73,6 +72,12 @@ namespace MediaBrowser.Common
string ApplicationUserAgent { get; }
/// <summary>
+ /// Gets the email address for use within a comment section of a user agent field.
+ /// Presently used to provide contact information to MusicBrainz service.
+ /// </summary>
+ string ApplicationUserAgentAddress { get; }
+
+ /// <summary>
/// Gets the exports.
/// </summary>
/// <typeparam name="T"></typeparam>
@@ -107,7 +112,7 @@ namespace MediaBrowser.Common
/// <summary>
/// Inits this instance.
/// </summary>
- Task Init(IServiceCollection serviceCollection);
+ Task InitAsync(IServiceCollection serviceCollection);
/// <summary>
/// Creates the instance.
diff --git a/MediaBrowser.Common/Properties/AssemblyInfo.cs b/MediaBrowser.Common/Properties/AssemblyInfo.cs
index 1a8fdb618..538e89fd1 100644
--- a/MediaBrowser.Common/Properties/AssemblyInfo.cs
+++ b/MediaBrowser.Common/Properties/AssemblyInfo.cs
@@ -9,8 +9,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Jellyfin Project")]
-[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")]
-[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")]
+[assembly: AssemblyProduct("Jellyfin Server")]
+[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
diff --git a/MediaBrowser.Common/Providers/SubtitleConfigurationFactory.cs b/MediaBrowser.Common/Providers/SubtitleConfigurationFactory.cs
new file mode 100644
index 000000000..09d974db6
--- /dev/null
+++ b/MediaBrowser.Common/Providers/SubtitleConfigurationFactory.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Providers;
+
+namespace MediaBrowser.Common.Providers
+{
+ public class SubtitleConfigurationFactory : IConfigurationFactory
+ {
+ public IEnumerable<ConfigurationStore> GetConfigurations()
+ {
+ yield return new ConfigurationStore()
+ {
+ Key = "subtitles",
+ ConfigurationType = typeof(SubtitleOptions)
+ };
+ }
+ }
+}
diff --git a/MediaBrowser.Common/System/OperatingSystem.cs b/MediaBrowser.Common/System/OperatingSystem.cs
new file mode 100644
index 000000000..640821d4d
--- /dev/null
+++ b/MediaBrowser.Common/System/OperatingSystem.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+using MediaBrowser.Model.System;
+
+namespace MediaBrowser.Common.System
+{
+ public static class OperatingSystem
+ {
+ // We can't use Interlocked.CompareExchange for enums
+ private static int _id = int.MaxValue;
+
+ public static OperatingSystemId Id
+ {
+ get
+ {
+ if (_id == int.MaxValue)
+ {
+ Interlocked.CompareExchange(ref _id, (int)GetId(), int.MaxValue);
+ }
+
+ return (OperatingSystemId)_id;
+ }
+ }
+
+ public static string Name
+ {
+ get
+ {
+ switch (Id)
+ {
+ case OperatingSystemId.BSD: return "BSD";
+ case OperatingSystemId.Linux: return "Linux";
+ case OperatingSystemId.Darwin: return "macOS";
+ case OperatingSystemId.Windows: return "Windows";
+ default: throw new Exception($"Unknown OS {Id}");
+ }
+ }
+ }
+
+ private static OperatingSystemId GetId()
+ {
+ switch (Environment.OSVersion.Platform)
+ {
+ // On .NET Core `MacOSX` got replaced by `Unix`, this case should never be hit.
+ case PlatformID.MacOSX:
+ return OperatingSystemId.Darwin;
+ case PlatformID.Win32NT:
+ return OperatingSystemId.Windows;
+ case PlatformID.Unix:
+ default:
+ {
+ string osDescription = RuntimeInformation.OSDescription;
+ if (osDescription.IndexOf("linux", StringComparison.OrdinalIgnoreCase) != -1)
+ {
+ return OperatingSystemId.Linux;
+ }
+ else if (osDescription.IndexOf("darwin", StringComparison.OrdinalIgnoreCase) != -1)
+ {
+ return OperatingSystemId.Darwin;
+ }
+ else if (osDescription.IndexOf("bsd", StringComparison.OrdinalIgnoreCase) != -1)
+ {
+ return OperatingSystemId.BSD;
+ }
+
+ throw new Exception($"Can't resolve OS with description: '{osDescription}'");
+ }
+ }
+ }
+ }
+}