diff options
Diffstat (limited to 'Emby.Server.Implementations')
15 files changed, 82 insertions, 438 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs index 76d0076a6..3e12bc0b6 100644 --- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs +++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs @@ -12,11 +12,16 @@ namespace Emby.Server.Implementations.AppBase /// <summary> /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class. /// </summary> - protected BaseApplicationPaths(string programDataPath, string appFolderPath, string logDirectoryPath) + protected BaseApplicationPaths( + string programDataPath, + string appFolderPath, + string logDirectoryPath = null, + string configurationDirectoryPath = null) { ProgramDataPath = programDataPath; ProgramSystemPath = appFolderPath; LogDirectoryPath = logDirectoryPath; + ConfigurationDirectoryPath = configurationDirectoryPath; } public string ProgramDataPath { get; private set; } @@ -135,6 +140,11 @@ namespace Emby.Server.Implementations.AppBase } /// <summary> + /// The _config directory + /// </summary> + private string _configurationDirectoryPath; + + /// <summary> /// Gets the path to the application configuration root directory /// </summary> /// <value>The configuration directory path.</value> @@ -142,7 +152,18 @@ namespace Emby.Server.Implementations.AppBase { get { - return Path.Combine(ProgramDataPath, "config"); + if (string.IsNullOrEmpty(_configurationDirectoryPath)) + { + _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config"); + + Directory.CreateDirectory(_configurationDirectoryPath); + } + + return _configurationDirectoryPath; + } + set + { + _configurationDirectoryPath = value; } } diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 236851968..b020b33c3 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -80,7 +80,6 @@ using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Net; -using MediaBrowser.Model.News; using MediaBrowser.Model.Reflection; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; @@ -369,7 +368,6 @@ namespace Emby.Server.Implementations public StartupOptions StartupOptions { get; private set; } - internal IPowerManagement PowerManagement { get; private set; } internal IImageEncoder ImageEncoder { get; private set; } protected IProcessFactory ProcessFactory { get; private set; } @@ -391,7 +389,6 @@ namespace Emby.Server.Implementations ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, - IPowerManagement powerManagement, IEnvironmentInfo environmentInfo, IImageEncoder imageEncoder, ISystemEvents systemEvents, @@ -417,12 +414,9 @@ namespace Emby.Server.Implementations Logger = LoggerFactory.CreateLogger("App"); StartupOptions = options; - PowerManagement = powerManagement; ImageEncoder = imageEncoder; - //SetBaseExceptionMessage(); - fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); NetworkManager.NetworkChanged += NetworkManager_NetworkChanged; @@ -506,14 +500,6 @@ namespace Emby.Server.Implementations return new StreamHelper(); } - public virtual bool SupportsAutoRunAtStartup - { - get - { - return EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows; - } - } - /// <summary> /// Creates an instance of type and resolves all constructor dependancies /// </summary> @@ -687,18 +673,6 @@ namespace Emby.Server.Implementations return parts; } - // TODO: @bond - /* - private void SetBaseExceptionMessage() - { - var builder = GetBaseExceptionMessage(ApplicationPaths); - - builder.Insert(0, string.Format("Version: {0}{1}", ApplicationVersion, Environment.NewLine)); - builder.Insert(0, "*** Error Report ***" + Environment.NewLine); - - LoggerFactory.ExceptionMessagePrefix = builder.ToString(); - }*/ - /// <summary> /// Runs the startup tasks. /// </summary> @@ -706,8 +680,6 @@ namespace Emby.Server.Implementations { Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false)); - ConfigureAutorun(); - ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated; MediaEncoder.Init(); @@ -734,8 +706,6 @@ namespace Emby.Server.Implementations RunEntryPoints(entryPoints, false); Logger.LogInformation("All entry points have started"); - //LoggerFactory.RemoveConsoleOutput(); - return Task.CompletedTask; } @@ -749,7 +719,7 @@ namespace Emby.Server.Implementations } var name = entryPoint.GetType().FullName; - Logger.LogInformation("Starting entry point {0}", name); + Logger.LogInformation("Starting entry point {Name}", name); var now = DateTime.UtcNow; try { @@ -757,24 +727,9 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError(ex, "Error in {name}", name); + Logger.LogError(ex, "Error while running entrypoint {Name}", name); } - Logger.LogInformation("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos"); - } - } - - /// <summary> - /// Configures the autorun. - /// </summary> - private void ConfigureAutorun() - { - try - { - ConfigureAutoRunAtStartup(ConfigurationManager.CommonConfiguration.RunAtStartup); - } - catch (Exception ex) - { - Logger.LogError(ex, "Error configuring autorun"); + Logger.LogInformation("Entry point completed: {Name}. Duration: {Duration} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos"); } } @@ -873,8 +828,6 @@ namespace Emby.Server.Implementations SocketFactory = new SocketFactory(LoggerFactory.CreateLogger("SocketFactory")); RegisterSingleInstance(SocketFactory); - RegisterSingleInstance(PowerManagement); - SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LoggerFactory, FileSystemManager, CryptographyProvider); RegisterSingleInstance(SecurityManager); @@ -1235,8 +1188,7 @@ namespace Emby.Server.Implementations HttpClient, ZipClient, ProcessFactory, - 5000, - EnvironmentInfo); + 5000); MediaEncoder = mediaEncoder; RegisterSingleInstance(MediaEncoder); @@ -1310,7 +1262,6 @@ namespace Emby.Server.Implementations { if (!ServerConfigurationManager.Configuration.IsPortAuthorized) { - RegisterServerWithAdministratorAccess(); ServerConfigurationManager.Configuration.IsPortAuthorized = true; ConfigurationManager.SaveConfiguration(); } @@ -1381,12 +1332,11 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError(ex, "Error getting plugin Id from {pluginName}.", plugin.GetType().FullName); + Logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName); } } - var hasPluginConfiguration = plugin as IHasPluginConfiguration; - if (hasPluginConfiguration != null) + if (plugin is IHasPluginConfiguration hasPluginConfiguration) { hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s)); } @@ -1591,8 +1541,6 @@ namespace Emby.Server.Implementations /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void OnConfigurationUpdated(object sender, EventArgs e) { - ConfigureAutorun(); - var requiresRestart = false; // Don't do anything if these haven't been set yet @@ -1698,25 +1646,25 @@ namespace Emby.Server.Implementations // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that // This will prevent the .dll file from getting locked, and allow us to replace it when needed - // Include composable parts in the Api assembly + // Include composable parts in the Api assembly list.Add(GetAssembly(typeof(ApiEntryPoint))); - // Include composable parts in the Dashboard assembly + // Include composable parts in the Dashboard assembly list.Add(GetAssembly(typeof(DashboardService))); - // Include composable parts in the Model assembly + // Include composable parts in the Model assembly list.Add(GetAssembly(typeof(SystemInfo))); - // Include composable parts in the Common assembly + // Include composable parts in the Common assembly list.Add(GetAssembly(typeof(IApplicationHost))); - // Include composable parts in the Controller assembly + // Include composable parts in the Controller assembly list.Add(GetAssembly(typeof(IServerApplicationHost))); - // Include composable parts in the Providers assembly + // Include composable parts in the Providers assembly list.Add(GetAssembly(typeof(ProviderUtils))); - // Include composable parts in the Photos assembly + // Include composable parts in the Photos assembly list.Add(GetAssembly(typeof(PhotoProvider))); // Emby.Server implementations @@ -1725,16 +1673,16 @@ namespace Emby.Server.Implementations // MediaEncoding list.Add(GetAssembly(typeof(MediaBrowser.MediaEncoding.Encoder.MediaEncoder))); - // Dlna + // Dlna list.Add(GetAssembly(typeof(DlnaEntryPoint))); - // Local metadata + // Local metadata list.Add(GetAssembly(typeof(BoxSetXmlSaver))); // Notifications list.Add(GetAssembly(typeof(NotificationManager))); - // Xbmc + // Xbmc list.Add(GetAssembly(typeof(ArtistNfoProvider))); list.AddRange(GetAssembliesWithPartsInternal().Select(i => new Tuple<Assembly, string>(i, null))); @@ -1805,13 +1753,13 @@ namespace Emby.Server.Implementations { var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion); - Logger.LogInformation("File {0} has version {1}", path, result); + Logger.LogInformation("File {Path} has version {Version}", path, result); return result; } catch (Exception ex) { - Logger.LogError(ex, "Error getting version number from {path}", path); + Logger.LogError(ex, "Error getting version number from {Path}", path); return new Version(1, 0); } @@ -1943,7 +1891,6 @@ namespace Emby.Server.Implementations CanLaunchWebBrowser = CanLaunchWebBrowser, WanAddress = wanAddress, HasUpdateAvailable = HasUpdateAvailable, - SupportsAutoRunAtStartup = SupportsAutoRunAtStartup, TranscodingTempPath = ApplicationPaths.TranscodingTempPath, ServerName = FriendlyName, LocalAddress = localAddress, @@ -2225,32 +2172,6 @@ namespace Emby.Server.Implementations protected abstract void ShutdownInternal(); - /// <summary> - /// Registers the server with administrator access. - /// </summary> - private void RegisterServerWithAdministratorAccess() - { - Logger.LogInformation("Requesting administrative access to authorize http server"); - - try - { - AuthorizeServer(); - } - catch (NotImplementedException) - { - - } - catch (Exception ex) - { - Logger.LogError(ex, "Error authorizing server"); - } - } - - protected virtual void AuthorizeServer() - { - throw new NotImplementedException(); - } - public event EventHandler HasUpdateAvailableChanged; private bool _hasUpdateAvailable; @@ -2297,24 +2218,7 @@ namespace Emby.Server.Implementations } /// <summary> - /// Configures the automatic run at startup. - /// </summary> - /// <param name="autorun">if set to <c>true</c> [autorun].</param> - protected void ConfigureAutoRunAtStartup(bool autorun) - { - if (SupportsAutoRunAtStartup) - { - ConfigureAutoRunInternal(autorun); - } - } - - protected virtual void ConfigureAutoRunInternal(bool autorun) - { - throw new NotImplementedException(); - } - - /// <summary> - /// This returns localhost in the case of no external dns, and the hostname if the + /// This returns localhost in the case of no external dns, and the hostname if the /// dns is prefixed with a valid Uri prefix. /// </summary> /// <param name="externalDns">The external dns prefix to get the hostname of.</param> @@ -2413,15 +2317,14 @@ namespace Emby.Server.Implementations { var type = GetType(); - //LoggerFactory.AddConsoleOutput(); - Logger.LogInformation("Disposing " + type.Name); + Logger.LogInformation("Disposing {Type}", type.Name); var parts = DisposableParts.Distinct().Where(i => i.GetType() != type).ToList(); DisposableParts.Clear(); foreach (var part in parts) { - Logger.LogInformation("Disposing " + part.GetType().Name); + Logger.LogInformation("Disposing {Type}", part.GetType().Name); try { @@ -2429,57 +2332,10 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError(ex, "Error disposing {0}", part.GetType().Name); - } - } - } - } - - private Dictionary<string, string> _values; - public string GetValue(string name) - { - if (_values == null) - { - _values = LoadValues(); - } - - string value; - - if (_values.TryGetValue(name, out value)) - { - return value; - } - - return null; - } - - // TODO: @bond Remove? - private Dictionary<string, string> LoadValues() - { - Dictionary<string, string> values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - - using (var stream = typeof(ApplicationHost).Assembly.GetManifestResourceStream(typeof(ApplicationHost).Namespace + ".values.txt")) - { - using (var reader = new StreamReader(stream)) - { - while (!reader.EndOfStream) - { - var line = reader.ReadLine(); - if (string.IsNullOrEmpty(line)) - { - continue; - } - - var index = line.IndexOf('='); - if (index != -1) - { - values[line.Substring(0, index)] = line.Substring(index + 1); - } + Logger.LogError(ex, "Error disposing {Type}", part.GetType().Name); } } } - - return values; } } diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 241505019..da3a4da07 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -45,7 +45,6 @@ <EmbeddedResource Include="TextEncoding\NLangDetect\Profiles\*" /> <EmbeddedResource Include="TextEncoding\NLangDetect\Utils\messages.properties" /> <EmbeddedResource Include="Localization\Ratings\*.txt" /> - <EmbeddedResource Include="values.txt" /> </ItemGroup> </Project> diff --git a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs b/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs deleted file mode 100644 index a6dadcef0..000000000 --- a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs +++ /dev/null @@ -1,65 +0,0 @@ -using MediaBrowser.Controller; -using MediaBrowser.Controller.Plugins; -using MediaBrowser.Controller.Session; -using Microsoft.Extensions.Logging; -using System; -using System.Linq; -using MediaBrowser.Model.System; -using MediaBrowser.Model.Threading; - -namespace Emby.Server.Implementations.EntryPoints -{ - public class KeepServerAwake : IServerEntryPoint - { - private readonly ISessionManager _sessionManager; - private readonly ILogger _logger; - private ITimer _timer; - private readonly IServerApplicationHost _appHost; - private readonly ITimerFactory _timerFactory; - private readonly IPowerManagement _powerManagement; - - public KeepServerAwake(ISessionManager sessionManager, ILogger logger, IServerApplicationHost appHost, ITimerFactory timerFactory, IPowerManagement powerManagement) - { - _sessionManager = sessionManager; - _logger = logger; - _appHost = appHost; - _timerFactory = timerFactory; - _powerManagement = powerManagement; - } - - public void Run() - { - _timer = _timerFactory.Create(OnTimerCallback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); - } - - private void OnTimerCallback(object state) - { - var now = DateTime.UtcNow; - - try - { - if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15)) - { - _powerManagement.PreventSystemStandby(); - } - else - { - _powerManagement.AllowSystemStandby(); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Error resetting system standby timer"); - } - } - - public void Dispose() - { - if (_timer != null) - { - _timer.Dispose(); - _timer = null; - } - } - } -} diff --git a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 03e10e7ea..655867577 100644 --- a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -1,11 +1,9 @@ using System; -using System.IO; using MediaBrowser.Model.System; using System.Runtime.InteropServices; namespace Emby.Server.Implementations.EnvironmentInfo { - // TODO: Rework @bond public class EnvironmentInfo : IEnvironmentInfo { public EnvironmentInfo(MediaBrowser.Model.System.OperatingSystem operatingSystem) @@ -39,29 +37,6 @@ namespace Emby.Server.Implementations.EnvironmentInfo } } - public char PathSeparator - { - get - { - return Path.PathSeparator; - } - } - public Architecture SystemArchitecture { get { return RuntimeInformation.OSArchitecture; } } - - public string GetEnvironmentVariable(string name) - { - return Environment.GetEnvironmentVariable(name); - } - - public string StackTrace - { - get { return Environment.StackTrace; } - } - - public void SetProcessEnvironmentVariable(string name, string value) - { - Environment.SetEnvironmentVariable(name, value); - } } } diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index e5fd28997..ddda4b2c3 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -160,9 +160,9 @@ namespace Emby.Server.Implementations.Library list.Add(source); } - foreach (var source in list) + if (user != null) { - if (user != null) + foreach (var source in list) { if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 59f9fe86f..81a47bfea 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -75,7 +75,23 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private readonly IStreamHelper _streamHelper; - public EmbyTV(IServerApplicationHost appHost, IStreamHelper streamHelper, IMediaSourceManager mediaSourceManager, IAssemblyInfo assemblyInfo, ILogger logger, IJsonSerializer jsonSerializer, IPowerManagement powerManagement, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IMediaEncoder mediaEncoder, ITimerFactory timerFactory, IProcessFactory processFactory, ISystemEvents systemEvents) + public EmbyTV(IServerApplicationHost appHost, + IStreamHelper streamHelper, + IMediaSourceManager mediaSourceManager, + IAssemblyInfo assemblyInfo, + ILogger logger, + IJsonSerializer jsonSerializer, + IHttpClient httpClient, + IServerConfigurationManager config, + ILiveTvManager liveTvManager, + IFileSystem fileSystem, + ILibraryManager libraryManager, + ILibraryMonitor libraryMonitor, + IProviderManager providerManager, + IMediaEncoder mediaEncoder, + ITimerFactory timerFactory, + IProcessFactory processFactory, + ISystemEvents systemEvents) { Current = this; @@ -97,7 +113,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _streamHelper = streamHelper; _seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers")); - _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory, powerManagement); + _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory); _timerProvider.TimerFired += _timerProvider_TimerFired; _config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated; diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs index 76a044c02..e4ab34770 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs @@ -9,7 +9,6 @@ using MediaBrowser.Model.Serialization; using MediaBrowser.Model.IO; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Threading; -using MediaBrowser.Model.System; namespace Emby.Server.Implementations.LiveTv.EmbyTV { @@ -20,14 +19,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired; private readonly ITimerFactory _timerFactory; - private readonly IPowerManagement _powerManagement; - public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory, IPowerManagement powerManagement) + public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory) : base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase)) { _logger = logger1; _timerFactory = timerFactory; - _powerManagement = powerManagement; } public void RestartTimers() @@ -36,7 +33,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV foreach (var item in GetAll().ToList()) { - AddOrUpdateSystemTimer(item, false); + AddOrUpdateSystemTimer(item); } } @@ -59,7 +56,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public override void Update(TimerInfo item) { base.Update(item); - AddOrUpdateSystemTimer(item, false); + AddOrUpdateSystemTimer(item); } public void AddOrUpdate(TimerInfo item, bool resetTimer) @@ -90,7 +87,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } base.Add(item); - AddOrUpdateSystemTimer(item, true); + AddOrUpdateSystemTimer(item); } private bool ShouldStartTimer(TimerInfo item) @@ -104,7 +101,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return true; } - private void AddOrUpdateSystemTimer(TimerInfo item, bool scheduleSystemWakeTimer) + private void AddOrUpdateSystemTimer(TimerInfo item) { StopTimer(item); @@ -124,23 +121,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var dueTime = startDate - now; StartTimer(item, dueTime); - - if (scheduleSystemWakeTimer && dueTime >= TimeSpan.FromMinutes(15)) - { - ScheduleSystemWakeTimer(startDate, item.Name); - } - } - - private void ScheduleSystemWakeTimer(DateTime startDate, string displayName) - { - try - { - _powerManagement.ScheduleWake(startDate.AddMinutes(-5), displayName); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error scheduling wake timer"); - } } private void StartTimer(TimerInfo item, TimeSpan dueTime) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index b597a935a..a81a0bcbb 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1056,7 +1056,7 @@ namespace Emby.Server.Implementations.LiveTv var numComplete = 0; double progressPerService = _services.Length == 0 ? 0 - : 1 / _services.Length; + : 1.0 / _services.Length; var newChannelIdList = new List<Guid>(); var newProgramIdList = new List<Guid>(); @@ -1262,7 +1262,7 @@ namespace Emby.Server.Implementations.LiveTv } numComplete++; - double percent = numComplete / allChannelsList.Count; + double percent = numComplete / (double) allChannelsList.Count; progress.Report(85 * percent + 15); } @@ -1307,7 +1307,7 @@ namespace Emby.Server.Implementations.LiveTv } numComplete++; - double percent = numComplete / list.Count; + double percent = numComplete / (double) list.Count; progress.Report(100 * percent); } diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs index b754d7cb5..95395f96c 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs @@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks foreach (var file in filesToDelete) { - double percent = index / filesToDelete.Count; + double percent = index / (double) filesToDelete.Count; progress.Report(100 * percent); diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs index f5986f943..8a0f2671a 100644 --- a/Emby.Server.Implementations/ServerApplicationPaths.cs +++ b/Emby.Server.Implementations/ServerApplicationPaths.cs @@ -13,8 +13,13 @@ namespace Emby.Server.Implementations /// <summary> /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class. /// </summary> - public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, string logDirectoryPath = null) - : base(programDataPath, appFolderPath, logDirectoryPath) + public ServerApplicationPaths( + string programDataPath, + string appFolderPath, + string applicationResourcesPath, + string logDirectoryPath = null, + string configurationDirectoryPath = null) + : base(programDataPath, appFolderPath, logDirectoryPath, configurationDirectoryPath) { ApplicationResourcesPath = applicationResourcesPath; } diff --git a/Emby.Server.Implementations/Session/FirebaseSessionController.cs b/Emby.Server.Implementations/Session/FirebaseSessionController.cs deleted file mode 100644 index cfe513305..000000000 --- a/Emby.Server.Implementations/Session/FirebaseSessionController.cs +++ /dev/null @@ -1,131 +0,0 @@ -using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Net; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Serialization; -using System; -using System.Threading; -using System.Threading.Tasks; -using System.Text; -using MediaBrowser.Common; - -namespace Emby.Server.Implementations.Session -{ - public class FirebaseSessionController : ISessionController - { - private readonly IHttpClient _httpClient; - private readonly IJsonSerializer _json; - private readonly ISessionManager _sessionManager; - - public SessionInfo Session { get; private set; } - - private readonly string _token; - - private IApplicationHost _appHost; - private string _senderId; - private string _applicationId; - - public FirebaseSessionController(IHttpClient httpClient, - IApplicationHost appHost, - IJsonSerializer json, - SessionInfo session, - string token, ISessionManager sessionManager) - { - _httpClient = httpClient; - _json = json; - _appHost = appHost; - Session = session; - _token = token; - _sessionManager = sessionManager; - - _applicationId = _appHost.GetValue("firebase_applicationid"); - _senderId = _appHost.GetValue("firebase_senderid"); - } - - public static bool IsSupported(IApplicationHost appHost) - { - return !string.IsNullOrEmpty(appHost.GetValue("firebase_applicationid")) && !string.IsNullOrEmpty(appHost.GetValue("firebase_senderid")); - } - - public bool IsSessionActive - { - get - { - return (DateTime.UtcNow - Session.LastActivityDate).TotalDays <= 3; - } - } - - public bool SupportsMediaControl - { - get { return true; } - } - - public async Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken) - { - if (!IsSessionActive) - { - return; - } - - if (string.IsNullOrEmpty(_senderId) || string.IsNullOrEmpty(_applicationId)) - { - return; - } - - foreach (var controller in allControllers) - { - // Don't send if there's an active web socket connection - if ((controller is WebSocketController) && controller.IsSessionActive) - { - return; - } - } - - var msg = new WebSocketMessage<T> - { - Data = data, - MessageType = name, - MessageId = messageId, - ServerId = _appHost.SystemId - }; - - var req = new FirebaseBody<T> - { - to = _token, - data = msg - }; - - var byteArray = Encoding.UTF8.GetBytes(_json.SerializeToString(req)); - - var enableLogging = false; - -#if DEBUG - enableLogging = true; -#endif - - var options = new HttpRequestOptions - { - Url = "https://fcm.googleapis.com/fcm/send", - RequestContentType = "application/json", - RequestContentBytes = byteArray, - CancellationToken = cancellationToken, - LogRequest = enableLogging, - LogResponse = enableLogging, - LogErrors = enableLogging - }; - - options.RequestHeaders["Authorization"] = string.Format("key={0}", _applicationId); - options.RequestHeaders["Sender"] = string.Format("id={0}", _senderId); - - using (var response = await _httpClient.Post(options).ConfigureAwait(false)) - { - - } - } - } - - internal class FirebaseBody<T> - { - public string to { get; set; } - public WebSocketMessage<T> data { get; set; } - } -} diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 419c24f13..7321e9f86 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1574,14 +1574,6 @@ namespace Emby.Server.Implementations.Session { session.Capabilities = capabilities; - if (!string.IsNullOrEmpty(capabilities.PushToken)) - { - if (string.Equals(capabilities.PushTokenType, "firebase", StringComparison.OrdinalIgnoreCase) && FirebaseSessionController.IsSupported(_appHost)) - { - EnsureFirebaseController(session, capabilities.PushToken); - } - } - if (saveCapabilities) { CapabilitiesChanged?.Invoke(this, new SessionEventArgs @@ -1600,11 +1592,6 @@ namespace Emby.Server.Implementations.Session } } - private void EnsureFirebaseController(SessionInfo session, string token) - { - session.EnsureController<FirebaseSessionController>(s => new FirebaseSessionController(_httpClient, _appHost, _jsonSerializer, s, token, this)); - } - private ClientCapabilities GetSavedCapabilities(string deviceId) { return _deviceManager.GetCapabilities(deviceId); diff --git a/Emby.Server.Implementations/Udp/UdpServer.cs b/Emby.Server.Implementations/Udp/UdpServer.cs index 8cacc1124..275bd83ea 100644 --- a/Emby.Server.Implementations/Udp/UdpServer.cs +++ b/Emby.Server.Implementations/Udp/UdpServer.cs @@ -40,6 +40,7 @@ namespace Emby.Server.Implementations.Udp _json = json; _socketFactory = socketFactory; + AddMessageResponder("who is JellyfinServer?", true, RespondToV2Message); AddMessageResponder("who is EmbyServer?", true, RespondToV2Message); AddMessageResponder("who is MediaBrowserServer_v2?", false, RespondToV2Message); } diff --git a/Emby.Server.Implementations/values.txt b/Emby.Server.Implementations/values.txt deleted file mode 100644 index e69de29bb..000000000 --- a/Emby.Server.Implementations/values.txt +++ /dev/null |
