EventingServiceCollectionExtensions.cs 4.2 KB

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