IInstallationManager.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #pragma warning disable CS1591
  2. #pragma warning disable SA1600
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using MediaBrowser.Common.Plugins;
  8. using MediaBrowser.Model.Events;
  9. using MediaBrowser.Model.Updates;
  10. namespace MediaBrowser.Common.Updates
  11. {
  12. public interface IInstallationManager : IDisposable
  13. {
  14. event EventHandler<InstallationEventArgs> PackageInstalling;
  15. event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
  16. event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
  17. event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
  18. /// <summary>
  19. /// Occurs when a plugin is uninstalled.
  20. /// </summary>
  21. event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
  22. /// <summary>
  23. /// Occurs when a plugin is updated.
  24. /// </summary>
  25. event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
  26. /// <summary>
  27. /// Occurs when a plugin is installed.
  28. /// </summary>
  29. event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
  30. /// <summary>
  31. /// Gets the completed installations.
  32. /// </summary>
  33. IEnumerable<InstallationInfo> CompletedInstallations { get; }
  34. /// <summary>
  35. /// Gets all available packages.
  36. /// </summary>
  37. /// <param name="cancellationToken">The cancellation token.</param>
  38. /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
  39. Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default);
  40. /// <summary>
  41. /// Returns all plugins matching the requirements.
  42. /// </summary>
  43. /// <param name="availablePackages">The available packages.</param>
  44. /// <param name="name">The name of the plugin.</param>
  45. /// <param name="guid">The id of the plugin.</param>
  46. /// <returns>All plugins matching the requirements.</returns>
  47. IEnumerable<PackageInfo> FilterPackages(
  48. IEnumerable<PackageInfo> availablePackages,
  49. string name = null,
  50. Guid guid = default);
  51. /// <summary>
  52. /// Returns all compatible versions ordered from newest to oldest.
  53. /// </summary>
  54. /// <param name="availableVersions">The available version of the plugin.</param>
  55. /// <param name="minVersion">The minimum required version of the plugin.</param>
  56. /// <param name="classification">The classification of updates.</param>
  57. /// <returns>All compatible versions ordered from newest to oldest.</returns>
  58. IEnumerable<PackageVersionInfo> GetCompatibleVersions(
  59. IEnumerable<PackageVersionInfo> availableVersions,
  60. Version minVersion = null,
  61. PackageVersionClass classification = PackageVersionClass.Release);
  62. /// <summary>
  63. /// Returns all compatible versions ordered from newest to oldest.
  64. /// </summary>
  65. /// <param name="availablePackages">The available packages.</param>
  66. /// <param name="name">The name.</param>
  67. /// <param name="guid">The guid of the plugin.</param>
  68. /// <param name="minVersion">The minimum required version of the plugin.</param>
  69. /// <param name="classification">The classification.</param>
  70. /// <returns>All compatible versions ordered from newest to oldest.</returns>
  71. IEnumerable<PackageVersionInfo> GetCompatibleVersions(
  72. IEnumerable<PackageInfo> availablePackages,
  73. string name = null,
  74. Guid guid = default,
  75. Version minVersion = null,
  76. PackageVersionClass classification = PackageVersionClass.Release);
  77. /// <summary>
  78. /// Returns the available plugin updates.
  79. /// </summary>
  80. /// <param name="cancellationToken">The cancellation token.</param>
  81. /// <returns>The available plugin updates.</returns>
  82. IAsyncEnumerable<PackageVersionInfo> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
  83. /// <summary>
  84. /// Installs the package.
  85. /// </summary>
  86. /// <param name="package">The package.</param>
  87. /// <param name="cancellationToken">The cancellation token.</param>
  88. /// <returns><see cref="Task" />.</returns>
  89. Task InstallPackage(PackageVersionInfo package, CancellationToken cancellationToken = default);
  90. /// <summary>
  91. /// Uninstalls a plugin.
  92. /// </summary>
  93. /// <param name="plugin">The plugin.</param>
  94. void UninstallPlugin(IPlugin plugin);
  95. /// <summary>
  96. /// Cancels the installation.
  97. /// </summary>
  98. /// <param name="id">The id of the package that is being installed.</param>
  99. /// <returns>Returns true if the install was cancelled.</returns>
  100. bool CancelInstallation(Guid id);
  101. }
  102. }