IInstallationManager.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.Common.Updates
  10. {
  11. public interface IInstallationManager : IDisposable
  12. {
  13. event EventHandler<InstallationEventArgs> PackageInstalling;
  14. event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
  15. event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
  16. event EventHandler<InstallationEventArgs> 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 all available packages from a static resource.
  49. /// </summary>
  50. /// <param name="cancellationToken">The cancellation token.</param>
  51. /// <returns>Task{List{PackageInfo}}.</returns>
  52. Task<IEnumerable<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken);
  53. /// <summary>
  54. /// Gets the package.
  55. /// </summary>
  56. /// <param name="name">The name.</param>
  57. /// <param name="classification">The classification.</param>
  58. /// <param name="version">The version.</param>
  59. /// <returns>Task{PackageVersionInfo}.</returns>
  60. Task<PackageVersionInfo> GetPackage(string name, PackageVersionClass classification, Version version);
  61. /// <summary>
  62. /// Gets the latest compatible version.
  63. /// </summary>
  64. /// <param name="name">The name.</param>
  65. /// <param name="currentServerVersion">The current server version.</param>
  66. /// <param name="classification">The classification.</param>
  67. /// <returns>Task{PackageVersionInfo}.</returns>
  68. Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
  69. /// <summary>
  70. /// Gets the latest compatible version.
  71. /// </summary>
  72. /// <param name="availablePackages">The available packages.</param>
  73. /// <param name="name">The name.</param>
  74. /// <param name="currentServerVersion">The current server version.</param>
  75. /// <param name="classification">The classification.</param>
  76. /// <returns>PackageVersionInfo.</returns>
  77. PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
  78. /// <summary>
  79. /// Gets the available plugin updates.
  80. /// </summary>
  81. /// <param name="currentServerVersion">The current server version.</param>
  82. /// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
  83. /// <param name="cancellationToken">The cancellation token.</param>
  84. /// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
  85. Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(Version currentServerVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken);
  86. /// <summary>
  87. /// Installs the package.
  88. /// </summary>
  89. /// <param name="package">The package.</param>
  90. /// <param name="progress">The progress.</param>
  91. /// <param name="cancellationToken">The cancellation token.</param>
  92. /// <returns>Task.</returns>
  93. /// <exception cref="System.ArgumentNullException">package</exception>
  94. Task InstallPackage(PackageVersionInfo package, IProgress<double> progress, CancellationToken cancellationToken);
  95. /// <summary>
  96. /// Uninstalls a plugin
  97. /// </summary>
  98. /// <param name="plugin">The plugin.</param>
  99. /// <exception cref="System.ArgumentException"></exception>
  100. void UninstallPlugin(IPlugin plugin);
  101. }
  102. }