2
0

IQuickConnect.cs 3.1 KB

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