IQuickConnect.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using MediaBrowser.Controller.Session;
  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. /// Authenticates a QuickConnect request.
  53. /// </summary>
  54. /// <param name="request">The request.</param>
  55. /// <param name="token">The token.</param>
  56. void AuthenticateRequest(AuthenticationRequest request, string token);
  57. /// <summary>
  58. /// Authorizes a quick connect request to connect as the calling user.
  59. /// </summary>
  60. /// <param name="userId">User id.</param>
  61. /// <param name="code">Identifying code for the request.</param>
  62. /// <returns>A boolean indicating if the authorization completed successfully.</returns>
  63. bool AuthorizeRequest(Guid userId, string code);
  64. /// <summary>
  65. /// Expire quick connect requests that are over the time limit. If <paramref name="expireAll"/> is true, all requests are unconditionally expired.
  66. /// </summary>
  67. /// <param name="expireAll">If true, all requests will be expired.</param>
  68. void ExpireRequests(bool expireAll = false);
  69. /// <summary>
  70. /// Deletes all quick connect access tokens for the provided user.
  71. /// </summary>
  72. /// <param name="user">Guid of the user to delete tokens for.</param>
  73. /// <returns>A count of the deleted tokens.</returns>
  74. int DeleteAllDevices(Guid user);
  75. /// <summary>
  76. /// Generates a short code to display to the user to uniquely identify this request.
  77. /// </summary>
  78. /// <returns>A short, unique alphanumeric string.</returns>
  79. string GenerateCode();
  80. }
  81. }