IQuickConnect.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #nullable disable
  2. using System;
  3. using MediaBrowser.Controller.Session;
  4. using MediaBrowser.Model.QuickConnect;
  5. namespace MediaBrowser.Controller.QuickConnect
  6. {
  7. /// <summary>
  8. /// Quick connect standard interface.
  9. /// </summary>
  10. public interface IQuickConnect
  11. {
  12. /// <summary>
  13. /// Gets or sets the length of user facing codes.
  14. /// </summary>
  15. int CodeLength { get; set; }
  16. /// <summary>
  17. /// Gets or sets the name of internal access tokens.
  18. /// </summary>
  19. string TokenName { get; set; }
  20. /// <summary>
  21. /// Gets the current state of quick connect.
  22. /// </summary>
  23. QuickConnectState State { get; }
  24. /// <summary>
  25. /// Gets or sets the time (in minutes) before quick connect will automatically deactivate.
  26. /// </summary>
  27. int Timeout { get; set; }
  28. /// <summary>
  29. /// Assert that quick connect is currently active and throws an exception if it is not.
  30. /// </summary>
  31. void AssertActive();
  32. /// <summary>
  33. /// Temporarily activates quick connect for a short amount of time.
  34. /// </summary>
  35. void Activate();
  36. /// <summary>
  37. /// Changes the state of quick connect.
  38. /// </summary>
  39. /// <param name="newState">New state to change to.</param>
  40. void SetState(QuickConnectState newState);
  41. /// <summary>
  42. /// Initiates a new quick connect request.
  43. /// </summary>
  44. /// <returns>A quick connect result with tokens to proceed or throws an exception if not active.</returns>
  45. QuickConnectResult TryConnect();
  46. /// <summary>
  47. /// Checks the status of an individual request.
  48. /// </summary>
  49. /// <param name="secret">Unique secret identifier of the request.</param>
  50. /// <returns>Quick connect result.</returns>
  51. QuickConnectResult CheckRequestStatus(string secret);
  52. /// <summary>
  53. /// Authenticates a QuickConnect request.
  54. /// </summary>
  55. /// <param name="request">The request.</param>
  56. /// <param name="token">The token.</param>
  57. void AuthenticateRequest(AuthenticationRequest request, string token);
  58. /// <summary>
  59. /// Authorizes a quick connect request to connect as the calling user.
  60. /// </summary>
  61. /// <param name="userId">User id.</param>
  62. /// <param name="code">Identifying code for the request.</param>
  63. /// <returns>A boolean indicating if the authorization completed successfully.</returns>
  64. bool AuthorizeRequest(Guid userId, string code);
  65. /// <summary>
  66. /// Expire quick connect requests that are over the time limit. If <paramref name="expireAll"/> is true, all requests are unconditionally expired.
  67. /// </summary>
  68. /// <param name="expireAll">If true, all requests will be expired.</param>
  69. void ExpireRequests(bool expireAll = false);
  70. /// <summary>
  71. /// Deletes all quick connect access tokens for the provided user.
  72. /// </summary>
  73. /// <param name="user">Guid of the user to delete tokens for.</param>
  74. /// <returns>A count of the deleted tokens.</returns>
  75. int DeleteAllDevices(Guid user);
  76. /// <summary>
  77. /// Generates a short code to display to the user to uniquely identify this request.
  78. /// </summary>
  79. /// <returns>A short, unique alphanumeric string.</returns>
  80. string GenerateCode();
  81. }
  82. }