diff options
| author | Claus Vium <clausvium@gmail.com> | 2019-01-04 22:42:56 +0100 |
|---|---|---|
| committer | Bond-009 <bond.009@outlook.com> | 2019-01-15 16:48:21 +0100 |
| commit | eca3c099d9bd54f1e745143589c12fb9008aee13 (patch) | |
| tree | 445f258922be4f14247a6e76624c74647f3aa6ae /MediaBrowser.Api/PluginService.cs | |
| parent | 8ea0c7207084e333be4973874b1e082a3166742f (diff) | |
removed a bunch of validation, security, registration, premiere, whatever bs
Diffstat (limited to 'MediaBrowser.Api/PluginService.cs')
| -rw-r--r-- | MediaBrowser.Api/PluginService.cs | 199 |
1 files changed, 41 insertions, 158 deletions
diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index c5a94e77c..75defa998 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -1,16 +1,13 @@ using MediaBrowser.Common; using MediaBrowser.Common.Net; -using MediaBrowser.Common.Security; using MediaBrowser.Common.Updates; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; using System; using System.IO; using System.Linq; -using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Common.Plugins; @@ -79,55 +76,6 @@ namespace MediaBrowser.Api public Stream RequestStream { get; set; } } - /// <summary> - /// Class GetPluginSecurityInfo - /// </summary> - [Route("/Plugins/SecurityInfo", "GET", Summary = "Gets plugin registration information", IsHidden = true)] - [Authenticated] - public class GetPluginSecurityInfo : IReturn<PluginSecurityInfo> - { - } - - /// <summary> - /// Class UpdatePluginSecurityInfo - /// </summary> - [Route("/Plugins/SecurityInfo", "POST", Summary = "Updates plugin registration information", IsHidden = true)] - [Authenticated(Roles = "Admin")] - public class UpdatePluginSecurityInfo : PluginSecurityInfo, IReturnVoid - { - } - - [Route("/Plugins/RegistrationRecords/{Name}", "GET", Summary = "Gets registration status for a feature", IsHidden = true)] - [Authenticated] - public class GetRegistrationStatus - { - [ApiMember(Name = "Name", Description = "Feature Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public string Name { get; set; } - } - - [Route("/Registrations/{Name}", "GET", Summary = "Gets registration status for a feature", IsHidden = true)] - [Authenticated] - public class GetRegistration : IReturn<RegistrationInfo> - { - [ApiMember(Name = "Name", Description = "Feature Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public string Name { get; set; } - } - - public class RegistrationInfo - { - public string Name { get; set; } - public DateTime ExpirationDate { get; set; } - public bool IsTrial { get; set; } - public bool IsRegistered { get; set; } - } - - [Route("/Appstore/Register", "POST", Summary = "Registers an appstore sale", IsHidden = true)] - [Authenticated] - public class RegisterAppstoreSale - { - [ApiMember(Name = "Parameters", Description = "Java representation of parameters to pass through to admin server", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Parameters { get; set; } - } /// <summary> /// Class PluginsService @@ -143,14 +91,11 @@ namespace MediaBrowser.Api /// The _app host /// </summary> private readonly IApplicationHost _appHost; - - private readonly ISecurityManager _securityManager; - private readonly IInstallationManager _installationManager; private readonly INetworkManager _network; private readonly IDeviceManager _deviceManager; - public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, ISecurityManager securityManager, IInstallationManager installationManager, INetworkManager network, IDeviceManager deviceManager) + public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, IInstallationManager installationManager, INetworkManager network, IDeviceManager deviceManager) : base() { if (jsonSerializer == null) @@ -159,39 +104,12 @@ namespace MediaBrowser.Api } _appHost = appHost; - _securityManager = securityManager; _installationManager = installationManager; _network = network; _deviceManager = deviceManager; _jsonSerializer = jsonSerializer; } - /// <summary> - /// Gets the specified request. - /// </summary> - /// <param name="request">The request.</param> - /// <returns>System.Object.</returns> - public async Task<object> Get(GetRegistrationStatus request) - { - var result = await _securityManager.GetRegistrationStatus(request.Name).ConfigureAwait(false); - - return ToOptimizedResult(result); - } - - public async Task<object> Get(GetRegistration request) - { - var result = await _securityManager.GetRegistrationStatus(request.Name).ConfigureAwait(false); - - var info = new RegistrationInfo - { - ExpirationDate = result.ExpirationDate, - IsRegistered = result.IsRegistered, - IsTrial = result.TrialVersion, - Name = request.Name - }; - - return ToOptimizedResult(info); - } /// <summary> /// Gets the specified request. @@ -200,46 +118,46 @@ namespace MediaBrowser.Api /// <returns>System.Object.</returns> public async Task<object> Get(GetPlugins request) { - var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToArray(); - var requireAppStoreEnabled = request.IsAppStoreEnabled.HasValue && request.IsAppStoreEnabled.Value; - - // Don't fail just on account of image url's - try - { - var packages = (await _installationManager.GetAvailablePackagesWithoutRegistrationInfo(CancellationToken.None)); - - foreach (var plugin in result) - { - var pkg = packages.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i.guid) && string.Equals(i.guid.Replace("-", string.Empty), plugin.Id.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase)); - - if (pkg != null) - { - plugin.ImageUrl = pkg.thumbImage; - } - } - - if (requireAppStoreEnabled) - { - result = result - .Where(plugin => - { - var pkg = packages.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i.guid) && new Guid(plugin.Id).Equals(new Guid(i.guid))); - return pkg != null && pkg.enableInAppStore; - - }) - .ToArray(); - } - } - catch (Exception ex) - { - Logger.LogError(ex, "Error getting plugin list"); - // Play it safe here - if (requireAppStoreEnabled) - { - result = new PluginInfo[] { }; - } - } - + // TODO cvium + var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToArray(); +// var requireAppStoreEnabled = request.IsAppStoreEnabled.HasValue && request.IsAppStoreEnabled.Value; +// +// // Don't fail just on account of image url's +// try +// { +// var packages = (await _installationManager.GetAvailablePackagesWithoutRegistrationInfo(CancellationToken.None)); +// +// foreach (var plugin in result) +// { +// var pkg = packages.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i.guid) && string.Equals(i.guid.Replace("-", string.Empty), plugin.Id.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase)); +// +// if (pkg != null) +// { +// plugin.ImageUrl = pkg.thumbImage; +// } +// } +// +// if (requireAppStoreEnabled) +// { +// result = result +// .Where(plugin => +// { +// var pkg = packages.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i.guid) && new Guid(plugin.Id).Equals(new Guid(i.guid))); +// return pkg != null && pkg.enableInAppStore; +// +// }) +// .ToArray(); +// } +// } +// catch (Exception ex) +// { +// Logger.LogError(ex, "Error getting plugin list"); +// // Play it safe here +// if (requireAppStoreEnabled) +// { +// result = new PluginInfo[] { }; +// } +// } return ToOptimizedResult(result); } @@ -257,41 +175,6 @@ namespace MediaBrowser.Api } /// <summary> - /// Gets the specified request. - /// </summary> - /// <param name="request">The request.</param> - /// <returns>System.Object.</returns> - public async Task<object> Get(GetPluginSecurityInfo request) - { - var result = new PluginSecurityInfo - { - IsMBSupporter = await _securityManager.IsSupporter().ConfigureAwait(false), - SupporterKey = _securityManager.SupporterKey - }; - - return ToOptimizedResult(result); - } - - /// <summary> - /// Post app store sale - /// </summary> - /// <param name="request"></param> - /// <returns></returns> - public Task Post(RegisterAppstoreSale request) - { - return _securityManager.RegisterAppStoreSale(request.Parameters); - } - - /// <summary> - /// Posts the specified request. - /// </summary> - /// <param name="request">The request.</param> - public Task Post(UpdatePluginSecurityInfo request) - { - return _securityManager.UpdateSupporterKey(request.SupporterKey); - } - - /// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> |
