EventingServiceCollectionExtensions.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Jellyfin.Data.Events.System;
  2. using Jellyfin.Data.Events.Users;
  3. using Jellyfin.Server.Implementations.Events.Consumers.Library;
  4. using Jellyfin.Server.Implementations.Events.Consumers.Security;
  5. using Jellyfin.Server.Implementations.Events.Consumers.Session;
  6. using Jellyfin.Server.Implementations.Events.Consumers.System;
  7. using Jellyfin.Server.Implementations.Events.Consumers.Updates;
  8. using Jellyfin.Server.Implementations.Events.Consumers.Users;
  9. using MediaBrowser.Common.Updates;
  10. using MediaBrowser.Controller.Events;
  11. using MediaBrowser.Controller.Events.Authentication;
  12. using MediaBrowser.Controller.Events.Session;
  13. using MediaBrowser.Controller.Events.Updates;
  14. using MediaBrowser.Controller.Library;
  15. using MediaBrowser.Controller.Subtitles;
  16. using MediaBrowser.Model.Tasks;
  17. using Microsoft.Extensions.DependencyInjection;
  18. namespace Jellyfin.Server.Implementations.Events
  19. {
  20. /// <summary>
  21. /// A class containing extensions to <see cref="IServiceCollection"/> for eventing.
  22. /// </summary>
  23. public static class EventingServiceCollectionExtensions
  24. {
  25. /// <summary>
  26. /// Adds the event services to the service collection.
  27. /// </summary>
  28. /// <param name="collection">The service collection.</param>
  29. public static void AddEventServices(this IServiceCollection collection)
  30. {
  31. // Library consumers
  32. collection.AddScoped<IEventConsumer<SubtitleDownloadFailureEventArgs>, SubtitleDownloadFailureLogger>();
  33. // Security consumers
  34. collection.AddScoped<IEventConsumer<AuthenticationRequestEventArgs>, AuthenticationFailedLogger>();
  35. collection.AddScoped<IEventConsumer<AuthenticationResultEventArgs>, AuthenticationSucceededLogger>();
  36. // Session consumers
  37. collection.AddScoped<IEventConsumer<PlaybackStartEventArgs>, PlaybackStartLogger>();
  38. collection.AddScoped<IEventConsumer<PlaybackStopEventArgs>, PlaybackStopLogger>();
  39. collection.AddScoped<IEventConsumer<SessionEndedEventArgs>, SessionEndedLogger>();
  40. collection.AddScoped<IEventConsumer<SessionStartedEventArgs>, SessionStartedLogger>();
  41. // System consumers
  42. collection.AddScoped<IEventConsumer<PendingRestartEventArgs>, PendingRestartNotifier>();
  43. collection.AddScoped<IEventConsumer<TaskCompletionEventArgs>, TaskCompletedLogger>();
  44. collection.AddScoped<IEventConsumer<TaskCompletionEventArgs>, TaskCompletedNotifier>();
  45. // Update consumers
  46. collection.AddScoped<IEventConsumer<PluginInstallationCancelledEventArgs>, PluginInstallationCancelledNotifier>();
  47. collection.AddScoped<IEventConsumer<InstallationFailedEventArgs>, PluginInstallationFailedLogger>();
  48. collection.AddScoped<IEventConsumer<InstallationFailedEventArgs>, PluginInstallationFailedNotifier>();
  49. collection.AddScoped<IEventConsumer<PluginInstalledEventArgs>, PluginInstalledLogger>();
  50. collection.AddScoped<IEventConsumer<PluginInstalledEventArgs>, PluginInstalledNotifier>();
  51. collection.AddScoped<IEventConsumer<PluginInstallingEventArgs>, PluginInstallingNotifier>();
  52. collection.AddScoped<IEventConsumer<PluginUninstalledEventArgs>, PluginUninstalledLogger>();
  53. collection.AddScoped<IEventConsumer<PluginUninstalledEventArgs>, PluginUninstalledNotifier>();
  54. collection.AddScoped<IEventConsumer<PluginUpdatedEventArgs>, PluginUpdatedLogger>();
  55. // User consumers
  56. collection.AddScoped<IEventConsumer<UserCreatedEventArgs>, UserCreatedLogger>();
  57. collection.AddScoped<IEventConsumer<UserDeletedEventArgs>, UserDeletedLogger>();
  58. collection.AddScoped<IEventConsumer<UserDeletedEventArgs>, UserDeletedNotifier>();
  59. collection.AddScoped<IEventConsumer<UserLockedOutEventArgs>, UserLockedOutLogger>();
  60. collection.AddScoped<IEventConsumer<UserPasswordChangedEventArgs>, UserPasswordChangedLogger>();
  61. collection.AddScoped<IEventConsumer<UserUpdatedEventArgs>, UserUpdatedNotifier>();
  62. }
  63. }
  64. }