IQuickConnect.cs 3.1 KB

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