EventingServiceCollectionExtensions.cs 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Jellyfin.Data.Events;
  2. using Jellyfin.Data.Events.System;
  3. using Jellyfin.Data.Events.Users;
  4. using Jellyfin.Server.Implementations.Events.Consumers.Library;
  5. using Jellyfin.Server.Implementations.Events.Consumers.Security;
  6. using Jellyfin.Server.Implementations.Events.Consumers.Session;
  7. using Jellyfin.Server.Implementations.Events.Consumers.System;
  8. using Jellyfin.Server.Implementations.Events.Consumers.Updates;
  9. using Jellyfin.Server.Implementations.Events.Consumers.Users;
  10. using MediaBrowser.Common.Updates;
  11. using MediaBrowser.Controller.Events;
  12. using MediaBrowser.Controller.Events.Authentication;
  13. using MediaBrowser.Controller.Events.Session;
  14. using MediaBrowser.Controller.Events.Updates;
  15. using MediaBrowser.Controller.Library;
  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<SubtitleDownloadFailureEventArgs>, SubtitleDownloadFailureLogger>();
  34. // Security consumers
  35. collection.AddScoped<IEventConsumer<AuthenticationRequestEventArgs>, AuthenticationFailedLogger>();
  36. collection.AddScoped<IEventConsumer<AuthenticationResultEventArgs>, AuthenticationSucceededLogger>();
  37. // Session consumers
  38. collection.AddScoped<IEventConsumer<PlaybackStartEventArgs>, PlaybackStartLogger>();
  39. collection.AddScoped<IEventConsumer<PlaybackStopEventArgs>, PlaybackStopLogger>();
  40. collection.AddScoped<IEventConsumer<SessionEndedEventArgs>, SessionEndedLogger>();
  41. collection.AddScoped<IEventConsumer<SessionStartedEventArgs>, SessionStartedLogger>();
  42. // System consumers
  43. collection.AddScoped<IEventConsumer<PendingRestartEventArgs>, PendingRestartNotifier>();
  44. collection.AddScoped<IEventConsumer<TaskCompletionEventArgs>, TaskCompletedLogger>();
  45. collection.AddScoped<IEventConsumer<TaskCompletionEventArgs>, TaskCompletedNotifier>();
  46. // Update consumers
  47. collection.AddScoped<IEventConsumer<PluginInstallationCancelledEventArgs>, PluginInstallationCancelledNotifier>();
  48. collection.AddScoped<IEventConsumer<InstallationFailedEventArgs>, PluginInstallationFailedLogger>();
  49. collection.AddScoped<IEventConsumer<InstallationFailedEventArgs>, PluginInstallationFailedNotifier>();
  50. collection.AddScoped<IEventConsumer<PluginInstalledEventArgs>, PluginInstalledLogger>();
  51. collection.AddScoped<IEventConsumer<PluginInstalledEventArgs>, PluginInstalledNotifier>();
  52. collection.AddScoped<IEventConsumer<PluginInstallingEventArgs>, PluginInstallingNotifier>();
  53. collection.AddScoped<IEventConsumer<PluginUninstalledEventArgs>, PluginUninstalledLogger>();
  54. collection.AddScoped<IEventConsumer<PluginUninstalledEventArgs>, PluginUninstalledNotifier>();
  55. collection.AddScoped<IEventConsumer<PluginUpdatedEventArgs>, PluginUpdatedLogger>();
  56. // User consumers
  57. collection.AddScoped<IEventConsumer<UserCreatedEventArgs>, UserCreatedLogger>();
  58. collection.AddScoped<IEventConsumer<UserDeletedEventArgs>, UserDeletedLogger>();
  59. collection.AddScoped<IEventConsumer<UserDeletedEventArgs>, UserDeletedNotifier>();
  60. collection.AddScoped<IEventConsumer<UserLockedOutEventArgs>, UserLockedOutLogger>();
  61. collection.AddScoped<IEventConsumer<UserPasswordChangedEventArgs>, UserPasswordChangedLogger>();
  62. collection.AddScoped<IEventConsumer<UserUpdatedEventArgs>, UserUpdatedNotifier>();
  63. }
  64. }
  65. }