aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-11-23 18:10:41 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-11-23 18:10:41 -0500
commit2df4273ee08425858f93cf86092df45a5a6deecc (patch)
treedaa20b4be88311cd070a6293ebc322ee141432e2
parent1923de72bf3c502ba9b942ef6caa5f73a33f43d6 (diff)
consolidate os display name
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs5
-rw-r--r--MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs2
-rw-r--r--MediaBrowser.Common/IApplicationHost.cs6
-rw-r--r--MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs2
-rw-r--r--MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj1
-rw-r--r--MediaBrowser.Server.Mono/Native/BaseMonoApp.cs193
-rw-r--r--MediaBrowser.Server.Mono/Native/NativeApp.cs178
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs9
-rw-r--r--MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs6
-rw-r--r--MediaBrowser.Server.Startup.Common/INativeApp.cs3
-rw-r--r--MediaBrowser.Server.Startup.Common/NativeEnvironment.cs1
-rw-r--r--MediaBrowser.ServerApplication/MainStartup.cs12
-rw-r--r--MediaBrowser.ServerApplication/Native/WindowsApp.cs3
13 files changed, 226 insertions, 195 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 708e42960..80ac37d52 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -193,6 +193,11 @@ namespace MediaBrowser.Common.Implementations
}
}
+ public virtual string OperatingSystemDisplayName
+ {
+ get { return Environment.OSVersion.VersionString; }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class.
/// </summary>
diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
index 5ebc1e4c5..2c387a4dd 100644
--- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
+++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
@@ -208,7 +208,7 @@ namespace MediaBrowser.Common.Implementations.Security
{ "systemid", _appHost.SystemId },
{ "mb2equiv", mb2Equivalent },
{ "ver", version },
- { "platform", Environment.OSVersion.VersionString },
+ { "platform", _appHost.OperatingSystemDisplayName },
{ "isservice", _appHost.IsRunningAsService.ToString().ToLower() }
};
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 26e556b1e..c843e828b 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -14,6 +14,12 @@ namespace MediaBrowser.Common
public interface IApplicationHost
{
/// <summary>
+ /// Gets the display name of the operating system.
+ /// </summary>
+ /// <value>The display name of the operating system.</value>
+ string OperatingSystemDisplayName { get; }
+
+ /// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs
index a736df977..85410faf2 100644
--- a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs
+++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{ "serverid", _applicationHost.SystemId },
{ "deviceid", _applicationHost.SystemId },
{ "ver", _applicationHost.ApplicationVersion.ToString() },
- { "platform", Environment.OSVersion.VersionString },
+ { "platform", _applicationHost.OperatingSystemDisplayName },
{ "isservice", _applicationHost.IsRunningAsService.ToString().ToLower()}
};
diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
index 449b9acaf..01c4cc291 100644
--- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
+++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
@@ -69,6 +69,7 @@
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
</Compile>
+ <Compile Include="Native\BaseMonoApp.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Native\NativeApp.cs" />
diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
new file mode 100644
index 000000000..ce81326fb
--- /dev/null
+++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
@@ -0,0 +1,193 @@
+using MediaBrowser.Common.Net;
+using MediaBrowser.IsoMounter;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Server.Mono.Networking;
+using MediaBrowser.Server.Startup.Common;
+using Mono.Unix.Native;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text.RegularExpressions;
+
+namespace MediaBrowser.Server.Mono.Native
+{
+ public abstract class BaseMonoApp : INativeApp
+ {
+ /// <summary>
+ /// Shutdowns this instance.
+ /// </summary>
+ public abstract void Shutdown();
+
+ /// <summary>
+ /// Restarts this instance.
+ /// </summary>
+ public void Restart()
+ {
+
+ }
+
+ /// <summary>
+ /// Determines whether this instance [can self restart].
+ /// </summary>
+ /// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
+ public bool CanSelfRestart
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this instance can self update.
+ /// </summary>
+ /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
+ public bool CanSelfUpdate
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool SupportsAutoRunAtStartup
+ {
+ get { return false; }
+ }
+
+ public void PreventSystemStandby()
+ {
+
+ }
+
+ public List<Assembly> GetAssembliesWithParts()
+ {
+ var list = new List<Assembly>();
+
+ if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)
+ {
+ list.AddRange(GetLinuxAssemblies());
+ }
+
+ list.Add(GetType().Assembly);
+
+ return list;
+ }
+
+ private IEnumerable<Assembly> GetLinuxAssemblies()
+ {
+ var list = new List<Assembly>();
+
+ list.Add(typeof(LinuxIsoManager).Assembly);
+
+ return list;
+ }
+
+ public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
+ {
+ }
+
+ private NativeEnvironment _nativeEnvironment;
+ public NativeEnvironment Environment
+ {
+ get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }
+ }
+
+ public bool SupportsRunningAsService
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsRunningAsService
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public void ConfigureAutoRun(bool autorun)
+ {
+ }
+
+ public INetworkManager CreateNetworkManager(ILogger logger)
+ {
+ return new NetworkManager(logger);
+ }
+
+ private NativeEnvironment GetEnvironmentInfo()
+ {
+ var info = new NativeEnvironment
+ {
+ OperatingSystem = Startup.Common.OperatingSystem.Linux
+ };
+
+ var uname = GetUnixName();
+
+ var sysName = uname.sysname ?? string.Empty;
+
+ if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
+ {
+ info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
+ }
+ else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
+ {
+ info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
+ }
+ else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
+ {
+ // TODO: How to detect BSD?
+ info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
+ }
+
+ var archX86 = new Regex("(i|I)[3-6]86");
+
+ if (archX86.IsMatch(uname.machine))
+ {
+ info.SystemArchitecture = Architecture.X86;
+ }
+ else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
+ {
+ info.SystemArchitecture = Architecture.X86_X64;
+ }
+ else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
+ {
+ info.SystemArchitecture = Architecture.Arm;
+ }
+
+ info.OperatingSystemVersionString = string.IsNullOrWhiteSpace(sysName) ?
+ System.Environment.OSVersion.VersionString :
+ sysName;
+
+ return info;
+ }
+
+ private NativeApp.Uname _unixName;
+ private NativeApp.Uname GetUnixName()
+ {
+ if (_unixName == null)
+ {
+ var uname = new NativeApp.Uname();
+ Utsname utsname;
+ var callResult = Syscall.uname(out utsname);
+ if (callResult == 0)
+ {
+ uname.sysname = utsname.sysname;
+ uname.machine = utsname.machine;
+ }
+
+ _unixName = uname;
+ }
+ return _unixName;
+ }
+
+ public class Uname
+ {
+ public string sysname = string.Empty;
+ public string machine = string.Empty;
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Mono/Native/NativeApp.cs b/MediaBrowser.Server.Mono/Native/NativeApp.cs
index 541b2bd7d..b71b74a66 100644
--- a/MediaBrowser.Server.Mono/Native/NativeApp.cs
+++ b/MediaBrowser.Server.Mono/Native/NativeApp.cs
@@ -1,189 +1,17 @@
-using MediaBrowser.Common.Net;
-using MediaBrowser.IsoMounter;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Mono.Networking;
-using MediaBrowser.Server.Startup.Common;
-using Mono.Unix.Native;
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Text.RegularExpressions;
-
+
namespace MediaBrowser.Server.Mono.Native
{
/// <summary>
/// Class NativeApp
/// </summary>
- public class NativeApp : INativeApp
+ public class NativeApp : BaseMonoApp
{
/// <summary>
/// Shutdowns this instance.
/// </summary>
- public void Shutdown()
+ public override void Shutdown()
{
MainClass.Shutdown();
}
-
- /// <summary>
- /// Restarts this instance.
- /// </summary>
- public void Restart()
- {
-
- }
-
- /// <summary>
- /// Determines whether this instance [can self restart].
- /// </summary>
- /// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
- public bool CanSelfRestart
- {
- get
- {
- return false;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this instance can self update.
- /// </summary>
- /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
- public bool CanSelfUpdate
- {
- get
- {
- return false;
- }
- }
-
- public bool SupportsAutoRunAtStartup
- {
- get { return false; }
- }
-
- public void PreventSystemStandby()
- {
-
- }
-
- public List<Assembly> GetAssembliesWithParts()
- {
- var list = new List<Assembly>();
-
- if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)
- {
- list.AddRange(GetLinuxAssemblies());
- }
-
- list.Add(GetType().Assembly);
-
- return list;
- }
-
- private List<Assembly> GetLinuxAssemblies()
- {
- var list = new List<Assembly>();
-
- list.Add(typeof(LinuxIsoManager).Assembly);
-
- return list;
- }
-
- public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
- {
- }
-
- private NativeEnvironment _nativeEnvironment;
- public NativeEnvironment Environment
- {
- get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }
- }
-
- public bool SupportsRunningAsService
- {
- get
- {
- return false;
- }
- }
-
- public bool IsRunningAsService
- {
- get
- {
- return false;
- }
- }
-
- public void ConfigureAutoRun(bool autorun)
- {
- }
-
- public INetworkManager CreateNetworkManager(ILogger logger)
- {
- return new NetworkManager(logger);
- }
-
- private NativeEnvironment GetEnvironmentInfo()
- {
- var info = new NativeEnvironment
- {
- OperatingSystem = Startup.Common.OperatingSystem.Linux
- };
-
- var uname = GetUnixName();
-
- var sysName = uname.sysname ?? string.Empty;
-
- if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
- {
- info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
- }
- else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
- {
- info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
- }
- else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
- {
- // TODO: How to detect BSD?
- info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
- }
-
- var archX86 = new Regex("(i|I)[3-6]86");
-
- if (archX86.IsMatch(uname.machine))
- {
- info.SystemArchitecture = Architecture.X86;
- }
- else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
- {
- info.SystemArchitecture = Architecture.X86_X64;
- }
- else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
- {
- info.SystemArchitecture = Architecture.Arm;
- }
-
- return info;
- }
-
- private static Uname GetUnixName()
- {
- var uname = new Uname();
- Utsname utsname;
- var callResult = Syscall.uname(out utsname);
- if (callResult == 0)
- {
- uname.sysname = utsname.sysname;
- uname.machine = utsname.machine;
- }
- return uname;
- }
-
- public class Uname
- {
- public string sysname = string.Empty;
- public string machine = string.Empty;
- }
}
}
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 1cfdfa3ab..73dcdaacb 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -266,6 +266,11 @@ namespace MediaBrowser.Server.Startup.Common
}
}
+ public override string OperatingSystemDisplayName
+ {
+ get { return NativeApp.Environment.OperatingSystemVersionString; }
+ }
+
public override bool IsRunningAsService
{
get { return NativeApp.IsRunningAsService; }
@@ -531,7 +536,7 @@ namespace MediaBrowser.Server.Startup.Common
/// <returns>Task.</returns>
private async Task RegisterMediaEncoder(IProgress<double> progress)
{
- var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager)
+ var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment)
.GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
new FFmpegValidator(Logger, ApplicationPaths).Validate(info);
@@ -909,7 +914,7 @@ namespace MediaBrowser.Server.Startup.Common
CachePath = ApplicationPaths.CachePath,
MacAddress = GetMacAddress(),
HttpServerPortNumber = HttpServerPort,
- OperatingSystem = Environment.OSVersion.ToString(),
+ OperatingSystem = OperatingSystemDisplayName,
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
WanAddress = ConnectManager.WanApiAddress,
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
index 2e58e75d8..229fee18d 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
@@ -22,19 +22,21 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private readonly ILogger _logger;
private readonly IZipClient _zipClient;
private readonly IFileSystem _fileSystem;
+ private readonly NativeEnvironment _environment;
private readonly string[] _fontUrls =
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z"
};
- public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem)
+ public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment)
{
_logger = logger;
_appPaths = appPaths;
_httpClient = httpClient;
_zipClient = zipClient;
_fileSystem = fileSystem;
+ _environment = environment;
}
public async Task<FFMpegInfo> GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress<double> progress)
@@ -240,7 +242,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private void SetFilePermissions(string targetFolder, string file)
{
// Linux: File permission to 666, and user's execute bit
- if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
+ if (_environment.OperatingSystem == OperatingSystem.Bsd || _environment.OperatingSystem == OperatingSystem.Linux || _environment.OperatingSystem == OperatingSystem.Osx)
{
Syscall.chmod(Path.Combine(targetFolder, Path.GetFileName(file)), FilePermissions.DEFFILEMODE | FilePermissions.S_IXUSR);
}
diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.cs
index c41c66665..5042e1cea 100644
--- a/MediaBrowser.Server.Startup.Common/INativeApp.cs
+++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs
@@ -1,5 +1,4 @@
-using System;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System.Collections.Generic;
using System.Reflection;
diff --git a/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs b/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs
index df9dacb4c..5b45afe73 100644
--- a/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs
+++ b/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs
@@ -5,6 +5,7 @@ namespace MediaBrowser.Server.Startup.Common
{
public OperatingSystem OperatingSystem { get; set; }
public Architecture SystemArchitecture { get; set; }
+ public string OperatingSystemVersionString { get; set; }
}
public enum OperatingSystem
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index 8974ca8da..e1c481d22 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -49,7 +49,7 @@ namespace MediaBrowser.ServerApplication
var logger = _logger = logManager.GetLogger("Main");
- BeginLog(logger, appPaths);
+ ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
// Install directly
if (options.ContainsOption("-installservice"))
@@ -188,16 +188,6 @@ namespace MediaBrowser.ServerApplication
}
}
- /// <summary>
- /// Begins the log.
- /// </summary>
- /// <param name="logger">The logger.</param>
- /// <param name="appPaths">The app paths.</param>
- private static void BeginLog(ILogger logger, IApplicationPaths appPaths)
- {
- ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
- }
-
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
/// <summary>
diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
index a4d0f74ab..9a37c268c 100644
--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs
+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
@@ -33,7 +33,8 @@ namespace MediaBrowser.ServerApplication.Native
return new NativeEnvironment
{
OperatingSystem = OperatingSystem.Windows,
- SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86
+ SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
+ OperatingSystemVersionString = System.Environment.OSVersion.VersionString
};
}
}