IServerApplicationHost.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. /// <returns>SystemInfo.</returns>
  49. Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken);
  50. Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken);
  51. /// <summary>
  52. /// Gets all the local IP addresses of this API instance. Each address is validated by sending a 'ping' request
  53. /// to the API that should exist at the address.
  54. /// </summary>
  55. /// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
  56. /// <returns>A list containing all the local IP addresses of the server.</returns>
  57. Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken);
  58. /// <summary>
  59. /// Gets a local (LAN) URL that can be used to access the API. The hostname used is the first valid configured
  60. /// IP address that can be found via <see cref="GetLocalIpAddresses"/>. HTTPS will be preferred when available.
  61. /// </summary>
  62. /// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
  63. /// <returns>The server URL.</returns>
  64. Task<string> GetLocalApiUrl(CancellationToken cancellationToken);
  65. /// <summary>
  66. /// Gets a localhost URL that can be used to access the API using the loop-back IP address (127.0.0.1)
  67. /// over HTTP (not HTTPS).
  68. /// </summary>
  69. /// <returns>The API URL.</returns>
  70. string GetLoopbackHttpApiUrl();
  71. /// <summary>
  72. /// Gets a local (LAN) URL that can be used to access the API. HTTPS will be preferred when available.
  73. /// </summary>
  74. /// <param name="address">The IP address to use as the hostname in the URL.</param>
  75. /// <returns>The API URL.</returns>
  76. string GetLocalApiUrl(IPAddress address);
  77. /// <summary>
  78. /// Gets a local (LAN) URL that can be used to access the API.
  79. /// Note: if passing non-null scheme or port it is up to the caller to ensure they form the correct pair.
  80. /// </summary>
  81. /// <param name="hostname">The hostname to use in the URL.</param>
  82. /// <param name="scheme">
  83. /// The scheme to use for the URL. If null, the scheme will be selected automatically,
  84. /// preferring HTTPS, if available.
  85. /// </param>
  86. /// <param name="port">
  87. /// The port to use for the URL. If null, the port will be selected automatically,
  88. /// preferring the HTTPS port, if available.
  89. /// </param>
  90. /// <returns>The API URL.</returns>
  91. string GetLocalApiUrl(ReadOnlySpan<char> hostname, string scheme = null, int? port = null);
  92. /// <summary>
  93. /// Open a URL in an external browser window.
  94. /// </summary>
  95. /// <param name="url">The URL to open.</param>
  96. /// <exception cref="NotSupportedException"><see cref="CanLaunchWebBrowser"/> is false.</exception>
  97. void LaunchUrl(string url);
  98. void EnableLoopback(string appName);
  99. IEnumerable<WakeOnLanInfo> GetWakeOnLanInfo();
  100. string ExpandVirtualPath(string path);
  101. string ReverseVirtualPath(string path);
  102. }
  103. }