MonoApp.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using MediaBrowser.Common.Net;
  2. using MediaBrowser.IsoMounter;
  3. using MediaBrowser.Model.Logging;
  4. using MediaBrowser.Server.Startup.Common;
  5. using Mono.Unix.Native;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Reflection;
  9. using System.Text.RegularExpressions;
  10. using Emby.Common.Implementations.Networking;
  11. using Emby.Server.Core;
  12. using Emby.Server.Core.Data;
  13. using Emby.Server.Core.FFMpeg;
  14. using MediaBrowser.Model.System;
  15. namespace MediaBrowser.Server.Mono.Native
  16. {
  17. public class MonoApp : INativeApp
  18. {
  19. protected StartupOptions StartupOptions { get; private set; }
  20. protected ILogger Logger { get; private set; }
  21. private readonly MonoEnvironmentInfo _environment;
  22. public MonoApp(StartupOptions startupOptions, ILogger logger, MonoEnvironmentInfo environment)
  23. {
  24. StartupOptions = startupOptions;
  25. Logger = logger;
  26. _environment = environment;
  27. }
  28. /// <summary>
  29. /// Shutdowns this instance.
  30. /// </summary>
  31. public void Shutdown()
  32. {
  33. MainClass.Shutdown();
  34. }
  35. /// <summary>
  36. /// Determines whether this instance [can self restart].
  37. /// </summary>
  38. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  39. public bool CanSelfRestart
  40. {
  41. get
  42. {
  43. // A restart script must be provided
  44. return StartupOptions.ContainsOption("-restartpath");
  45. }
  46. }
  47. /// <summary>
  48. /// Restarts this instance.
  49. /// </summary>
  50. public void Restart(StartupOptions startupOptions)
  51. {
  52. MainClass.Restart(startupOptions);
  53. }
  54. /// <summary>
  55. /// Gets a value indicating whether this instance can self update.
  56. /// </summary>
  57. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  58. public bool CanSelfUpdate
  59. {
  60. get
  61. {
  62. return false;
  63. }
  64. }
  65. public bool SupportsAutoRunAtStartup
  66. {
  67. get { return false; }
  68. }
  69. public List<Assembly> GetAssembliesWithParts()
  70. {
  71. var list = new List<Assembly>();
  72. list.Add(GetType().Assembly);
  73. return list;
  74. }
  75. private IEnumerable<Assembly> GetLinuxAssemblies()
  76. {
  77. var list = new List<Assembly>();
  78. //list.Add(typeof(LinuxIsoManager).Assembly);
  79. return list;
  80. }
  81. public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, string tempDirectory)
  82. {
  83. }
  84. public bool SupportsRunningAsService
  85. {
  86. get
  87. {
  88. return false;
  89. }
  90. }
  91. public bool IsRunningAsService
  92. {
  93. get
  94. {
  95. return false;
  96. }
  97. }
  98. public void ConfigureAutoRun(bool autorun)
  99. {
  100. }
  101. public INetworkManager CreateNetworkManager(ILogger logger)
  102. {
  103. return new NetworkManager(logger);
  104. }
  105. public FFMpegInstallInfo GetFfmpegInstallInfo()
  106. {
  107. var info = new FFMpegInstallInfo();
  108. // Windows builds: http://ffmpeg.zeranoe.com/builds/
  109. // Linux builds: http://johnvansickle.com/ffmpeg/
  110. // OS X builds: http://ffmpegmac.net/
  111. // OS X x64: http://www.evermeet.cx/ffmpeg/
  112. if (_environment.IsBsd)
  113. {
  114. }
  115. else if (_environment.OperatingSystem == Model.System.OperatingSystem.Linux)
  116. {
  117. info.ArchiveType = "7z";
  118. info.Version = "20160215";
  119. }
  120. // No version available - user requirement
  121. info.DownloadUrls = new string[] { };
  122. return info;
  123. }
  124. public void LaunchUrl(string url)
  125. {
  126. throw new NotImplementedException();
  127. }
  128. public IDbConnector GetDbConnector()
  129. {
  130. return new DbConnector(Logger);
  131. }
  132. public void EnableLoopback(string appName)
  133. {
  134. }
  135. }
  136. }