extracted an installation manager interface
This commit is contained in:
parent
4c725e69a8
commit
bf9e24502c
|
@ -1,8 +1,7 @@
|
|||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Implementations.HttpServer;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Model.Updates;
|
||||
using ServiceStack.ServiceHost;
|
||||
using System;
|
||||
|
@ -95,11 +94,14 @@ namespace MediaBrowser.Api
|
|||
/// </summary>
|
||||
public class PackageService : BaseRestService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the application host.
|
||||
/// </summary>
|
||||
/// <value>The application host.</value>
|
||||
public IApplicationHost ApplicationHost { get; set; }
|
||||
private readonly IInstallationManager _installationManager;
|
||||
private readonly IApplicationHost _appHost;
|
||||
|
||||
public PackageService(IInstallationManager installationManager, IApplicationHost appHost)
|
||||
{
|
||||
_installationManager = installationManager;
|
||||
_appHost = appHost;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
|
@ -113,12 +115,12 @@ namespace MediaBrowser.Api
|
|||
|
||||
if (request.PackageType == PackageType.UserInstalled || request.PackageType == PackageType.All)
|
||||
{
|
||||
result.AddRange(Kernel.Instance.InstallationManager.GetAvailablePluginUpdates(false, CancellationToken.None).Result.ToList());
|
||||
result.AddRange(_installationManager.GetAvailablePluginUpdates(false, CancellationToken.None).Result.ToList());
|
||||
}
|
||||
|
||||
else if (request.PackageType == PackageType.System || request.PackageType == PackageType.All)
|
||||
{
|
||||
var updateCheckResult = ApplicationHost.CheckForApplicationUpdate(CancellationToken.None, new Progress<double> { }).Result;
|
||||
var updateCheckResult = _appHost.CheckForApplicationUpdate(CancellationToken.None, new Progress<double> { }).Result;
|
||||
|
||||
if (updateCheckResult.IsUpdateAvailable)
|
||||
{
|
||||
|
@ -136,7 +138,7 @@ namespace MediaBrowser.Api
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetPackage request)
|
||||
{
|
||||
var packages = Kernel.Instance.InstallationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: ApplicationHost.ApplicationVersion).Result;
|
||||
var packages = _installationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: _appHost.ApplicationVersion).Result;
|
||||
|
||||
var result = packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
|
@ -150,7 +152,7 @@ namespace MediaBrowser.Api
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetPackages request)
|
||||
{
|
||||
var packages = Kernel.Instance.InstallationManager.GetAvailablePackages(CancellationToken.None, request.PackageType, ApplicationHost.ApplicationVersion).Result;
|
||||
var packages = _installationManager.GetAvailablePackages(CancellationToken.None, request.PackageType, _appHost.ApplicationVersion).Result;
|
||||
|
||||
return ToOptimizedResult(packages.ToList());
|
||||
}
|
||||
|
@ -163,15 +165,15 @@ namespace MediaBrowser.Api
|
|||
public void Post(InstallPackage request)
|
||||
{
|
||||
var package = string.IsNullOrEmpty(request.Version) ?
|
||||
Kernel.Instance.InstallationManager.GetLatestCompatibleVersion(request.Name, request.UpdateClass).Result :
|
||||
Kernel.Instance.InstallationManager.GetPackage(request.Name, request.UpdateClass, Version.Parse(request.Version)).Result;
|
||||
_installationManager.GetLatestCompatibleVersion(request.Name, request.UpdateClass).Result :
|
||||
_installationManager.GetPackage(request.Name, request.UpdateClass, Version.Parse(request.Version)).Result;
|
||||
|
||||
if (package == null)
|
||||
{
|
||||
throw new ResourceNotFoundException(string.Format("Package not found: {0}", request.Name));
|
||||
}
|
||||
|
||||
Task.Run(() => Kernel.Instance.InstallationManager.InstallPackage(package, new Progress<double> { }, CancellationToken.None));
|
||||
Task.Run(() => _installationManager.InstallPackage(package, new Progress<double> { }, CancellationToken.None));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -180,7 +182,7 @@ namespace MediaBrowser.Api
|
|||
/// <param name="request">The request.</param>
|
||||
public void Delete(CancelPackageInstallation request)
|
||||
{
|
||||
var info = Kernel.Instance.InstallationManager.CurrentInstallations.FirstOrDefault(i => i.Item1.Id == request.Id);
|
||||
var info = _installationManager.CurrentInstallations.FirstOrDefault(i => i.Item1.Id == request.Id);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Common.Extensions;
|
|||
using MediaBrowser.Common.Implementations.HttpServer;
|
||||
using MediaBrowser.Common.Security;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
@ -127,6 +128,8 @@ namespace MediaBrowser.Api
|
|||
|
||||
private readonly ISecurityManager _securityManager;
|
||||
|
||||
private readonly IInstallationManager _installationManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginService" /> class.
|
||||
/// </summary>
|
||||
|
@ -134,7 +137,7 @@ namespace MediaBrowser.Api
|
|||
/// <param name="appHost">The app host.</param>
|
||||
/// <param name="securityManager">The security manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
||||
public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, ISecurityManager securityManager)
|
||||
public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, ISecurityManager securityManager, IInstallationManager installationManager)
|
||||
: base()
|
||||
{
|
||||
if (jsonSerializer == null)
|
||||
|
@ -144,6 +147,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
_appHost = appHost;
|
||||
_securityManager = securityManager;
|
||||
_installationManager = installationManager;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
}
|
||||
|
||||
|
@ -254,7 +258,7 @@ namespace MediaBrowser.Api
|
|||
{
|
||||
var plugin = _appHost.Plugins.First(p => p.Id == request.Id);
|
||||
|
||||
Kernel.Instance.InstallationManager.UninstallPlugin(plugin);
|
||||
_installationManager.UninstallPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,8 @@ namespace MediaBrowser.Common.Implementations
|
|||
protected IKernel Kernel { get; private set; }
|
||||
protected ITaskManager TaskManager { get; private set; }
|
||||
protected ISecurityManager SecurityManager { get; private set; }
|
||||
protected IPackageManager PackageManager { get; private set; }
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
protected IConfigurationManager ConfigurationManager { get; private set; }
|
||||
|
||||
|
@ -249,18 +251,20 @@ namespace MediaBrowser.Common.Implementations
|
|||
RegisterSingleInstance(ProtobufSerializer);
|
||||
RegisterSingleInstance<IUdpServer>(new UdpServer(Logger), false);
|
||||
|
||||
var httpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger);
|
||||
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger);
|
||||
|
||||
RegisterSingleInstance<IHttpClient>(httpClient);
|
||||
RegisterSingleInstance(HttpClient);
|
||||
|
||||
RegisterSingleInstance<INetworkManager>(networkManager);
|
||||
RegisterSingleInstance<IServerManager>(serverManager);
|
||||
|
||||
SecurityManager = new PluginSecurityManager(Kernel, httpClient, JsonSerializer, ApplicationPaths);
|
||||
SecurityManager = new PluginSecurityManager(Kernel, HttpClient, JsonSerializer, ApplicationPaths);
|
||||
|
||||
RegisterSingleInstance(SecurityManager);
|
||||
|
||||
RegisterSingleInstance<IPackageManager>(new PackageManager(SecurityManager, networkManager, httpClient, ApplicationPaths, JsonSerializer, Logger));
|
||||
PackageManager = new PackageManager(SecurityManager, networkManager, HttpClient, ApplicationPaths, JsonSerializer, Logger);
|
||||
|
||||
RegisterSingleInstance(PackageManager);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,6 @@ namespace MediaBrowser.Controller
|
|||
/// <value>The FFMPEG controller.</value>
|
||||
public FFMpegManager FFMpegManager { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the installation manager.
|
||||
/// </summary>
|
||||
/// <value>The installation manager.</value>
|
||||
public InstallationManager InstallationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file system manager.
|
||||
/// </summary>
|
||||
|
@ -331,10 +325,12 @@ namespace MediaBrowser.Controller
|
|||
{
|
||||
var info = base.GetSystemInfo();
|
||||
|
||||
if (InstallationManager != null)
|
||||
var installationManager = ApplicationHost.Resolve<IInstallationManager>();
|
||||
|
||||
if (installationManager != null)
|
||||
{
|
||||
info.InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToArray();
|
||||
info.CompletedInstallations = InstallationManager.CompletedInstallations.ToArray();
|
||||
info.InProgressInstallations = installationManager.CurrentInstallations.Select(i => i.Item1).ToArray();
|
||||
info.CompletedInstallations = installationManager.CompletedInstallations.ToArray();
|
||||
}
|
||||
|
||||
return info;
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
<Compile Include="Providers\MediaInfo\FFProbeVideoInfoProvider.cs" />
|
||||
<Compile Include="Sorting\BaseItemComparer.cs" />
|
||||
<Compile Include="Sorting\SortOrder.cs" />
|
||||
<Compile Include="Updates\InstallationManager.cs" />
|
||||
<Compile Include="Updates\IInstallationManager.cs" />
|
||||
<Compile Include="Weather\IWeatherProvider.cs" />
|
||||
<Compile Include="Providers\BaseItemXmlParser.cs" />
|
||||
</ItemGroup>
|
||||
|
|
106
MediaBrowser.Controller/Updates/IInstallationManager.cs
Normal file
106
MediaBrowser.Controller/Updates/IInstallationManager.cs
Normal file
|
@ -0,0 +1,106 @@
|
|||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Model.Updates;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Updates
|
||||
{
|
||||
public interface IInstallationManager : IDisposable
|
||||
{
|
||||
event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstalling;
|
||||
event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCompleted;
|
||||
event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationFailed;
|
||||
event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCancelled;
|
||||
|
||||
/// <summary>
|
||||
/// The current installations
|
||||
/// </summary>
|
||||
List<Tuple<InstallationInfo, CancellationTokenSource>> CurrentInstallations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The completed installations
|
||||
/// </summary>
|
||||
ConcurrentBag<InstallationInfo> CompletedInstallations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [plugin uninstalled].
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [plugin updated].
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>>> PluginUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [plugin updated].
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
|
||||
|
||||
/// <summary>
|
||||
/// Gets all available packages.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="packageType">Type of the package.</param>
|
||||
/// <param name="applicationVersion">The application version.</param>
|
||||
/// <returns>Task{List{PackageInfo}}.</returns>
|
||||
Task<IEnumerable<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken,
|
||||
PackageType? packageType = null,
|
||||
Version applicationVersion = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the package.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <param name="version">The version.</param>
|
||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
||||
Task<PackageVersionInfo> GetPackage(string name, PackageVersionClass classification, Version version);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the latest compatible version.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
||||
Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, PackageVersionClass classification = PackageVersionClass.Release);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the latest compatible version.
|
||||
/// </summary>
|
||||
/// <param name="availablePackages">The available packages.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="classification">The classification.</param>
|
||||
/// <returns>PackageVersionInfo.</returns>
|
||||
PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available plugin updates.
|
||||
/// </summary>
|
||||
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
|
||||
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Installs the package.
|
||||
/// </summary>
|
||||
/// <param name="package">The package.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">package</exception>
|
||||
Task InstallPackage(PackageVersionInfo package, IProgress<double> progress, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls a plugin
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin.</param>
|
||||
/// <exception cref="System.ArgumentException"></exception>
|
||||
void UninstallPlugin(IPlugin plugin);
|
||||
}
|
||||
}
|
|
@ -88,6 +88,7 @@
|
|||
<Compile Include="Sqlite\SQLiteRepository.cs" />
|
||||
<Compile Include="Sqlite\SQLiteUserDataRepository.cs" />
|
||||
<Compile Include="Sqlite\SQLiteUserRepository.cs" />
|
||||
<Compile Include="Updates\InstallationManager.cs" />
|
||||
<Compile Include="WorldWeatherOnline\WeatherProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
|
@ -25,15 +26,18 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private IInstallationManager _installationManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginUpdateTask" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public PluginUpdateTask(Kernel kernel, ILogger logger)
|
||||
public PluginUpdateTask(Kernel kernel, ILogger logger, IInstallationManager installationManager)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_logger = logger;
|
||||
_installationManager = installationManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -61,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||
{
|
||||
progress.Report(0);
|
||||
|
||||
var packagesToInstall = (await _kernel.InstallationManager.GetAvailablePluginUpdates(true, cancellationToken).ConfigureAwait(false)).ToList();
|
||||
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(true, cancellationToken).ConfigureAwait(false)).ToList();
|
||||
|
||||
progress.Report(10);
|
||||
|
||||
|
@ -74,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||
|
||||
try
|
||||
{
|
||||
await _kernel.InstallationManager.InstallPackage(i, new Progress<double> { }, cancellationToken).ConfigureAwait(false);
|
||||
await _installationManager.InstallPackage(i, new Progress<double> { }, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,8 @@ using MediaBrowser.Common.Net;
|
|||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Updates;
|
||||
|
@ -17,12 +18,12 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Updates
|
||||
namespace MediaBrowser.Server.Implementations.Updates
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages all install, uninstall and update operations (both plugins and system)
|
||||
/// </summary>
|
||||
public class InstallationManager : BaseManager<Kernel>
|
||||
public class InstallationManager : IInstallationManager
|
||||
{
|
||||
public event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstalling;
|
||||
public event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCompleted;
|
||||
|
@ -65,7 +66,7 @@ namespace MediaBrowser.Controller.Updates
|
|||
/// </summary>
|
||||
/// <param name="plugin">The plugin.</param>
|
||||
/// <param name="newVersion">The new version.</param>
|
||||
public void OnPluginUpdated(IPlugin plugin, PackageVersionInfo newVersion)
|
||||
private void OnPluginUpdated(IPlugin plugin, PackageVersionInfo newVersion)
|
||||
{
|
||||
_logger.Info("Plugin updated: {0} {1} {2}", newVersion.name, newVersion.version, newVersion.classification);
|
||||
|
||||
|
@ -84,7 +85,7 @@ namespace MediaBrowser.Controller.Updates
|
|||
/// Called when [plugin installed].
|
||||
/// </summary>
|
||||
/// <param name="package">The package.</param>
|
||||
public void OnPluginInstalled(PackageVersionInfo package)
|
||||
private void OnPluginInstalled(PackageVersionInfo package)
|
||||
{
|
||||
_logger.Info("New plugin installed: {0} {1} {2}", package.name, package.version, package.classification);
|
||||
|
||||
|
@ -99,11 +100,6 @@ namespace MediaBrowser.Controller.Updates
|
|||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// The _network manager
|
||||
/// </summary>
|
||||
private readonly INetworkManager _networkManager;
|
||||
|
||||
/// <summary>
|
||||
/// The package manager
|
||||
/// </summary>
|
||||
|
@ -127,24 +123,20 @@ namespace MediaBrowser.Controller.Updates
|
|||
/// <value>The application host.</value>
|
||||
protected IApplicationHost ApplicationHost { get; private set; }
|
||||
|
||||
private IKernel Kernel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InstallationManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="networkManager">The network manager.</param>
|
||||
/// <param name="packageManager">The package manager.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="appHost">The app host.</param>
|
||||
/// <exception cref="System.ArgumentNullException">zipClient</exception>
|
||||
public InstallationManager(Kernel kernel, IHttpClient httpClient, INetworkManager networkManager, IPackageManager packageManager, IJsonSerializer jsonSerializer, ILogger logger, IApplicationHost appHost)
|
||||
: base(kernel)
|
||||
public InstallationManager(IKernel kernel, IHttpClient httpClient, IPackageManager packageManager, IJsonSerializer jsonSerializer, ILogger logger, IApplicationHost appHost)
|
||||
{
|
||||
if (networkManager == null)
|
||||
{
|
||||
throw new ArgumentNullException("networkManager");
|
||||
}
|
||||
if (packageManager == null)
|
||||
{
|
||||
throw new ArgumentNullException("packageManager");
|
||||
|
@ -167,9 +159,9 @@ namespace MediaBrowser.Controller.Updates
|
|||
JsonSerializer = jsonSerializer;
|
||||
HttpClient = httpClient;
|
||||
ApplicationHost = appHost;
|
||||
_networkManager = networkManager;
|
||||
_packageManager = packageManager;
|
||||
_logger = logger;
|
||||
Kernel = kernel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -474,7 +466,7 @@ namespace MediaBrowser.Controller.Updates
|
|||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool dispose)
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
|
@ -488,7 +480,11 @@ namespace MediaBrowser.Controller.Updates
|
|||
CurrentInstallations.Clear();
|
||||
}
|
||||
}
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ using MediaBrowser.Server.Implementations;
|
|||
using MediaBrowser.Server.Implementations.BdInfo;
|
||||
using MediaBrowser.Server.Implementations.Configuration;
|
||||
using MediaBrowser.Server.Implementations.Library;
|
||||
using MediaBrowser.Server.Implementations.Updates;
|
||||
using MediaBrowser.ServerApplication.Implementations;
|
||||
using MediaBrowser.WebDashboard.Api;
|
||||
using System;
|
||||
|
@ -42,11 +43,6 @@ namespace MediaBrowser.ServerApplication
|
|||
/// </summary>
|
||||
public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>
|
||||
{
|
||||
/// <summary>
|
||||
/// The _web socket events
|
||||
/// </summary>
|
||||
private WebSocketEvents _webSocketEvents;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the server kernel.
|
||||
/// </summary>
|
||||
|
@ -114,6 +110,8 @@ namespace MediaBrowser.ServerApplication
|
|||
RegisterSingleInstance<IUserManager>(userManager);
|
||||
|
||||
RegisterSingleInstance<ILibraryManager>(new LibraryManager(ServerKernel, Logger, TaskManager, userManager, ServerConfigurationManager));
|
||||
|
||||
RegisterSingleInstance<IInstallationManager>(new InstallationManager(Kernel, HttpClient, PackageManager, JsonSerializer, Logger, this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -124,10 +122,6 @@ namespace MediaBrowser.ServerApplication
|
|||
base.FindParts();
|
||||
|
||||
Resolve<ILibraryManager>().AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>());
|
||||
|
||||
ServerKernel.InstallationManager = (InstallationManager)CreateInstance(typeof(InstallationManager));
|
||||
|
||||
_webSocketEvents = new WebSocketEvents(Resolve<IServerManager>(), Resolve<IKernel>(), Resolve<ILogger>(), Resolve<IUserManager>(), Resolve<ILibraryManager>(), ServerKernel.InstallationManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -157,7 +151,7 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
var pkgManager = Resolve<IPackageManager>();
|
||||
var availablePackages = await pkgManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
||||
var version = ServerKernel.InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||
var version = Resolve<IInstallationManager>().GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||
|
||||
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
||||
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
|
||||
|
@ -223,22 +217,5 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
App.Instance.Dispatcher.Invoke(App.Instance.Shutdown);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
if (_webSocketEvents != null)
|
||||
{
|
||||
_webSocketEvents.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Common.Kernel;
|
|||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Updates;
|
||||
|
@ -13,7 +14,7 @@ namespace MediaBrowser.ServerApplication
|
|||
/// <summary>
|
||||
/// Class WebSocketEvents
|
||||
/// </summary>
|
||||
public class WebSocketEvents : IDisposable
|
||||
public class WebSocketEvents : IServerEntryPoint, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The _server manager
|
||||
|
@ -37,7 +38,7 @@ namespace MediaBrowser.ServerApplication
|
|||
/// <summary>
|
||||
/// The _installation manager
|
||||
/// </summary>
|
||||
private readonly InstallationManager _installationManager;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _kernel
|
||||
|
@ -50,7 +51,7 @@ namespace MediaBrowser.ServerApplication
|
|||
/// <param name="serverManager">The server manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
public WebSocketEvents(IServerManager serverManager, IKernel kernel, ILogger logger, IUserManager userManager, ILibraryManager libraryManager, InstallationManager installationManager)
|
||||
public WebSocketEvents(IServerManager serverManager, IKernel kernel, ILogger logger, IUserManager userManager, ILibraryManager libraryManager, IInstallationManager installationManager)
|
||||
{
|
||||
_serverManager = serverManager;
|
||||
_logger = logger;
|
||||
|
@ -58,19 +59,22 @@ namespace MediaBrowser.ServerApplication
|
|||
_libraryManager = libraryManager;
|
||||
_installationManager = installationManager;
|
||||
_kernel = kernel;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
_userManager.UserDeleted += userManager_UserDeleted;
|
||||
_userManager.UserUpdated += userManager_UserUpdated;
|
||||
|
||||
_libraryManager.LibraryChanged += libraryManager_LibraryChanged;
|
||||
|
||||
kernel.HasPendingRestartChanged += kernel_HasPendingRestartChanged;
|
||||
_kernel.HasPendingRestartChanged += kernel_HasPendingRestartChanged;
|
||||
|
||||
installationManager.PluginUninstalled += InstallationManager_PluginUninstalled;
|
||||
installationManager.PackageInstalling += installationManager_PackageInstalling;
|
||||
installationManager.PackageInstallationCancelled += installationManager_PackageInstallationCancelled;
|
||||
installationManager.PackageInstallationCompleted += installationManager_PackageInstallationCompleted;
|
||||
installationManager.PackageInstallationFailed += installationManager_PackageInstallationFailed;
|
||||
_installationManager.PluginUninstalled += InstallationManager_PluginUninstalled;
|
||||
_installationManager.PackageInstalling += installationManager_PackageInstalling;
|
||||
_installationManager.PackageInstallationCancelled += installationManager_PackageInstallationCancelled;
|
||||
_installationManager.PackageInstallationCompleted += installationManager_PackageInstallationCompleted;
|
||||
_installationManager.PackageInstallationFailed += installationManager_PackageInstallationFailed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.31</version>
|
||||
<version>3.0.32</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.31" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.32" />
|
||||
<dependency id="NLog" version="2.0.0.2000" />
|
||||
<dependency id="ServiceStack" version="3.9.38" />
|
||||
<dependency id="ServiceStack.Api.Swagger" version="3.9.38" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.31</version>
|
||||
<version>3.0.32</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.31</version>
|
||||
<version>3.0.32</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.31" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.32" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue
Block a user