IServerApplicationHost.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Net;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using MediaBrowser.Common;
  8. using MediaBrowser.Model.System;
  9. using Microsoft.AspNetCore.Http;
  10. namespace MediaBrowser.Controller
  11. {
  12. /// <summary>
  13. /// Interface IServerApplicationHost.
  14. /// </summary>
  15. public interface IServerApplicationHost : IApplicationHost
  16. {
  17. event EventHandler HasUpdateAvailableChanged;
  18. IServiceProvider ServiceProvider { get; }
  19. bool CanLaunchWebBrowser { get; }
  20. /// <summary>
  21. /// Gets the HTTP server port.
  22. /// </summary>
  23. /// <value>The HTTP server port.</value>
  24. int HttpPort { get; }
  25. /// <summary>
  26. /// Gets the HTTPS port.
  27. /// </summary>
  28. /// <value>The HTTPS port.</value>
  29. int HttpsPort { get; }
  30. /// <summary>
  31. /// Gets a value indicating whether the server should listen on an HTTPS port.
  32. /// </summary>
  33. bool ListenWithHttps { get; }
  34. /// <summary>
  35. /// Gets a value indicating whether this instance has update available.
  36. /// </summary>
  37. /// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>
  38. bool HasUpdateAvailable { get; }
  39. /// <summary>
  40. /// Gets the name of the friendly.
  41. /// </summary>
  42. /// <value>The name of the friendly.</value>
  43. string FriendlyName { get; }
  44. /// <summary>
  45. /// Gets the system info.
  46. /// </summary>
  47. /// <returns>SystemInfo.</returns>
  48. Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken);
  49. Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken);
  50. /// <summary>
  51. /// Gets all the local IP addresses of this API instance. Each address is validated by sending a 'ping' request
  52. /// to the API that should exist at the address.
  53. /// </summary>
  54. /// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
  55. /// <returns>A list containing all the local IP addresses of the server.</returns>
  56. Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken);
  57. /// <summary>
  58. /// Gets a local (LAN) URL that can be used to access the API. The hostname used is the first valid configured
  59. /// IP address that can be found via <see cref="GetLocalIpAddresses"/>. HTTPS will be preferred when available.
  60. /// </summary>
  61. /// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
  62. /// <returns>The server URL.</returns>
  63. Task<string> GetLocalApiUrl(CancellationToken cancellationToken);
  64. /// <summary>
  65. /// Gets a localhost URL that can be used to access the API using the loop-back IP address (127.0.0.1)
  66. /// over HTTP (not HTTPS).
  67. /// </summary>
  68. /// <returns>The API URL.</returns>
  69. string GetLoopbackHttpApiUrl();
  70. /// <summary>
  71. /// Gets a local (LAN) URL that can be used to access the API. HTTPS will be preferred when available.
  72. /// </summary>
  73. /// <param name="address">The IP address to use as the hostname in the URL.</param>
  74. /// <returns>The API URL.</returns>
  75. string GetLocalApiUrl(IPAddress address);
  76. /// <summary>
  77. /// Gets a local (LAN) URL that can be used to access the API.
  78. /// Note: if passing non-null scheme or port it is up to the caller to ensure they form the correct pair.
  79. /// </summary>
  80. /// <param name="hostname">The hostname to use in the URL.</param>
  81. /// <param name="scheme">
  82. /// The scheme to use for the URL. If null, the scheme will be selected automatically,
  83. /// preferring HTTPS, if available.
  84. /// </param>
  85. /// <param name="port">
  86. /// The port to use for the URL. If null, the port will be selected automatically,
  87. /// preferring the HTTPS port, if available.
  88. /// </param>
  89. /// <returns>The API URL.</returns>
  90. string GetLocalApiUrl(ReadOnlySpan<char> hostname, string scheme = null, int? port = null);
  91. /// <summary>
  92. /// Open a URL in an external browser window.
  93. /// </summary>
  94. /// <param name="url">The URL to open.</param>
  95. /// <exception cref="NotSupportedException"><see cref="CanLaunchWebBrowser"/> is false.</exception>
  96. void LaunchUrl(string url);
  97. void EnableLoopback(string appName);
  98. IEnumerable<WakeOnLanInfo> GetWakeOnLanInfo();
  99. string ExpandVirtualPath(string path);
  100. string ReverseVirtualPath(string path);
  101. Task ExecuteHttpHandlerAsync(HttpContext context, Func<Task> next);
  102. }
  103. }