IInstallationManager.cs 3.9 KB

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