IInstallationManager.cs 4.3 KB

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