IInstallationManager.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using MediaBrowser.Common.Events;
  2. using MediaBrowser.Common.Plugins;
  3. using MediaBrowser.Model.Updates;
  4. using System;
  5. using System.Collections.Concurrent;
  6. using System.Collections.Generic;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. namespace MediaBrowser.Controller.Updates
  10. {
  11. public interface IInstallationManager : IDisposable
  12. {
  13. event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstalling;
  14. event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCompleted;
  15. event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationFailed;
  16. event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCancelled;
  17. /// <summary>
  18. /// The current installations
  19. /// </summary>
  20. List<Tuple<InstallationInfo, CancellationTokenSource>> CurrentInstallations { get; set; }
  21. /// <summary>
  22. /// The completed installations
  23. /// </summary>
  24. ConcurrentBag<InstallationInfo> CompletedInstallations { get; set; }
  25. /// <summary>
  26. /// Occurs when [plugin uninstalled].
  27. /// </summary>
  28. event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
  29. /// <summary>
  30. /// Occurs when [plugin updated].
  31. /// </summary>
  32. event EventHandler<GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>>> PluginUpdated;
  33. /// <summary>
  34. /// Occurs when [plugin updated].
  35. /// </summary>
  36. event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
  37. /// <summary>
  38. /// Gets all available packages.
  39. /// </summary>
  40. /// <param name="cancellationToken">The cancellation token.</param>
  41. /// <param name="packageType">Type of the package.</param>
  42. /// <param name="applicationVersion">The application version.</param>
  43. /// <returns>Task{List{PackageInfo}}.</returns>
  44. Task<IEnumerable<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken,
  45. PackageType? packageType = null,
  46. Version applicationVersion = null);
  47. /// <summary>
  48. /// Gets the package.
  49. /// </summary>
  50. /// <param name="name">The name.</param>
  51. /// <param name="classification">The classification.</param>
  52. /// <param name="version">The version.</param>
  53. /// <returns>Task{PackageVersionInfo}.</returns>
  54. Task<PackageVersionInfo> GetPackage(string name, PackageVersionClass classification, Version version);
  55. /// <summary>
  56. /// Gets the latest compatible version.
  57. /// </summary>
  58. /// <param name="name">The name.</param>
  59. /// <param name="classification">The classification.</param>
  60. /// <returns>Task{PackageVersionInfo}.</returns>
  61. Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, PackageVersionClass classification = PackageVersionClass.Release);
  62. /// <summary>
  63. /// Gets the latest compatible version.
  64. /// </summary>
  65. /// <param name="availablePackages">The available packages.</param>
  66. /// <param name="name">The name.</param>
  67. /// <param name="classification">The classification.</param>
  68. /// <returns>PackageVersionInfo.</returns>
  69. PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release);
  70. /// <summary>
  71. /// Gets the available plugin updates.
  72. /// </summary>
  73. /// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
  74. /// <param name="cancellationToken">The cancellation token.</param>
  75. /// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
  76. Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken);
  77. /// <summary>
  78. /// Installs the package.
  79. /// </summary>
  80. /// <param name="package">The package.</param>
  81. /// <param name="progress">The progress.</param>
  82. /// <param name="cancellationToken">The cancellation token.</param>
  83. /// <returns>Task.</returns>
  84. /// <exception cref="System.ArgumentNullException">package</exception>
  85. Task InstallPackage(PackageVersionInfo package, IProgress<double> progress, CancellationToken cancellationToken);
  86. /// <summary>
  87. /// Uninstalls a plugin
  88. /// </summary>
  89. /// <param name="plugin">The plugin.</param>
  90. /// <exception cref="System.ArgumentException"></exception>
  91. void UninstallPlugin(IPlugin plugin);
  92. }
  93. }