IInstallationManager.cs 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #nullable enable
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Common.Plugins;
  7. using MediaBrowser.Model.Updates;
  8. namespace MediaBrowser.Common.Updates
  9. {
  10. /// <summary>
  11. /// Defines the <see cref="IInstallationManager" />.
  12. /// </summary>
  13. public interface IInstallationManager : IDisposable
  14. {
  15. /// <summary>
  16. /// Gets the completed installations.
  17. /// </summary>
  18. IEnumerable<InstallationInfo> CompletedInstallations { get; }
  19. /// <summary>
  20. /// Parses a plugin manifest at the supplied URL.
  21. /// </summary>
  22. /// <param name="manifestName">Name of the repository.</param>
  23. /// <param name="manifest">The URL to query.</param>
  24. /// <param name="filterIncompatible">Filter out incompatible plugins.</param>
  25. /// <param name="cancellationToken">The cancellation token.</param>
  26. /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
  27. Task<IList<PackageInfo>> GetPackages(string manifestName, string manifest, bool filterIncompatible, CancellationToken cancellationToken = default);
  28. /// <summary>
  29. /// Gets all available packages that are supported by this version.
  30. /// </summary>
  31. /// <param name="cancellationToken">The cancellation token.</param>
  32. /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
  33. Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default);
  34. /// <summary>
  35. /// Returns all plugins matching the requirements.
  36. /// </summary>
  37. /// <param name="availablePackages">The available packages.</param>
  38. /// <param name="name">The name of the plugin.</param>
  39. /// <param name="id">The id of the plugin.</param>
  40. /// <param name="specificVersion">The version of the plugin.</param>
  41. /// <returns>All plugins matching the requirements.</returns>
  42. IEnumerable<PackageInfo> FilterPackages(
  43. IEnumerable<PackageInfo> availablePackages,
  44. string? name = null,
  45. Guid? id = default,
  46. Version? specificVersion = null);
  47. /// <summary>
  48. /// Returns all compatible versions ordered from newest to oldest.
  49. /// </summary>
  50. /// <param name="availablePackages">The available packages.</param>
  51. /// <param name="name">The name.</param>
  52. /// <param name="id">The id of the plugin.</param>
  53. /// <param name="minVersion">The minimum required version of the plugin.</param>
  54. /// <param name="specificVersion">The specific version of the plugin to install.</param>
  55. /// <returns>All compatible versions ordered from newest to oldest.</returns>
  56. IEnumerable<InstallationInfo> GetCompatibleVersions(
  57. IEnumerable<PackageInfo> availablePackages,
  58. string? name = null,
  59. Guid? id = default,
  60. Version? minVersion = null,
  61. Version? specificVersion = null);
  62. /// <summary>
  63. /// Returns the available compatible plugin updates.
  64. /// </summary>
  65. /// <param name="cancellationToken">The cancellation token.</param>
  66. /// <returns>The available plugin updates.</returns>
  67. Task<IEnumerable<InstallationInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
  68. /// <summary>
  69. /// Installs the package.
  70. /// </summary>
  71. /// <param name="package">The package.</param>
  72. /// <param name="cancellationToken">The cancellation token.</param>
  73. /// <returns><see cref="Task" />.</returns>
  74. Task InstallPackage(InstallationInfo package, CancellationToken cancellationToken = default);
  75. /// <summary>
  76. /// Uninstalls a plugin.
  77. /// </summary>
  78. /// <param name="plugin">The plugin.</param>
  79. void UninstallPlugin(LocalPlugin plugin);
  80. /// <summary>
  81. /// Cancels the installation.
  82. /// </summary>
  83. /// <param name="id">The id of the package that is being installed.</param>
  84. /// <returns>Returns true if the install was cancelled.</returns>
  85. bool CancelInstallation(Guid id);
  86. }
  87. }