2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-04-15 19:28:42 +00:00
|
|
|
using System;
|
2021-04-14 00:01:21 +00:00
|
|
|
using MediaBrowser.Controller.Session;
|
2020-04-15 19:28:42 +00:00
|
|
|
using MediaBrowser.Model.QuickConnect;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.QuickConnect
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Quick connect standard interface.
|
|
|
|
/// </summary>
|
|
|
|
public interface IQuickConnect
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the length of user facing codes.
|
|
|
|
/// </summary>
|
2020-07-27 20:40:14 +00:00
|
|
|
int CodeLength { get; set; }
|
2020-04-15 19:28:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-08-17 21:36:45 +00:00
|
|
|
/// Gets or sets the name of internal access tokens.
|
2020-04-15 19:28:42 +00:00
|
|
|
/// </summary>
|
2020-08-17 21:36:45 +00:00
|
|
|
string TokenName { get; set; }
|
2020-04-15 19:28:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the current state of quick connect.
|
|
|
|
/// </summary>
|
2020-07-27 20:40:14 +00:00
|
|
|
QuickConnectState State { get; }
|
2020-04-15 19:28:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-06-18 06:29:47 +00:00
|
|
|
/// Gets or sets the time (in minutes) before quick connect will automatically deactivate.
|
2020-04-15 19:28:42 +00:00
|
|
|
/// </summary>
|
2020-07-27 20:40:14 +00:00
|
|
|
int Timeout { get; set; }
|
2020-04-15 19:28:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Assert that quick connect is currently active and throws an exception if it is not.
|
|
|
|
/// </summary>
|
|
|
|
void AssertActive();
|
|
|
|
|
2020-04-19 06:33:09 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Temporarily activates quick connect for a short amount of time.
|
|
|
|
/// </summary>
|
2020-06-18 06:58:58 +00:00
|
|
|
void Activate();
|
2020-04-19 06:33:09 +00:00
|
|
|
|
2020-04-15 19:28:42 +00:00
|
|
|
/// <summary>
|
2020-07-27 04:13:14 +00:00
|
|
|
/// Changes the state of quick connect.
|
2020-04-15 19:28:42 +00:00
|
|
|
/// </summary>
|
2020-04-19 06:33:09 +00:00
|
|
|
/// <param name="newState">New state to change to.</param>
|
2020-07-27 04:13:14 +00:00
|
|
|
void SetState(QuickConnectState newState);
|
2020-04-15 19:28:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initiates a new quick connect request.
|
|
|
|
/// </summary>
|
2020-07-27 04:13:14 +00:00
|
|
|
/// <returns>A quick connect result with tokens to proceed or throws an exception if not active.</returns>
|
2020-08-17 21:36:45 +00:00
|
|
|
QuickConnectResult TryConnect();
|
2020-04-15 19:28:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks the status of an individual request.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="secret">Unique secret identifier of the request.</param>
|
|
|
|
/// <returns>Quick connect result.</returns>
|
|
|
|
QuickConnectResult CheckRequestStatus(string secret);
|
|
|
|
|
2021-04-14 00:01:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Authenticates a QuickConnect request.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
void AuthenticateRequest(AuthenticationRequest request, string token);
|
|
|
|
|
2020-04-15 19:28:42 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Authorizes a quick connect request to connect as the calling user.
|
|
|
|
/// </summary>
|
2020-08-17 21:36:45 +00:00
|
|
|
/// <param name="userId">User id.</param>
|
2020-06-18 06:58:58 +00:00
|
|
|
/// <param name="code">Identifying code for the request.</param>
|
2020-04-15 19:28:42 +00:00
|
|
|
/// <returns>A boolean indicating if the authorization completed successfully.</returns>
|
2020-08-17 21:36:45 +00:00
|
|
|
bool AuthorizeRequest(Guid userId, string code);
|
2020-04-15 19:28:42 +00:00
|
|
|
|
2020-06-18 06:58:58 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Expire quick connect requests that are over the time limit. If <paramref name="expireAll"/> is true, all requests are unconditionally expired.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="expireAll">If true, all requests will be expired.</param>
|
2020-07-27 20:40:14 +00:00
|
|
|
void ExpireRequests(bool expireAll = false);
|
2020-06-18 06:58:58 +00:00
|
|
|
|
2020-04-15 19:28:42 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Deletes all quick connect access tokens for the provided user.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">Guid of the user to delete tokens for.</param>
|
|
|
|
/// <returns>A count of the deleted tokens.</returns>
|
|
|
|
int DeleteAllDevices(Guid user);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Generates a short code to display to the user to uniquely identify this request.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>A short, unique alphanumeric string.</returns>
|
|
|
|
string GenerateCode();
|
|
|
|
}
|
|
|
|
}
|