IDeviceManager.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using System.Threading.Tasks;
  3. using Jellyfin.Data.Dtos;
  4. using Jellyfin.Data.Events;
  5. using Jellyfin.Data.Queries;
  6. using Jellyfin.Database.Implementations.Entities;
  7. using Jellyfin.Database.Implementations.Entities.Security;
  8. using MediaBrowser.Model.Devices;
  9. using MediaBrowser.Model.Dto;
  10. using MediaBrowser.Model.Querying;
  11. using MediaBrowser.Model.Session;
  12. namespace MediaBrowser.Controller.Devices;
  13. /// <summary>
  14. /// Device manager interface.
  15. /// </summary>
  16. public interface IDeviceManager
  17. {
  18. /// <summary>
  19. /// Event handler for updated device options.
  20. /// </summary>
  21. event EventHandler<GenericEventArgs<Tuple<string, DeviceOptions>>> DeviceOptionsUpdated;
  22. /// <summary>
  23. /// Creates a new device.
  24. /// </summary>
  25. /// <param name="device">The device to create.</param>
  26. /// <returns>A <see cref="Task{Device}"/> representing the creation of the device.</returns>
  27. Task<Device> CreateDevice(Device device);
  28. /// <summary>
  29. /// Saves the capabilities.
  30. /// </summary>
  31. /// <param name="deviceId">The device id.</param>
  32. /// <param name="capabilities">The capabilities.</param>
  33. void SaveCapabilities(string deviceId, ClientCapabilities capabilities);
  34. /// <summary>
  35. /// Gets the capabilities.
  36. /// </summary>
  37. /// <param name="deviceId">The device id.</param>
  38. /// <returns>ClientCapabilities.</returns>
  39. ClientCapabilities GetCapabilities(string? deviceId);
  40. /// <summary>
  41. /// Gets the device information.
  42. /// </summary>
  43. /// <param name="id">The identifier.</param>
  44. /// <returns>DeviceInfoDto.</returns>
  45. DeviceInfoDto? GetDevice(string id);
  46. /// <summary>
  47. /// Gets devices based on the provided query.
  48. /// </summary>
  49. /// <param name="query">The device query.</param>
  50. /// <returns>A <see cref="Task{QueryResult}"/> representing the retrieval of the devices.</returns>
  51. QueryResult<Device> GetDevices(DeviceQuery query);
  52. /// <summary>
  53. /// Gets device information based on the provided query.
  54. /// </summary>
  55. /// <param name="query">The device query.</param>
  56. /// <returns>A <see cref="Task{QueryResult}"/> representing the retrieval of the device information.</returns>
  57. QueryResult<DeviceInfo> GetDeviceInfos(DeviceQuery query);
  58. /// <summary>
  59. /// Gets the device information.
  60. /// </summary>
  61. /// <param name="userId">The user's id, or <c>null</c>.</param>
  62. /// <returns>IEnumerable&lt;DeviceInfoDto&gt;.</returns>
  63. QueryResult<DeviceInfoDto> GetDevicesForUser(Guid? userId);
  64. /// <summary>
  65. /// Deletes a device.
  66. /// </summary>
  67. /// <param name="device">The device.</param>
  68. /// <returns>A <see cref="Task"/> representing the deletion of the device.</returns>
  69. Task DeleteDevice(Device device);
  70. /// <summary>
  71. /// Updates a device.
  72. /// </summary>
  73. /// <param name="device">The device.</param>
  74. /// <returns>A <see cref="Task"/> representing the update of the device.</returns>
  75. Task UpdateDevice(Device device);
  76. /// <summary>
  77. /// Determines whether this instance [can access device] the specified user identifier.
  78. /// </summary>
  79. /// <param name="user">The user to test.</param>
  80. /// <param name="deviceId">The device id to test.</param>
  81. /// <returns>Whether the user can access the device.</returns>
  82. bool CanAccessDevice(User user, string deviceId);
  83. /// <summary>
  84. /// Updates the options of a device.
  85. /// </summary>
  86. /// <param name="deviceId">The device id.</param>
  87. /// <param name="deviceName">The device name.</param>
  88. /// <returns>A <see cref="Task"/> representing the update of the device options.</returns>
  89. Task UpdateDeviceOptions(string deviceId, string? deviceName);
  90. /// <summary>
  91. /// Gets the options of a device.
  92. /// </summary>
  93. /// <param name="deviceId">The device id.</param>
  94. /// <returns><see cref="DeviceOptions"/> of the device.</returns>
  95. DeviceOptionsDto? GetDeviceOptions(string deviceId);
  96. /// <summary>
  97. /// Gets the dto for client capabilities.
  98. /// </summary>
  99. /// <param name="capabilities">The client capabilities.</param>
  100. /// <returns><see cref="ClientCapabilitiesDto"/> of the device.</returns>
  101. ClientCapabilitiesDto ToClientCapabilitiesDto(ClientCapabilities capabilities);
  102. }