From bfcd1b520fd79b893e721ba916ae5e1656407d2f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 16 Aug 2017 02:43:41 -0400 Subject: merge common implementations and server implementations --- MediaBrowser.ServerApplication/MainStartup.cs | 5 +---- MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj | 4 ---- MediaBrowser.ServerApplication/Networking/NetworkManager.cs | 2 +- MediaBrowser.ServerApplication/WindowsAppHost.cs | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index e687b34cf5..7f72473ea5 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -17,15 +17,12 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using Emby.Common.Implementations.EnvironmentInfo; -using Emby.Common.Implementations.IO; -using Emby.Common.Implementations.Logging; -using Emby.Common.Implementations.Networking; using Emby.Server.Core.Cryptography; using Emby.Drawing; using Emby.Server.Core; using Emby.Server.Implementations; using Emby.Server.Implementations.Browser; +using Emby.Server.Implementations.EnvironmentInfo; using Emby.Server.Implementations.IO; using Emby.Server.Implementations.Logging; using MediaBrowser.Common.Net; diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index a4138a57da..41015a98b7 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -199,10 +199,6 @@ {713f42b5-878e-499d-a878-e4c652b1d5e8} DvdLib - - {1e37a338-9f57-4b70-bd6d-bb9c591e319b} - Emby.Common.Implementations - {805844ab-e92f-45e6-9d99-4f6d48d129a5} Emby.Dlna diff --git a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs index 6d3d96e19a..8933a5760d 100644 --- a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs +++ b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.ServerApplication.Networking /// /// Class NetUtils /// - public class NetworkManager : Emby.Common.Implementations.Networking.NetworkManager + public class NetworkManager : Emby.Server.Implementations.Networking.NetworkManager { public NetworkManager(ILogger logger) : base(logger) diff --git a/MediaBrowser.ServerApplication/WindowsAppHost.cs b/MediaBrowser.ServerApplication/WindowsAppHost.cs index 7a35c56147..c872d96e2d 100644 --- a/MediaBrowser.ServerApplication/WindowsAppHost.cs +++ b/MediaBrowser.ServerApplication/WindowsAppHost.cs @@ -4,13 +4,13 @@ using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices.ComTypes; -using Emby.Common.Implementations.IO; using Emby.Server.CinemaMode; using Emby.Server.Connect; using Emby.Server.Core; using Emby.Server.Implementations; using Emby.Server.Implementations.EntryPoints; using Emby.Server.Implementations.FFMpeg; +using Emby.Server.Implementations.IO; using Emby.Server.Sync; using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Sync; -- cgit v1.2.3 From 56263a9fa26a93bbfa34f673be0e373572ec2fee Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 16 Aug 2017 11:42:36 -0400 Subject: remove unused libs --- Emby.Server.Implementations/ApplicationHost.cs | 3 - .../Emby.Server.Implementations.csproj | 9 +- .../IO/MemoryStreamProvider.cs | 27 - Emby.Server.Implementations/Logging/NLogger.cs | 224 --------- Emby.Server.Implementations/Logging/NlogManager.cs | 553 --------------------- .../Logging/SimpleLogManager.cs | 301 +++++++++++ Emby.Server.Implementations/packages.config | 2 - MediaBrowser.Model/Logging/ILogManager.cs | 6 - .../MediaBrowser.Server.Mono.csproj | 3 - MediaBrowser.Server.Mono/packages.config | 1 - MediaBrowser.ServerApplication/MainStartup.cs | 2 +- .../MediaBrowser.ServerApplication.csproj | 3 - MediaBrowser.ServerApplication/packages.config | 1 - 13 files changed, 303 insertions(+), 832 deletions(-) delete mode 100644 Emby.Server.Implementations/Logging/NLogger.cs delete mode 100644 Emby.Server.Implementations/Logging/NlogManager.cs create mode 100644 Emby.Server.Implementations/Logging/SimpleLogManager.cs (limited to 'MediaBrowser.ServerApplication') diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 318f7d9121..b8506eb867 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1795,9 +1795,6 @@ namespace Emby.Server.Implementations // Include composable parts in the Photos assembly list.Add(GetAssembly(typeof(PhotoProvider))); - // Common implementations - list.Add(GetAssembly(typeof(TaskManager))); - // Emby.Server implementations list.Add(GetAssembly(typeof(InstallationManager))); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 891d9cfc43..89b9325a25 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -434,8 +434,7 @@ - - + @@ -671,12 +670,6 @@ ..\packages\MediaBrowser.Naming.1.0.5\lib\portable-net45+win8\MediaBrowser.Naming.dll True - - ..\packages\Microsoft.IO.RecyclableMemoryStream.1.2.2\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll - - - ..\packages\NLog.4.4.12\lib\net45\NLog.dll - ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll True diff --git a/Emby.Server.Implementations/IO/MemoryStreamProvider.cs b/Emby.Server.Implementations/IO/MemoryStreamProvider.cs index eca76203c5..e9ecb7e44f 100644 --- a/Emby.Server.Implementations/IO/MemoryStreamProvider.cs +++ b/Emby.Server.Implementations/IO/MemoryStreamProvider.cs @@ -1,35 +1,8 @@ using System.IO; using MediaBrowser.Model.IO; -using Microsoft.IO; namespace Emby.Server.Implementations.IO { - public class RecyclableMemoryStreamProvider : IMemoryStreamFactory - { - readonly RecyclableMemoryStreamManager _manager = new RecyclableMemoryStreamManager(); - - public MemoryStream CreateNew() - { - return _manager.GetStream(); - } - - public MemoryStream CreateNew(int capacity) - { - return _manager.GetStream("RecyclableMemoryStream", capacity); - } - - public MemoryStream CreateNew(byte[] buffer) - { - return _manager.GetStream("RecyclableMemoryStream", buffer, 0, buffer.Length); - } - - public bool TryGetBuffer(MemoryStream stream, out byte[] buffer) - { - buffer = stream.GetBuffer(); - return true; - } - } - public class MemoryStreamProvider : IMemoryStreamFactory { public MemoryStream CreateNew() diff --git a/Emby.Server.Implementations/Logging/NLogger.cs b/Emby.Server.Implementations/Logging/NLogger.cs deleted file mode 100644 index c380a640f3..0000000000 --- a/Emby.Server.Implementations/Logging/NLogger.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using System.Text; -using MediaBrowser.Model.Logging; - -namespace Emby.Server.Implementations.Logging -{ - /// - /// Class NLogger - /// - public class NLogger : ILogger - { - /// - /// The _logger - /// - private readonly NLog.Logger _logger; - - private readonly ILogManager _logManager; - - /// - /// The _lock object - /// - private static readonly object LockObject = new object(); - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The log manager. - public NLogger(string name, ILogManager logManager) - { - _logManager = logManager; - lock (LockObject) - { - _logger = NLog.LogManager.GetLogger(name); - } - } - - /// - /// Infoes the specified message. - /// - /// The message. - /// The param list. - public void Info(string message, params object[] paramList) - { - _logger.Info(message, paramList); - } - - /// - /// Errors the specified message. - /// - /// The message. - /// The param list. - public void Error(string message, params object[] paramList) - { - _logger.Error(message, paramList); - } - - /// - /// Warns the specified message. - /// - /// The message. - /// The param list. - public void Warn(string message, params object[] paramList) - { - _logger.Warn(message, paramList); - } - - /// - /// Debugs the specified message. - /// - /// The message. - /// The param list. - public void Debug(string message, params object[] paramList) - { - if (_logManager.LogSeverity == LogSeverity.Info) - { - return; - } - - _logger.Debug(message, paramList); - } - - /// - /// Logs the exception. - /// - /// The message. - /// The exception. - /// The param list. - /// - public void ErrorException(string message, Exception exception, params object[] paramList) - { - LogException(LogSeverity.Error, message, exception, paramList); - } - - /// - /// Logs the exception. - /// - /// The level. - /// The message. - /// The exception. - /// The param list. - private void LogException(LogSeverity level, string message, Exception exception, params object[] paramList) - { - message = FormatMessage(message, paramList).Replace(Environment.NewLine, ". "); - - var messageText = LogHelper.GetLogMessage(exception); - - var prefix = _logManager.ExceptionMessagePrefix; - - if (!string.IsNullOrWhiteSpace(prefix)) - { - messageText.Insert(0, prefix); - } - - LogMultiline(message, level, messageText); - } - - /// - /// Formats the message. - /// - /// The message. - /// The param list. - /// System.String. - private static string FormatMessage(string message, params object[] paramList) - { - if (paramList != null) - { - for (var i = 0; i < paramList.Length; i++) - { - var obj = paramList[i]; - - message = message.Replace("{" + i + "}", (obj == null ? "null" : obj.ToString())); - } - } - - return message; - } - - /// - /// Logs the multiline. - /// - /// The message. - /// The severity. - /// Content of the additional. - public void LogMultiline(string message, LogSeverity severity, StringBuilder additionalContent) - { - if (severity == LogSeverity.Debug && _logManager.LogSeverity == LogSeverity.Info) - { - return; - } - - additionalContent.Insert(0, message + Environment.NewLine); - - const char tabChar = '\t'; - - var text = additionalContent.ToString() - .Replace(Environment.NewLine, Environment.NewLine + tabChar) - .TrimEnd(tabChar); - - if (text.EndsWith(Environment.NewLine)) - { - text = text.Substring(0, text.LastIndexOf(Environment.NewLine, StringComparison.OrdinalIgnoreCase)); - } - - _logger.Log(GetLogLevel(severity), text); - } - - /// - /// Gets the log level. - /// - /// The severity. - /// NLog.LogLevel. - private NLog.LogLevel GetLogLevel(LogSeverity severity) - { - switch (severity) - { - case LogSeverity.Debug: - return NLog.LogLevel.Debug; - case LogSeverity.Error: - return NLog.LogLevel.Error; - case LogSeverity.Warn: - return NLog.LogLevel.Warn; - case LogSeverity.Fatal: - return NLog.LogLevel.Fatal; - case LogSeverity.Info: - return NLog.LogLevel.Info; - default: - throw new ArgumentException("Unknown LogSeverity: " + severity.ToString()); - } - } - - /// - /// Logs the specified severity. - /// - /// The severity. - /// The message. - /// The param list. - public void Log(LogSeverity severity, string message, params object[] paramList) - { - _logger.Log(GetLogLevel(severity), message, paramList); - } - - /// - /// Fatals the specified message. - /// - /// The message. - /// The param list. - public void Fatal(string message, params object[] paramList) - { - _logger.Fatal(message, paramList); - } - - /// - /// Fatals the exception. - /// - /// The message. - /// The exception. - /// The param list. - public void FatalException(string message, Exception exception, params object[] paramList) - { - LogException(LogSeverity.Fatal, message, exception, paramList); - } - } -} diff --git a/Emby.Server.Implementations/Logging/NlogManager.cs b/Emby.Server.Implementations/Logging/NlogManager.cs deleted file mode 100644 index 77f8d02970..0000000000 --- a/Emby.Server.Implementations/Logging/NlogManager.cs +++ /dev/null @@ -1,553 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using MediaBrowser.Model.Logging; -using NLog; -using NLog.Config; -using NLog.Filters; -using NLog.Targets; -using NLog.Targets.Wrappers; - -namespace Emby.Server.Implementations.Logging -{ - /// - /// Class NlogManager - /// - public class NlogManager : ILogManager - { - #region Private Fields - - private LogSeverity _severity = LogSeverity.Debug; - - /// - /// Gets or sets the log directory. - /// - /// The log directory. - private readonly string LogDirectory; - - /// - /// Gets or sets the log file prefix. - /// - /// The log file prefix. - private readonly string LogFilePrefix; - - #endregion - - #region Event Declarations - - /// - /// Occurs when [logger loaded]. - /// - public event EventHandler LoggerLoaded; - - #endregion - - #region Public Properties - - /// - /// Gets the log file path. - /// - /// The log file path. - public string LogFilePath { get; private set; } - - /// - /// Gets or sets the exception message prefix. - /// - /// The exception message prefix. - public string ExceptionMessagePrefix { get; set; } - - public string NLogConfigurationFilePath { get; set; } - - public LogSeverity LogSeverity - { - - get - { - return _severity; - } - - set - { - DebugFileWriter( - LogDirectory, String.Format( - "SET LogSeverity, _severity = [{0}], value = [{1}]", - _severity.ToString(), - value.ToString() - )); - - var changed = _severity != value; - - _severity = value; - - if (changed) - { - UpdateLogLevel(value); - } - - } - } - - #endregion - - #region Constructor(s) - - /// - /// Initializes a new instance of the class. - /// - /// The log directory. - /// The log file name prefix. - public NlogManager(string logDirectory, string logFileNamePrefix) - { - DebugFileWriter( - logDirectory, String.Format( - "NlogManager constructor called, logDirectory is [{0}], logFileNamePrefix is [{1}], _severity is [{2}].", - logDirectory, - logFileNamePrefix, - _severity.ToString() - )); - - LogDirectory = logDirectory; - LogFilePrefix = logFileNamePrefix; - - LogManager.Configuration = new LoggingConfiguration(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The log directory. - /// The log file name prefix. - public NlogManager(string logDirectory, string logFileNamePrefix, LogSeverity initialSeverity) : this(logDirectory, logFileNamePrefix) - { - _severity = initialSeverity; - - DebugFileWriter( - logDirectory, String.Format( - "NlogManager constructor called, logDirectory is [{0}], logFileNamePrefix is [{1}], _severity is [{2}].", - logDirectory, - logFileNamePrefix, - _severity.ToString() - )); - } - - #endregion - - #region Private Methods - - /// - /// Adds the file target. - /// - /// The path. - /// The level. - private void AddFileTarget(string path, LogSeverity level) - { - - DebugFileWriter( - LogDirectory, String.Format( - "AddFileTarget called, path = [{0}], level = [{1}].", - path, - level.ToString() - )); - - RemoveTarget("ApplicationLogFileWrapper"); - - // https://github.com/NLog/NLog/wiki/Performance - var wrapper = new AsyncTargetWrapper - { - OverflowAction = AsyncTargetWrapperOverflowAction.Block, - QueueLimit = 10000, - BatchSize = 500, - TimeToSleepBetweenBatches = 50 - }; - - wrapper.Name = "ApplicationLogFileWrapper"; - - var logFile = new FileTarget - { - FileName = path, - Layout = "${longdate} ${level} ${logger}: ${message}", - KeepFileOpen = true, - ConcurrentWrites = false - }; - - logFile.Name = "ApplicationLogFile"; - - wrapper.WrappedTarget = logFile; - - AddLogTarget(wrapper, level); - - } - - /// - /// Gets the log level. - /// - /// The severity. - /// LogLevel. - /// Unrecognized LogSeverity - private LogLevel GetLogLevel(LogSeverity severity) - { - switch (severity) - { - case LogSeverity.Debug: - return LogLevel.Debug; - case LogSeverity.Error: - return LogLevel.Error; - case LogSeverity.Fatal: - return LogLevel.Fatal; - case LogSeverity.Info: - return LogLevel.Info; - case LogSeverity.Warn: - return LogLevel.Warn; - default: - throw new ArgumentException("Unrecognized LogSeverity"); - } - } - - private void UpdateLogLevel(LogSeverity newLevel) - { - DebugFileWriter( - LogDirectory, String.Format( - "UpdateLogLevel called, newLevel = [{0}].", - newLevel.ToString() - )); - - var level = GetLogLevel(newLevel); - - var rules = LogManager.Configuration.LoggingRules; - - foreach (var rule in rules) - { - if (!rule.IsLoggingEnabledForLevel(level)) - { - rule.EnableLoggingForLevel(level); - } - foreach (var lev in rule.Levels.ToArray()) - { - if (lev < level) - { - rule.DisableLoggingForLevel(lev); - } - } - } - } - - private void AddCustomFilters(string defaultLoggerNamePattern, LoggingRule defaultRule) - { - DebugFileWriter( - LogDirectory, String.Format( - "AddCustomFilters called, defaultLoggerNamePattern = [{0}], defaultRule.LoggerNamePattern = [{1}].", - defaultLoggerNamePattern, - defaultRule.LoggerNamePattern - )); - - try - { - var customConfig = new NLog.Config.XmlLoggingConfiguration(NLogConfigurationFilePath); - - DebugFileWriter( - LogDirectory, String.Format( - "Custom Configuration Loaded, Rule Count = [{0}].", - customConfig.LoggingRules.Count.ToString() - )); - - foreach (var customRule in customConfig.LoggingRules) - { - - DebugFileWriter( - LogDirectory, String.Format( - "Read Custom Rule, LoggerNamePattern = [{0}], Targets = [{1}].", - customRule.LoggerNamePattern, - string.Join(",", customRule.Targets.Select(x => x.Name).ToList()) - )); - - if (customRule.LoggerNamePattern.Equals(defaultLoggerNamePattern)) - { - - if (customRule.Targets.Any((arg) => arg.Name.Equals(defaultRule.Targets.First().Name))) - { - - DebugFileWriter( - LogDirectory, String.Format( - "Custom rule filters can be applied to this target, Filter Count = [{0}].", - customRule.Filters.Count.ToString() - )); - - foreach (ConditionBasedFilter customFilter in customRule.Filters) - { - - DebugFileWriter( - LogDirectory, String.Format( - "Read Custom Filter, Filter = [{0}], Action = [{1}], Type = [{2}].", - customFilter.Condition.ToString(), - customFilter.Action.ToString(), - customFilter.GetType().ToString() - )); - - defaultRule.Filters.Add(customFilter); - - } - } - else - { - - DebugFileWriter( - LogDirectory, String.Format( - "Ignoring custom rule as [Target] does not match." - )); - - } - - } - else - { - - DebugFileWriter( - LogDirectory, String.Format( - "Ignoring custom rule as [LoggerNamePattern] does not match." - )); - - } - } - } - catch (Exception ex) - { - // Intentionally do nothing, prevent issues affecting normal execution. - DebugFileWriter( - LogDirectory, String.Format( - "Exception in AddCustomFilters, ex.Message = [{0}].", - ex.Message - ) - ); - - } - } - - #endregion - - #region Public Methods - - /// - /// Gets the logger. - /// - /// The name. - /// ILogger. - public MediaBrowser.Model.Logging.ILogger GetLogger(string name) - { - - DebugFileWriter( - LogDirectory, String.Format( - "GetLogger called, name = [{0}].", - name - )); - - return new NLogger(name, this); - - } - - /// - /// Adds the log target. - /// - /// The target. - /// The level. - public void AddLogTarget(Target target, LogSeverity level) - { - - DebugFileWriter( - LogDirectory, String.Format( - "AddLogTarget called, target.Name = [{0}], level = [{1}].", - target.Name, - level.ToString() - )); - - string loggerNamePattern = "*"; - var config = LogManager.Configuration; - var rule = new LoggingRule(loggerNamePattern, GetLogLevel(level), target); - - config.AddTarget(target.Name, target); - - AddCustomFilters(loggerNamePattern, rule); - - config.LoggingRules.Add(rule); - - LogManager.Configuration = config; - - } - - /// - /// Removes the target. - /// - /// The name. - public void RemoveTarget(string name) - { - - DebugFileWriter( - LogDirectory, String.Format( - "RemoveTarget called, name = [{0}].", - name - )); - - var config = LogManager.Configuration; - - var target = config.FindTargetByName(name); - - if (target != null) - { - foreach (var rule in config.LoggingRules.ToList()) - { - var contains = rule.Targets.Contains(target); - - rule.Targets.Remove(target); - - if (contains) - { - config.LoggingRules.Remove(rule); - } - } - - config.RemoveTarget(name); - LogManager.Configuration = config; - } - } - - public void AddConsoleOutput() - { - - DebugFileWriter( - LogDirectory, String.Format( - "AddConsoleOutput called." - )); - - RemoveTarget("ConsoleTargetWrapper"); - - var wrapper = new AsyncTargetWrapper(); - wrapper.Name = "ConsoleTargetWrapper"; - - var target = new ConsoleTarget() - { - Layout = "${level}, ${logger}, ${message}", - Error = false - }; - - target.Name = "ConsoleTarget"; - - wrapper.WrappedTarget = target; - - AddLogTarget(wrapper, LogSeverity); - - } - - public void RemoveConsoleOutput() - { - - DebugFileWriter( - LogDirectory, String.Format( - "RemoveConsoleOutput called." - )); - - RemoveTarget("ConsoleTargetWrapper"); - - } - - /// - /// Reloads the logger, maintaining the current log level. - /// - public void ReloadLogger() - { - ReloadLogger(LogSeverity); - } - - /// - /// Reloads the logger, using the specified logging level. - /// - /// The level. - public void ReloadLogger(LogSeverity level) - { - - DebugFileWriter( - LogDirectory, String.Format( - "ReloadLogger called, level = [{0}], LogFilePath (existing) = [{1}].", - level.ToString(), - LogFilePath - )); - - LogFilePath = Path.Combine(LogDirectory, LogFilePrefix + "-" + decimal.Floor(DateTime.Now.Ticks / 10000000) + ".txt"); - - Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath)); - - AddFileTarget(LogFilePath, level); - - LogSeverity = level; - - if (LoggerLoaded != null) - { - try - { - - DebugFileWriter( - LogDirectory, String.Format( - "ReloadLogger called, raised event LoggerLoaded." - )); - - LoggerLoaded(this, EventArgs.Empty); - - } - catch (Exception ex) - { - GetLogger("Logger").ErrorException("Error in LoggerLoaded event", ex); - } - } - } - - /// - /// Flushes this instance. - /// - public void Flush() - { - - DebugFileWriter( - LogDirectory, String.Format( - "Flush called." - )); - - LogManager.Flush(); - - } - - #endregion - - #region Conditional Debug Methods - - /// - /// DEBUG: Standalone method to write out debug to assist with logger development/troubleshooting. - /// - /// The output file will be written to the server's log directory. - /// Calls to the method are safe and will never throw any exceptions. - /// Method calls will be omitted unless the library is compiled with DEBUG defined. - /// - /// - private static void DebugFileWriter(string logDirectory, string message) - { -#if DEBUG - try - { - - System.IO.File.AppendAllText( - Path.Combine(logDirectory, "NlogManager.txt"), - String.Format( - "{0} : {1}{2}", - System.DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), - message, - System.Environment.NewLine - ) - ); - - } - catch (Exception ex) - { - // Intentionally do nothing, prevent issues affecting normal execution. - } -#endif - } - #endregion - } -} \ No newline at end of file diff --git a/Emby.Server.Implementations/Logging/SimpleLogManager.cs b/Emby.Server.Implementations/Logging/SimpleLogManager.cs new file mode 100644 index 0000000000..1a50f162a1 --- /dev/null +++ b/Emby.Server.Implementations/Logging/SimpleLogManager.cs @@ -0,0 +1,301 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Model.Logging; + +namespace Emby.Server.Implementations.Logging +{ + public class SimpleLogManager : ILogManager, IDisposable + { + public LogSeverity LogSeverity { get; set; } + public string ExceptionMessagePrefix { get; set; } + private FileLogger _fileLogger; + + private readonly string LogDirectory; + private readonly string LogFilePrefix; + public string DateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff"; + + public SimpleLogManager(string logDirectory, string logFileNamePrefix) + { + LogDirectory = logDirectory; + LogFilePrefix = logFileNamePrefix; + } + + public ILogger GetLogger(string name) + { + return new NamedLogger(name, this); + } + + public void ReloadLogger(LogSeverity severity) + { + LogSeverity = severity; + + var logger = _fileLogger; + if (logger != null) + { + logger.Dispose(); + } + + var path = Path.Combine(LogDirectory, LogFilePrefix + "-" + decimal.Floor(DateTime.Now.Ticks / 10000000) + ".txt"); + + _fileLogger = new FileLogger(path); + + if (LoggerLoaded != null) + { + try + { + + LoggerLoaded(this, EventArgs.Empty); + + } + catch (Exception ex) + { + GetLogger("Logger").ErrorException("Error in LoggerLoaded event", ex); + } + } + } + + public event EventHandler LoggerLoaded; + + public void Flush() + { + var logger = _fileLogger; + if (logger != null) + { + logger.Flush(); + } + } + + private bool _console = true; + public void AddConsoleOutput() + { + _console = true; + } + + public void RemoveConsoleOutput() + { + _console = false; + } + + public void Log(string message) + { + if (_console) + { + Console.WriteLine(message); + } + + var logger = _fileLogger; + if (logger != null) + { + message = DateTime.Now.ToString(DateTimeFormat) + " " + message; + + logger.Log(message); + } + } + + public void Dispose() + { + var logger = _fileLogger; + if (logger != null) + { + logger.Dispose(); + } + + _fileLogger = null; + } + } + + public class FileLogger : IDisposable + { + private readonly Stream _fileStream; + + private bool _disposed; + private readonly CancellationTokenSource _cancellationTokenSource; + private readonly BlockingCollection _queue = new BlockingCollection(); + + public FileLogger(string path) + { + Directory.CreateDirectory(Path.GetDirectoryName(path)); + + _fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read); + _cancellationTokenSource = new CancellationTokenSource(); + + Task.Factory.StartNew(LogInternal, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); + } + + private void LogInternal() + { + while (!_cancellationTokenSource.IsCancellationRequested) + { + try + { + var any = false; + + foreach (var message in _queue.GetConsumingEnumerable()) + { + any = true; + + var bytes = Encoding.UTF8.GetBytes(message + Environment.NewLine); + _fileStream.Write(bytes, 0, bytes.Length); + } + + if (any) + { + _fileStream.Flush(); + } + } + catch + { + + } + } + } + + public void Log(string message) + { + if (_disposed) + { + return; + } + + _queue.Add(message); + } + + public void Flush() + { + if (_disposed) + { + return; + } + + _fileStream.Flush(); + } + + public void Dispose() + { + _cancellationTokenSource.Cancel(); + + _disposed = true; + + _fileStream.Flush(); + _fileStream.Dispose(); + } + } + + public class NamedLogger : ILogger + { + public string Name { get; private set; } + private readonly SimpleLogManager _logManager; + + public NamedLogger(string name, SimpleLogManager logManager) + { + Name = name; + _logManager = logManager; + } + + public void Info(string message, params object[] paramList) + { + Log(LogSeverity.Info, message, paramList); + } + + public void Error(string message, params object[] paramList) + { + Log(LogSeverity.Error, message, paramList); + } + + public void Warn(string message, params object[] paramList) + { + Log(LogSeverity.Warn, message, paramList); + } + + public void Debug(string message, params object[] paramList) + { + if (_logManager.LogSeverity == LogSeverity.Info) + { + return; + } + Log(LogSeverity.Debug, message, paramList); + } + + public void Fatal(string message, params object[] paramList) + { + Log(LogSeverity.Fatal, message, paramList); + } + + public void FatalException(string message, Exception exception, params object[] paramList) + { + ErrorException(message, exception, paramList); + } + + public void ErrorException(string message, Exception exception, params object[] paramList) + { + LogException(LogSeverity.Error, message, exception, paramList); + } + + private void LogException(LogSeverity level, string message, Exception exception, params object[] paramList) + { + message = FormatMessage(message, paramList).Replace(Environment.NewLine, ". "); + + var messageText = LogHelper.GetLogMessage(exception); + + var prefix = _logManager.ExceptionMessagePrefix; + + if (!string.IsNullOrWhiteSpace(prefix)) + { + messageText.Insert(0, prefix); + } + + LogMultiline(message, level, messageText); + } + + private static string FormatMessage(string message, params object[] paramList) + { + if (paramList != null) + { + for (var i = 0; i < paramList.Length; i++) + { + var obj = paramList[i]; + + message = message.Replace("{" + i + "}", (obj == null ? "null" : obj.ToString())); + } + } + + return message; + } + + public void LogMultiline(string message, LogSeverity severity, StringBuilder additionalContent) + { + if (severity == LogSeverity.Debug && _logManager.LogSeverity == LogSeverity.Info) + { + return; + } + + additionalContent.Insert(0, message + Environment.NewLine); + + const char tabChar = '\t'; + + var text = additionalContent.ToString() + .Replace(Environment.NewLine, Environment.NewLine + tabChar) + .TrimEnd(tabChar); + + if (text.EndsWith(Environment.NewLine)) + { + text = text.Substring(0, text.LastIndexOf(Environment.NewLine, StringComparison.OrdinalIgnoreCase)); + } + + Log(severity, text); + } + + public void Log(LogSeverity severity, string message, params object[] paramList) + { + message = severity + " " + Name + ": " + FormatMessage(message, paramList); + + _logManager.Log(message); + } + } +} diff --git a/Emby.Server.Implementations/packages.config b/Emby.Server.Implementations/packages.config index fc28b26539..0933cd5e43 100644 --- a/Emby.Server.Implementations/packages.config +++ b/Emby.Server.Implementations/packages.config @@ -2,8 +2,6 @@ - - diff --git a/MediaBrowser.Model/Logging/ILogManager.cs b/MediaBrowser.Model/Logging/ILogManager.cs index 59bb867563..218f13eb4b 100644 --- a/MediaBrowser.Model/Logging/ILogManager.cs +++ b/MediaBrowser.Model/Logging/ILogManager.cs @@ -31,12 +31,6 @@ namespace MediaBrowser.Model.Logging /// void ReloadLogger(LogSeverity severity); - /// - /// Gets the log file path. - /// - /// The log file path. - string LogFilePath { get; } - /// /// Occurs when [logger loaded]. /// diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj index bb113bf03a..a0b1d526a2 100644 --- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj +++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj @@ -51,9 +51,6 @@ False ..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll - - ..\packages\NLog.4.4.12\lib\net45\NLog.dll - ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll True diff --git a/MediaBrowser.Server.Mono/packages.config b/MediaBrowser.Server.Mono/packages.config index c77327e228..525a0098c8 100644 --- a/MediaBrowser.Server.Mono/packages.config +++ b/MediaBrowser.Server.Mono/packages.config @@ -1,7 +1,6 @@  - diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 7f72473ea5..169ac2eefe 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -73,7 +73,7 @@ namespace MediaBrowser.ServerApplication var appPaths = CreateApplicationPaths(ApplicationPath, IsRunningAsService); - var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); + var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Debug); logManager.AddConsoleOutput(); diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 41015a98b7..cb7c92a886 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -73,9 +73,6 @@ ..\ThirdParty\emby\Emby.Server.Sync.dll - - ..\packages\NLog.4.4.12\lib\net45\NLog.dll - ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll True diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index ed953e299a..3af1bcf4d8 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -1,6 +1,5 @@  - -- cgit v1.2.3 From a57c887f7f367402cd1e3e215a8b8052f3c603da Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 16 Aug 2017 13:30:16 -0400 Subject: update components --- Emby.Server.Implementations/ApplicationHost.cs | 10 +-- .../ApplicationPathHelper.cs | 51 --------------- .../Data/SqliteItemRepository.cs | 4 +- .../Devices/CameraUploadsDynamicFolder.cs | 1 - .../Devices/CameraUploadsFolder.cs | 71 +++++++++++++++++++++ .../Emby.Server.Implementations.csproj | 15 ++--- Emby.Server.Implementations/IO/FileRefresher.cs | 6 +- .../Playlists/ManualPlaylistsFolder.cs | 58 +++++++++++++++++ .../Playlists/PlaylistsDynamicFolder.cs | 1 - Emby.Server.Implementations/packages.config | 4 +- .../Devices/CameraUploadsFolder.cs | 73 ---------------------- .../MediaBrowser.Server.Implementations.csproj | 69 -------------------- .../Playlists/ManualPlaylistsFolder.cs | 62 ------------------ .../Properties/AssemblyInfo.cs | 30 --------- MediaBrowser.Server.Implementations/app.config | 11 ---- MediaBrowser.Server.Mono/ApplicationPathHelper.cs | 51 +++++++++++++++ .../MediaBrowser.Server.Mono.csproj | 5 +- .../ApplicationPathHelper.cs | 51 +++++++++++++++ MediaBrowser.ServerApplication/MainStartup.cs | 1 - .../MediaBrowser.ServerApplication.csproj | 5 +- MediaBrowser.Tests/MediaBrowser.Tests.csproj | 4 -- MediaBrowser.sln | 33 ---------- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 24 files changed, 253 insertions(+), 369 deletions(-) delete mode 100644 Emby.Server.Implementations/ApplicationPathHelper.cs create mode 100644 Emby.Server.Implementations/Devices/CameraUploadsFolder.cs create mode 100644 Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs delete mode 100644 MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs delete mode 100644 MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj delete mode 100644 MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs delete mode 100644 MediaBrowser.Server.Implementations/Properties/AssemblyInfo.cs delete mode 100644 MediaBrowser.Server.Implementations/app.config create mode 100644 MediaBrowser.Server.Mono/ApplicationPathHelper.cs create mode 100644 MediaBrowser.ServerApplication/ApplicationPathHelper.cs (limited to 'MediaBrowser.ServerApplication') diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index b8506eb867..3ad8fe7df9 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1254,7 +1254,7 @@ namespace Emby.Server.Implementations { switch (EnvironmentInfo.SystemArchitecture) { - case Architecture.X64: + case MediaBrowser.Model.System.Architecture.X64: return new[] { "https://embydata.com/downloads/ffmpeg/osx/ffmpeg-x64-20170308.7z" @@ -1268,12 +1268,12 @@ namespace Emby.Server.Implementations { switch (EnvironmentInfo.SystemArchitecture) { - case Architecture.X64: + case MediaBrowser.Model.System.Architecture.X64: return new[] { "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win64.7z" }; - case Architecture.X86: + case MediaBrowser.Model.System.Architecture.X86: return new[] { "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win32.7z" @@ -1287,12 +1287,12 @@ namespace Emby.Server.Implementations { switch (EnvironmentInfo.SystemArchitecture) { - case Architecture.X64: + case MediaBrowser.Model.System.Architecture.X64: return new[] { "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-64bit-static.7z" }; - case Architecture.X86: + case MediaBrowser.Model.System.Architecture.X86: return new[] { "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-32bit-static.7z" diff --git a/Emby.Server.Implementations/ApplicationPathHelper.cs b/Emby.Server.Implementations/ApplicationPathHelper.cs deleted file mode 100644 index 262cc526ec..0000000000 --- a/Emby.Server.Implementations/ApplicationPathHelper.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Configuration; -using System.IO; - -namespace Emby.Server.Implementations -{ - public static class ApplicationPathHelper - { - /// - /// Gets the path to the application's ProgramDataFolder - /// - /// System.String. - public static string GetProgramDataPath(string applicationPath) - { - var useDebugPath = false; - -#if DEBUG - useDebugPath = true; -#endif - - var programDataPath = useDebugPath ? - ConfigurationManager.AppSettings["DebugProgramDataPath"] : - ConfigurationManager.AppSettings["ReleaseProgramDataPath"]; - - programDataPath = programDataPath.Replace("%ApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); - - programDataPath = programDataPath - .Replace('/', Path.DirectorySeparatorChar) - .Replace('\\', Path.DirectorySeparatorChar); - - // If it's a relative path, e.g. "..\" - if (!Path.IsPathRooted(programDataPath)) - { - var path = Path.GetDirectoryName(applicationPath); - - if (string.IsNullOrEmpty(path)) - { - throw new ApplicationException("Unable to determine running assembly location"); - } - - programDataPath = Path.Combine(path, programDataPath); - - programDataPath = Path.GetFullPath(programDataPath); - } - - Directory.CreateDirectory(programDataPath); - - return programDataPath; - } - } -} diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 7fb2f02dbf..6743e96fd3 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -7,6 +7,8 @@ using System.Runtime.Serialization; using System.Text; using System.Threading; using System.Threading.Tasks; +using Emby.Server.Implementations.Devices; +using Emby.Server.Implementations.Playlists; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Collections; using MediaBrowser.Controller.Configuration; @@ -25,8 +27,6 @@ using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Serialization; -using MediaBrowser.Server.Implementations.Devices; -using MediaBrowser.Server.Implementations.Playlists; using MediaBrowser.Model.Reflection; using SQLitePCL.pretty; using MediaBrowser.Model.System; diff --git a/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs b/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs index 52979f085c..bb9ef157c4 100644 --- a/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs +++ b/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs @@ -10,7 +10,6 @@ using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Serialization; -using MediaBrowser.Server.Implementations.Devices; namespace Emby.Server.Implementations.Devices { diff --git a/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs b/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs new file mode 100644 index 0000000000..55063872c1 --- /dev/null +++ b/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -0,0 +1,71 @@ +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Serialization; + +namespace Emby.Server.Implementations.Devices +{ + public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView + { + public CameraUploadsFolder() + { + Name = "Camera Uploads"; + } + + public override bool IsVisible(User user) + { + if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsVisible(user) && HasChildren(); + } + + [IgnoreDataMember] + public override string CollectionType + { + get { return MediaBrowser.Model.Entities.CollectionType.Photos; } + } + + [IgnoreDataMember] + public override bool SupportsInheritedParentImages + { + get + { + return false; + } + } + + public override string GetClientTypeName() + { + return typeof(CollectionFolder).Name; + } + + private bool? _hasChildren; + private bool HasChildren() + { + if (!_hasChildren.HasValue) + { + _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { Parent = this }).Count > 0; + } + + return _hasChildren.Value; + } + + protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) + { + _hasChildren = null; + return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); + } + + [IgnoreDataMember] + public bool EnableUserSpecificView + { + get { return true; } + } + } +} diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 89b9325a25..1e897016e3 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -43,7 +43,6 @@ - @@ -83,6 +82,7 @@ + @@ -458,6 +458,7 @@ + @@ -635,10 +636,6 @@ {442b5058-dcaf-4263-bb6a-f21e31120a1b} MediaBrowser.Providers - - {2e781478-814d-4a48-9d80-bff206441a65} - MediaBrowser.Server.Implementations - {5624b7b5-b5a7-41d8-9f10-cc5611109619} MediaBrowser.WebDashboard @@ -663,12 +660,10 @@ ..\ThirdParty\emby\Emby.Server.MediaEncoding.dll - ..\packages\Emby.XmlTv.1.0.9\lib\portable-net45+win8\Emby.XmlTv.dll - True + ..\packages\Emby.XmlTv.1.0.10\lib\portable-net45+netstandard2.0+win8\Emby.XmlTv.dll - - ..\packages\MediaBrowser.Naming.1.0.5\lib\portable-net45+win8\MediaBrowser.Naming.dll - True + + ..\packages\MediaBrowser.Naming.1.0.6\lib\portable-net45+netstandard2.0+win8\MediaBrowser.Naming.dll ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index b2554049d1..0ec62d8958 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.IO RestartTimer(); } - private async void OnTimerCallback(object state) + private void OnTimerCallback(object state) { List paths; @@ -137,7 +137,7 @@ namespace Emby.Server.Implementations.IO try { - await ProcessPathChanges(paths.ToList()).ConfigureAwait(false); + ProcessPathChanges(paths.ToList()); } catch (Exception ex) { @@ -145,7 +145,7 @@ namespace Emby.Server.Implementations.IO } } - private async Task ProcessPathChanges(List paths) + private void ProcessPathChanges(List paths) { var itemsToRefresh = paths .Distinct(StringComparer.OrdinalIgnoreCase) diff --git a/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs new file mode 100644 index 0000000000..2a178895cc --- /dev/null +++ b/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using System.Linq; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Playlists; +using MediaBrowser.Model.Querying; +using MediaBrowser.Model.Serialization; + +namespace Emby.Server.Implementations.Playlists +{ + public class PlaylistsFolder : BasePluginFolder + { + public PlaylistsFolder() + { + Name = "Playlists"; + } + + public override bool IsVisible(User user) + { + return base.IsVisible(user) && GetChildren(user, true).Any(); + } + + protected override IEnumerable GetEligibleChildrenForRecursiveChildren(User user) + { + return base.GetEligibleChildrenForRecursiveChildren(user).OfType(); + } + + [IgnoreDataMember] + public override bool IsHidden + { + get + { + return true; + } + } + + [IgnoreDataMember] + public override bool SupportsInheritedParentImages + { + get + { + return false; + } + } + + [IgnoreDataMember] + public override string CollectionType + { + get { return MediaBrowser.Model.Entities.CollectionType.Playlists; } + } + + protected override QueryResult GetItemsInternal(InternalItemsQuery query) + { + query.Recursive = false; + return base.GetItemsInternal(query); + } + } +} + diff --git a/Emby.Server.Implementations/Playlists/PlaylistsDynamicFolder.cs b/Emby.Server.Implementations/Playlists/PlaylistsDynamicFolder.cs index dacc937e1a..2ce835576e 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistsDynamicFolder.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistsDynamicFolder.cs @@ -2,7 +2,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Server.Implementations.Playlists; namespace Emby.Server.Implementations.Playlists { diff --git a/Emby.Server.Implementations/packages.config b/Emby.Server.Implementations/packages.config index 0933cd5e43..8d4d249950 100644 --- a/Emby.Server.Implementations/packages.config +++ b/Emby.Server.Implementations/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs deleted file mode 100644 index ae700e250f..0000000000 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ /dev/null @@ -1,73 +0,0 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Controller.Entities; -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Serialization; - -namespace MediaBrowser.Server.Implementations.Devices -{ - public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView - { - public CameraUploadsFolder() - { - Name = "Camera Uploads"; - } - - public override bool IsVisible(User user) - { - if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsVisible(user) && HasChildren(); - } - - [IgnoreDataMember] - public override string CollectionType - { - get { return Model.Entities.CollectionType.Photos; } - } - - [IgnoreDataMember] - public override bool SupportsInheritedParentImages - { - get - { - return false; - } - } - - public override string GetClientTypeName() - { - return typeof(CollectionFolder).Name; - } - - private bool? _hasChildren; - private bool HasChildren() - { - if (!_hasChildren.HasValue) - { - _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { Parent = this }).Count > 0; - } - - return _hasChildren.Value; - } - - protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) - { - _hasChildren = null; - return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); - } - - [IgnoreDataMember] - public bool EnableUserSpecificView - { - get { return true; } - } - } -} diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj deleted file mode 100644 index 31c400915e..0000000000 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Debug - AnyCPU - {2E781478-814D-4A48-9D80-BFF206441A65} - Library - Properties - MediaBrowser.Server.Implementations - MediaBrowser.Server.Implementations - 512 - ..\ - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile7 - v4.5 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - TRACE - prompt - 4 - - - - Properties\SharedVersion.cs - - - - - - - - {9142EEFA-7570-41E1-BFCC-468BB571AF2F} - MediaBrowser.Common - - - {17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2} - MediaBrowser.Controller - - - {7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B} - MediaBrowser.Model - - - - - - - - - \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs deleted file mode 100644 index 236dbde9cc..0000000000 --- a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using MediaBrowser.Common.Configuration; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Playlists; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Querying; -using MediaBrowser.Model.Serialization; - -namespace MediaBrowser.Server.Implementations.Playlists -{ - public class PlaylistsFolder : BasePluginFolder - { - public PlaylistsFolder() - { - Name = "Playlists"; - } - - public override bool IsVisible(User user) - { - return base.IsVisible(user) && GetChildren(user, true).Any(); - } - - protected override IEnumerable GetEligibleChildrenForRecursiveChildren(User user) - { - return base.GetEligibleChildrenForRecursiveChildren(user).OfType(); - } - - [IgnoreDataMember] - public override bool IsHidden - { - get - { - return true; - } - } - - [IgnoreDataMember] - public override bool SupportsInheritedParentImages - { - get - { - return false; - } - } - - [IgnoreDataMember] - public override string CollectionType - { - get { return MediaBrowser.Model.Entities.CollectionType.Playlists; } - } - - protected override QueryResult GetItemsInternal(InternalItemsQuery query) - { - query.Recursive = false; - return base.GetItemsInternal(query); - } - } -} - diff --git a/MediaBrowser.Server.Implementations/Properties/AssemblyInfo.cs b/MediaBrowser.Server.Implementations/Properties/AssemblyInfo.cs deleted file mode 100644 index db656b9341..0000000000 --- a/MediaBrowser.Server.Implementations/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MediaBrowser.Server.Implementations")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MediaBrowser.Server.Implementations")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0537cdd3-a069-4d86-9318-d46d8b119903")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// diff --git a/MediaBrowser.Server.Implementations/app.config b/MediaBrowser.Server.Implementations/app.config deleted file mode 100644 index 9d8c1ac93a..0000000000 --- a/MediaBrowser.Server.Implementations/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/MediaBrowser.Server.Mono/ApplicationPathHelper.cs b/MediaBrowser.Server.Mono/ApplicationPathHelper.cs new file mode 100644 index 0000000000..c8cca40ff8 --- /dev/null +++ b/MediaBrowser.Server.Mono/ApplicationPathHelper.cs @@ -0,0 +1,51 @@ +using System; +using System.Configuration; +using System.IO; + +namespace MediaBrowser.Server.Mono +{ + public static class ApplicationPathHelper + { + /// + /// Gets the path to the application's ProgramDataFolder + /// + /// System.String. + public static string GetProgramDataPath(string applicationPath) + { + var useDebugPath = false; + +#if DEBUG + useDebugPath = true; +#endif + + var programDataPath = useDebugPath ? + ConfigurationManager.AppSettings["DebugProgramDataPath"] : + ConfigurationManager.AppSettings["ReleaseProgramDataPath"]; + + programDataPath = programDataPath.Replace("%ApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); + + programDataPath = programDataPath + .Replace('/', Path.DirectorySeparatorChar) + .Replace('\\', Path.DirectorySeparatorChar); + + // If it's a relative path, e.g. "..\" + if (!Path.IsPathRooted(programDataPath)) + { + var path = Path.GetDirectoryName(applicationPath); + + if (string.IsNullOrEmpty(path)) + { + throw new ApplicationException("Unable to determine running assembly location"); + } + + programDataPath = Path.Combine(path, programDataPath); + + programDataPath = Path.GetFullPath(programDataPath); + } + + Directory.CreateDirectory(programDataPath); + + return programDataPath; + } + } +} diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj index a0b1d526a2..7ddafb6360 100644 --- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj +++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj @@ -86,6 +86,7 @@ Properties\SharedVersion.cs + @@ -131,10 +132,6 @@ {5624B7B5-B5A7-41D8-9F10-CC5611109619} MediaBrowser.WebDashboard - - {2E781478-814D-4A48-9D80-BFF206441A65} - MediaBrowser.Server.Implementations - {442B5058-DCAF-4263-BB6A-F21E31120A1B} MediaBrowser.Providers diff --git a/MediaBrowser.ServerApplication/ApplicationPathHelper.cs b/MediaBrowser.ServerApplication/ApplicationPathHelper.cs new file mode 100644 index 0000000000..e8dad62134 --- /dev/null +++ b/MediaBrowser.ServerApplication/ApplicationPathHelper.cs @@ -0,0 +1,51 @@ +using System; +using System.Configuration; +using System.IO; + +namespace MediaBrowser.ServerApplication +{ + public static class ApplicationPathHelper + { + /// + /// Gets the path to the application's ProgramDataFolder + /// + /// System.String. + public static string GetProgramDataPath(string applicationPath) + { + var useDebugPath = false; + +#if DEBUG + useDebugPath = true; +#endif + + var programDataPath = useDebugPath ? + ConfigurationManager.AppSettings["DebugProgramDataPath"] : + ConfigurationManager.AppSettings["ReleaseProgramDataPath"]; + + programDataPath = programDataPath.Replace("%ApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); + + programDataPath = programDataPath + .Replace('/', Path.DirectorySeparatorChar) + .Replace('\\', Path.DirectorySeparatorChar); + + // If it's a relative path, e.g. "..\" + if (!Path.IsPathRooted(programDataPath)) + { + var path = Path.GetDirectoryName(applicationPath); + + if (string.IsNullOrEmpty(path)) + { + throw new ApplicationException("Unable to determine running assembly location"); + } + + programDataPath = Path.Combine(path, programDataPath); + + programDataPath = Path.GetFullPath(programDataPath); + } + + Directory.CreateDirectory(programDataPath); + + return programDataPath; + } + } +} diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 169ac2eefe..fba8f48118 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -1,5 +1,4 @@ using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Startup.Common; using MediaBrowser.ServerApplication.Native; using MediaBrowser.ServerApplication.Splash; diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index cb7c92a886..eed5bab8d3 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -113,6 +113,7 @@ Properties\SharedVersion.cs + Component @@ -244,10 +245,6 @@ {442b5058-dcaf-4263-bb6a-f21e31120a1b} MediaBrowser.Providers - - {2e781478-814d-4a48-9d80-bff206441a65} - MediaBrowser.Server.Implementations - {5624b7b5-b5a7-41d8-9f10-cc5611109619} MediaBrowser.WebDashboard diff --git a/MediaBrowser.Tests/MediaBrowser.Tests.csproj b/MediaBrowser.Tests/MediaBrowser.Tests.csproj index 8e63ab9c3f..62bcad000b 100644 --- a/MediaBrowser.Tests/MediaBrowser.Tests.csproj +++ b/MediaBrowser.Tests/MediaBrowser.Tests.csproj @@ -88,10 +88,6 @@ {442B5058-DCAF-4263-BB6A-F21E31120A1B} MediaBrowser.Providers - - {2E781478-814D-4A48-9D80-BFF206441A65} - MediaBrowser.Server.Implementations - {23499896-b135-4527-8574-c26e926ea99e} MediaBrowser.XbmcMetadata diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 79d6d90b2b..32485a8c9f 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -34,8 +34,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Model", "Media EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.WebDashboard", "MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj", "{5624B7B5-B5A7-41D8-9F10-CC5611109619}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Server.Implementations", "MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj", "{2E781478-814D-4A48-9D80-BFF206441A65}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Tests", "MediaBrowser.Tests\MediaBrowser.Tests.csproj", "{E22BFD35-0FCD-4A85-978A-C22DCD73A081}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Providers", "MediaBrowser.Providers\MediaBrowser.Providers.csproj", "{442B5058-DCAF-4263-BB6A-F21E31120A1B}" @@ -266,37 +264,6 @@ Global {5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|x64.Build.0 = Release|Any CPU {5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|x86.ActiveCfg = Release|Any CPU {5624B7B5-B5A7-41D8-9F10-CC5611109619}.Signed|x86.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Win32.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x64.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Mixed Platforms.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Mixed Platforms.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Win32.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x64.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Win32.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|x64.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Any CPU.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Any CPU.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Mixed Platforms.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Mixed Platforms.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Win32.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Win32.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x64.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x64.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x86.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x86.Build.0 = Release|Any CPU {E22BFD35-0FCD-4A85-978A-C22DCD73A081}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E22BFD35-0FCD-4A85-978A-C22DCD73A081}.Debug|Any CPU.Build.0 = Debug|Any CPU {E22BFD35-0FCD-4A85-978A-C22DCD73A081}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 9be89112ad..d9e6fdc7d9 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.729 + 3.0.730 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 1d2e484dbe..b79e0c4353 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.729 + 3.0.730 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + -- cgit v1.2.3 From a7dcf7191a71bfefd4a8c69d24d2eec53973bb83 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 17 Aug 2017 16:19:02 -0400 Subject: add fixes for .net core --- .../AppBase/BaseApplicationPaths.cs | 9 ++-- Emby.Server.Implementations/ApplicationHost.cs | 56 +++++++++++----------- .../Cryptography/CertificateGenerator.cs | 42 +++++++++++++++- .../EnvironmentInfo/EnvironmentInfo.cs | 20 +++++--- .../HttpClientManager/HttpClientManager.cs | 10 ++-- Emby.Server.Implementations/Library/UserManager.cs | 6 +-- .../Logging/SimpleLogManager.cs | 4 +- Emby.Server.Implementations/Net/SocketFactory.cs | 23 ++++++--- .../ServerApplicationPaths.cs | 4 +- MediaBrowser.Model/Session/PlaybackProgressInfo.cs | 2 +- MediaBrowser.Server.Mono/MonoAppHost.cs | 2 +- MediaBrowser.Server.Mono/Program.cs | 49 +++++-------------- .../ImageEncoderHelper.cs | 1 - MediaBrowser.ServerApplication/MainStartup.cs | 16 ++----- .../MediaBrowser.ServerApplication.csproj | 4 -- MediaBrowser.ServerApplication/WindowsAppHost.cs | 4 +- 16 files changed, 132 insertions(+), 120 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs index 54d1d53023..1e63aa1a6d 100644 --- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs +++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs @@ -13,15 +13,12 @@ namespace Emby.Server.Implementations.AppBase /// /// Initializes a new instance of the class. /// - protected BaseApplicationPaths(string programDataPath, string appFolderPath, Action createDirectoryFn) + protected BaseApplicationPaths(string programDataPath, string appFolderPath) { ProgramDataPath = programDataPath; ProgramSystemPath = appFolderPath; - CreateDirectoryFn = createDirectoryFn; } - protected Action CreateDirectoryFn; - public string ProgramDataPath { get; private set; } /// @@ -45,7 +42,7 @@ namespace Emby.Server.Implementations.AppBase { _dataDirectory = Path.Combine(ProgramDataPath, "data"); - CreateDirectoryFn(_dataDirectory); + Directory.CreateDirectory(_dataDirectory); } return _dataDirectory; @@ -152,7 +149,7 @@ namespace Emby.Server.Implementations.AppBase { _cachePath = Path.Combine(ProgramDataPath, "cache"); - CreateDirectoryFn(_cachePath); + Directory.CreateDirectory(_cachePath); } return _cachePath; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3ad8fe7df9..bc88d652c4 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -111,6 +111,7 @@ using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading; using System.Threading.Tasks; +using Emby.Server.Core.Cryptography; using Emby.Server.Implementations.Archiving; using Emby.Server.Implementations.Cryptography; using Emby.Server.Implementations.Diagnostics; @@ -368,8 +369,6 @@ namespace Emby.Server.Implementations internal IPowerManagement PowerManagement { get; private set; } internal IImageEncoder ImageEncoder { get; private set; } - private readonly Action _certificateGenerator; - private readonly Func _defaultUserNameFactory; protected IProcessFactory ProcessFactory { get; private set; } protected ITimerFactory TimerFactory { get; private set; } protected ICryptoProvider CryptographyProvider = new CryptographyProvider(); @@ -394,10 +393,7 @@ namespace Emby.Server.Implementations IEnvironmentInfo environmentInfo, IImageEncoder imageEncoder, ISystemEvents systemEvents, - IMemoryStreamFactory memoryStreamFactory, - INetworkManager networkManager, - Action certificateGenerator, - Func defaultUsernameFactory) + INetworkManager networkManager) { // hack alert, until common can target .net core BaseExtensions.CryptographyProvider = CryptographyProvider; @@ -407,7 +403,7 @@ namespace Emby.Server.Implementations NetworkManager = networkManager; EnvironmentInfo = environmentInfo; SystemEvents = systemEvents; - MemoryStreamFactory = memoryStreamFactory; + MemoryStreamFactory = new MemoryStreamProvider(); FailedAssemblies = new List(); @@ -421,9 +417,7 @@ namespace Emby.Server.Implementations Logger = LogManager.GetLogger("App"); StartupOptions = options; - _certificateGenerator = certificateGenerator; _releaseAssetFilename = releaseAssetFilename; - _defaultUserNameFactory = defaultUsernameFactory; PowerManagement = powerManagement; ImageEncoder = imageEncoder; @@ -917,7 +911,7 @@ namespace Emby.Server.Implementations AuthenticationRepository = GetAuthenticationRepository(); RegisterSingleInstance(AuthenticationRepository); - UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider, _defaultUserNameFactory()); + UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider); RegisterSingleInstance(UserManager); LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager); @@ -1257,7 +1251,7 @@ namespace Emby.Server.Implementations case MediaBrowser.Model.System.Architecture.X64: return new[] { - "https://embydata.com/downloads/ffmpeg/osx/ffmpeg-x64-20170308.7z" + "https://embydata.com/downloads/ffmpeg/osx/ffmpeg-x64-20170308.7z" }; } @@ -1271,12 +1265,12 @@ namespace Emby.Server.Implementations case MediaBrowser.Model.System.Architecture.X64: return new[] { - "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win64.7z" + "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win64.7z" }; case MediaBrowser.Model.System.Architecture.X86: return new[] { - "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win32.7z" + "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win32.7z" }; } @@ -1290,12 +1284,12 @@ namespace Emby.Server.Implementations case MediaBrowser.Model.System.Architecture.X64: return new[] { - "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-64bit-static.7z" + "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-64bit-static.7z" }; case MediaBrowser.Model.System.Architecture.X86: return new[] { - "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-32bit-static.7z" + "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-32bit-static.7z" }; } @@ -1442,17 +1436,17 @@ namespace Emby.Server.Implementations StartServer(); LibraryManager.AddParts(GetExports(), - GetExports(), - GetExports(), - GetExports(), - GetExports(), - GetExports()); + GetExports(), + GetExports(), + GetExports(), + GetExports(), + GetExports()); ProviderManager.AddParts(GetExports(), - GetExports(), - GetExports(), - GetExports(), - GetExports()); + GetExports(), + GetExports(), + GetExports(), + GetExports()); ImageProcessor.AddParts(GetExports()); @@ -1652,7 +1646,7 @@ namespace Emby.Server.Implementations try { - _certificateGenerator(certPath, certHost, password); + CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, password, Logger); } catch (Exception ex) { @@ -2158,7 +2152,7 @@ namespace Emby.Server.Implementations list.Remove(plugin); Plugins = list.ToArray(); } - + /// /// Checks for update. /// @@ -2176,7 +2170,7 @@ namespace Emby.Server.Implementations } var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, updateLevel, _releaseAssetFilename, - "MBServer", "Mbserver.zip", cacheLength, cancellationToken).ConfigureAwait(false); + "MBServer", "Mbserver.zip", cacheLength, cancellationToken).ConfigureAwait(false); HasUpdateAvailable = result.IsUpdateAvailable; @@ -2314,12 +2308,18 @@ namespace Emby.Server.Implementations NotifyPendingRestart(); } + private bool _disposed; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { - Dispose(true); + if (!_disposed) + { + _disposed = true; + + Dispose(true); + } } /// diff --git a/Emby.Server.Implementations/Cryptography/CertificateGenerator.cs b/Emby.Server.Implementations/Cryptography/CertificateGenerator.cs index 2600d74702..b4c84a6003 100644 --- a/Emby.Server.Implementations/Cryptography/CertificateGenerator.cs +++ b/Emby.Server.Implementations/Cryptography/CertificateGenerator.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Security.Cryptography; +using System.Xml; namespace Emby.Server.Core.Cryptography { @@ -27,7 +28,11 @@ namespace Emby.Server.Core.Cryptography DateTime notAfter = DateTime.Now.AddYears(10); RSA issuerKey = RSA.Create(); +#if NET46 issuerKey.FromXmlString(MonoTestRootAgency); +#else + RSACryptoServiceProviderExtensions.FromXmlString(issuerKey, MonoTestRootAgency); +#endif RSA subjectKey = RSA.Create(); // serial number MUST be positive @@ -44,7 +49,7 @@ namespace Emby.Server.Core.Cryptography cb.NotAfter = notAfter; cb.SubjectName = subject; cb.SubjectPublicKey = subjectKey; - + // signature cb.Hash = "SHA256"; byte[] rawcert = cb.Sign(issuerKey); @@ -66,4 +71,39 @@ namespace Emby.Server.Core.Cryptography p12.SaveToFile(fileName); } } + + public static class RSACryptoServiceProviderExtensions + { + public static void FromXmlString(RSA rsa, string xmlString) + { + RSAParameters parameters = new RSAParameters(); + + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(xmlString); + + if (xmlDoc.DocumentElement.Name.Equals("RSAKeyValue")) + { + foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes) + { + switch (node.Name) + { + case "Modulus": parameters.Modulus = Convert.FromBase64String(node.InnerText); break; + case "Exponent": parameters.Exponent = Convert.FromBase64String(node.InnerText); break; + case "P": parameters.P = Convert.FromBase64String(node.InnerText); break; + case "Q": parameters.Q = Convert.FromBase64String(node.InnerText); break; + case "DP": parameters.DP = Convert.FromBase64String(node.InnerText); break; + case "DQ": parameters.DQ = Convert.FromBase64String(node.InnerText); break; + case "InverseQ": parameters.InverseQ = Convert.FromBase64String(node.InnerText); break; + case "D": parameters.D = Convert.FromBase64String(node.InnerText); break; + } + } + } + else + { + throw new Exception("Invalid XML RSA key."); + } + + rsa.ImportParameters(parameters); + } + } } diff --git a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 0999fa1418..f86279f372 100644 --- a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -6,16 +6,16 @@ namespace Emby.Server.Implementations.EnvironmentInfo { public class EnvironmentInfo : IEnvironmentInfo { - public Architecture? CustomArchitecture { get; set; } - public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; } + private Architecture? _customArchitecture; + private MediaBrowser.Model.System.OperatingSystem? _customOperatingSystem; public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem { get { - if (CustomOperatingSystem.HasValue) + if (_customOperatingSystem.HasValue) { - return CustomOperatingSystem.Value; + return _customOperatingSystem.Value; } switch (Environment.OSVersion.Platform) @@ -30,6 +30,10 @@ namespace Emby.Server.Implementations.EnvironmentInfo return MediaBrowser.Model.System.OperatingSystem.Windows; } + set + { + _customOperatingSystem = value; + } } public string OperatingSystemName @@ -60,13 +64,17 @@ namespace Emby.Server.Implementations.EnvironmentInfo { get { - if (CustomArchitecture.HasValue) + if (_customArchitecture.HasValue) { - return CustomArchitecture.Value; + return _customArchitecture.Value; } return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86; } + set + { + _customArchitecture = value; + } } public string GetEnvironmentVariable(string name) diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 1017953ba7..f512b723d8 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -66,8 +66,10 @@ namespace Emby.Server.Implementations.HttpClientManager // http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c ServicePointManager.Expect100Continue = false; - // Trakt requests sometimes fail without this +#if NET46 +// Trakt requests sometimes fail without this ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; +#endif } /// @@ -428,7 +430,7 @@ namespace Emby.Server.Implementations.HttpClientManager try { var bytes = options.RequestContentBytes ?? - Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); + Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; @@ -727,7 +729,7 @@ namespace Emby.Server.Implementations.HttpClientManager } var webException = ex as WebException - ?? ex.InnerException as WebException; + ?? ex.InnerException as WebException; if (webException != null) { @@ -762,7 +764,7 @@ namespace Emby.Server.Implementations.HttpClientManager } var operationCanceledException = ex as OperationCanceledException - ?? ex.InnerException as OperationCanceledException; + ?? ex.InnerException as OperationCanceledException; if (operationCanceledException != null) { diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 019b8162af..211c54ceea 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -71,9 +71,8 @@ namespace Emby.Server.Implementations.Library private readonly IServerApplicationHost _appHost; private readonly IFileSystem _fileSystem; private readonly ICryptoProvider _cryptographyProvider; - private readonly string _defaultUserName; - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, ICryptoProvider cryptographyProvider, string defaultUserName) + public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, ICryptoProvider cryptographyProvider) { _logger = logger; UserRepository = userRepository; @@ -86,7 +85,6 @@ namespace Emby.Server.Implementations.Library _jsonSerializer = jsonSerializer; _fileSystem = fileSystem; _cryptographyProvider = cryptographyProvider; - _defaultUserName = defaultUserName; ConfigurationManager = configurationManager; Users = new List(); @@ -381,7 +379,7 @@ namespace Emby.Server.Implementations.Library // There always has to be at least one user. if (users.Count == 0) { - var name = MakeValidUsername(_defaultUserName); + var name = MakeValidUsername(Environment.UserName); var user = InstantiateNewUser(name); diff --git a/Emby.Server.Implementations/Logging/SimpleLogManager.cs b/Emby.Server.Implementations/Logging/SimpleLogManager.cs index 1a50f162a1..5c83766fe8 100644 --- a/Emby.Server.Implementations/Logging/SimpleLogManager.cs +++ b/Emby.Server.Implementations/Logging/SimpleLogManager.cs @@ -138,10 +138,10 @@ namespace Emby.Server.Implementations.Logging foreach (var message in _queue.GetConsumingEnumerable()) { - any = true; - var bytes = Encoding.UTF8.GetBytes(message + Environment.NewLine); _fileStream.Write(bytes, 0, bytes.Length); + + any = true; } if (any) diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index ab3bd0b315..f78fbdfd72 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -69,8 +69,8 @@ namespace Emby.Server.Implementations.Net if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", "remotePort"); var addressFamily = remoteAddress.AddressFamily == IpAddressFamily.InterNetwork - ? AddressFamily.InterNetwork - : AddressFamily.InterNetworkV6; + ? AddressFamily.InterNetwork + : AddressFamily.InterNetworkV6; var retVal = new Socket(addressFamily, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp); @@ -82,7 +82,7 @@ namespace Emby.Server.Implementations.Net { // This is not supported on all operating systems (qnap) } - + try { return new UdpSocket(retVal, new IpEndPointInfo(remoteAddress, remotePort)); @@ -139,11 +139,11 @@ namespace Emby.Server.Implementations.Net throw; } } - + /// - /// Creates a new UDP acceptSocket that is a member of the SSDP multicast local admin group and binds it to the specified local port. - /// - /// An implementation of the interface used by RSSDP components to perform acceptSocket operations. + /// Creates a new UDP acceptSocket that is a member of the SSDP multicast local admin group and binds it to the specified local port. + /// + /// An implementation of the interface used by RSSDP components to perform acceptSocket operations. public ISocket CreateSsdpUdpSocket(IpAddressInfo localIpAddress, int localPort) { if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); @@ -186,7 +186,16 @@ namespace Emby.Server.Implementations.Net try { + // not supported on all platforms. throws on ubuntu with .net core 2.0 retVal.ExclusiveAddressUse = false; + } + catch (SocketException) + { + + } + + try + { //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive); diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs index b4b2bb139e..675b0d78cd 100644 --- a/Emby.Server.Implementations/ServerApplicationPaths.cs +++ b/Emby.Server.Implementations/ServerApplicationPaths.cs @@ -13,8 +13,8 @@ namespace Emby.Server.Implementations /// /// Initializes a new instance of the class. /// - public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, Action createDirectoryFn) - : base(programDataPath, appFolderPath, createDirectoryFn) + public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath) + : base(programDataPath, appFolderPath) { ApplicationResourcesPath = applicationResourcesPath; } diff --git a/MediaBrowser.Model/Session/PlaybackProgressInfo.cs b/MediaBrowser.Model/Session/PlaybackProgressInfo.cs index 5f81f7269a..0319f67117 100644 --- a/MediaBrowser.Model/Session/PlaybackProgressInfo.cs +++ b/MediaBrowser.Model/Session/PlaybackProgressInfo.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.Model.Session /// The position ticks. public long? PositionTicks { get; set; } - public long? playbackStartTimeTicks { get; set; } + public long? PlaybackStartTimeTicks { get; set; } /// /// Gets or sets the volume level. diff --git a/MediaBrowser.Server.Mono/MonoAppHost.cs b/MediaBrowser.Server.Mono/MonoAppHost.cs index 1153d0f7db..e51324ec4d 100644 --- a/MediaBrowser.Server.Mono/MonoAppHost.cs +++ b/MediaBrowser.Server.Mono/MonoAppHost.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Server.Mono { public class MonoAppHost : ApplicationHost { - public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action certificateGenerator, Func defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory) + public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager) { } diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index c50f97fc12..73a568ca97 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -21,7 +21,6 @@ using Emby.Server.Implementations.Networking; using MediaBrowser.Model.IO; using MediaBrowser.Model.System; using Mono.Unix.Native; -using NLog; using ILogger = MediaBrowser.Model.Logging.ILogger; using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate; @@ -48,7 +47,7 @@ namespace MediaBrowser.Server.Mono var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath); - var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); + var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); logManager.AddConsoleOutput(); @@ -84,9 +83,7 @@ namespace MediaBrowser.Server.Mono var appFolderPath = Path.GetDirectoryName(applicationPath); - Action createDirectoryFn = s => Directory.CreateDirectory(s); - - return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath), createDirectoryFn); + return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath)); } private static readonly TaskCompletionSource ApplicationTaskCompletionSource = new TaskCompletionSource(); @@ -113,10 +110,7 @@ namespace MediaBrowser.Server.Mono environmentInfo, imageEncoder, new SystemEvents(logManager.GetLogger("SystemEvents")), - new MemoryStreamProvider(), - new NetworkManager(logManager.GetLogger("NetworkManager")), - GenerateCertificate, - () => Environment.UserName); + new NetworkManager(logManager.GetLogger("NetworkManager"))); if (options.ContainsOption("-v")) { @@ -141,11 +135,6 @@ namespace MediaBrowser.Server.Mono Task.WaitAll(task); } - private static void GenerateCertificate(string certPath, string certHost, string certPassword) - { - CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger); - } - private static MonoEnvironmentInfo GetEnvironmentInfo() { var info = new MonoEnvironmentInfo(); @@ -156,39 +145,38 @@ namespace MediaBrowser.Server.Mono if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase)) { - //info.OperatingSystem = Startup.Common.OperatingSystem.Osx; + info.OperatingSystem = Model.System.OperatingSystem.OSX; } else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase)) { - //info.OperatingSystem = Startup.Common.OperatingSystem.Linux; + info.OperatingSystem = Model.System.OperatingSystem.Linux; } else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase)) { - //info.OperatingSystem = Startup.Common.OperatingSystem.Bsd; - info.IsBsd = true; + info.OperatingSystem = Model.System.OperatingSystem.BSD; } var archX86 = new Regex("(i|I)[3-6]86"); if (archX86.IsMatch(uname.machine)) { - info.CustomArchitecture = Architecture.X86; + info.SystemArchitecture = Architecture.X86; } else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase)) { - info.CustomArchitecture = Architecture.X64; + info.SystemArchitecture = Architecture.X64; } else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase)) { - info.CustomArchitecture = Architecture.Arm; + info.SystemArchitecture = Architecture.Arm; } else if (System.Environment.Is64BitOperatingSystem) { - info.CustomArchitecture = Architecture.X64; + info.SystemArchitecture = Architecture.X64; } else { - info.CustomArchitecture = Architecture.X86; + info.SystemArchitecture = Architecture.X86; } return info; @@ -308,24 +296,9 @@ namespace MediaBrowser.Server.Mono public class MonoEnvironmentInfo : EnvironmentInfo { - public bool IsBsd { get; set; } - public override string GetUserId() { return Syscall.getuid().ToString(CultureInfo.InvariantCulture); } - - public override Model.System.OperatingSystem OperatingSystem - { - get - { - if (IsBsd) - { - return Model.System.OperatingSystem.BSD; - } - - return base.OperatingSystem; - } - } } } diff --git a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs index 77e6c65fec..0e99bbbad1 100644 --- a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs +++ b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs @@ -1,6 +1,5 @@ using System; using Emby.Drawing; -using Emby.Drawing.ImageMagick; using Emby.Drawing.Skia; using Emby.Server.Core; using Emby.Server.Implementations; diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index fba8f48118..6635cddb7b 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -236,18 +236,16 @@ namespace MediaBrowser.ServerApplication var resourcesPath = Path.GetDirectoryName(applicationPath); - Action createDirectoryFn = s => Directory.CreateDirectory(s); - if (runAsService) { var systemPath = Path.GetDirectoryName(applicationPath); var programDataPath = Path.GetDirectoryName(systemPath); - return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath, createDirectoryFn); + return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath); } - return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath, createDirectoryFn); + return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath); } /// @@ -316,10 +314,7 @@ namespace MediaBrowser.ServerApplication environmentInfo, new NullImageEncoder(), new SystemEvents(logManager.GetLogger("SystemEvents")), - new MemoryStreamProvider(), - new Networking.NetworkManager(logManager.GetLogger("NetworkManager")), - GenerateCertificate, - () => Environment.UserDomainName); + new Networking.NetworkManager(logManager.GetLogger("NetworkManager"))); var initProgress = new Progress(); @@ -366,11 +361,6 @@ namespace MediaBrowser.ServerApplication } } - private static void GenerateCertificate(string certPath, string certHost, string certPassword) - { - CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger); - } - private static ServerNotifyIcon _serverNotifyIcon; private static TaskScheduler _mainTaskScheduler; private static void ShowTrayIcon() diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index eed5bab8d3..2ee2acfc2e 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -201,10 +201,6 @@ {805844ab-e92f-45e6-9d99-4f6d48d129a5} Emby.Dlna - - {6cfee013-6e7c-432b-ac37-cabf0880c69a} - Emby.Drawing.ImageMagick - {2312da6d-ff86-4597-9777-bceec32d96dd} Emby.Drawing.Skia diff --git a/MediaBrowser.ServerApplication/WindowsAppHost.cs b/MediaBrowser.ServerApplication/WindowsAppHost.cs index c872d96e2d..d72bd532e1 100644 --- a/MediaBrowser.ServerApplication/WindowsAppHost.cs +++ b/MediaBrowser.ServerApplication/WindowsAppHost.cs @@ -25,8 +25,8 @@ namespace MediaBrowser.ServerApplication { public class WindowsAppHost : ApplicationHost { - public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action certificateGenerator, Func defaultUsernameFactory) - : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory) + public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) + : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager) { } -- cgit v1.2.3