IInstallationManager.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. /// Parses a plugin manifest at the supplied URL.
  35. /// </summary>
  36. /// <param name="manifest">The URL to query.</param>
  37. /// <param name="cancellationToken">The cancellation token.</param>
  38. /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
  39. Task<IEnumerable<PackageInfo>> GetPackages(string manifest, CancellationToken cancellationToken = default);
  40. /// <summary>
  41. /// Gets all available packages.
  42. /// </summary>
  43. /// <param name="cancellationToken">The cancellation token.</param>
  44. /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
  45. Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default);
  46. /// <summary>
  47. /// Returns all plugins matching the requirements.
  48. /// </summary>
  49. /// <param name="availablePackages">The available packages.</param>
  50. /// <param name="name">The name of the plugin.</param>
  51. /// <param name="guid">The id of the plugin.</param>
  52. /// <returns>All plugins matching the requirements.</returns>
  53. IEnumerable<PackageInfo> FilterPackages(
  54. IEnumerable<PackageInfo> availablePackages,
  55. string name = null,
  56. Guid guid = default);
  57. /// <summary>
  58. /// Returns all compatible versions ordered from newest to oldest.
  59. /// </summary>
  60. /// <param name="availablePackages">The available packages.</param>
  61. /// <param name="name">The name.</param>
  62. /// <param name="guid">The guid of the plugin.</param>
  63. /// <param name="minVersion">The minimum required version of the plugin.</param>
  64. /// <returns>All compatible versions ordered from newest to oldest.</returns>
  65. IEnumerable<InstallationInfo> GetCompatibleVersions(
  66. IEnumerable<PackageInfo> availablePackages,
  67. string name = null,
  68. Guid guid = default,
  69. Version minVersion = null);
  70. /// <summary>
  71. /// Returns the available plugin updates.
  72. /// </summary>
  73. /// <param name="cancellationToken">The cancellation token.</param>
  74. /// <returns>The available plugin updates.</returns>
  75. Task<IEnumerable<InstallationInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
  76. /// <summary>
  77. /// Installs the package.
  78. /// </summary>
  79. /// <param name="package">The package.</param>
  80. /// <param name="cancellationToken">The cancellation token.</param>
  81. /// <returns><see cref="Task" />.</returns>
  82. Task InstallPackage(InstallationInfo package, CancellationToken cancellationToken = default);
  83. /// <summary>
  84. /// Uninstalls a plugin.
  85. /// </summary>
  86. /// <param name="plugin">The plugin.</param>
  87. void UninstallPlugin(IPlugin plugin);
  88. /// <summary>
  89. /// Cancels the installation.
  90. /// </summary>
  91. /// <param name="id">The id of the package that is being installed.</param>
  92. /// <returns>Returns true if the install was cancelled.</returns>
  93. bool CancelInstallation(Guid id);
  94. }
  95. }