ApplicationHost.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. using MediaBrowser.Api;
  2. using MediaBrowser.Common;
  3. using MediaBrowser.Common.Configuration;
  4. using MediaBrowser.Common.Events;
  5. using MediaBrowser.Common.Extensions;
  6. using MediaBrowser.Common.Implementations;
  7. using MediaBrowser.Common.Implementations.ScheduledTasks;
  8. using MediaBrowser.Common.IO;
  9. using MediaBrowser.Common.Net;
  10. using MediaBrowser.Common.Progress;
  11. using MediaBrowser.Controller;
  12. using MediaBrowser.Controller.Channels;
  13. using MediaBrowser.Controller.Chapters;
  14. using MediaBrowser.Controller.Collections;
  15. using MediaBrowser.Controller.Configuration;
  16. using MediaBrowser.Controller.Dlna;
  17. using MediaBrowser.Controller.Drawing;
  18. using MediaBrowser.Controller.Dto;
  19. using MediaBrowser.Controller.Entities;
  20. using MediaBrowser.Controller.FileOrganization;
  21. using MediaBrowser.Controller.Library;
  22. using MediaBrowser.Controller.LiveTv;
  23. using MediaBrowser.Controller.Localization;
  24. using MediaBrowser.Controller.MediaEncoding;
  25. using MediaBrowser.Controller.Net;
  26. using MediaBrowser.Controller.News;
  27. using MediaBrowser.Controller.Notifications;
  28. using MediaBrowser.Controller.Persistence;
  29. using MediaBrowser.Controller.Plugins;
  30. using MediaBrowser.Controller.Providers;
  31. using MediaBrowser.Controller.Resolvers;
  32. using MediaBrowser.Controller.Security;
  33. using MediaBrowser.Controller.Session;
  34. using MediaBrowser.Controller.Sorting;
  35. using MediaBrowser.Controller.Subtitles;
  36. using MediaBrowser.Controller.Themes;
  37. using MediaBrowser.Dlna;
  38. using MediaBrowser.Dlna.ConnectionManager;
  39. using MediaBrowser.Dlna.ContentDirectory;
  40. using MediaBrowser.Dlna.Main;
  41. using MediaBrowser.LocalMetadata.Providers;
  42. using MediaBrowser.MediaEncoding.BdInfo;
  43. using MediaBrowser.MediaEncoding.Encoder;
  44. using MediaBrowser.MediaEncoding.Subtitles;
  45. using MediaBrowser.Model.Logging;
  46. using MediaBrowser.Model.MediaInfo;
  47. using MediaBrowser.Model.System;
  48. using MediaBrowser.Model.Updates;
  49. using MediaBrowser.Providers.Chapters;
  50. using MediaBrowser.Providers.Manager;
  51. using MediaBrowser.Providers.Subtitles;
  52. using MediaBrowser.Server.Implementations;
  53. using MediaBrowser.Server.Implementations.Channels;
  54. using MediaBrowser.Server.Implementations.Collections;
  55. using MediaBrowser.Server.Implementations.Configuration;
  56. using MediaBrowser.Server.Implementations.Drawing;
  57. using MediaBrowser.Server.Implementations.Dto;
  58. using MediaBrowser.Server.Implementations.EntryPoints;
  59. using MediaBrowser.Server.Implementations.FileOrganization;
  60. using MediaBrowser.Server.Implementations.HttpServer;
  61. using MediaBrowser.Server.Implementations.HttpServer.Security;
  62. using MediaBrowser.Server.Implementations.IO;
  63. using MediaBrowser.Server.Implementations.Library;
  64. using MediaBrowser.Server.Implementations.LiveTv;
  65. using MediaBrowser.Server.Implementations.Localization;
  66. using MediaBrowser.Server.Implementations.MediaEncoder;
  67. using MediaBrowser.Server.Implementations.Notifications;
  68. using MediaBrowser.Server.Implementations.Persistence;
  69. using MediaBrowser.Server.Implementations.Security;
  70. using MediaBrowser.Server.Implementations.ServerManager;
  71. using MediaBrowser.Server.Implementations.Session;
  72. using MediaBrowser.Server.Implementations.Themes;
  73. using MediaBrowser.Server.Implementations.WebSocket;
  74. using MediaBrowser.ServerApplication.EntryPoints;
  75. using MediaBrowser.ServerApplication.FFMpeg;
  76. using MediaBrowser.ServerApplication.IO;
  77. using MediaBrowser.ServerApplication.Native;
  78. using MediaBrowser.ServerApplication.Networking;
  79. using MediaBrowser.WebDashboard.Api;
  80. using MediaBrowser.XbmcMetadata.Providers;
  81. using System;
  82. using System.Collections.Generic;
  83. using System.Globalization;
  84. using System.IO;
  85. using System.Linq;
  86. using System.Reflection;
  87. using System.Threading;
  88. using System.Threading.Tasks;
  89. namespace MediaBrowser.ServerApplication
  90. {
  91. /// <summary>
  92. /// Class CompositionRoot
  93. /// </summary>
  94. public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost
  95. {
  96. /// <summary>
  97. /// Gets the server configuration manager.
  98. /// </summary>
  99. /// <value>The server configuration manager.</value>
  100. public IServerConfigurationManager ServerConfigurationManager
  101. {
  102. get { return (IServerConfigurationManager)ConfigurationManager; }
  103. }
  104. /// <summary>
  105. /// Gets the name of the web application that can be used for url building.
  106. /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/...
  107. /// </summary>
  108. /// <value>The name of the web application.</value>
  109. public string WebApplicationName
  110. {
  111. get { return "mediabrowser"; }
  112. }
  113. /// <summary>
  114. /// Gets the HTTP server URL prefix.
  115. /// </summary>
  116. /// <value>The HTTP server URL prefix.</value>
  117. private IEnumerable<string> HttpServerUrlPrefixes
  118. {
  119. get
  120. {
  121. var list = new List<string>
  122. {
  123. "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/"
  124. };
  125. return list;
  126. }
  127. }
  128. /// <summary>
  129. /// Gets the configuration manager.
  130. /// </summary>
  131. /// <returns>IConfigurationManager.</returns>
  132. protected override IConfigurationManager GetConfigurationManager()
  133. {
  134. return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
  135. }
  136. /// <summary>
  137. /// Gets or sets the server manager.
  138. /// </summary>
  139. /// <value>The server manager.</value>
  140. private IServerManager ServerManager { get; set; }
  141. /// <summary>
  142. /// Gets or sets the user manager.
  143. /// </summary>
  144. /// <value>The user manager.</value>
  145. public IUserManager UserManager { get; set; }
  146. /// <summary>
  147. /// Gets or sets the library manager.
  148. /// </summary>
  149. /// <value>The library manager.</value>
  150. internal ILibraryManager LibraryManager { get; set; }
  151. /// <summary>
  152. /// Gets or sets the directory watchers.
  153. /// </summary>
  154. /// <value>The directory watchers.</value>
  155. private ILibraryMonitor LibraryMonitor { get; set; }
  156. /// <summary>
  157. /// Gets or sets the provider manager.
  158. /// </summary>
  159. /// <value>The provider manager.</value>
  160. private IProviderManager ProviderManager { get; set; }
  161. /// <summary>
  162. /// Gets or sets the HTTP server.
  163. /// </summary>
  164. /// <value>The HTTP server.</value>
  165. private IHttpServer HttpServer { get; set; }
  166. private IDtoService DtoService { get; set; }
  167. private IImageProcessor ImageProcessor { get; set; }
  168. private ISeriesOrderManager SeriesOrderManager { get; set; }
  169. /// <summary>
  170. /// Gets or sets the media encoder.
  171. /// </summary>
  172. /// <value>The media encoder.</value>
  173. private IMediaEncoder MediaEncoder { get; set; }
  174. private ISessionManager SessionManager { get; set; }
  175. private ILiveTvManager LiveTvManager { get; set; }
  176. internal ILocalizationManager LocalizationManager { get; set; }
  177. private IEncodingManager EncodingManager { get; set; }
  178. private IChannelManager ChannelManager { get; set; }
  179. /// <summary>
  180. /// Gets or sets the user data repository.
  181. /// </summary>
  182. /// <value>The user data repository.</value>
  183. private IUserDataManager UserDataManager { get; set; }
  184. private IUserRepository UserRepository { get; set; }
  185. internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
  186. internal IItemRepository ItemRepository { get; set; }
  187. private INotificationsRepository NotificationsRepository { get; set; }
  188. private IFileOrganizationRepository FileOrganizationRepository { get; set; }
  189. private IProviderRepository ProviderRepository { get; set; }
  190. private INotificationManager NotificationManager { get; set; }
  191. private ISubtitleManager SubtitleManager { get; set; }
  192. private IChapterManager ChapterManager { get; set; }
  193. private IUserViewManager UserViewManager { get; set; }
  194. private IAuthenticationRepository AuthenticationRepository { get; set; }
  195. /// <summary>
  196. /// Initializes a new instance of the <see cref="ApplicationHost"/> class.
  197. /// </summary>
  198. /// <param name="applicationPaths">The application paths.</param>
  199. /// <param name="logManager">The log manager.</param>
  200. public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, bool isRunningAsService)
  201. : base(applicationPaths, logManager)
  202. {
  203. _isRunningAsService = isRunningAsService;
  204. }
  205. private readonly bool _isRunningAsService;
  206. public override bool IsRunningAsService
  207. {
  208. get { return _isRunningAsService; }
  209. }
  210. /// <summary>
  211. /// Gets the name.
  212. /// </summary>
  213. /// <value>The name.</value>
  214. public override string Name
  215. {
  216. get
  217. {
  218. return "Media Browser Server";
  219. }
  220. }
  221. /// <summary>
  222. /// Gets a value indicating whether this instance can self restart.
  223. /// </summary>
  224. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  225. public override bool CanSelfRestart
  226. {
  227. get { return NativeApp.CanSelfRestart; }
  228. }
  229. public bool SupportsAutoRunAtStartup
  230. {
  231. get { return NativeApp.SupportsAutoRunAtStartup; }
  232. }
  233. /// <summary>
  234. /// Runs the startup tasks.
  235. /// </summary>
  236. /// <returns>Task.</returns>
  237. public override async Task RunStartupTasks()
  238. {
  239. await base.RunStartupTasks().ConfigureAwait(false);
  240. Logger.Info("Core startup complete");
  241. Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint =>
  242. {
  243. try
  244. {
  245. entryPoint.Run();
  246. }
  247. catch (Exception ex)
  248. {
  249. Logger.ErrorException("Error in {0}", ex, entryPoint.GetType().Name);
  250. }
  251. });
  252. LogManager.RemoveConsoleOutput();
  253. }
  254. public override async Task Init(IProgress<double> progress)
  255. {
  256. PerformVersionMigration();
  257. await base.Init(progress).ConfigureAwait(false);
  258. MigrateModularConfigurations();
  259. ApplyDefaultMetadataSettings();
  260. }
  261. private void PerformVersionMigration()
  262. {
  263. DeleteDeprecatedModules();
  264. }
  265. private void MigrateModularConfigurations()
  266. {
  267. var saveConfig = false;
  268. if (ServerConfigurationManager.Configuration.DlnaOptions != null)
  269. {
  270. ServerConfigurationManager.SaveConfiguration("dlna", ServerConfigurationManager.Configuration.DlnaOptions);
  271. ServerConfigurationManager.Configuration.DlnaOptions = null;
  272. saveConfig = true;
  273. }
  274. if (ServerConfigurationManager.Configuration.ChapterOptions != null)
  275. {
  276. ServerConfigurationManager.SaveConfiguration("chapters", ServerConfigurationManager.Configuration.ChapterOptions);
  277. ServerConfigurationManager.Configuration.ChapterOptions = null;
  278. saveConfig = true;
  279. }
  280. if (ServerConfigurationManager.Configuration.ChannelOptions != null)
  281. {
  282. ServerConfigurationManager.SaveConfiguration("channels", ServerConfigurationManager.Configuration.ChannelOptions);
  283. ServerConfigurationManager.Configuration.ChannelOptions = null;
  284. saveConfig = true;
  285. }
  286. if (ServerConfigurationManager.Configuration.NotificationOptions != null)
  287. {
  288. ServerConfigurationManager.SaveConfiguration("notifications", ServerConfigurationManager.Configuration.NotificationOptions);
  289. ServerConfigurationManager.Configuration.NotificationOptions = null;
  290. saveConfig = true;
  291. }
  292. if (saveConfig)
  293. {
  294. ServerConfigurationManager.SaveConfiguration();
  295. }
  296. }
  297. private void ApplyDefaultMetadataSettings()
  298. {
  299. if (!ServerConfigurationManager.Configuration.DefaultMetadataSettingsApplied &&
  300. ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
  301. {
  302. // Make sure xbmc metadata is disabled for existing users.
  303. // New users will be handled by the startup wizard.
  304. ServerConfigurationManager.SetPreferredMetadataService("Media Browser Xml");
  305. }
  306. ServerConfigurationManager.Configuration.DefaultMetadataSettingsApplied = true;
  307. ServerConfigurationManager.SaveConfiguration();
  308. }
  309. private void DeleteDeprecatedModules()
  310. {
  311. try
  312. {
  313. MigrateUserFolders();
  314. }
  315. catch (IOException)
  316. {
  317. }
  318. try
  319. {
  320. File.Delete(Path.Combine(ApplicationPaths.PluginsPath, "MBPhoto.dll"));
  321. }
  322. catch (IOException)
  323. {
  324. // Not there, no big deal
  325. }
  326. try
  327. {
  328. File.Delete(Path.Combine(ApplicationPaths.PluginsPath, "MediaBrowser.Plugins.XbmcMetadata.dll"));
  329. }
  330. catch (IOException)
  331. {
  332. // Not there, no big deal
  333. }
  334. Task.Run(() =>
  335. {
  336. try
  337. {
  338. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "remote-images"), true);
  339. }
  340. catch (IOException)
  341. {
  342. // Not there, no big deal
  343. }
  344. try
  345. {
  346. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "chapter-images"), true);
  347. }
  348. catch (IOException)
  349. {
  350. // Not there, no big deal
  351. }
  352. try
  353. {
  354. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "extracted-video-images"), true);
  355. }
  356. catch (IOException)
  357. {
  358. // Not there, no big deal
  359. }
  360. try
  361. {
  362. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "extracted-audio-images"), true);
  363. }
  364. catch (IOException)
  365. {
  366. // Not there, no big deal
  367. }
  368. try
  369. {
  370. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "tmdb-tv"), true);
  371. }
  372. catch (IOException)
  373. {
  374. // Not there, no big deal
  375. }
  376. try
  377. {
  378. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "tmdb-collections"), true);
  379. }
  380. catch (IOException)
  381. {
  382. // Not there, no big deal
  383. }
  384. try
  385. {
  386. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "tmdb-movies"), true);
  387. }
  388. catch (IOException)
  389. {
  390. // Not there, no big deal
  391. }
  392. try
  393. {
  394. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "fanart-movies"), true);
  395. }
  396. catch (IOException)
  397. {
  398. // Not there, no big deal
  399. }
  400. try
  401. {
  402. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "fanart-music"), true);
  403. }
  404. catch (IOException)
  405. {
  406. // Not there, no big deal
  407. }
  408. try
  409. {
  410. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "fanart-tv"), true);
  411. }
  412. catch (IOException)
  413. {
  414. // Not there, no big deal
  415. }
  416. try
  417. {
  418. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "tmdb-people"), true);
  419. }
  420. catch (IOException)
  421. {
  422. // Not there, no big deal
  423. }
  424. try
  425. {
  426. Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "tvdb-v3"), true);
  427. }
  428. catch (IOException)
  429. {
  430. // Not there, no big deal
  431. }
  432. });
  433. }
  434. private void MigrateUserFolders()
  435. {
  436. var rootPath = ApplicationPaths.RootFolderPath;
  437. var folders = new DirectoryInfo(rootPath).EnumerateDirectories("*", SearchOption.TopDirectoryOnly).Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
  438. .ToList();
  439. foreach (var folder in folders)
  440. {
  441. Directory.Delete(folder.FullName, true);
  442. }
  443. }
  444. /// <summary>
  445. /// Registers resources that classes will depend on
  446. /// </summary>
  447. /// <returns>Task.</returns>
  448. protected override async Task RegisterResources(IProgress<double> progress)
  449. {
  450. await base.RegisterResources(progress).ConfigureAwait(false);
  451. RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager, FileSystemManager, JsonSerializer));
  452. RegisterSingleInstance<IServerApplicationHost>(this);
  453. RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
  454. RegisterSingleInstance(ServerConfigurationManager);
  455. LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer);
  456. RegisterSingleInstance(LocalizationManager);
  457. RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
  458. RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
  459. UserDataManager = new UserDataManager(LogManager);
  460. RegisterSingleInstance(UserDataManager);
  461. UserRepository = await GetUserRepository().ConfigureAwait(false);
  462. RegisterSingleInstance(UserRepository);
  463. DisplayPreferencesRepository = new SqliteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
  464. RegisterSingleInstance(DisplayPreferencesRepository);
  465. ItemRepository = new SqliteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
  466. RegisterSingleInstance(ItemRepository);
  467. ProviderRepository = new SqliteProviderInfoRepository(ApplicationPaths, LogManager);
  468. RegisterSingleInstance(ProviderRepository);
  469. FileOrganizationRepository = await GetFileOrganizationRepository().ConfigureAwait(false);
  470. RegisterSingleInstance(FileOrganizationRepository);
  471. AuthenticationRepository = await GetAuthenticationRepository().ConfigureAwait(false);
  472. RegisterSingleInstance(AuthenticationRepository);
  473. UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer);
  474. RegisterSingleInstance(UserManager);
  475. LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);
  476. RegisterSingleInstance(LibraryManager);
  477. var musicManager = new MusicManager(LibraryManager);
  478. RegisterSingleInstance<IMusicManager>(new MusicManager(LibraryManager));
  479. LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager);
  480. RegisterSingleInstance(LibraryMonitor);
  481. ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager);
  482. RegisterSingleInstance(ProviderManager);
  483. SeriesOrderManager = new SeriesOrderManager();
  484. RegisterSingleInstance(SeriesOrderManager);
  485. RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
  486. HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html");
  487. RegisterSingleInstance(HttpServer, false);
  488. progress.Report(10);
  489. ServerManager = new ServerManager(this, JsonSerializer, LogManager.GetLogger("ServerManager"), ServerConfigurationManager);
  490. RegisterSingleInstance(ServerManager);
  491. var innerProgress = new ActionableProgress<double>();
  492. innerProgress.RegisterAction(p => progress.Report((.75 * p) + 15));
  493. await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);
  494. progress.Report(90);
  495. ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
  496. RegisterSingleInstance(ImageProcessor);
  497. DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager);
  498. RegisterSingleInstance(DtoService);
  499. SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository);
  500. RegisterSingleInstance(SessionManager);
  501. var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
  502. RegisterSingleInstance<INewsService>(newsService);
  503. var fileOrganizationService = new FileOrganizationService(TaskManager, FileOrganizationRepository, LogManager.GetLogger("FileOrganizationService"), LibraryMonitor, LibraryManager, ServerConfigurationManager, FileSystemManager, ProviderManager);
  504. RegisterSingleInstance<IFileOrganizationService>(fileOrganizationService);
  505. progress.Report(15);
  506. ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, Logger, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager);
  507. RegisterSingleInstance(ChannelManager);
  508. var appThemeManager = new AppThemeManager(ApplicationPaths, FileSystemManager, JsonSerializer, Logger);
  509. RegisterSingleInstance<IAppThemeManager>(appThemeManager);
  510. var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer);
  511. RegisterSingleInstance<IDlnaManager>(dlnaManager);
  512. var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient);
  513. RegisterSingleInstance<IContentDirectory>(contentDirectory);
  514. var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient);
  515. RegisterSingleInstance<IConnectionManager>(connectionManager);
  516. var collectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("CollectionManager"));
  517. RegisterSingleInstance<ICollectionManager>(collectionManager);
  518. LiveTvManager = new LiveTvManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager);
  519. RegisterSingleInstance(LiveTvManager);
  520. UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, FileSystemManager, UserManager, ChannelManager, LiveTvManager);
  521. RegisterSingleInstance(UserViewManager);
  522. NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);
  523. RegisterSingleInstance(NotificationManager);
  524. RegisterSingleInstance<IEncryptionManager>(new EncryptionManager());
  525. SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, ItemRepository);
  526. RegisterSingleInstance(SubtitleManager);
  527. ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
  528. RegisterSingleInstance(ChapterManager);
  529. EncodingManager = new EncodingManager(ServerConfigurationManager, FileSystemManager, Logger,
  530. MediaEncoder, ChapterManager);
  531. RegisterSingleInstance(EncodingManager);
  532. var authContext = new AuthorizationContext();
  533. RegisterSingleInstance<IAuthorizationContext>(authContext);
  534. RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
  535. RegisterSingleInstance<IAuthService>(new AuthService(UserManager, SessionManager, authContext, ServerConfigurationManager));
  536. RegisterSingleInstance<ISubtitleEncoder>(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder));
  537. var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
  538. var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
  539. var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
  540. await ConfigureNotificationsRepository().ConfigureAwait(false);
  541. progress.Report(92);
  542. await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
  543. progress.Report(100);
  544. SetStaticProperties();
  545. await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
  546. SetKernelProperties();
  547. }
  548. protected override INetworkManager CreateNetworkManager()
  549. {
  550. return new NetworkManager();
  551. }
  552. protected override IFileSystem CreateFileSystemManager()
  553. {
  554. return FileSystemFactory.CreateFileSystemManager(LogManager);
  555. }
  556. /// <summary>
  557. /// Registers the media encoder.
  558. /// </summary>
  559. /// <returns>Task.</returns>
  560. private async Task RegisterMediaEncoder(IProgress<double> progress)
  561. {
  562. var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager).GetFFMpegInfo(progress).ConfigureAwait(false);
  563. MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), JsonSerializer, info.EncoderPath, info.ProbePath, info.Version);
  564. RegisterSingleInstance(MediaEncoder);
  565. }
  566. /// <summary>
  567. /// Sets the kernel properties.
  568. /// </summary>
  569. private void SetKernelProperties()
  570. {
  571. LocalizedStrings.StringFiles = GetExports<LocalizedStringData>();
  572. }
  573. /// <summary>
  574. /// Gets the user repository.
  575. /// </summary>
  576. /// <returns>Task{IUserRepository}.</returns>
  577. private async Task<IUserRepository> GetUserRepository()
  578. {
  579. var repo = new SqliteUserRepository(JsonSerializer, LogManager, ApplicationPaths);
  580. await repo.Initialize().ConfigureAwait(false);
  581. return repo;
  582. }
  583. /// <summary>
  584. /// Gets the file organization repository.
  585. /// </summary>
  586. /// <returns>Task{IUserRepository}.</returns>
  587. private async Task<IFileOrganizationRepository> GetFileOrganizationRepository()
  588. {
  589. var repo = new SqliteFileOrganizationRepository(LogManager, ServerConfigurationManager.ApplicationPaths);
  590. await repo.Initialize().ConfigureAwait(false);
  591. return repo;
  592. }
  593. private async Task<IAuthenticationRepository> GetAuthenticationRepository()
  594. {
  595. var repo = new AuthenticationRepository(LogManager.GetLogger("AuthenticationRepository"), ServerConfigurationManager.ApplicationPaths);
  596. await repo.Initialize().ConfigureAwait(false);
  597. return repo;
  598. }
  599. /// <summary>
  600. /// Configures the repositories.
  601. /// </summary>
  602. /// <returns>Task.</returns>
  603. private async Task ConfigureNotificationsRepository()
  604. {
  605. var repo = new SqliteNotificationsRepository(LogManager, ApplicationPaths);
  606. await repo.Initialize().ConfigureAwait(false);
  607. NotificationsRepository = repo;
  608. RegisterSingleInstance(NotificationsRepository);
  609. }
  610. /// <summary>
  611. /// Configures the repositories.
  612. /// </summary>
  613. /// <returns>Task.</returns>
  614. private async Task ConfigureDisplayPreferencesRepositories()
  615. {
  616. await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
  617. }
  618. /// <summary>
  619. /// Configures the item repositories.
  620. /// </summary>
  621. /// <returns>Task.</returns>
  622. private async Task ConfigureItemRepositories()
  623. {
  624. await ItemRepository.Initialize().ConfigureAwait(false);
  625. await ProviderRepository.Initialize().ConfigureAwait(false);
  626. ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
  627. }
  628. /// <summary>
  629. /// Configures the user data repositories.
  630. /// </summary>
  631. /// <returns>Task.</returns>
  632. private async Task ConfigureUserDataRepositories()
  633. {
  634. var repo = new SqliteUserDataRepository(ApplicationPaths, LogManager);
  635. await repo.Initialize().ConfigureAwait(false);
  636. ((UserDataManager)UserDataManager).Repository = repo;
  637. }
  638. /// <summary>
  639. /// Dirty hacks
  640. /// </summary>
  641. private void SetStaticProperties()
  642. {
  643. // For now there's no real way to inject these properly
  644. BaseItem.Logger = LogManager.GetLogger("BaseItem");
  645. BaseItem.ConfigurationManager = ServerConfigurationManager;
  646. BaseItem.LibraryManager = LibraryManager;
  647. BaseItem.ProviderManager = ProviderManager;
  648. BaseItem.LocalizationManager = LocalizationManager;
  649. BaseItem.ItemRepository = ItemRepository;
  650. User.XmlSerializer = XmlSerializer;
  651. User.UserManager = UserManager;
  652. LocalizedStrings.ApplicationPaths = ApplicationPaths;
  653. Folder.UserManager = UserManager;
  654. BaseItem.FileSystem = FileSystemManager;
  655. BaseItem.UserDataManager = UserDataManager;
  656. ChannelVideoItem.ChannelManager = ChannelManager;
  657. }
  658. /// <summary>
  659. /// Finds the parts.
  660. /// </summary>
  661. protected override void FindParts()
  662. {
  663. if (IsFirstRun)
  664. {
  665. RegisterServerWithAdministratorAccess();
  666. }
  667. base.FindParts();
  668. HttpServer.Init(GetExports<IRestfulService>(false));
  669. ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
  670. StartServer(true);
  671. LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
  672. GetExports<IVirtualFolderCreator>(),
  673. GetExports<IItemResolver>(),
  674. GetExports<IIntroProvider>(),
  675. GetExports<IBaseItemComparer>(),
  676. GetExports<ILibraryPostScanTask>());
  677. ProviderManager.AddParts(GetExports<IImageProvider>(),
  678. GetExports<IMetadataService>(),
  679. GetExports<IItemIdentityProvider>(),
  680. GetExports<IItemIdentityConverter>(),
  681. GetExports<IMetadataProvider>(),
  682. GetExports<IMetadataSaver>(),
  683. GetExports<IImageSaver>(),
  684. GetExports<IExternalId>());
  685. SeriesOrderManager.AddParts(GetExports<ISeriesOrderProvider>());
  686. ImageProcessor.AddParts(GetExports<IImageEnhancer>());
  687. LiveTvManager.AddParts(GetExports<ILiveTvService>());
  688. SubtitleManager.AddParts(GetExports<ISubtitleProvider>());
  689. ChapterManager.AddParts(GetExports<IChapterProvider>());
  690. SessionManager.AddParts(GetExports<ISessionControllerFactory>());
  691. ChannelManager.AddParts(GetExports<IChannel>(), GetExports<IChannelFactory>());
  692. NotificationManager.AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());
  693. }
  694. /// <summary>
  695. /// Starts the server.
  696. /// </summary>
  697. /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
  698. private void StartServer(bool retryOnFailure)
  699. {
  700. try
  701. {
  702. ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.EnableHttpLevelLogging);
  703. }
  704. catch (Exception ex)
  705. {
  706. Logger.ErrorException("Error starting http server", ex);
  707. if (retryOnFailure)
  708. {
  709. RegisterServerWithAdministratorAccess();
  710. StartServer(false);
  711. }
  712. else
  713. {
  714. throw;
  715. }
  716. }
  717. ServerManager.StartWebSocketServer();
  718. }
  719. /// <summary>
  720. /// Called when [configuration updated].
  721. /// </summary>
  722. /// <param name="sender">The sender.</param>
  723. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  724. protected override void OnConfigurationUpdated(object sender, EventArgs e)
  725. {
  726. base.OnConfigurationUpdated(sender, e);
  727. HttpServer.EnableHttpRequestLogging = ServerConfigurationManager.Configuration.EnableHttpLevelLogging;
  728. if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase))
  729. {
  730. NotifyPendingRestart();
  731. }
  732. else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber)
  733. {
  734. NotifyPendingRestart();
  735. }
  736. }
  737. /// <summary>
  738. /// Restarts this instance.
  739. /// </summary>
  740. public override async Task Restart()
  741. {
  742. if (!CanSelfRestart)
  743. {
  744. throw new InvalidOperationException("The server is unable to self-restart. Please restart manually.");
  745. }
  746. try
  747. {
  748. await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false);
  749. }
  750. catch (Exception ex)
  751. {
  752. Logger.ErrorException("Error sending server restart notification", ex);
  753. }
  754. Logger.Debug("Calling NativeApp.Restart");
  755. NativeApp.Restart();
  756. }
  757. /// <summary>
  758. /// Gets or sets a value indicating whether this instance can self update.
  759. /// </summary>
  760. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  761. public override bool CanSelfUpdate
  762. {
  763. get
  764. {
  765. #if DEBUG
  766. return false;
  767. #endif
  768. #pragma warning disable 162
  769. return NativeApp.CanSelfUpdate;
  770. #pragma warning restore 162
  771. }
  772. }
  773. /// <summary>
  774. /// Gets the composable part assemblies.
  775. /// </summary>
  776. /// <returns>IEnumerable{Assembly}.</returns>
  777. protected override IEnumerable<Assembly> GetComposablePartAssemblies()
  778. {
  779. var list = GetPluginAssemblies()
  780. .ToList();
  781. // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
  782. // This will prevent the .dll file from getting locked, and allow us to replace it when needed
  783. // Include composable parts in the Api assembly
  784. list.Add(typeof(ApiEntryPoint).Assembly);
  785. // Include composable parts in the Dashboard assembly
  786. list.Add(typeof(DashboardService).Assembly);
  787. // Include composable parts in the Model assembly
  788. list.Add(typeof(SystemInfo).Assembly);
  789. // Include composable parts in the Common assembly
  790. list.Add(typeof(IApplicationHost).Assembly);
  791. // Include composable parts in the Controller assembly
  792. list.Add(typeof(IServerApplicationHost).Assembly);
  793. // Include composable parts in the Providers assembly
  794. list.Add(typeof(ProviderUtils).Assembly);
  795. // Common implementations
  796. list.Add(typeof(TaskManager).Assembly);
  797. // Server implementations
  798. list.Add(typeof(ServerApplicationPaths).Assembly);
  799. // MediaEncoding
  800. list.Add(typeof(MediaEncoder).Assembly);
  801. // Dlna
  802. list.Add(typeof(DlnaEntryPoint).Assembly);
  803. // Local metadata
  804. list.Add(typeof(AlbumXmlProvider).Assembly);
  805. // Xbmc
  806. list.Add(typeof(ArtistNfoProvider).Assembly);
  807. list.AddRange(Assemblies.GetAssembliesWithParts());
  808. // Include composable parts in the running assembly
  809. list.Add(GetType().Assembly);
  810. return list;
  811. }
  812. /// <summary>
  813. /// Gets the plugin assemblies.
  814. /// </summary>
  815. /// <returns>IEnumerable{Assembly}.</returns>
  816. private IEnumerable<Assembly> GetPluginAssemblies()
  817. {
  818. try
  819. {
  820. return Directory.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
  821. .Select(LoadAssembly)
  822. .Where(a => a != null)
  823. .ToList();
  824. }
  825. catch (DirectoryNotFoundException)
  826. {
  827. return new List<Assembly>();
  828. }
  829. }
  830. private readonly string _systemId = Environment.MachineName.GetMD5().ToString();
  831. /// <summary>
  832. /// Gets the system status.
  833. /// </summary>
  834. /// <returns>SystemInfo.</returns>
  835. public virtual SystemInfo GetSystemInfo()
  836. {
  837. return new SystemInfo
  838. {
  839. HasPendingRestart = HasPendingRestart,
  840. Version = ApplicationVersion.ToString(),
  841. IsNetworkDeployed = CanSelfUpdate,
  842. WebSocketPortNumber = ServerManager.WebSocketPortNumber,
  843. SupportsNativeWebSocket = ServerManager.SupportsNativeWebSocket,
  844. FailedPluginAssemblies = FailedAssemblies.ToList(),
  845. InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(),
  846. CompletedInstallations = InstallationManager.CompletedInstallations.ToList(),
  847. Id = _systemId,
  848. ProgramDataPath = ApplicationPaths.ProgramDataPath,
  849. LogPath = ApplicationPaths.LogDirectoryPath,
  850. ItemsByNamePath = ApplicationPaths.ItemsByNamePath,
  851. InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
  852. CachePath = ApplicationPaths.CachePath,
  853. MacAddress = GetMacAddress(),
  854. HttpServerPortNumber = HttpServerPort,
  855. OperatingSystem = Environment.OSVersion.ToString(),
  856. CanSelfRestart = CanSelfRestart,
  857. CanSelfUpdate = CanSelfUpdate,
  858. WanAddress = GetWanAddress(),
  859. HasUpdateAvailable = HasUpdateAvailable,
  860. SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
  861. TranscodingTempPath = ApplicationPaths.TranscodingTempPath,
  862. IsRunningAsService = IsRunningAsService,
  863. ServerName = string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.ServerName) ? Environment.MachineName : ServerConfigurationManager.Configuration.ServerName
  864. };
  865. }
  866. public int HttpServerPort
  867. {
  868. get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; }
  869. }
  870. private readonly CultureInfo _usCulture = new CultureInfo("en-US");
  871. private string GetWanAddress()
  872. {
  873. var ip = ServerConfigurationManager.Configuration.WanDdns;
  874. if (string.IsNullOrWhiteSpace(ip))
  875. {
  876. ip = WanAddressEntryPoint.WanAddress;
  877. }
  878. if (!string.IsNullOrEmpty(ip))
  879. {
  880. if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
  881. !ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
  882. {
  883. ip = "http://" + ip;
  884. }
  885. return ip + ":" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(_usCulture);
  886. }
  887. return null;
  888. }
  889. /// <summary>
  890. /// Gets the mac address.
  891. /// </summary>
  892. /// <returns>System.String.</returns>
  893. private string GetMacAddress()
  894. {
  895. try
  896. {
  897. return NetworkManager.GetMacAddress();
  898. }
  899. catch (Exception ex)
  900. {
  901. Logger.ErrorException("Error getting mac address", ex);
  902. return null;
  903. }
  904. }
  905. /// <summary>
  906. /// Shuts down.
  907. /// </summary>
  908. public override async Task Shutdown()
  909. {
  910. try
  911. {
  912. await SessionManager.SendServerShutdownNotification(CancellationToken.None).ConfigureAwait(false);
  913. }
  914. catch (Exception ex)
  915. {
  916. Logger.ErrorException("Error sending server shutdown notification", ex);
  917. }
  918. NativeApp.Shutdown();
  919. }
  920. /// <summary>
  921. /// Registers the server with administrator access.
  922. /// </summary>
  923. private void RegisterServerWithAdministratorAccess()
  924. {
  925. Logger.Info("Requesting administrative access to authorize http server");
  926. try
  927. {
  928. ServerAuthorization.AuthorizeServer(
  929. ServerConfigurationManager.Configuration.HttpServerPortNumber,
  930. HttpServerUrlPrefixes.First(),
  931. ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber,
  932. UdpServerEntryPoint.PortNumber,
  933. ConfigurationManager.CommonApplicationPaths.TempDirectory);
  934. }
  935. catch (Exception ex)
  936. {
  937. Logger.ErrorException("Error authorizing server", ex);
  938. }
  939. }
  940. public event EventHandler HasUpdateAvailableChanged;
  941. private bool _hasUpdateAvailable;
  942. public bool HasUpdateAvailable
  943. {
  944. get { return _hasUpdateAvailable; }
  945. set
  946. {
  947. var fireEvent = value && !_hasUpdateAvailable;
  948. _hasUpdateAvailable = value;
  949. if (fireEvent)
  950. {
  951. EventHelper.FireEventIfNotNull(HasUpdateAvailableChanged, this, EventArgs.Empty, Logger);
  952. }
  953. }
  954. }
  955. /// <summary>
  956. /// Checks for update.
  957. /// </summary>
  958. /// <param name="cancellationToken">The cancellation token.</param>
  959. /// <param name="progress">The progress.</param>
  960. /// <returns>Task{CheckForUpdateResult}.</returns>
  961. public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
  962. {
  963. var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
  964. var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, "MBServer", null, ApplicationVersion,
  965. ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
  966. var versionObject = version == null || string.IsNullOrWhiteSpace(version.versionStr) ? null : new Version(version.versionStr);
  967. HasUpdateAvailable = versionObject != null && versionObject >= ApplicationVersion;
  968. if (versionObject != null && versionObject >= ApplicationVersion)
  969. {
  970. Logger.Info("New application version is available: {0}", versionObject);
  971. }
  972. return versionObject != null ?
  973. new CheckForUpdateResult { AvailableVersion = versionObject.ToString(), IsUpdateAvailable = versionObject > ApplicationVersion, Package = version } :
  974. new CheckForUpdateResult { AvailableVersion = ApplicationVersion.ToString(), IsUpdateAvailable = false };
  975. }
  976. /// <summary>
  977. /// Updates the application.
  978. /// </summary>
  979. /// <param name="package">The package that contains the update</param>
  980. /// <param name="cancellationToken">The cancellation token.</param>
  981. /// <param name="progress">The progress.</param>
  982. /// <returns>Task.</returns>
  983. public override async Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress)
  984. {
  985. await InstallationManager.InstallPackage(package, progress, cancellationToken).ConfigureAwait(false);
  986. HasUpdateAvailable = false;
  987. OnApplicationUpdated(package);
  988. }
  989. /// <summary>
  990. /// Configures the automatic run at startup.
  991. /// </summary>
  992. /// <param name="autorun">if set to <c>true</c> [autorun].</param>
  993. protected override void ConfigureAutoRunAtStartup(bool autorun)
  994. {
  995. if (SupportsAutoRunAtStartup)
  996. {
  997. Autorun.Configure(autorun);
  998. }
  999. }
  1000. }
  1001. }