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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Services;
using MediaBrowser.Common.Plugins;
namespace MediaBrowser.Api
{
///
/// Class Plugins
///
[Route("/Plugins", "GET", Summary = "Gets a list of currently installed plugins")]
[Authenticated]
public class GetPlugins : IReturn
{
public bool? IsAppStoreEnabled { get; set; }
}
///
/// Class UninstallPlugin
///
[Route("/Plugins/{Id}", "DELETE", Summary = "Uninstalls a plugin")]
[Authenticated(Roles = "Admin")]
public class UninstallPlugin : IReturnVoid
{
///
/// Gets or sets the id.
///
/// The id.
[ApiMember(Name = "Id", Description = "Plugin Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
public string Id { get; set; }
}
///
/// Class GetPluginConfiguration
///
[Route("/Plugins/{Id}/Configuration", "GET", Summary = "Gets a plugin's configuration")]
[Authenticated]
public class GetPluginConfiguration
{
///
/// Gets or sets the id.
///
/// The id.
[ApiMember(Name = "Id", Description = "Plugin Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Id { get; set; }
}
///
/// Class UpdatePluginConfiguration
///
[Route("/Plugins/{Id}/Configuration", "POST", Summary = "Updates a plugin's configuration")]
[Authenticated]
public class UpdatePluginConfiguration : IRequiresRequestStream, IReturnVoid
{
///
/// Gets or sets the id.
///
/// The id.
[ApiMember(Name = "Id", Description = "Plugin Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
public string Id { get; set; }
///
/// The raw Http Request Input Stream
///
/// The request stream.
public Stream RequestStream { get; set; }
}
///
/// Class GetPluginSecurityInfo
///
[Route("/Plugins/SecurityInfo", "GET", Summary = "Gets plugin registration information", IsHidden = true)]
[Authenticated]
public class GetPluginSecurityInfo : IReturn
{
}
///
/// Class UpdatePluginSecurityInfo
///
[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
{
[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; }
}
///
/// Class PluginsService
///
public class PluginService : BaseApiService
{
///
/// The _json serializer
///
private readonly IJsonSerializer _jsonSerializer;
///
/// The _app host
///
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)
: base()
{
if (jsonSerializer == null)
{
throw new ArgumentNullException("jsonSerializer");
}
_appHost = appHost;
_securityManager = securityManager;
_installationManager = installationManager;
_network = network;
_deviceManager = deviceManager;
_jsonSerializer = jsonSerializer;
}
///
/// Gets the specified request.
///
/// The request.
/// System.Object.
public async Task