WindowsApp.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using MediaBrowser.Common.IO;
  2. using MediaBrowser.Common.Net;
  3. using MediaBrowser.Controller.Diagnostics;
  4. using MediaBrowser.IsoMounter;
  5. using MediaBrowser.Model.Logging;
  6. using MediaBrowser.Server.Startup.Common;
  7. using MediaBrowser.ServerApplication.Networking;
  8. using System.Collections.Generic;
  9. using System.Reflection;
  10. namespace MediaBrowser.ServerApplication.Native
  11. {
  12. public class WindowsApp : INativeApp
  13. {
  14. private readonly IFileSystem _fileSystem;
  15. public WindowsApp(IFileSystem fileSystem)
  16. {
  17. _fileSystem = fileSystem;
  18. }
  19. public List<Assembly> GetAssembliesWithParts()
  20. {
  21. var list = new List<Assembly>();
  22. list.Add(typeof(PismoIsoManager).Assembly);
  23. list.Add(GetType().Assembly);
  24. return list;
  25. }
  26. public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string tempDirectory)
  27. {
  28. ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, tempDirectory);
  29. }
  30. public NativeEnvironment Environment
  31. {
  32. get
  33. {
  34. return new NativeEnvironment
  35. {
  36. OperatingSystem = OperatingSystem.Windows,
  37. SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
  38. OperatingSystemVersionString = System.Environment.OSVersion.VersionString
  39. };
  40. }
  41. }
  42. public bool SupportsRunningAsService
  43. {
  44. get
  45. {
  46. return true;
  47. }
  48. }
  49. public bool IsRunningAsService
  50. {
  51. get;
  52. set;
  53. }
  54. public bool CanSelfRestart
  55. {
  56. get
  57. {
  58. return MainStartup.CanSelfRestart;
  59. }
  60. }
  61. public bool SupportsAutoRunAtStartup
  62. {
  63. get
  64. {
  65. return true;
  66. }
  67. }
  68. public bool CanSelfUpdate
  69. {
  70. get
  71. {
  72. return MainStartup.CanSelfUpdate;
  73. }
  74. }
  75. public void Shutdown()
  76. {
  77. MainStartup.Shutdown();
  78. }
  79. public void Restart()
  80. {
  81. MainStartup.Restart();
  82. }
  83. public void ConfigureAutoRun(bool autorun)
  84. {
  85. Autorun.Configure(autorun, _fileSystem);
  86. }
  87. public INetworkManager CreateNetworkManager(ILogger logger)
  88. {
  89. return new NetworkManager(logger);
  90. }
  91. public void PreventSystemStandby()
  92. {
  93. Standby.PreventSystemStandby();
  94. }
  95. public IProcessManager GetProcessManager()
  96. {
  97. return new WindowsProcessManager();
  98. }
  99. }
  100. }