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