2020-12-06 23:48:54 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Reflection;
|
2020-12-23 16:28:50 +00:00
|
|
|
using System.Threading.Tasks;
|
2021-04-06 19:59:47 +00:00
|
|
|
using MediaBrowser.Model.Plugins;
|
2021-02-12 13:33:10 +00:00
|
|
|
using MediaBrowser.Model.Updates;
|
2020-12-06 23:48:54 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Plugins
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="IPluginManager" />.
|
|
|
|
/// </summary>
|
|
|
|
public interface IPluginManager
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the Plugins.
|
|
|
|
/// </summary>
|
2021-03-05 10:15:14 +00:00
|
|
|
IReadOnlyList<LocalPlugin> Plugins { get; }
|
2020-12-06 23:48:54 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates the plugins.
|
|
|
|
/// </summary>
|
|
|
|
void CreatePlugins();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns all the assemblies.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>An IEnumerable{Assembly}.</returns>
|
|
|
|
IEnumerable<Assembly> LoadAssemblies();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Registers the plugin's services with the DI.
|
|
|
|
/// Note: DI is not yet instantiated yet.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="serviceCollection">A <see cref="ServiceCollection"/> instance.</param>
|
|
|
|
void RegisterServices(IServiceCollection serviceCollection);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the manifest back to disk.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="manifest">The <see cref="PluginManifest"/> to save.</param>
|
|
|
|
/// <param name="path">The path where to save the manifest.</param>
|
|
|
|
/// <returns>True if successful.</returns>
|
|
|
|
bool SaveManifest(PluginManifest manifest, string path);
|
|
|
|
|
2021-02-12 13:33:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Generates a manifest from repository data.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="packageInfo">The <see cref="PackageInfo"/> used to generate a manifest.</param>
|
|
|
|
/// <param name="version">Version to be installed.</param>
|
|
|
|
/// <param name="path">The path where to save the manifest.</param>
|
2021-04-06 19:59:47 +00:00
|
|
|
/// <param name="status">Initial status of the plugin.</param>
|
2021-02-12 13:33:10 +00:00
|
|
|
/// <returns>True if successful.</returns>
|
2021-04-06 19:59:47 +00:00
|
|
|
Task<bool> GenerateManifest(PackageInfo packageInfo, Version version, string path, PluginStatus status);
|
2021-02-12 13:33:10 +00:00
|
|
|
|
2020-12-06 23:48:54 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Imports plugin details from a folder.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="folder">Folder of the plugin.</param>
|
|
|
|
void ImportPluginFrom(string folder);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Disable the plugin.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="assembly">The <see cref="Assembly"/> of the plug to disable.</param>
|
|
|
|
void FailPlugin(Assembly assembly);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Disable the plugin.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
|
|
|
|
void DisablePlugin(LocalPlugin plugin);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Enables the plugin, disabling all other versions.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
|
|
|
|
void EnablePlugin(LocalPlugin plugin);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Attempts to find the plugin with and id of <paramref name="id"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Id of plugin.</param>
|
|
|
|
/// <param name="version">The version of the plugin to locate.</param>
|
2020-12-15 20:27:42 +00:00
|
|
|
/// <returns>A <see cref="LocalPlugin"/> if located, or null if not.</returns>
|
|
|
|
LocalPlugin? GetPlugin(Guid id, Version? version = null);
|
2020-12-06 23:48:54 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Removes the plugin.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="plugin">The plugin.</param>
|
|
|
|
/// <returns>Outcome of the operation.</returns>
|
|
|
|
bool RemovePlugin(LocalPlugin plugin);
|
|
|
|
}
|
|
|
|
}
|